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 Make binary updates work be...
details: https://anonhg.NetBSD.org/pkgsrc/rev/08dd7d5de8ce
branches: trunk
changeset: 485387:08dd7d5de8ce
user: erh <erh%pkgsrc.org@localhost>
date: Thu Dec 09 20:10:34 2004 +0000
description:
Make binary updates work better when there are dependant packages to
update also. Specifying -u twice will now update the named package
and its dependencies.
Also make sure Fake really means Fake, even if update is specified.
diffstat:
pkgtools/pkg_install/files/add/add.h | 3 +-
pkgtools/pkg_install/files/add/main.c | 22 ++++++-----
pkgtools/pkg_install/files/add/perform.c | 63 ++++++++++++++++++++-----------
pkgtools/pkg_install/files/lib/lib.h | 3 +-
4 files changed, 55 insertions(+), 36 deletions(-)
diffs (238 lines):
diff -r 423827f6148e -r 08dd7d5de8ce pkgtools/pkg_install/files/add/add.h
--- a/pkgtools/pkg_install/files/add/add.h Thu Dec 09 18:56:53 2004 +0000
+++ b/pkgtools/pkg_install/files/add/add.h Thu Dec 09 20:10:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: add.h,v 1.3 2003/09/23 07:13:46 grant Exp $ */
+/* $NetBSD: add.h,v 1.4 2004/12/09 20:10:34 erh Exp $ */
/* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp */
@@ -36,6 +36,7 @@
extern Boolean NoInstall;
extern Boolean NoRecord;
extern Boolean Force;
+extern int Replace;
extern char *Mode;
extern char *Owner;
extern char *Group;
diff -r 423827f6148e -r 08dd7d5de8ce pkgtools/pkg_install/files/add/main.c
--- a/pkgtools/pkg_install/files/add/main.c Thu Dec 09 18:56:53 2004 +0000
+++ b/pkgtools/pkg_install/files/add/main.c Thu Dec 09 20:10:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.6 2003/12/20 04:23:05 grant Exp $ */
+/* $NetBSD: main.c,v 1.7 2004/12/09 20:10:34 erh Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -11,7 +11,7 @@
#if 0
static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.6 2003/12/20 04:23:05 grant Exp $");
+__RCSID("$NetBSD: main.c,v 1.7 2004/12/09 20:10:34 erh Exp $");
#endif
#endif
@@ -65,7 +65,7 @@
char *Directory = NULL;
char FirstPen[FILENAME_MAX];
add_mode_t AddMode = NORMAL;
-Boolean Replace = FALSE;
+int Replace = 0;
static void
usage(void)
@@ -134,7 +134,7 @@
break;
case 'u':
- Replace = 1;
+ Replace++;
break;
case 'V':
@@ -178,12 +178,14 @@
TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
}
- } else if (!ch)
- /* If no packages, yelp */
- warnx("missing package name(s)"), usage();
- else if (ch > 1 && AddMode == MASTER)
- warnx("only one package name may be specified with master mode"),
- usage();
+
+ if (!ch)
+ /* If no packages, yelp */
+ warnx("missing package name(s)"), usage();
+ else if (ch > 1 && AddMode == MASTER)
+ warnx("only one package name may be specified with master mode"),
+ usage();
+ }
/* Increase # of max. open file descriptors as high as possible */
rc = getrlimit(RLIMIT_NOFILE, &rlim);
diff -r 423827f6148e -r 08dd7d5de8ce pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c Thu Dec 09 18:56:53 2004 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c Thu Dec 09 20:10:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perform.c,v 1.25 2004/11/02 00:10:15 erh Exp $ */
+/* $NetBSD: perform.c,v 1.26 2004/12/09 20:10:34 erh Exp $ */
#if HAVE_CONFIG_H
#include "config.h"
@@ -11,7 +11,7 @@
#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.25 2004/11/02 00:10:15 erh Exp $");
+__RCSID("$NetBSD: perform.c,v 1.26 2004/12/09 20:10:34 erh Exp $");
#endif
#endif
@@ -147,7 +147,7 @@
/* install a pre-requisite package. Returns 1 if it installed it */
static int
-installprereq(const char *name, int *errc)
+installprereq(const char *name, int *errc, int doupdate)
{
int ret;
ret = 0;
@@ -158,6 +158,8 @@
if (fexec_skipempty(BINDIR "/pkg_add", "-K", _pkgdb_getPKGDB_DIR(),
"-s", get_verification(),
+ doupdate ? "-u" : "",
+ Fake ? "-n" : "",
NoView ? "-L" : "",
View ? "-w" : "", View ? View : "",
Viewbase ? "-W" : "", Viewbase ? Viewbase : "",
@@ -180,7 +182,7 @@
* Returns 0 if everything is ok, >0 else
*/
static int
-pkg_do(const char *pkg)
+pkg_do(const char *pkg, lpkg_head_t *pkgs)
{
char playpen[FILENAME_MAX];
char replace_from[FILENAME_MAX];
@@ -492,7 +494,8 @@
(void) snprintf(buf, sizeof(buf), "%.*s[0-9]*",
(int)(s - PkgName) + 1, PkgName);
if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0) {
- if (Replace) {
+ if (Replace && !Fake) {
+ /* XXX Should list the steps in Fake mode */
snprintf(replace_from, sizeof(replace_from), "%s/%s/" REQUIRED_BY_FNAME,
dbdir, installed);
snprintf(replace_via, sizeof(replace_via), "%s/.%s." REQUIRED_BY_FNAME,
@@ -560,7 +563,7 @@
* one at all.
*/
strlcpy(base_new, PkgName, sizeof(base_new));
- s2 = strpbrk(base_new, "<>[]?*{");
+ s2 = strpbrk(base_new, "<>[]?*{"); /* } */
if (s2)
*s2 = '\0';
else {
@@ -569,7 +572,7 @@
*s2 = '\0';
}
strlcpy(base_exist, depp->name, sizeof(base_exist));
- s2 = strpbrk(base_exist, "<>[]?*{");
+ s2 = strpbrk(base_exist, "<>[]?*{"); /* } */
if (s2)
*s2 = '\0';
else {
@@ -685,21 +688,35 @@
(void) snprintf(buf, sizeof(buf),
skip ? "%.*s[0-9]*" : "%.*s-[0-9]*",
(int)(s - p->name) + skip, p->name);
- if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0) {
- warnx("pkg `%s' required, but `%s' found installed.",
- p->name, installed);
+ if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0)
+ {
+ int done = 0;
+
+ if (Replace > 1)
+ {
+ int errc0 = 0;
+ char tmp[FILENAME_MAX];
- if (replacing) {
- printf("HF: replace note -- could 'pkg_delete %s', and let the normal\n"
- "dependency handling reinstall the replaced package, assuming one IS\n"
- "available. But then I'd expect proper binary pkgs being available for\n"
- "the replace case.\n", installed);
+ warnx("Attempting to update `%s' using binary package\n", p->name);
+ /* Yes, append .tgz after the version so the */
+ /* pattern can match a filename. */
+ snprintf(tmp, sizeof(tmp), "%s.tgz", p->name);
+ done = installprereq(tmp, &errc0, 1);
+ }
+ else if (Replace)
+ {
+ warnx("To perform necessary upgrades on required packages specify -u twice.\n");
}
- if (Force) {
- warnx("Proceeding anyway.");
- } else {
- err_prescan++;
+ if (!done)
+ {
+ warnx("pkg `%s' required, but `%s' found installed.",
+ p->name, installed);
+ if (Force) {
+ warnx("Proceeding anyway.");
+ } else {
+ err_prescan++;
+ }
}
}
}
@@ -741,10 +758,10 @@
if (exact != NULL) {
/* first try the exact name, from the @blddep */
- done = installprereq(exact, &errc0);
+ done = installprereq(exact, &errc0, 0);
}
if (!done) {
- done = installprereq(p->name, &errc0);
+ done = installprereq(p->name, &errc0, 0);
}
if (!done && !Force) {
errc += errc0;
@@ -1025,11 +1042,11 @@
signal(SIGHUP, cleanup);
if (AddMode == SLAVE)
- err_cnt = pkg_do(NULL);
+ err_cnt = pkg_do(NULL, NULL);
else {
while ((lpp = TAILQ_FIRST(pkgs)) != NULL) {
path_prepend_from_pkgname(lpp->lp_name);
- err_cnt += pkg_do(lpp->lp_name);
+ err_cnt += pkg_do(lpp->lp_name, pkgs);
path_prepend_clear();
TAILQ_REMOVE(pkgs, lpp, lp_link);
free_lpkg(lpp);
diff -r 423827f6148e -r 08dd7d5de8ce pkgtools/pkg_install/files/lib/lib.h
--- a/pkgtools/pkg_install/files/lib/lib.h Thu Dec 09 18:56:53 2004 +0000
+++ b/pkgtools/pkg_install/files/lib/lib.h Thu Dec 09 20:10:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.13 2004/11/20 06:42:12 grant Exp $ */
+/* $NetBSD: lib.h,v 1.14 2004/12/09 20:10:34 erh Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -352,6 +352,5 @@
extern Boolean Verbose;
extern Boolean Fake;
extern Boolean Force;
-extern Boolean Replace;
#endif /* _INST_LIB_LIB_H_ */
Home |
Main Index |
Thread Index |
Old Index