Write out status files for the correct pkg->dest, instead of the default.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Sun, 15 Nov 2009 04:23:56 +0000 (04:23 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Sun, 15 Nov 2009 04:23:56 +0000 (04:23 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@301 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_conf.c
libopkg/pkg_dest.h

index 2a3ea0c56f7060e05375c76a346d33e6bdac63ae..425c72bd9e6832d34d69bcf1f665cd2947044e06 100644 (file)
@@ -687,22 +687,24 @@ static int opkg_conf_set_option(const opkg_option_t *options,
 
 int opkg_conf_write_status_files(opkg_conf_t *conf)
 {
+     pkg_dest_list_elt_t *iter;
      pkg_dest_t *dest;
      pkg_vec_t *all;
      pkg_t *pkg;
-     int i;
-     FILE *fp;
+     int i, ret = 0;
 
      if (conf->noaction)
          return 0;
 
-     dest = (pkg_dest_t *)void_list_first(&conf->pkg_dest_list)->data;
+     list_for_each_entry(iter, &conf->pkg_dest_list.head, node) {
+          dest = (pkg_dest_t *)iter->data;
 
-     fp = fopen(dest->status_file_name, "w");
-     if (fp == NULL) {
-         fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
-                 __FUNCTION__, dest->status_file_name, strerror(errno));
-        return -1;
+          dest->status_fp = fopen(dest->status_file_name, "w");
+          if (dest->status_fp == NULL) {
+               fprintf(stderr, "%s: Can't open status file: %s: %s\n",
+                    __FUNCTION__, dest->status_file_name, strerror(errno));
+               ret = -1;
+          }
      }
 
      all = pkg_vec_alloc();
@@ -723,13 +725,18 @@ int opkg_conf_write_status_files(opkg_conf_t *conf)
                       __FUNCTION__, pkg->name);
               continue;
          }
-         pkg_print_status(pkg, fp);
+         if (pkg->dest->status_fp)
+              pkg_print_status(pkg, pkg->dest->status_fp);
      }
 
      pkg_vec_free(all);
-     fclose(fp);
 
-     return 0;
+     list_for_each_entry(iter, &conf->pkg_dest_list.head, node) {
+          dest = (pkg_dest_t *)iter->data;
+          fclose(dest->status_fp);
+     }
+
+     return ret;
 }
 
 
index b29066472a3179c0b59f64a28e333c887a2b5b5e..e0840cc737b69a50b669a5927da80f7388cfac9d 100644 (file)
@@ -29,6 +29,7 @@ struct pkg_dest
     char *lists_dir;
     char *info_dir;
     char *status_file_name;
+    FILE *status_fp;
 };
 
 int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const char *lists_dir);