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
This commit is contained in:
parent
389c8bd51e
commit
8781da230c
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 *);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user