pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files pkg_install-20100130:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/28a245a1e311
branches:  trunk
changeset: 570517:28a245a1e311
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sat Jan 30 20:09:34 2010 +0000

description:
pkg_install-20100130:
Add -U for pkg_add.  It works similar to -u, but replaces an already
installed version.

diffstat:

 pkgtools/pkg_install/files/add/add.h     |   3 +-
 pkgtools/pkg_install/files/add/main.c    |  13 ++++++--
 pkgtools/pkg_install/files/add/perform.c |  47 +++++++++++++++++++++++++++----
 pkgtools/pkg_install/files/add/pkg_add.1 |  11 ++++--
 pkgtools/pkg_install/files/lib/version.h |   4 +-
 5 files changed, 62 insertions(+), 16 deletions(-)

diffs (250 lines):

diff -r 7eb4d96f02be -r 28a245a1e311 pkgtools/pkg_install/files/add/add.h
--- a/pkgtools/pkg_install/files/add/add.h      Sat Jan 30 19:36:35 2010 +0000
+++ b/pkgtools/pkg_install/files/add/add.h      Sat Jan 30 20:09:34 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: add.h,v 1.17 2010/01/22 13:30:41 joerg Exp $ */
+/* $NetBSD: add.h,v 1.18 2010/01/30 20:09:34 joerg Exp $ */
 
 /* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp  */
 
@@ -37,6 +37,7 @@
 extern Boolean Automatic;
 extern int LicenseCheck;
 extern int Replace;
+extern int ReplaceSame;
 
 extern Boolean ForceDepends;
 
diff -r 7eb4d96f02be -r 28a245a1e311 pkgtools/pkg_install/files/add/main.c
--- a/pkgtools/pkg_install/files/add/main.c     Sat Jan 30 19:36:35 2010 +0000
+++ b/pkgtools/pkg_install/files/add/main.c     Sat Jan 30 20:09:34 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.23 2010/01/22 13:30:41 joerg Exp $  */
+/*     $NetBSD: main.c,v 1.24 2010/01/30 20:09:34 joerg Exp $  */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -7,7 +7,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: main.c,v 1.23 2010/01/22 13:30:41 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.24 2010/01/30 20:09:34 joerg Exp $");
 
 /*
  *
@@ -39,7 +39,7 @@
 #include "lib.h"
 #include "add.h"
 
-static char Options[] = "AIK:LP:RVW:fhm:np:t:uvw:";
+static char Options[] = "AIK:LP:RVW:fhm:np:t:Uuvw:";
 
 char   *Destdir = NULL;
 char   *OverrideMachine = NULL;
@@ -54,6 +54,7 @@
 
 int    LicenseCheck = 0;
 int     Replace = 0;
+int    ReplaceSame = 0;
 
 static void
 usage(void)
@@ -120,6 +121,12 @@
                        Prefix = optarg;
                        break;
 
+               case 'U':
+                       ReplaceSame = 1;
+                       if (!Replace)
+                               Replace = 1;
+                       break;
+
                case 'u':
                        Replace++;
                        break;
diff -r 7eb4d96f02be -r 28a245a1e311 pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Sat Jan 30 19:36:35 2010 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Sat Jan 30 20:09:34 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.92 2010/01/22 13:30:41 joerg Exp $       */
+/*     $NetBSD: perform.c,v 1.93 2010/01/30 20:09:34 joerg Exp $       */
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -6,7 +6,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: perform.c,v 1.92 2010/01/22 13:30:41 joerg Exp $");
+__RCSID("$NetBSD: perform.c,v 1.93 2010/01/30 20:09:34 joerg Exp $");
 
 /*-
  * Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -84,6 +84,7 @@
 
        char *logdir;
        char *install_logdir;
+       char *install_logdir_real;
        char *other_version;
 
        package_t plist;
@@ -338,13 +339,27 @@
        int fd;
 
        if (Force)
-               return -1;
+               return 1;
 
        filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME);
        fd = open(filename, O_RDONLY);
        free(filename);
        if (fd == -1)
-               return -1;
+               return 1;
+
+       if (ReplaceSame) {
+               struct stat sb;
+
+               pkg->install_logdir_real = pkg->install_logdir;
+               pkg->install_logdir = xasprintf("%s.xxxxxx", pkg->install_logdir);
+               if (stat(pkg->install_logdir, &sb) == 0) {
+                       warnx("package `%s' already has a temporary update "
+                           "directory `%s', remove it manually",
+                           pkg->pkgname, pkg->install_logdir);
+                       return -1;
+               }
+               return 1;
+       }
 
        /* We can only arrive here for explicitly requested packages. */
        if (!Automatic && is_automatic_installed(pkg->pkgname)) {
@@ -372,6 +387,11 @@
        plist_t *p;
        int status;
 
+       if (pkg->install_logdir_real) {
+               pkg->other_version = xstrdup(pkg->pkgname);
+               return 0;
+       }
+
        pkgbase = xstrdup(pkg->pkgname);
 
        if ((iter = strrchr(pkgbase, '-')) == NULL) {
@@ -1110,7 +1130,7 @@
                return 0;
 
        old_file = pkgdb_pkg_file(pkg->other_version, name);
-       new_file = pkgdb_pkg_file(pkg->pkgname, name);
+       new_file = xasprintf("%s/%s", pkg->install_logdir, name);
        rv = 0;
        if (rename(old_file, new_file) == -1 && errno != ENOENT) {
                warn("Can't move %s from %s to %s", name, old_file, new_file);
@@ -1353,9 +1373,14 @@
                }
        }
 
-       if (check_already_installed(pkg) == 0) {
+       switch (check_already_installed(pkg)) {
+       case 0:
                status = 0;
                goto clean_memory;
+       case 1:
+               break;
+       case -1:
+               goto clean_memory;
        }
 
        if (check_platform(pkg))
@@ -1382,6 +1407,13 @@
                if (start_replacing(pkg))
                        goto nuke_pkgdb;
 
+               if (pkg->install_logdir_real) {
+                       rename(pkg->install_logdir, pkg->install_logdir_real);
+                       free(pkg->install_logdir);
+                       pkg->install_logdir = pkg->install_logdir_real;
+                       pkg->install_logdir_real = NULL;
+               }
+
                if (check_dependencies(pkg))
                        goto nuke_pkgdb;
        } else {
@@ -1438,8 +1470,10 @@
        if (!Fake) {
                if (recursive_remove(pkg->install_logdir, 1))
                        warn("Couldn't remove %s", pkg->install_logdir);
+               free(pkg->install_logdir_real);
                free(pkg->install_logdir);
                free(pkg->logdir);
+               pkg->install_logdir_real = NULL;
                pkg->install_logdir = NULL;
                pkg->logdir = NULL;
        }
@@ -1450,6 +1484,7 @@
                        warn("Couldn't remove %s", pkg->install_logdir);
        }
        free(pkg->install_prefix);
+       free(pkg->install_logdir_real);
        free(pkg->install_logdir);
        free(pkg->logdir);
        free_buildinfo(pkg);
diff -r 7eb4d96f02be -r 28a245a1e311 pkgtools/pkg_install/files/add/pkg_add.1
--- a/pkgtools/pkg_install/files/add/pkg_add.1  Sat Jan 30 19:36:35 2010 +0000
+++ b/pkgtools/pkg_install/files/add/pkg_add.1  Sat Jan 30 20:09:34 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pkg_add.1,v 1.41 2010/01/22 13:30:41 joerg Exp $
+.\" $NetBSD: pkg_add.1,v 1.42 2010/01/30 20:09:34 joerg Exp $
 .\"
 .\" FreeBSD install - a package for the installation and maintenance
 .\" of non-core utilities.
@@ -17,7 +17,7 @@
 .\"
 .\"     @(#)pkg_add.1
 .\"
-.Dd January 22, 2010
+.Dd January 30, 2010
 .Dt PKG_ADD 1
 .Os
 .Sh NAME
@@ -25,7 +25,7 @@
 .Nd a utility for installing and upgrading software package distributions
 .Sh SYNOPSIS
 .Nm
-.Op Fl AfILnRuVv
+.Op Fl AfILnRUuVv
 .Op Fl K Ar pkg_dbdir
 .Op Fl m Ar machine
 .Op Fl P Ar destdir
@@ -155,10 +155,13 @@
 .Fl I .
 This means that you cannot deinstall it later, so only use this option if
 you know what you are doing!
+.It Fl U
+Replace an already installed version from a package.
+Implies
+.Fl u .
 .It Fl u
 If the package that's being installed is already installed,
 an update is performed.
-It is currently not possible to update to an identical version.
 If this is specified twice, then any dependent packages that are
 too old will also be updated to fulfill the dependency.
 See below for a more detailed description of the process.
diff -r 7eb4d96f02be -r 28a245a1e311 pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Sat Jan 30 19:36:35 2010 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Sat Jan 30 20:09:34 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.147 2010/01/26 15:48:13 joerg Exp $      */
+/*     $NetBSD: version.h,v 1.148 2010/01/30 20:09:34 joerg Exp $      */
 
 /*
  * Copyright (c) 2001 Thomas Klausner.  All rights reserved.
@@ -27,6 +27,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION "20100126"
+#define PKGTOOLS_VERSION "20100130"
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index