aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--FAQ6
-rw-r--r--Makefile2
-rw-r--r--README8
-rw-r--r--TODO1
-rw-r--r--example.slapt-getrc78
-rw-r--r--slack-desc6
-rw-r--r--src/action.c54
-rw-r--r--src/configuration.c28
-rw-r--r--src/configuration.h8
-rw-r--r--src/curl.c105
-rw-r--r--src/curl.h5
-rw-r--r--src/package.c65
-rw-r--r--src/package.h5
14 files changed, 215 insertions, 164 deletions
diff --git a/ChangeLog b/ChangeLog
index 9878664..88dd388 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,16 +1,20 @@
-0.9.5f Oct 12, 2003
+0.9.5f Oct 13, 2003
* removed needless check in get_md5sum looking for common slack mirror
directories.
* Prompt to upgrade before downloading (thanks kyotou)
* updated FAQ with dropline question, and upgrade single package question
- * options can now be passed in in any order, so --no-prompt at the end now works
+ * options can now be passed in in any order, so --no-prompt at the end now
+ works
* created struct pkg_list *get_available_and_update_pkgs(void) to search for
updates and newer available at once, simplified --install and --upgrade
part of roadmap to package action transactions.
* implemented transaction engine
* --interactive option to emulate old upgrade procedure, prompting for each
upgrade.
+ * multiple source support complete. Linuxpackage integration should be
+ working. slapt-getrc syntax has changed. Updated documentation
+ appropriately.
0.9.5e Oct 10, 2003
* added a doinst.sh script (generated from the Makefile) to help
diff --git a/FAQ b/FAQ
index 781aa59..b8e7842 100644
--- a/FAQ
+++ b/FAQ
@@ -170,9 +170,9 @@ Frequenty Asked Questions:
11. What about multiple package sources, ala linuxpackages.net?
- You can now use linuxpackages.net as your slapt-get source. Support for
- multiple sources at once is forthcoming.
-
+ You can now use multiple sources with slapt-get (including linuxpackages.net).
+ See the example slapt-getrc in the source tarball, or look in
+ /etc/slapt-getrc.new if you installed via slackpack.
12. I don't like the download spinner, how can I get more statistics?
diff --git a/Makefile b/Makefile
index 8c411d1..096ca33 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 -g -ansi -pedantic -Iinclude $(DEFINES)
+CFLAGS=-W -Werror -Wall -O2 -ansi -pedantic -Iinclude $(DEFINES)
default: $(PROGRAM_NAME)
diff --git a/README b/README
index 47c2052..c8ad8da 100644
--- a/README
+++ b/README
@@ -61,7 +61,7 @@ Table of Contents:
4. slapt-getrc
The slapt-getrc file consists currently of the following keys:
- MIRROR
+ SOURCE
WORKINGDIR
EXCLUDE
@@ -69,7 +69,11 @@ Table of Contents:
lynx -source http://www.slackware.com/getslack/|grep -i href \
|awk -F "HREF=" '{print $2}'|cut -f2 -d'"'
- The MIRROR must be a path to a valid slackware release directory.
+ The SOURCE must be a path to a valid slackware release directory,
+ or a source such as linuxpackages.net (see example within rc).
+ Multiple sources can be defined. Please do not add redundant
+ mirror locations to the same release. Mirror fallback is not
+ yet implemented.
WORKINGDIR will hold the package data and downloaded packages.
diff --git a/TODO b/TODO
index 1ee1320..8c8fada 100644
--- a/TODO
+++ b/TODO
@@ -9,6 +9,7 @@ Future enhancements, fixes, or features:
* add more error checking/handling, remove some exit() calls
* find memory leaks
+ * mirror fall back in case pkg is not available on current mirror
* dependancy tracking (ideally that will happen in PACKAGES.TXT)
* source pkg handling (maybe)
diff --git a/example.slapt-getrc b/example.slapt-getrc
index 369225e..133eb71 100644
--- a/example.slapt-getrc
+++ b/example.slapt-getrc
@@ -1,42 +1,46 @@
# base mirror url to directory with a PACKAGES.TXT
# mirror can point to any release, ie: 9.0, 9.1, current, etc
-# MIRROR=ftp://distro.ibiblio.org/pub/Linux/distributions/slackware/slackware-9.1/
-MIRROR=ftp://distro.ibiblio.org/pub/Linux/distributions/slackware/slackware-9.0/
+#SOURCE=ftp://distro.ibiblio.org/pub/Linux/distributions/slackware/slackware-9.0/
+SOURCE=ftp://distro.ibiblio.org/pub/Linux/distributions/slackware/slackware-9.1/
+
+# you can use multiple sources, such as linuxpackages.net
+#SOURCE=http://www3.linuxpackages.net/packages/Slackware-9.1/
+
WORKINGDIR=/var/slapt-get
EXCLUDE=kernel-ide,kernel-source,kernel-headers,kernel-modules,lilo
-# MIRROR=ftp://mirror.aarnet.edu.au/pub/slackware/slackware-9.0/
-# MIRROR=http://mirror.aarnet.edu.au/pub/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.planetmirror.com/pub/slackware/slackware-9.0/
-# MIRROR=http://ftp.planetmirror.com/pub/slackware/slackware-9.0/
-# MIRROR=ftp://gd.tuwien.ac.at/opsys/linux/slackware/slackware-9.0/
-# MIRROR=http://gd.tuwien.ac.at/opsys/linux/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.slackwarebrasil.org/pub/linux/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.linux.tucows.com/pub/distributions/Slackware/slackware-9.0/
-# MIRROR=ftp://sunsite.ualberta.ca/pub/Mirror/Linux/slackware/slackware-9.0/
-# MIRROR=http://sunsite.ualberta.ca/pub/Mirror/Linux/slackware-9.0/
-# MIRROR=ftp://ncart.scs.ryerson.ca/pub/slackware/slackware-9.0/
-# MIRROR=http://ncart.scs.ryerson.ca/pub/slackware/slackware-9.0/
-# MIRROR=ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.heanet.ie/mirrors/ftp.slackware.com/pub/slackware/slackware-9.0/
-# MIRROR=ftp://sunsite.sut.ac.jp/pub/archives/linux/slackware/slackware-9.0/
-# MIRROR=http://sunsite.sut.ac.jp/pub/archives/linux/slackware/slackware-9.0/
-# MIRROR=http://www.rarf.riken.go.jp/archives/Linux/slackware/slackware-9.0/
-# MIRROR=ftp://linux.sarang.net/mirror/os/linux/distribution/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.man.olsztyn.pl/pub/linux/distributions/slackware/slackware-9.0/
-# MIRROR=http://ftp.man.olsztyn.pl/pub/linux/distributions/slackware/slackware-9.0/
-# MIRROR=ftp://sunsite.pub.ro/pub/Linux/distributions/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.rediris.es/mirror/linux/distributions/slackware/slackware-9.0/
-# MIRROR=ftp://luna.gui.uva.es/pub/linux.new/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.uniovi.es/pub/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.etse.urv.es/pub/linux/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.sunet.se/pub/Linux/distributions/slackware/slackware-9.0/
-# MIRROR=http://sunsite.cnlab-switch.ch/ftp/mirror/slackware/slackware/slackware-9.0/
-# MIRROR=ftp://sunsite.cnlab-switch.ch/mirror/slackware/slackware-9.0/
-# MIRROR=ftp://sunsite.cnlab-switch.ch/mirror/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.loxinfo.co.th/linux/slackware/slackware-9.0/
-# MIRROR=ftp://ftp.mirror.ac.uk/sites/ftp.slackware.com/pub/slackware/slackware-9.0/
-# MIRROR=ftp://carroll.cac.psu.edu/pub/linux/distributions/slackware/slackware-9.0/
-# MIRROR=http://carroll.cac.psu.edu/pub/linux/distributions/slackware/slackware-9.0/
-# MIRROR=ftp://distro.ibiblio.org/pub/Linux/distributions/slackware/slackware-9.0/
-# MIRROR=ftp://ftp-linux.cc.gatech.edu/pub/Linux/distributions/slackware/slackware-9.0/
+# SOURCE=ftp://mirror.aarnet.edu.au/pub/slackware/slackware-9.0/
+# SOURCE=http://mirror.aarnet.edu.au/pub/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.planetmirror.com/pub/slackware/slackware-9.0/
+# SOURCE=http://ftp.planetmirror.com/pub/slackware/slackware-9.0/
+# SOURCE=ftp://gd.tuwien.ac.at/opsys/linux/slackware/slackware-9.0/
+# SOURCE=http://gd.tuwien.ac.at/opsys/linux/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.slackwarebrasil.org/pub/linux/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.linux.tucows.com/pub/distributions/Slackware/slackware-9.0/
+# SOURCE=ftp://sunsite.ualberta.ca/pub/Mirror/Linux/slackware/slackware-9.0/
+# SOURCE=http://sunsite.ualberta.ca/pub/Mirror/Linux/slackware-9.0/
+# SOURCE=ftp://ncart.scs.ryerson.ca/pub/slackware/slackware-9.0/
+# SOURCE=http://ncart.scs.ryerson.ca/pub/slackware/slackware-9.0/
+# SOURCE=ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.heanet.ie/mirrors/ftp.slackware.com/pub/slackware/slackware-9.0/
+# SOURCE=ftp://sunsite.sut.ac.jp/pub/archives/linux/slackware/slackware-9.0/
+# SOURCE=http://sunsite.sut.ac.jp/pub/archives/linux/slackware/slackware-9.0/
+# SOURCE=http://www.rarf.riken.go.jp/archives/Linux/slackware/slackware-9.0/
+# SOURCE=ftp://linux.sarang.net/mirror/os/linux/distribution/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.man.olsztyn.pl/pub/linux/distributions/slackware/slackware-9.0/
+# SOURCE=http://ftp.man.olsztyn.pl/pub/linux/distributions/slackware/slackware-9.0/
+# SOURCE=ftp://sunsite.pub.ro/pub/Linux/distributions/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.rediris.es/mirror/linux/distributions/slackware/slackware-9.0/
+# SOURCE=ftp://luna.gui.uva.es/pub/linux.new/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.uniovi.es/pub/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.etse.urv.es/pub/linux/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.sunet.se/pub/Linux/distributions/slackware/slackware-9.0/
+# SOURCE=http://sunsite.cnlab-switch.ch/ftp/mirror/slackware/slackware/slackware-9.0/
+# SOURCE=ftp://sunsite.cnlab-switch.ch/mirror/slackware/slackware-9.0/
+# SOURCE=ftp://sunsite.cnlab-switch.ch/mirror/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.loxinfo.co.th/linux/slackware/slackware-9.0/
+# SOURCE=ftp://ftp.mirror.ac.uk/sites/ftp.slackware.com/pub/slackware/slackware-9.0/
+# SOURCE=ftp://carroll.cac.psu.edu/pub/linux/distributions/slackware/slackware-9.0/
+# SOURCE=http://carroll.cac.psu.edu/pub/linux/distributions/slackware/slackware-9.0/
+# SOURCE=ftp://distro.ibiblio.org/pub/Linux/distributions/slackware/slackware-9.0/
+# SOURCE=ftp://ftp-linux.cc.gatech.edu/pub/Linux/distributions/slackware/slackware-9.0/
diff --git a/slack-desc b/slack-desc
index c28b15f..f6926eb 100644
--- a/slack-desc
+++ b/slack-desc
@@ -13,7 +13,7 @@ slapt-get: It allows one to search slackware.com and mirrors for packages,
slapt-get: compare them with installed packages, install new packages or
slapt-get: upgrade installed packages all with a few simple commands.
slapt-get:
-slapt-get: Additional features include listing all available packages,
-slapt-get: listing all installed packages, and removing installed packages.
-slapt-get:
+slapt-get: See /usr/doc/slapt-get* for complete documentation. The syntax for
+slapt-get: /etc/slapt-getrc has been updated for 0.9.5f. See
+slapt-get: /etc/slapt-getrc.new for example.
slapt-get:
diff --git a/src/action.c b/src/action.c
index 5e30a6a..aee23f6 100644
--- a/src/action.c
+++ b/src/action.c
@@ -192,8 +192,9 @@ void pkg_action_show(const char *pkg_name){
if( pkg != NULL ){
printf("Package Name: %s\n",pkg->name);
+ printf("Package Mirror: %s\n",pkg->mirror);
printf("Package Location: %s\n",pkg->location);
- printf("Package version: %s\n",pkg->version);
+ printf("Package Version: %s\n",pkg->version);
printf("Package Description:\n");
printf("%s",pkg->description);
}else{
@@ -205,20 +206,63 @@ void pkg_action_show(const char *pkg_name){
/* update package data from mirror url */
void pkg_action_update(const rc_config *global_config){
+ int i;
FILE *pkg_list_fh;
FILE *patches_list_fh;
FILE *checksum_list_fh;
+ FILE *tmp_file;
+ struct pkg_list *available_pkgs = NULL;
/* download our PKG_LIST */
- pkg_list_fh = download_pkg_list(global_config);
+ #if USE_CURL_PROGRESS == 0
+ printf("Retrieving package data...");
+ #else
+ printf("Retrieving package data...\n");
+ #endif
+ pkg_list_fh = open_file(PKG_LIST_L,"w+");
+ for(i = 0; i < global_config->sources.count; i++){
+ tmp_file = tmpfile();
+ if( get_mirror_data_from_source(tmp_file,global_config->sources.url[i],PKG_LIST) == 0 ){
+ rewind(tmp_file); /* make sure we are back at the front of the file */
+ available_pkgs = parse_packages_txt(tmp_file);
+ write_pkg_data(global_config->sources.url[i],pkg_list_fh,available_pkgs);
+ free_pkg_list(available_pkgs);
+ }
+ fclose(tmp_file);
+ }
+ #if USE_CURL_PROGRESS == 0
+ printf("Done\n");
+ #endif
fclose(pkg_list_fh);
/* download PATCHES_LIST */
- patches_list_fh = download_patches_list(global_config);
+ #if USE_CURL_PROGRESS == 0
+ printf("Retrieving patch list...");
+ #else
+ printf("Retrieving patch list...\n");
+ #endif
+ patches_list_fh = open_file(PATCHES_LIST_L,"w+");
+ for(i = 0; i < global_config->sources.count; i++){
+ get_mirror_data_from_source(patches_list_fh,global_config->sources.url[i],PATCHES_LIST);
+ }
+ #if USE_CURL_PROGRESS == 0
+ printf("Done\n");
+ #endif
fclose(patches_list_fh);
- /* download */
- checksum_list_fh = download_checksum_list(global_config);
+ /* download checksum file */
+ #if USE_CURL_PROGRESS == 0
+ printf("Retrieving checksum list...");
+ #else
+ printf("Retrieving checksum list...\n");
+ #endif
+ checksum_list_fh = open_file(CHECKSUM_FILE,"w+");
+ for(i = 0; i < global_config->sources.count; i++){
+ get_mirror_data_from_source(checksum_list_fh,global_config->sources.url[i],CHECKSUM_FILE);
+ }
+ #if USE_CURL_PROGRESS == 0
+ printf("Done\n");
+ #endif
fclose(checksum_list_fh);
/* source listing to go here */
diff --git a/src/configuration.c b/src/configuration.c
index 71ee48d..04c65c5 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -34,6 +34,8 @@ rc_config *read_rc_config(const char *file_name){
}
}
+ global_config->sources.count = 0;
+
rc = open_file(file_name,"r");
while( (g_size = getline(&getline_buffer,&gb_length,rc) ) != EOF ){
@@ -46,19 +48,27 @@ rc_config *read_rc_config(const char *file_name){
continue;
}
- if( strstr(getline_buffer,MIRROR_TOKEN) != NULL ){ /* MIRROR URL */
+ if( strstr(getline_buffer,SOURCE_TOKEN) != NULL ){ /* SOURCE URL */
- if( strlen(getline_buffer) > strlen(MIRROR_TOKEN) ){
+ if( strlen(getline_buffer) > strlen(SOURCE_TOKEN) ){
strncpy(
- global_config->mirror_url,
- getline_buffer + strlen(MIRROR_TOKEN),
- (strlen(getline_buffer) - strlen(MIRROR_TOKEN))
+ global_config->sources.url[global_config->sources.count],
+ getline_buffer + strlen(SOURCE_TOKEN),
+ (strlen(getline_buffer) - strlen(SOURCE_TOKEN))
);
+ global_config->sources.url[global_config->sources.count][
+ (strlen(getline_buffer) - strlen(SOURCE_TOKEN))
+ ] = '\0';
/* make sure our url has a trailing '/' */
- if( global_config->mirror_url[strlen(global_config->mirror_url) - 1] != '/' ){
- strcat(global_config->mirror_url,"/");
+ if( global_config->sources.url[global_config->sources.count]
+ [
+ strlen(global_config->sources.url[global_config->sources.count]) - 1
+ ] != '/'
+ ){
+ strcat(global_config->sources.url[global_config->sources.count],"/");
}
+ ++global_config->sources.count;
}
@@ -83,8 +93,8 @@ rc_config *read_rc_config(const char *file_name){
fprintf(stderr,"WORKINGDIR directive not set within %s.\n",file_name);
exit(1);
}
- if( strcmp(global_config->mirror_url,"") == 0 ){
- fprintf(stderr,"MIRROR directive not set within %s.\n",file_name);
+ if( global_config->sources.count == 0 ){
+ fprintf(stderr,"SOURCE directive not set within %s.\n",file_name);
exit(1);
}
diff --git a/src/configuration.h b/src/configuration.h
index 1cc22f7..244c7be 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#define MIRROR_TOKEN "MIRROR="
+#define SOURCE_TOKEN "SOURCE="
#define WORKINGDIR_TOKEN "WORKINGDIR="
#define EXCLUDE_TOKEN "EXCLUDE="
@@ -25,8 +25,14 @@ struct exclude_list {
int count;
};
+struct source_list {
+ char url[10][200];
+ int count;
+};
+
struct _configuration {
char mirror_url[256];
+ struct source_list sources;
char working_dir[256];
int download_only;
int dist_upgrade;
diff --git a/src/curl.c b/src/curl.c
index 7a19bec..c9244e7 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -22,7 +22,7 @@ int download_data(FILE *fh,const char *url){
CURL *ch = NULL;
CURLcode response;
char curl_err_buff[1024];
- int return_code = 1;
+ int return_code = 0;
#if DEBUG == 1
printf("Fetching url:[%s]\n",url);
@@ -52,104 +52,27 @@ int download_data(FILE *fh,const char *url){
return return_code;
}
-FILE *download_pkg_list(const rc_config *global_config){
- FILE *fh = NULL;
+int get_mirror_data_from_source(FILE *fh,const char *base_url,const char *filename){
+ int return_code;
char *url = NULL;
- fh = open_file(PKG_LIST_L,"w+");
-
-#if USE_CURL_PROGRESS == 0
- printf("Retrieving package data...");
-#else
- printf("Retrieving package data...\n");
-#endif
-
url = calloc(
- strlen(global_config->mirror_url) + strlen(PKG_LIST) + 1, sizeof *url
+ strlen(base_url) + strlen(filename) + 1, sizeof *url
);
if( url == NULL ){
fprintf(stderr,"Failed to calloc url\n");
exit(1);
}
- strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url) );
- strncat(url,PKG_LIST,strlen(PKG_LIST) );
- if( download_data(fh,url) == 1 ){
-#if USE_CURL_PROGRESS == 0
- printf("Done\n");
-#endif
- }
+ strncpy(url,base_url,strlen(base_url) );
+ strncat(url,filename,strlen(filename) );
+ return_code = download_data(fh,url);
free(url);
- rewind(fh); /* make sure we are back at the front of the file */
- return fh;
-}
-
-FILE *download_patches_list(const rc_config *global_config){
- FILE *fh = NULL;
- char *url = NULL;
-
- fh = open_file(PATCHES_LIST_L,"w+");
-
-#if USE_CURL_PROGRESS == 0
- printf("Retrieving patch list...");
-#else
- printf("Retrieving patch list...\n");
-#endif
-
- url = calloc(
- strlen(global_config->mirror_url) + strlen(PATCHDIR) + strlen(PATCHES_LIST) + 1 , sizeof *url
- );
- if( url == NULL ){
- fprintf(stderr,"Failed to calloc url\n");
- exit(1);
- }
-
- strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url) );
- strncat(url,PATCHDIR,strlen(PATCHDIR) );
- strncat(url,PATCHES_LIST,strlen(PATCHES_LIST) );
- if( download_data(fh,url) == 1 ){
-#if USE_CURL_PROGRESS == 0
- printf("Done\n");
-#endif
- }
-
- free(url);
- rewind(fh); /* make sure we are back at the front of the file */
- return fh;
-}
-
-FILE *download_checksum_list(const rc_config *global_config){
- FILE *fh = NULL;
- char *url = NULL;
-
- fh = open_file(CHECKSUM_FILE,"w+");
-
-#if USE_CURL_PROGRESS == 0
- printf("Retrieving checksum list...");
-#else
- printf("Retrieving checksum list...\n");
-#endif
-
- url = calloc(
- strlen(global_config->mirror_url) + strlen(CHECKSUM_FILE) + 1 , sizeof *url
- );
- if( url == NULL ){
- fprintf(stderr,"Failed to calloc url\n");
- exit(1);
- }
-
- strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url) );
- strncat(url,CHECKSUM_FILE,strlen(CHECKSUM_FILE) );
- if( download_data(fh,url) == 1 ){
-#if USE_CURL_PROGRESS == 0
- printf("Done\n");
-#endif
- }
-
- free(url);
- rewind(fh); /* make sure we are back at the front of the file */
- return fh;
+ /* make sure we are back at the front of the file */
+ /* DISABLED */
+ /* rewind(fh); */
+ return return_code;
}
char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
@@ -199,7 +122,7 @@ char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
/* build the url */
url = calloc(
- strlen(global_config->mirror_url) + strlen(pkg->location)
+ strlen(pkg->mirror) + strlen(pkg->location)
+ strlen(file_name) + strlen("/") + 1,
sizeof *url
);
@@ -207,7 +130,7 @@ char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
fprintf(stderr,"Failed to calloc url\n");
exit(1);
}
- url = strncpy(url,global_config->mirror_url,strlen(global_config->mirror_url));
+ url = strncpy(url,pkg->mirror,strlen(pkg->mirror));
url = strncat(url,pkg->location,strlen(pkg->location));
url = strncat(url,"/",strlen("/"));
url = strncat(url,file_name,strlen(file_name));
@@ -220,7 +143,7 @@ char *download_pkg(const rc_config *global_config,pkg_info_t *pkg){
#endif
fh = open_file(file_name,"wb");
- if( download_data(fh,url) == 1 ){
+ if( download_data(fh,url) == 0 ){
#if USE_CURL_PROGRESS == 0
printf("Done\n");
#endif
diff --git a/src/curl.h b/src/curl.h
index c809cfb..460e2ad 100644
--- a/src/curl.h
+++ b/src/curl.h
@@ -20,9 +20,6 @@
/* FUNCTION DEFINITIONS */
int download_data(FILE *,const char *);
-FILE *download_pkg_list(const rc_config *);
-FILE *download_file_list(const rc_config *);
-FILE *download_patches_list(const rc_config *);
-FILE *download_checksum_list(const rc_config *global_config);
+int get_mirror_data_from_source(FILE *,const char *,const char *);
char *download_pkg(const rc_config *,pkg_info_t *);
int progress_callback(void *,double,double,double,double);
diff --git a/src/package.c b/src/package.c
index 664e42c..ee1c2fd 100644
--- a/src/package.c
+++ b/src/package.c
@@ -20,9 +20,20 @@
/* parse the PACKAGES.TXT file */
struct pkg_list *get_available_pkgs(void){
- sg_regex name_regex, location_regex, size_c_regex, size_u_regex;
- ssize_t bytes_read;
FILE *pkg_list_fh;
+ struct pkg_list *list;
+
+ /* open pkg list */
+ pkg_list_fh = open_file(PKG_LIST_L,"r");
+ list = parse_packages_txt(pkg_list_fh);
+ fclose(pkg_list_fh);
+
+ return list;
+}
+
+struct pkg_list *parse_packages_txt(FILE *pkg_list_fh){
+ sg_regex name_regex, mirror_regex,location_regex, size_c_regex, size_u_regex;
+ ssize_t bytes_read;
pkg_info_t **realloc_tmp;
struct pkg_list *list;
long f_pos = 0;
@@ -34,16 +45,15 @@ struct pkg_list *get_available_pkgs(void){
list = malloc( sizeof *list );
name_regex.nmatch = MAX_REGEX_PARTS;
+ mirror_regex.nmatch = MAX_REGEX_PARTS;
location_regex.nmatch = MAX_REGEX_PARTS;
size_c_regex.nmatch = MAX_REGEX_PARTS;
size_u_regex.nmatch = MAX_REGEX_PARTS;
- /* open pkg list */
- pkg_list_fh = open_file(PKG_LIST_L,"r");
-
/* compile our regexen */
regcomp(&name_regex.regex,PKG_NAME_PATTERN, REG_EXTENDED|REG_NEWLINE);
+ regcomp(&mirror_regex.regex,PKG_MIRROR_PATTERN,REG_EXTENDED|REG_NEWLINE);
regcomp(&location_regex.regex,PKG_LOCATION_PATTERN, REG_EXTENDED|REG_NEWLINE);
regcomp(&size_c_regex.regex,PKG_SIZEC_PATTERN, REG_EXTENDED|REG_NEWLINE);
regcomp(&size_u_regex.regex,PKG_SIZEU_PATTERN, REG_EXTENDED|REG_NEWLINE);
@@ -101,6 +111,33 @@ struct pkg_list *get_available_pkgs(void){
continue;
}
+ /* mirror */
+ f_pos = ftell(pkg_list_fh);
+ if(getline(&getline_buffer,&getline_len,pkg_list_fh) != EOF){
+ /* add in support for the mirror url */
+ mirror_regex.reg_return = regexec(
+ &mirror_regex.regex,
+ getline_buffer,
+ mirror_regex.nmatch,
+ mirror_regex.pmatch,
+ 0
+ );
+ if( mirror_regex.reg_return == 0 ){
+
+ strncpy( list->pkgs[list->pkg_count]->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[
+ mirror_regex.pmatch[1].rm_eo - mirror_regex.pmatch[1].rm_so
+ ] = '\0';
+
+ }else{
+ /* mirror isn't provided... rewind one line */
+ fseek(pkg_list_fh, (ftell(pkg_list_fh) - f_pos) * -1, SEEK_CUR);
+ }
+ }
+
/* location */
if( (getline(&getline_buffer,&getline_len,pkg_list_fh) != EOF) ){
@@ -246,8 +283,8 @@ struct pkg_list *get_available_pkgs(void){
continue;
}
if( getline_buffer) free(getline_buffer);
- fclose(pkg_list_fh);
regfree(&name_regex.regex);
+ regfree(&mirror_regex.regex);
regfree(&location_regex.regex);
regfree(&size_c_regex.regex);
regfree(&size_u_regex.regex);
@@ -837,3 +874,19 @@ struct pkg_list *get_available_and_update_pkgs(void){
return all;
}
+void write_pkg_data(const char *source_url,FILE *d_file,struct pkg_list *pkgs){
+ int i;
+
+ for(i=0;i < pkgs->pkg_count;i++){
+
+ fprintf(d_file,"PACKAGE NAME: %s-%s.tgz\n",pkgs->pkgs[i]->name,pkgs->pkgs[i]->version);
+ fprintf(d_file,"PACKAGE MIRROR: %s\n",source_url);
+ fprintf(d_file,"PACKAGE LOCATION: %s\n",pkgs->pkgs[i]->location);
+ fprintf(d_file,"PACKAGE SIZE (compressed): %d K\n",pkgs->pkgs[i]->size_c);
+ fprintf(d_file,"PACKAGE SIZE (uncompressed): %d K\n",pkgs->pkgs[i]->size_u);
+ fprintf(d_file,"PACKAGE DESCRIPTION:\n");
+ fprintf(d_file,"%s\n",pkgs->pkgs[i]->description);
+
+ }
+}
+
diff --git a/src/package.h b/src/package.h
index ba5fe6a..78435fe 100644
--- a/src/package.h
+++ b/src/package.h
@@ -19,6 +19,7 @@
#define MAX_PKG_ENTRIES 1300
#define PKG_PARSE_REGEX "([a-zA-Z0-9._\\-\\/]+/)([a-zA-Z0-9\\+_\\-]+)-([a-zA-Z0-9._\\-]+).tgz$"
#define PKG_NAME_PATTERN "^PACKAGE NAME:[ ]+([a-zA-Z0-9\\+_\\-]+)-([a-zA-Z0-9._\\-]+).tgz$"
+#define PKG_MIRROR_PATTERN "^PACKAGE MIRROR:[ ]+(.*)$"
#define PKG_LOCATION_PATTERN "^PACKAGE LOCATION:[ ]+(.*)$"
#define PKG_SIZEC_PATTERN "^PACKAGE SIZE [(]+compressed[)]+:[ ]+([0-9]+) K$"
#define PKG_SIZEU_PATTERN "^PACKAGE SIZE [(]+uncompressed[)]+:[ ]+([0-9]+) K$"
@@ -32,6 +33,7 @@
struct _pkg_info {
char name[50];
char version[50];
+ char mirror[200];
char location[50];
int size_c;
int size_u;
@@ -56,6 +58,7 @@ struct pkg_upgrade_list {
* FUNCTION DEFINITIONS
*/
/* parse the PACKAGES.TXT file */
+struct pkg_list *parse_packages_txt(FILE *);
struct pkg_list *get_available_pkgs(void);
/* retrieve list of installed pkgs */
struct pkg_list *get_installed_pkgs(void);
@@ -83,4 +86,6 @@ int cmp_pkg_versions(char *, char *);
int break_down_pkg_version(int *,char *);
/* get available, installed, and update pkgs all in one */
struct pkg_list *get_available_and_update_pkgs(void);
+/* write pkg data to disk */
+void write_pkg_data(const char *,FILE *,struct pkg_list *);