Author: bapt
Date: Tue Oct  2 17:04:53 2012
New Revision: 241135
URL: http://svn.freebsd.org/changeset/base/241135

Log:
  MFC r240682
  
  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 <cit...@citrin.ru> [2]
                Ighighi <ighi...@gmail.com> [3]
                "N.J. Mann" <n...@njm.me.uk> [4]
                gcooper [5]
                David Naylor <naylor.b.da...@gmail.com> [6]
                netchild [7]

Modified:
  stable/9/usr.sbin/pkg_install/add/main.c
  stable/9/usr.sbin/pkg_install/create/perform.c
  stable/9/usr.sbin/pkg_install/info/info.h
  stable/9/usr.sbin/pkg_install/info/perform.c
  stable/9/usr.sbin/pkg_install/info/show.c
  stable/9/usr.sbin/pkg_install/lib/lib.h
  stable/9/usr.sbin/pkg_install/lib/plist.c
  stable/9/usr.sbin/pkg_install/version/perform.c
Directory Properties:
  stable/9/usr.sbin/pkg_install/   (props changed)
  stable/9/usr.sbin/pkg_install/add/   (props changed)
  stable/9/usr.sbin/pkg_install/info/   (props changed)

Modified: stable/9/usr.sbin/pkg_install/add/main.c
==============================================================================
--- stable/9/usr.sbin/pkg_install/add/main.c    Tue Oct  2 14:48:03 2012        
(r241134)
+++ stable/9/usr.sbin/pkg_install/add/main.c    Tue Oct  2 17:04:53 2012        
(r241135)
@@ -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 */

Modified: stable/9/usr.sbin/pkg_install/create/perform.c
==============================================================================
--- stable/9/usr.sbin/pkg_install/create/perform.c      Tue Oct  2 14:48:03 
2012        (r241134)
+++ stable/9/usr.sbin/pkg_install/create/perform.c      Tue Oct  2 17:04:53 
2012        (r241135)
@@ -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 */

Modified: stable/9/usr.sbin/pkg_install/info/info.h
==============================================================================
--- stable/9/usr.sbin/pkg_install/info/info.h   Tue Oct  2 14:48:03 2012        
(r241134)
+++ stable/9/usr.sbin/pkg_install/info/info.h   Tue Oct  2 17:04:53 2012        
(r241135)
@@ -77,7 +77,7 @@ extern void   show_plist(const char *, Pac
 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 *);
 

Modified: stable/9/usr.sbin/pkg_install/info/perform.c
==============================================================================
--- stable/9/usr.sbin/pkg_install/info/perform.c        Tue Oct  2 14:48:03 
2012        (r241134)
+++ stable/9/usr.sbin/pkg_install/info/perform.c        Tue Oct  2 17:04:53 
2012        (r241135)
@@ -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

Modified: stable/9/usr.sbin/pkg_install/info/show.c
==============================================================================
--- stable/9/usr.sbin/pkg_install/info/show.c   Tue Oct  2 14:48:03 2012        
(r241134)
+++ stable/9/usr.sbin/pkg_install/info/show.c   Tue Oct  2 17:04:53 2012        
(r241135)
@@ -61,8 +61,10 @@ show_index(const char *title, const char
 
     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 *p
     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 *pl
     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 *pl
 }
 
 /* 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 *p
                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 *p
                }
            }
        }
+    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);
 }

Modified: stable/9/usr.sbin/pkg_install/lib/lib.h
==============================================================================
--- stable/9/usr.sbin/pkg_install/lib/lib.h     Tue Oct  2 14:48:03 2012        
(r241134)
+++ stable/9/usr.sbin/pkg_install/lib/lib.h     Tue Oct  2 17:04:53 2012        
(r241135)
@@ -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)

Modified: stable/9/usr.sbin/pkg_install/lib/plist.c
==============================================================================
--- stable/9/usr.sbin/pkg_install/lib/plist.c   Tue Oct  2 14:48:03 2012        
(r241134)
+++ stable/9/usr.sbin/pkg_install/lib/plist.c   Tue Oct  2 17:04:53 2012        
(r241135)
@@ -458,7 +458,10 @@ delete_package(Boolean ign_err, Boolean 
 
        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);

Modified: stable/9/usr.sbin/pkg_install/version/perform.c
==============================================================================
--- stable/9/usr.sbin/pkg_install/version/perform.c     Tue Oct  2 14:48:03 
2012        (r241134)
+++ stable/9/usr.sbin/pkg_install/version/perform.c     Tue Oct  2 17:04:53 
2012        (r241135)
@@ -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 *
        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");
        }
     }
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to