Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pkg_install/add Fix a few comments, and add some ot...



details:   https://anonhg.NetBSD.org/src/rev/606bfc6da421
branches:  trunk
changeset: 535346:606bfc6da421
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Fri Aug 16 00:47:39 2002 +0000

description:
Fix a few comments, and add some others to outline what's missing
in the pkg upgrade case (two TODOs :)

diffstat:

 usr.sbin/pkg_install/add/perform.c |  36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)

diffs (76 lines):

diff -r 6f91a139d2f3 -r 606bfc6da421 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Fri Aug 16 00:06:26 2002 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Fri Aug 16 00:47:39 2002 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.70 2002/07/20 08:36:19 grant Exp $       */
+/*     $NetBSD: perform.c,v 1.71 2002/08/16 00:47:39 hubertf Exp $     */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.70 2002/07/20 08:36:19 grant Exp $");
+__RCSID("$NetBSD: perform.c,v 1.71 2002/08/16 00:47:39 hubertf Exp $");
 #endif
 #endif
 
@@ -93,9 +93,8 @@
 }
 
 /*
- * This is seriously ugly code following.  Written very fast!
- * [And subsequently made even worse..  Sigh!  This code was just born
- * to be hacked, I guess.. :) -jkh]
+ * Install a single package
+ * Returns 0 if everything is ok, >0 else
  */
 static int
 pkg_do(const char *pkg)
@@ -302,10 +301,26 @@
                        char    buf[FILENAME_MAX];
                        char    installed[FILENAME_MAX];
 
+                       /*
+                        * See if the pkg is already installed. If so, we might
+                        * want to upgrade it. 
+                        */
                        (void) snprintf(buf, sizeof(buf), "%.*s[0-9]*",
                                (int)(s - PkgName) + 1, PkgName);
                        if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0) {
                                if (upgrade) {
+                                       /*
+                                        * Upgrade step 1/4: Check if the new version is ok with all pkgs
+                                        * that require this pkg
+                                        */
+                                       /* TODO */
+
+                                       /*
+                                        * Upgrade step 2/4: Do the actual update by moving aside
+                                        * the +REQUIRED_BY file, deinstalling the old pkg, adding
+                                        * the new one and moving the +REQUIRED_BY file back
+                                        * into place (finished in step 3/4)
+                                        */
                                        snprintf(upgrade_from, sizeof(upgrade_from), "%s/%s/" REQUIRED_BY_FNAME,
                                                 dbdir, installed);
                                        snprintf(upgrade_via, sizeof(upgrade_via), "%s/.%s." REQUIRED_BY_FNAME,
@@ -649,8 +664,19 @@
        leave_playpen(Home);
 
        if (upgrading) {
+               /*
+                * Upgrade step 3/4: move back +REQUIRED_BY file
+                * (see also step 2/4)
+                */
                rc = rename(upgrade_via, upgrade_to);
                assert(rc == 0);
+               
+               /*
+                * Upgrade step 4/4: Fix pkgs that depend on us to
+                * depend on the new version instead of the old
+                * one by fixing @pkgdep lines in +CONTENTS files.
+                */
+               /* TODO */
        }
 
        return errc;



Home | Main Index | Thread Index | Old Index