poldek: poldek/install-dist.c, poldek/poldek_intern.h, poldek/pold...

mis mis at pld-linux.org
Wed Aug 23 00:46:37 CEST 2006


Author: mis                          Date: Tue Aug 22 22:46:37 2006 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- --dump packages in installing order && related cleanups

---- Files affected:
poldek/poldek:
   install-dist.c (1.8 -> 1.9) , poldek_intern.h (1.9 -> 1.10) , poldek_ts.c (1.57 -> 1.58) 
poldek/poldek/install:
   install.c (1.4 -> 1.5) 
poldek/poldek/pm/rpm:
   rpminstall.c (1.16 -> 1.17) 

---- Diffs:

================================================================
Index: poldek/poldek/install-dist.c
diff -u poldek/poldek/install-dist.c:1.8 poldek/poldek/install-dist.c:1.9
--- poldek/poldek/install-dist.c:1.8	Sat Jun 11 23:18:36 2005
+++ poldek/poldek/install-dist.c	Wed Aug 23 00:46:32 2006
@@ -95,6 +95,7 @@
     int               i, nerr;
     struct inf        inf;
     char              tmpdir[PATH_MAX];
+    tn_array          *pkgs = NULL;
     
     n_assert(ts->db->rootdir);
     if (!poldek_util_is_rwxdir(ts->db->rootdir)) {
@@ -118,13 +119,13 @@
     n_array_map_arg(ts->ctx->ps->pkgs, (tn_fn_map2)is_marked_mapfn, &inf);
     
     display_iinf_start(&inf);
-    for (i=0; i < n_array_size(ts->ctx->ps->ordered_pkgs); i++) {
-        struct pkg *pkg = n_array_nth(ts->ctx->ps->ordered_pkgs, i);
+    pkgs = ts__packages_in_install_order(ts);
+    
+    for (i=0; i < n_array_size(pkgs); i++) {
+        struct pkg *pkg = n_array_nth(pkgs, i);
         char *pkgpath;
         
-        if (pkg_isnot_marked(ts->pms, pkg))
-            continue;
-        
+        n_assert(pkg_is_marked(ts->pms, pkg));
         pkgpath = pkg_path_s(pkg);
         
         if (poldek_VERBOSE > 1) {
@@ -165,6 +166,7 @@
                          inf.ninstalled);
     if (nerr) 
         logn(LOGERR, _("There were errors during install"));
-    
+
+    n_array_cfree(&pkgs);
     return nerr == 0;
 }

================================================================
Index: poldek/poldek/poldek_intern.h
diff -u poldek/poldek/poldek_intern.h:1.9 poldek/poldek/poldek_intern.h:1.10
--- poldek/poldek/poldek_intern.h:1.9	Sun Aug 20 20:14:58 2006
+++ poldek/poldek/poldek_intern.h	Wed Aug 23 00:46:32 2006
@@ -45,4 +45,5 @@
 
 void poldek__ts_dump_settings(struct poldek_ctx *ctx, struct poldek_ts *ts);
 
+tn_array *ts__packages_in_install_order(const struct poldek_ts *ts);
 #endif

================================================================
Index: poldek/poldek/poldek_ts.c
diff -u poldek/poldek/poldek_ts.c:1.57 poldek/poldek/poldek_ts.c:1.58
--- poldek/poldek/poldek_ts.c:1.57	Sun Aug 20 20:14:58 2006
+++ poldek/poldek/poldek_ts.c	Wed Aug 23 00:46:32 2006
@@ -834,20 +834,31 @@
     return rc;
 }
 
-/* --fetch, --dump */
-static int ts_fetch_or_dump_packages(struct poldek_ts *ts) 
+tn_array *ts__packages_in_install_order(const struct poldek_ts *ts)
 {
-    int i, rc = 0;
-    tn_array *pkgs = n_array_new(512, NULL, NULL);
-
-    /* dump/fetch packages in install order */
+    tn_array *pkgs = n_array_new(512, (tn_fn_free)pkg_free, NULL);
+    int i;
+    
     for (i=0; i < n_array_size(ts->ctx->ps->ordered_pkgs); i++) {
         struct pkg *pkg = n_array_nth(ts->ctx->ps->ordered_pkgs, i);
 
-        if (pkg_isnot_marked(ts->pms, pkg))
-            continue;
-        n_array_push(pkgs, pkg);
+        if (pkg_is_marked(ts->pms, pkg))
+            n_array_push(pkgs, pkg_link(pkg));
     }
+
+    return pkgs;
+}
+
+
+/* --fetch, --dump, packages in install order; used by install_dist()
+   only - install/ calls directly packages_{dump,fetch}()
+*/
+static int ts_fetch_or_dump_packages(struct poldek_ts *ts) 
+{
+    tn_array *pkgs;
+    int rc = 0;
+    
+    pkgs = ts__packages_in_install_order(ts);
     
     if (ts->getop_v(ts, POLDEK_OP_JUSTPRINT, POLDEK_OP_JUSTPRINT_N, 0)) {
         rc = packages_dump(pkgs, ts->dumpfile,

================================================================
Index: poldek/poldek/install/install.c
diff -u poldek/poldek/install/install.c:1.4 poldek/poldek/install/install.c:1.5
--- poldek/poldek/install/install.c:1.4	Thu Nov  3 01:21:05 2005
+++ poldek/poldek/install/install.c	Wed Aug 23 00:46:32 2006
@@ -214,8 +214,8 @@
 static
 int do_install(struct install_ctx *ictx, struct poldek_iinf *iinf)
 {
-    int rc, nerr = 0, any_err = 0;
-    tn_array *pkgs;
+    int rc = 1, nerr = 0, any_err = 0;
+    tn_array *pkgs = NULL;
     struct poldek_ts *ts;
     int i;
 
@@ -231,16 +231,9 @@
             break;
     }
 
-    pkgs = n_array_new(64, NULL, NULL);
-    for (i = n_array_size(ictx->ps->ordered_pkgs) - 1; i > -1; i--) {
-        struct pkg *pkg = n_array_nth(ictx->ps->ordered_pkgs, i);
-        if (pkg_is_marked(ictx->ts->pms, pkg))
-            n_array_push(pkgs, pkg);
-    }
-    
     if (ictx->nerr_fatal || sigint_reached())
         return 0;
-
+    
     n_array_sort(ictx->install_pkgs);
     print_install_summary(ictx);
     pkgdb_close(ts->db); /* release db as soon as possible */
@@ -253,44 +246,52 @@
 
     rc = (any_err == 0);
     if (nerr)
-        return 0;
-    
-    if ((ts->getop_v(ts, POLDEK_OP_JUSTPRINT, POLDEK_OP_JUSTPRINT_N,
-                     POLDEK_OP_JUSTFETCH, 0)) == 0)
-        if (!valid_arch_os(ictx->ts, ictx->install_pkgs)) 
-            return 0;
+        goto l_end;
 
+    pkgs = ts__packages_in_install_order(ictx->ts);
+    n_assert(n_array_size(pkgs) == n_array_size(ictx->install_pkgs));
 
     if (ts->getop_v(ts, POLDEK_OP_JUSTPRINT, POLDEK_OP_JUSTPRINT_N, 0)) {
-        rc = packages_dump(ictx->install_pkgs, ts->dumpfile,
+        rc = packages_dump(pkgs, ts->dumpfile,
                            ts->getop(ts, POLDEK_OP_JUSTPRINT_N) == 0);
-        return rc;
+        goto l_end;
+    }
+
+    if ((ts->getop_v(ts, POLDEK_OP_JUSTPRINT, POLDEK_OP_JUSTPRINT_N,
+                     POLDEK_OP_JUSTFETCH, 0)) == 0) {
+        if (!valid_arch_os(ictx->ts, ictx->install_pkgs)) {
+            rc = 0;
+            goto l_end;
+        }
     }
 
     /* poldek's test only  */
     if (ts->getop(ts, POLDEK_OP_TEST) && !ts->getop(ts, POLDEK_OP_RPMTEST))
-        return rc;
+        goto l_end;
     
     if (ts->getop(ts, POLDEK_OP_JUSTFETCH)) {
         const char *destdir = ts->fetchdir;
         if (destdir == NULL)
             destdir = ts->cachedir;
 
-        rc = packages_fetch(ts->pmctx, ictx->install_pkgs, destdir,
-                            ts->fetchdir ? 1 : 0);
+        rc = packages_fetch(ts->pmctx, pkgs, destdir, ts->fetchdir ? 1 : 0);
 
     } else if (!ts->getop(ts, POLDEK_OP_HOLD) || (rc = verify_holds(ictx))) {
         int is_test = ts->getop(ts, POLDEK_OP_RPMTEST);
 
         if (!is_test && ts->getop(ts, POLDEK_OP_CONFIRM_INST) && ts->ask_fn) {
-            if (!ts->ask_fn(1, _("Proceed? [Y/n]")))
-                return 1;
+            if (!ts->ask_fn(1, _("Proceed? [Y/n]"))) {
+                rc = 1;
+                goto l_end;
+            }
         }
         
         if (!ts->getop(ts, POLDEK_OP_NOFETCH))
-            if (!packages_fetch(ts->pmctx, pkgs, ts->cachedir, 0))
-                return 0;
-
+            if (!packages_fetch(ts->pmctx, pkgs, ts->cachedir, 0)) {
+                rc = 0;
+                goto l_end;
+            }
+        
         rc = pm_pminstall(ts->db, pkgs, ictx->uninst_set->dbpkgs, ts);
         
         if (!is_test && iinf)
@@ -300,6 +301,10 @@
                                POLDEK_OP_NOFETCH, 0))
             packages_fetch_remove(pkgs, ts->cachedir);
     }
+
+l_end:
+    if (pkgs)
+        n_array_free(pkgs);
     
     return rc;
 }
@@ -403,10 +408,10 @@
         ts->setop(ts, POLDEK_OP_PARTICLE, 0);
     
     n = 1;
-#if 0                           /* debug */
-    for (i = 0; i < n_array_size(ps->ordered_pkgs); i++) {
-        struct pkg *pkg = n_array_nth(ps->ordered_pkgs, i);
-        if (pkg_is_marked_i(pkg)) 
+#if DEVEL                        /* debug */
+    for (i = 0; i < n_array_size(ictx.ps->ordered_pkgs); i++) {
+        struct pkg *pkg = n_array_nth(ictx.ps->ordered_pkgs, i);
+        if (pkg_is_marked_i(ts->pms, pkg)) 
             printf("MARKED %s\n", pkg_id(pkg));
     }
 #endif    

================================================================
Index: poldek/poldek/pm/rpm/rpminstall.c
diff -u poldek/poldek/pm/rpm/rpminstall.c:1.16 poldek/poldek/pm/rpm/rpminstall.c:1.17
--- poldek/poldek/pm/rpm/rpminstall.c:1.16	Sat Oct  8 02:05:46 2005
+++ poldek/poldek/pm/rpm/rpminstall.c	Wed Aug 23 00:46:32 2006
@@ -361,41 +361,41 @@
     
     nsignerr = 0;
     nopts = n;
-    for (i=0; i < n_array_size(ts->ctx->ps->ordered_pkgs); i++) {
-        struct pkg *pkg = n_array_nth(ts->ctx->ps->ordered_pkgs, i);
-        if (pkg_is_marked(ts->pms, pkg)) {
-            char path[PATH_MAX], *s, name[1024];
-            char *pkgpath = pkg->pkgdir->path;
-            unsigned vrfyflags;
-            int len;
-            
+    for (i=0; i < n_array_size(pkgs); i++) {
+        char path[PATH_MAX], *s, name[1024], *pkgpath;
+        unsigned vrfyflags;
+        struct pkg *pkg;
+        int len;
+
+        pkg = n_array_nth(pkgs, i);
+        char *pkgpath = pkg->pkgdir->path;
+        
+        n_assert(pkg_is_marked(ts->pms, pkg));
             
-            pkg_filename(pkg, name, sizeof(name));
-            if (vf_url_type(pkgpath) == VFURL_PATH) {
-                len = n_snprintf(path, sizeof(path), "%s/%s", pkgpath, name);
+        pkg_filename(pkg, name, sizeof(name));
+        if (vf_url_type(pkgpath) == VFURL_PATH) {
+            len = n_snprintf(path, sizeof(path), "%s/%s", pkgpath, name);
             
-            } else {
-                char buf[1024];
+        } else {
+            char buf[1024];
                 
-                vf_url_as_dirpath(buf, sizeof(buf), pkgpath);
-                len = n_snprintf(path, sizeof(path), "%s/%s/%s", ts->cachedir,
-                                 buf, n_basenam(name));
-            }
+            vf_url_as_dirpath(buf, sizeof(buf), pkgpath);
+            len = n_snprintf(path, sizeof(path), "%s/%s/%s", ts->cachedir,
+                             buf, n_basenam(name));
+        }
 
-            if ((vrfyflags = pkg_get_verify_signflags(pkg))) {
-                if (!pm_rpm_verify_signature(pm, path, vrfyflags)) {
-                    logn(LOGERR, _("%s: signature verification failed"),
-                         pkg_snprintf_s(pkg));
-                    nsignerr++;
-                }
+        if ((vrfyflags = pkg_get_verify_signflags(pkg))) {
+            if (!pm_rpm_verify_signature(pm, path, vrfyflags)) {
+                logn(LOGERR, _("%s: signature verification failed"),
+                     pkg_snprintf_s(pkg));
+                nsignerr++;
             }
-            
-            
-            s = alloca(len + 1);
-            memcpy(s, path, len);
-            s[len] = '\0';
-            argv[n++] = s;
         }
+
+        s = alloca(len + 1);
+        memcpy(s, path, len);
+        s[len] = '\0';
+        argv[n++] = s;
     }
 
     if (nsignerr) {
@@ -421,31 +421,16 @@
             p += n_snprintf(p, &buf[sizeof(buf) - 1] - p, " %s", argv[i]);
         *p = '\0';
         msgn(1, _("Executing%s..."), buf);
-    }
-    
-    
-    ec = pm_rpm_execrpm(cmd, argv, 1, 1);
-#if 0                           /* moved to packages_fetch_remove() */
-    if (ec == 0 && !ts->getop(ts, POLDEK_OP_RPMTEST) &&
-        !ts->getop(ts, POLDEK_OP_KEEP_DOWNLOADS)) {
-        
-        n = nopts;
-        for (i=0; i < n_array_size(ts->ctx->ps->ordered_pkgs); i++) {
-            struct pkg *pkg = n_array_nth(ts->ctx->ps->ordered_pkgs, i);
-            int url_type;
-            
-            if (!pkg_is_marked(ts->pms, pkg))
-                continue;
-            
-            url_type = vf_url_type(pkg->pkgdir->path);
-            if ((url_type & (VFURL_PATH | VFURL_UNKNOWN)) == 0) {
-                DBG("unlink %s\n", argv[n]); 
-                unlink(argv[n]);
+        if (poldek_VERBOSE > 2) {
+            for (i = 0; i < n_array_size(pkgs); i++) {
+                struct pkg *pkg = n_array_nth(pkgs, i);
+                msgn("  %s", pkg_id(pkg));
             }
-            n++;
         }
     }
-#endif
+    
+    ec = pm_rpm_execrpm(cmd, argv, 1, 1);
+
     return ec == 0;
     
  l_err_end:
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/install-dist.c?r1=1.8&r2=1.9&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_intern.h?r1=1.9&r2=1.10&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_ts.c?r1=1.57&r2=1.58&f=u
    http://cvs.pld-linux.org/poldek/poldek/install/install.c?r1=1.4&r2=1.5&f=u
    http://cvs.pld-linux.org/poldek/poldek/pm/rpm/rpminstall.c?r1=1.16&r2=1.17&f=u



More information about the pld-cvs-commit mailing list