summaryrefslogtreecommitdiff
path: root/pkgtools/pkg_install
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2010-01-30 20:09:34 +0000
committerjoerg <joerg@pkgsrc.org>2010-01-30 20:09:34 +0000
commitd73db715bbc84fa6bec525dd189e9abe7f4bc4e0 (patch)
treedb8866496233aaae53bd0e453883345796155344 /pkgtools/pkg_install
parent8e45140b6d443ee542b3ee640a9d34dc6cd81bb4 (diff)
downloadpkgsrc-d73db715bbc84fa6bec525dd189e9abe7f4bc4e0.tar.gz
pkg_install-20100130:
Add -U for pkg_add. It works similar to -u, but replaces an already installed version.
Diffstat (limited to 'pkgtools/pkg_install')
-rw-r--r--pkgtools/pkg_install/files/add/add.h3
-rw-r--r--pkgtools/pkg_install/files/add/main.c13
-rw-r--r--pkgtools/pkg_install/files/add/perform.c47
-rw-r--r--pkgtools/pkg_install/files/add/pkg_add.111
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
5 files changed, 62 insertions, 16 deletions
diff --git a/pkgtools/pkg_install/files/add/add.h b/pkgtools/pkg_install/files/add/add.h
index d897a429e61..9c1f285fab3 100644
--- a/pkgtools/pkg_install/files/add/add.h
+++ b/pkgtools/pkg_install/files/add/add.h
@@ -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 Force;
extern Boolean Automatic;
extern int LicenseCheck;
extern int Replace;
+extern int ReplaceSame;
extern Boolean ForceDepends;
diff --git a/pkgtools/pkg_install/files/add/main.c b/pkgtools/pkg_install/files/add/main.c
index f1479f54f97..c42e873aaad 100644
--- a/pkgtools/pkg_install/files/add/main.c
+++ b/pkgtools/pkg_install/files/add/main.c
@@ -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 @@ __RCSID("$NetBSD: main.c,v 1.23 2010/01/22 13:30:41 joerg Exp $");
#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 @@ Boolean ForceDepends = FALSE;
int LicenseCheck = 0;
int Replace = 0;
+int ReplaceSame = 0;
static void
usage(void)
@@ -120,6 +121,12 @@ main(int argc, char **argv)
Prefix = optarg;
break;
+ case 'U':
+ ReplaceSame = 1;
+ if (!Replace)
+ Replace = 1;
+ break;
+
case 'u':
Replace++;
break;
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
index c58b853a9fb..d9994f78200 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -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>
@@ -84,6 +84,7 @@ struct pkg_task {
char *logdir;
char *install_logdir;
+ char *install_logdir_real;
char *other_version;
package_t plist;
@@ -338,13 +339,27 @@ check_already_installed(struct pkg_task *pkg)
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 @@ check_other_installed(struct pkg_task *pkg)
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 @@ preserve_meta_data_file(struct pkg_task *pkg, const char *name)
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 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
}
}
- 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 @@ pkg_do(const char *pkgpath, int mark_automatic, int top_level)
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 @@ nuke_pkgdb:
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 @@ clean_memory:
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 --git a/pkgtools/pkg_install/files/add/pkg_add.1 b/pkgtools/pkg_install/files/add/pkg_add.1
index f895b67e5cc..4c80199b9be 100644
--- a/pkgtools/pkg_install/files/add/pkg_add.1
+++ b/pkgtools/pkg_install/files/add/pkg_add.1
@@ -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 @@ This implies
.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 --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index 65019255c3c..664accac449 100644
--- a/pkgtools/pkg_install/files/lib/version.h
+++ b/pkgtools/pkg_install/files/lib/version.h
@@ -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_ */