diff options
author | erh <erh> | 2004-12-09 20:10:34 +0000 |
---|---|---|
committer | erh <erh> | 2004-12-09 20:10:34 +0000 |
commit | 34df48f3c81c80bcddc58d8c2028150ab81a5c40 (patch) | |
tree | 4837d4a1b00a8182a9076d54de24f37676c898d3 /pkgtools | |
parent | 4e102bf33eaa02e19ad8df7471bedd12f9c37d6f (diff) | |
download | pkgsrc-34df48f3c81c80bcddc58d8c2028150ab81a5c40.tar.gz |
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 (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/add/add.h | 3 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/main.c | 22 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/add/perform.c | 65 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/lib.h | 3 |
4 files changed, 56 insertions, 37 deletions
diff --git a/pkgtools/pkg_install/files/add/add.h b/pkgtools/pkg_install/files/add/add.h index 9f468cd4660..327d51cc123 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.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 NoView; extern Boolean NoInstall; extern Boolean NoRecord; extern Boolean Force; +extern int Replace; extern char *Mode; extern char *Owner; extern char *Group; diff --git a/pkgtools/pkg_install/files/add/main.c b/pkgtools/pkg_install/files/add/main.c index 2359fb0fb99..e8893095019 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.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 *PkgName = NULL; 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 @@ main(int argc, char **argv) break; case 'u': - Replace = 1; + Replace++; break; case 'V': @@ -178,12 +178,14 @@ main(int argc, char **argv) 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 --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index 8fb095aee29..e8a1a4919a2 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.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 @@ sanity_check(const char *pkg) /* 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 @@ installprereq(const char *name, int *errc) 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 @@ installprereq(const char *name, int *errc) * 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 @@ pkg_do(const char *pkg) (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 @@ pkg_do(const char *pkg) * 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 @@ pkg_do(const char *pkg) *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 @@ ignore_replace_depends_check: (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 (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); + if (findmatchingname(dbdir, buf, note_whats_installed, installed) > 0) + { + int done = 0; + + if (Replace > 1) + { + int errc0 = 0; + char tmp[FILENAME_MAX]; + + 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 @@ ignore_replace_depends_check: 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 @@ pkg_perform(lpkg_head_t *pkgs) 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 --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h index b07727e07b6..f0a264aabaa 100644 --- a/pkgtools/pkg_install/files/lib/lib.h +++ b/pkgtools/pkg_install/files/lib/lib.h @@ -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 @@ int pkg_perform(lpkg_head_t *); extern Boolean Verbose; extern Boolean Fake; extern Boolean Force; -extern Boolean Replace; #endif /* _INST_LIB_LIB_H_ */ |