diff options
author | bapt <bapt@FreeBSD.org> | 2012-09-18 22:09:23 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2012-09-18 22:09:23 +0000 |
commit | c572b3700b5f5a886c712abe51a0c11e0694893e (patch) | |
tree | 69719e7f7b03fdbfee3b9405328a678f568189c8 /usr.sbin/pkg_install | |
parent | 5005c75c5d4c3cea0b6150e4a8c7a1d2f928c052 (diff) | |
download | FreeBSD-src-c572b3700b5f5a886c712abe51a0c11e0694893e.zip FreeBSD-src-c572b3700b5f5a886c712abe51a0c11e0694893e.tar.gz |
if a file in plist starts with / then do not prefix it with "prefix" [1]
pkg info -g returns 1 if a file mismatch [2]
flush stdout in pkg info -g [3]
clean up quiet mode (-q | --quiet) output of pkg_version(1) [4]
fix missing error call in uname check added to pkg_version(1) [5]
fix pkg_add(1) fails to install with -C from bad path [6]
only resolve path from pkg_add(1) -p if the given prefix do not start with a '/' [7]
PR: bin/13128 [1]
bin/139015 [2]
bin/113702 [3]
bin/142570 [4]
bin/146857 [5]
bin/157543 [6]
Submitted by: cy [1]
Anton Yuzhaninov <citrin@citrin.ru> [2]
Ighighi <ighighi@gmail.com> [3]
"N.J. Mann" <njm@njm.me.uk> [4]
gcooper [5]
David Naylor <naylor.b.david@gmail.com> [6]
netchild [7]
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r-- | usr.sbin/pkg_install/add/main.c | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/perform.c | 12 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/info.h | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/perform.c | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/show.c | 33 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/lib.h | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/plist.c | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_install/version/perform.c | 35 |
8 files changed, 67 insertions, 30 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index 39c1247..5932e1a 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -288,7 +288,9 @@ main(int argc, char **argv) } /* Perform chroot if requested */ if (Chroot != NULL) { - if (chroot(Chroot)) + if (chdir(Chroot)) + errx(1, "chdir to %s failed", Chroot); + if (chroot(".")) errx(1, "chroot to %s failed", Chroot); } /* Make sure the sub-execs we invoke get found */ diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 4409551..e2a884a 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -215,10 +215,14 @@ pkg_perform(char **pkgs) /* Prefix should add an @cwd to the packing list */ if (Prefix) { - char resolved_prefix[PATH_MAX]; - if (realpath(Prefix, resolved_prefix) == NULL) - err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix); - add_plist_top(&plist, PLIST_CWD, resolved_prefix); + if (Prefix[0] != '/') { + char resolved_prefix[PATH_MAX]; + if (realpath(Prefix, resolved_prefix) == NULL) + err(EXIT_FAILURE, "couldn't resolve path for prefix: %s", Prefix); + add_plist_top(&plist, PLIST_CWD, resolved_prefix); + } else { + add_plist_top(&plist, PLIST_CWD, Prefix); + } } /* Add the origin if asked, at the top */ diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 6aa1aa7..6569b5f 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -77,7 +77,7 @@ extern void show_plist(const char *, Package *, plist_t, Boolean); extern void show_files(const char *, Package *); extern void show_index(const char *, const char *); extern void show_size(const char *, Package *); -extern void show_cksum(const char *, Package *); +extern int show_cksum(const char *, Package *); extern void show_origin(const char *, Package *); extern void show_fmtrev(const char *, Package *); diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index bba2de8..551f862 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -221,7 +221,7 @@ pkg_do(char *pkg) if ((Flags & SHOW_SIZE) && installed) show_size("Package Size:\n", &plist); if ((Flags & SHOW_CKSUM) && installed) - show_cksum("Mismatched Checksums:\n", &plist); + code += show_cksum("Mismatched Checksums:\n", &plist); if (Flags & SHOW_ORIGIN) show_origin("Origin:\n", &plist); if (Flags & SHOW_FMTREV) @@ -234,7 +234,7 @@ pkg_do(char *pkg) leave_playpen(); if (isTMP) unlink(fname); - return code; + return (code ? 1 : 0); } void diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 3dc47f9..be05695 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -61,8 +61,10 @@ show_index(const char *title, const char *fname) strlcpy(line, "???\n", sizeof(line)); - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } fp = fopen(fname, "r"); if (fp == (FILE *) NULL) { warnx("show_file: can't open '%s' for reading", fname); @@ -88,8 +90,10 @@ show_plist(const char *title, Package *plist, plist_t type, Boolean showall) Boolean ign = FALSE; char *prefix = NULL; - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } p = plist->head; while (p) { if (p->type != type && showall != TRUE) { @@ -272,8 +276,10 @@ show_size(const char *title, Package *plist) char *prefix = NULL; descr = getbsize(&headerlen, &blksize); - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } for (p = plist->head; p != NULL; p = p->next) { switch (p->type) { case PLIST_FILE: @@ -316,16 +322,19 @@ show_size(const char *title, Package *plist) } /* Show files that don't match the recorded checksum */ -void +int show_cksum(const char *title, Package *plist) { PackingList p; const char *dir = "."; char *prefix = NULL; char tmp[FILENAME_MAX]; + int errcode = 0; - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } for (p = plist->head; p != NULL; p = p->next) if (p->type == PLIST_CWD) { @@ -337,9 +346,10 @@ show_cksum(const char *title, Package *plist) dir = p->name; } else if (p->type == PLIST_FILE) { snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name); - if (!fexists(tmp)) + if (!fexists(tmp)) { warnx("%s doesn't exist", tmp); - else if (p->next && p->next->type == PLIST_COMMENT && + errcode = 1; + } else if (p->next && p->next->type == PLIST_COMMENT && (strncmp(p->next->name, "MD5:", 4) == 0)) { char *cp = NULL, buf[33]; @@ -366,6 +376,7 @@ show_cksum(const char *title, Package *plist) } } } + return (errcode); } /* Show an "origin" path (usually category/portname) */ @@ -373,8 +384,10 @@ void show_origin(const char *title, Package *plist) { - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } printf("%s\n", plist->origin != NULL ? plist->origin : ""); } @@ -383,7 +396,9 @@ void show_fmtrev(const char *title, Package *plist) { - if (!Quiet) + if (!Quiet) { printf("%s%s", InfoPrefix, title); + fflush(stdout); + } printf("%d.%d\n", plist->fmtver_maj, plist->fmtver_mnr); } diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index e368b80..a6935ad 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -99,7 +99,7 @@ * Version of the package tools - increase whenever you make a change * in the code that is not cosmetic only. */ -#define PKG_INSTALL_VERSION 20120913 +#define PKG_INSTALL_VERSION 20120918 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" #define main(argc, argv) real_main(argc, argv) diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index a1b5c55..bce6d04 100644 --- a/usr.sbin/pkg_install/lib/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -458,7 +458,10 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) case PLIST_FILE: last_file = p->name; - sprintf(tmp, "%s/%s", Where, p->name); + if (*p->name == '/') + strlcpy(tmp, p->name, FILENAME_MAX); + else + sprintf(tmp, "%s/%s", Where, p->name); if (isdir(tmp) && fexists(tmp) && !issymlink(tmp)) { warnx("cannot delete specified file '%s' - it is a directory!\n" "this packing list is incorrect - ignoring delete request", tmp); diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c index 733cb5e..a5ac36f 100644 --- a/usr.sbin/pkg_install/version/perform.c +++ b/usr.sbin/pkg_install/version/perform.c @@ -56,10 +56,11 @@ pkg_perform(char **indexarg) struct utsname u; if (uname(&u) == -1) { - warn("%s(): failed to determine uname information", __func__); + warn("%s: failed to determine uname information", __func__); return 1; } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) { - + warnx("%s: bad release version specified: %s", __func__, u.release); + return 1; } /* @@ -321,19 +322,31 @@ show_version(Package plist, const char *latest, const char *source) ver = strrchr(latest, '-'); ver = ver ? &ver[1] : latest; if (cmp < 0 && OUTPUT('<')) { - printf("%-34s %c", tmp, Quiet ? '\0' : '<'); - if (Verbose) - printf(" needs updating (%s has %s)", source, ver); + if (Quiet) + printf("%s", tmp); + else { + printf("%-34s <", tmp); + if (Verbose) + printf(" needs updating (%s has %s)", source, ver); + } printf("\n"); } else if (cmp == 0 && OUTPUT('=')) { - printf("%-34s %c", tmp, Quiet ? '\0' : '='); - if (Verbose) - printf(" up-to-date with %s", source); + if (Quiet) + printf("%s", tmp); + else { + printf("%-34s =", tmp); + if (Verbose) + printf(" up-to-date with %s", source); + } printf("\n"); } else if (cmp > 0 && OUTPUT('>')) { - printf("%-34s %c", tmp, Quiet ? '\0' : '>'); - if (Verbose) - printf(" succeeds %s (%s has %s)", source, source, ver); + if (Quiet) + printf("%s", tmp); + else { + printf("%-34s >", tmp); + if (Verbose) + printf(" succeeds %s (%s has %s)", source, source, ver); + } printf("\n"); } } |