aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2003-10-18 19:57:23 +0000
committerJason Woodward2003-10-18 19:57:23 +0000
commit511e2df6b427934429ad171105f618dbf0f1d3d2 (patch)
tree9ee50482463e156b29d1bbb7f4e06fa21cebcbe1
parentcfd98f1e8822079ee65b1ec3599141f29b7c90fb (diff)
downloadslapt-get-511e2df6b427934429ad171105f618dbf0f1d3d2.tar.gz
doc updates and reworked parse_packages_txt function
-rw-r--r--ChangeLog4
-rw-r--r--FAQ129
-rw-r--r--Makefile2
-rw-r--r--README10
-rw-r--r--src/package.c86
-rw-r--r--src/package.h6
6 files changed, 195 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index dbab624..2df69f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
+0.9.6d Oct 18, 2003
+ * updated docs
+ * reworked parse_packages_txt function
+
0.9.6c Oct 15, 2003
* patch data is now fetched from patches/PACKAGES.TXT instead of
parsing patches/FILE_LIST
diff --git a/FAQ b/FAQ
index eea4aab..7f4b4a8 100644
--- a/FAQ
+++ b/FAQ
@@ -17,6 +17,7 @@ Frequenty Asked Questions:
14. What if I only want to upgrade one package?
15. What about Dropline support?
16. How can I generate an exclude list for an entire disk set?
+17. How do I use a local file mirror?
@@ -243,3 +244,131 @@ Frequenty Asked Questions:
done
echo
+17. How do I use a local file mirror?
+
+ Within slapt-getrc, change your SOURCE= lines to point to file:// url's.
+
+ For example, you could have an official and a local source like:
+ SOURCE=ftp://ftp.slackware.no/pub/linux/slackware/slackware-9.1/
+ SOURCE=file:///usr/src/local_pkg_repository/
+
+ This local directory must have the PACKAGES.TXT and CHECKSUMS.md5 files present.
+
+ The CHECKSUMS.md5 file can be generated with find:
+ rm CHECKSUMS.md5; find . -name '*.tgz' -exec md5sum {} >> CHECKSUMS.MD5 \;
+
+ The PACKAGES.TXT can be generated by the following script:
+
+ ### BEGIN SCRIPT
+ #!/bin/sh
+ base_dir=`pwd`
+ file_target=PACKAGES.TXT
+ target=$base_dir/$file_target.tmp
+ final_target=$base_dir/$file_target
+ debugger=0
+ ## initialize over size count for compressed and uncompressed
+ totalcomp_k=0
+ totaluncomp_k=0
+
+ for ini_dir_struct in `find . | grep -m1 '\.tgz$'`
+ do
+ ## Path from script location to package, not including package
+ ini_location=`echo $ini_dir_struct |\
+ sed -re "s/([a-zA-Z0-9._\/-]+\/)([a-zA-Z0-9.+_-]+)-([a-zA-Z0-9._-]+).tgz/\1/"`
+
+ ### Build Header for file
+ echo "$file_target `date`" > $target
+ echo "" >> $target
+ echo "This file provides details on the Slackware packages found " >> $target
+ echo "in the ./ directory. " >> $target
+ echo "" >> $target
+ echo "Total size of all packages (compressed): ZXaXZ MB " >> $target
+ echo "Total size of all packages (uncompressed): ZXbXZ MB" >> $target
+ done
+
+
+ for dir_struct in `find . | grep '\.tgz$'`
+ do
+
+ ## File Name (xxxx-n.n.nbeta1-pre.tgz)
+ # name_o_file=`echo $dir_struct |\
+ # sed -re "s/([a-zA-Z0-9-\+_i.]+)*\///g"`
+ name_o_file=`echo $dir_struct |sed -re "s/([a-zA-Z0-9._\/-]+\/)/\2/"`
+
+ ## Base File Name, no version number (xxxx)
+ base_name=`echo $dir_struct |\
+ sed -re "s/([a-zA-Z0-9._\/-]+\/)([a-zA-Z0-9+_-]+)-([a-zA-Z0-9._-]+).tgz/\2/"`
+
+ ## Path from script location to package, not including package
+ location=`echo $dir_struct |\
+ sed -re "s/([a-zA-Z0-9._\/-]+\/)([a-zA-Z0-9+_-]+)-([a-zA-Z0-9._-]+).tgz/\1/"`
+
+ ## Size of file in KB
+ compressed=`gunzip -l $dir_struct | grep -v compress | awk '{print $1 }'`
+ uncompressed=`gunzip -l $dir_struct | grep -v compress | awk '{print $2 }'`
+ comp_k=`echo "${compressed}/1024" | bc`
+ uncomp_k=`echo "${uncompressed}/1024" | bc`
+ totalcomp_k=`expr $totalcomp_k + $comp_k`
+ totaluncomp_k=`expr $totaluncomp_k + $uncomp_k`
+
+ ## Contents of slack-required
+ required=`tar ztf $dir_struct | grep "slack-required" |\
+ xargs -r -i"XFILEZ" tar xzf $dir_struct -O XFILEZ |\
+ xargs -r | sed "s/ /,/g"`
+
+ if [ $debugger -eq 1 ]; then
+ ## Debug output to $target
+ echo "" >> $target
+ echo "dir_struct = $dir_struct" >> $target
+ echo "location = $location" >> $target
+ echo "name_o_file = $name_o_file" >> $target
+ echo "target = $target" >> $target
+ echo "base_dir = $base_dir" >> $target
+ echo "base_name = $base_name" >> $target
+ echo "total compressed size in KB = $totalcomp_k" >> $target
+ echo "total uncompressed size in KB = $totaluncomp_k" >> $target
+ echo "tar zxf $dir_struct -O install/slack-desc | grep ^${base_name}:" >> $target
+ echo "" >> $target
+ fi
+
+
+ ## Build PACKAGES.TXT
+
+ echo "" >> $target
+ echo "PACKAGE NAME: $name_o_file" >> $target
+ echo "PACKAGE LOCATION: $location" >> $target
+ echo "PACKAGE SIZE (compressed): $comp_k K" >> $target
+ echo "PACKAGE SIZE (uncompressed): $uncomp_k K" >> $target
+ echo "PACKAGE REQUIRED: $required" >> $target
+ echo "PACKAGE DESCRIPTION: " >> $target
+ tar ztf $dir_struct | grep "slack-desc" |\
+ xargs -r -i"XFILEZ" tar xzf $dir_struct -O XFILEZ |\
+ grep "^${base_name}:" >> $target
+
+ #tar zxf $dir_struct -O install/slack-desc | grep "^${base_name}:" >> $target
+
+
+ ## Count number of lines in desc... should be 11 (0+10)
+ ## Append to description
+ lines=`tar ztf $dir_struct | grep "slack-desc" |\
+ xargs -r -i"XFILEZ" tar xzf $dir_struct -O XFILEZ |\
+ grep "^${base_name}:" | wc -l`
+ #lines=`tar zxf $dir_struct -O install/slack-desc | grep "^${base_name}:" | wc -l`
+
+ while [ ${lines} -le 10 ]
+ do
+ echo "${base_name}:" >> $target
+ lines=`expr $lines + 1`
+ done
+
+ done
+
+ ## calculate totals in MB
+ totalcomp_m=`expr $totalcomp_k / 1024`
+ totaluncomp_m=`expr $totaluncomp_k / 1024`
+
+ cat $target | \
+ sed -e "s/ZXaXZ/$totalcomp_m/g" \
+ -e "s/ZXbXZ/$totaluncomp_m/g" > $final_target && rm $target
+ ### END SCRIPT
+
diff --git a/Makefile b/Makefile
index 6667e81..4a32f1a 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ RCDEST=/etc/slapt-getrc
RCSOURCE=example.slapt-getrc
SBINDIR=/sbin/
DEFINES=-DPROGRAM_NAME="\"$(PROGRAM_NAME)\"" -DVERSION="\"$(VERSION)\"" -DRC_LOCATION="\"$(RCDEST)\""
-CFLAGS=-W -Werror -Wall -O2 -ansi -pedantic -Iinclude $(DEFINES)
+CFLAGS=-W -Werror -Wall -g -ansi -pedantic -Iinclude $(DEFINES)
default: $(PROGRAM_NAME)
diff --git a/README b/README
index 4d8c1b2..61a0f15 100644
--- a/README
+++ b/README
@@ -34,14 +34,18 @@ Table of Contents:
* multiple sources (linuxpackage.net support)
* show packages that are available (from cached data)
* allow packages to be retrieved and installed by name
- * allow updates to be retrieved and applied (frontent to updatepkg)
+ * remove packages
+ * allow updates to be retrieved and applied
+ * install and remove multiple packages at once
+ * uses native Slackware tools (installpkg, upgradepkg, and removepkg)
* show description of packages
* list installed packages
- * remove packages (frontent to removepkg)
- * dist-upgrade from one slackware release to another
+ * upgrade from one slackware release to another
* exclude (hold) packages from upgrades
* easy to script with
* extremely fast
+ * transaction engine
+ * compare package version algorithm to prevent downgrades
diff --git a/src/package.c b/src/package.c
index 3e42ae6..f5df515 100644
--- a/src/package.c
+++ b/src/package.c
@@ -41,6 +41,7 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
char *getline_buffer = NULL;
char *size_c = NULL;
char *size_u = NULL;
+ pkg_info_t *tmp_pkg = NULL;
list = malloc( sizeof *list );
@@ -81,40 +82,42 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
0
);
- if( name_regex.reg_return == 0 ){
- list->pkgs[list->pkg_count] = malloc( sizeof *list->pkgs[list->pkg_count] );
-
- if( list->pkgs[list->pkg_count] == NULL ){
- fprintf(stderr,"Failed to malloc list->pkgs[list->pkg_count]\n");
- exit(1);
- }
-
- /* pkg name base */
- strncpy(list->pkgs[list->pkg_count]->name,
- getline_buffer + name_regex.pmatch[1].rm_so,
- name_regex.pmatch[1].rm_eo - name_regex.pmatch[1].rm_so
- );
- list->pkgs[list->pkg_count]->name[
- name_regex.pmatch[1].rm_eo - name_regex.pmatch[1].rm_so
- ] = '\0';
- /* pkg version */
- strncpy(list->pkgs[list->pkg_count]->version,
- getline_buffer + name_regex.pmatch[2].rm_so,
- name_regex.pmatch[2].rm_eo - name_regex.pmatch[2].rm_so
- );
- list->pkgs[list->pkg_count]->version[
- name_regex.pmatch[2].rm_eo - name_regex.pmatch[2].rm_so
- ] = '\0';
-
- }else{
+ /* skip this line if we didn't find a package name */
+ if( name_regex.reg_return != 0 ){
fprintf(stderr,"regex failed on [%s]\n",getline_buffer);
+ free(tmp_pkg);
continue;
}
+ /* otherwise keep going and parse out the rest of the pkg data */
+
+ tmp_pkg = malloc( sizeof *tmp_pkg );
+ if( tmp_pkg == NULL ){
+ fprintf(stderr,"Failed to malloc tmp_pkg\n");
+ exit(1);
+ }
+
+ /* pkg name base */
+ strncpy(tmp_pkg->name,
+ getline_buffer + name_regex.pmatch[1].rm_so,
+ name_regex.pmatch[1].rm_eo - name_regex.pmatch[1].rm_so
+ );
+ tmp_pkg->name[
+ name_regex.pmatch[1].rm_eo - name_regex.pmatch[1].rm_so
+ ] = '\0';
+
+ /* pkg version */
+ strncpy(tmp_pkg->version,
+ getline_buffer + name_regex.pmatch[2].rm_so,
+ name_regex.pmatch[2].rm_eo - name_regex.pmatch[2].rm_so
+ );
+ tmp_pkg->version[
+ name_regex.pmatch[2].rm_eo - name_regex.pmatch[2].rm_so
+ ] = '\0';
/* mirror */
f_pos = ftell(pkg_list_fh);
if(getline(&getline_buffer,&getline_len,pkg_list_fh) != EOF){
- /* add in support for the mirror url */
+ /* add in support for the mirror url */
mirror_regex.reg_return = regexec(
&mirror_regex.regex,
getline_buffer,
@@ -124,11 +127,11 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
);
if( mirror_regex.reg_return == 0 ){
- strncpy( list->pkgs[list->pkg_count]->mirror,
+ strncpy( tmp_pkg->mirror,
getline_buffer + mirror_regex.pmatch[1].rm_so,
mirror_regex.pmatch[1].rm_eo - mirror_regex.pmatch[1].rm_so
);
- list->pkgs[list->pkg_count]->mirror[
+ tmp_pkg->mirror[
mirror_regex.pmatch[1].rm_eo - mirror_regex.pmatch[1].rm_so
] = '\0';
@@ -149,19 +152,21 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
0
);
if( location_regex.reg_return == 0){
- strncpy(list->pkgs[list->pkg_count]->location,
+ strncpy(tmp_pkg->location,
getline_buffer + location_regex.pmatch[1].rm_so,
location_regex.pmatch[1].rm_eo - location_regex.pmatch[1].rm_so
);
- list->pkgs[list->pkg_count]->location[
+ tmp_pkg->location[
location_regex.pmatch[1].rm_eo - location_regex.pmatch[1].rm_so
] = '\0';
}else{
fprintf(stderr,"regexec failed to parse location\n");
+ free(tmp_pkg);
continue;
}
}else{
fprintf(stderr,"getline reached EOF attempting to read location\n");
+ free(tmp_pkg);
continue;
}
@@ -187,14 +192,16 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
getline_buffer + size_c_regex.pmatch[1].rm_so,
(size_c_regex.pmatch[1].rm_eo - size_c_regex.pmatch[1].rm_so)
);
- list->pkgs[list->pkg_count]->size_c = strtol(size_c, (char **)NULL, 10);
+ tmp_pkg->size_c = strtol(size_c, (char **)NULL, 10);
free(size_c);
}else{
fprintf(stderr,"regexec failed to parse size_c\n");
+ free(tmp_pkg);
continue;
}
}else{
fprintf(stderr,"getline reached EOF attempting to read size_c\n");
+ free(tmp_pkg);
continue;
}
@@ -220,14 +227,16 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
size_u,getline_buffer + size_u_regex.pmatch[1].rm_so,
(size_u_regex.pmatch[1].rm_eo - size_u_regex.pmatch[1].rm_so)
);
- list->pkgs[list->pkg_count]->size_u = strtol(size_u, (char **)NULL, 10);
+ tmp_pkg->size_u = strtol(size_u, (char **)NULL, 10);
free(size_u);
}else{
fprintf(stderr,"regexec failed to parse size_u\n");
+ free(tmp_pkg);
continue;
}
}else{
fprintf(stderr,"getline reached EOF attempting to read size_u\n");
+ free(tmp_pkg);
continue;
}
@@ -248,14 +257,14 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
&& (strstr(getline_buffer,"PACKAGE DESCRIPTION") != NULL)
){
- list->pkgs[list->pkg_count]->description[0] = '\0';
+ tmp_pkg->description[0] = '\0';
while( 1 ){
if( (bytes_read = getline(&getline_buffer,&getline_len,pkg_list_fh)) != EOF ){
if( strcmp(getline_buffer,"\n") != 0 ){
- strncat(list->pkgs[list->pkg_count]->description,getline_buffer,bytes_read);
- list->pkgs[list->pkg_count]->description[
- strlen(list->pkgs[list->pkg_count]->description)
+ strncat(tmp_pkg->description,getline_buffer,bytes_read);
+ tmp_pkg->description[
+ strlen(tmp_pkg->description)
] = '\0';
}else{
break;
@@ -266,9 +275,12 @@ struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
}
}else{
fprintf(stderr,"error attempting to read pkg description\n");
+ free(tmp_pkg);
continue;
}
+ list->pkgs[list->pkg_count] = tmp_pkg;
+ tmp_pkg = NULL;
list->pkg_count += 1;
/* grow our struct array */
realloc_tmp = realloc(list->pkgs , sizeof *list->pkgs * (list->pkg_count + 1) );
diff --git a/src/package.h b/src/package.h
index 6ee2f89..e054ec2 100644
--- a/src/package.h
+++ b/src/package.h
@@ -34,7 +34,7 @@ struct _pkg_info {
char name[50];
char version[50];
char mirror[200];
- char location[50];
+ char location[60];
int size_c;
int size_u;
char description[1024];
@@ -87,6 +87,10 @@ int upgrade_pkg(const rc_config *,pkg_info_t *,pkg_info_t *);
/* remove pkg */
int remove_pkg(const rc_config *,pkg_info_t *);
+/* initialize pkg_list structure */
+void init_pkg_list(struct pkg_list *);
+/* add pkg to pkg_list structure */
+void add_pkg_to_list(struct pkg_list *, pkg_info_t *);
/* free memory allocated for pkg_list struct */
void free_pkg_list(struct pkg_list *);