aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2003-10-13 20:48:13 +0000
committerJason Woodward2003-10-13 20:48:13 +0000
commit4537dd87ae11fa6a774bc255b4e1127dc05f4898 (patch)
tree394c67cf68094aff2724819166072ad54e264313
parent2f3773ccfc9d2afbd6ec8b8153389d9b35aae781 (diff)
downloadslapt-get-4537dd87ae11fa6a774bc255b4e1127dc05f4898.tar.gz
continueing work on merging update pkg info into main package data
-rw-r--r--src/action.c13
-rw-r--r--src/package.c12
-rw-r--r--src/package.h1
3 files changed, 19 insertions, 7 deletions
diff --git a/src/action.c b/src/action.c
index aee23f6..ad1dda8 100644
--- a/src/action.c
+++ b/src/action.c
@@ -233,7 +233,6 @@ void pkg_action_update(const rc_config *global_config){
#if USE_CURL_PROGRESS == 0
printf("Done\n");
#endif
- fclose(pkg_list_fh);
/* download PATCHES_LIST */
#if USE_CURL_PROGRESS == 0
@@ -241,14 +240,20 @@ void pkg_action_update(const rc_config *global_config){
#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);
+ patches_list_fh = tmpfile();
+ if( get_mirror_data_from_source(patches_list_fh,global_config->sources.url[i],PATCHES_LIST) == 0 ){
+ rewind(patches_list_fh); /* make sure we are back at the front of the file */
+ available_pkgs = parse_file_list(patches_list_fh);
+ write_pkg_data(global_config->sources.url[i],pkg_list_fh,available_pkgs);
+ free_pkg_list(available_pkgs);
+ }
+ fclose(patches_list_fh);
}
#if USE_CURL_PROGRESS == 0
printf("Done\n");
#endif
- fclose(patches_list_fh);
+ fclose(pkg_list_fh);
/* download checksum file */
#if USE_CURL_PROGRESS == 0
diff --git a/src/package.c b/src/package.c
index 5c627c2..6bb886b 100644
--- a/src/package.c
+++ b/src/package.c
@@ -439,6 +439,15 @@ pkg_info_t *get_newest_pkg(pkg_info_t **pkgs,const char *pkg_name,int pkg_count)
/* parse the update list */
struct pkg_list *get_update_pkgs(void){
FILE *fh;
+ struct pkg_list *list;
+
+ fh = open_file(PATCHES_LIST_L,"r");
+ list = parse_file_list(fh);
+ fclose(fh);
+ return list;
+}
+
+struct pkg_list *parse_file_list(FILE *fh){
size_t getline_len;
ssize_t bytes_read;
sg_regex up_regex;
@@ -450,8 +459,6 @@ struct pkg_list *get_update_pkgs(void){
list->pkg_count = 0;
up_regex.nmatch = MAX_REGEX_PARTS;
- fh = open_file(PATCHES_LIST_L,"r");
-
up_regex.reg_return = regcomp(&up_regex.regex,PKG_PARSE_REGEX, REG_EXTENDED|REG_NEWLINE);
list->pkgs = malloc( sizeof *list->pkgs );
@@ -533,7 +540,6 @@ struct pkg_list *get_update_pkgs(void){
if( getline_buffer ) free(getline_buffer);
regfree(&up_regex.regex);
- fclose(fh);
return list;
}
diff --git a/src/package.h b/src/package.h
index 78435fe..520f815 100644
--- a/src/package.h
+++ b/src/package.h
@@ -63,6 +63,7 @@ struct pkg_list *get_available_pkgs(void);
/* retrieve list of installed pkgs */
struct pkg_list *get_installed_pkgs(void);
/* return list of update pkgs */
+struct pkg_list *parse_file_list(FILE *);
struct pkg_list *get_update_pkgs(void);
/* generate a short description */
char *gen_short_pkg_description(pkg_info_t *);