Date: Tue, 18 Sep 2012 20:20:29 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r240674 - in stable/8/usr.sbin/pkg_install: add lib Message-ID: <201209182020.q8IKKT4q055880@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Tue Sep 18 20:20:29 2012 New Revision: 240674 URL: http://svn.freebsd.org/changeset/base/240674 Log: MFC: r236213, r236333, r236336, r240476 - Let pkg_add use the ENV variable PACKAGESUFFIX - Make sure that each va_start has one and only one matching va_end - Do not change owner, group, or mode when package database directory and its contents are created with pkg_add(1). It may happen when the packing list contains @owner, @group, or @mode. Modified: stable/8/usr.sbin/pkg_install/add/add.h stable/8/usr.sbin/pkg_install/add/extract.c stable/8/usr.sbin/pkg_install/add/futil.c stable/8/usr.sbin/pkg_install/add/main.c stable/8/usr.sbin/pkg_install/add/perform.c stable/8/usr.sbin/pkg_install/add/pkg_add.1 stable/8/usr.sbin/pkg_install/lib/exec.c stable/8/usr.sbin/pkg_install/lib/file.c stable/8/usr.sbin/pkg_install/lib/lib.h stable/8/usr.sbin/pkg_install/lib/msg.c stable/8/usr.sbin/pkg_install/lib/url.c Directory Properties: stable/8/usr.sbin/pkg_install/ (props changed) stable/8/usr.sbin/pkg_install/add/ (props changed) Modified: stable/8/usr.sbin/pkg_install/add/add.h ============================================================================== --- stable/8/usr.sbin/pkg_install/add/add.h Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/add/add.h Tue Sep 18 20:20:29 2012 (r240674) @@ -41,7 +41,7 @@ extern char *PkgAddCmd; extern char FirstPen[]; extern add_mode_t AddMode; -int make_hierarchy(char *); +int make_hierarchy(char *, Boolean); void extract_plist(const char *, Package *); void apply_perms(const char *, const char *); Modified: stable/8/usr.sbin/pkg_install/add/extract.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/extract.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/add/extract.c Tue Sep 18 20:20:29 2012 (r240674) @@ -225,7 +225,7 @@ extract_plist(const char *home, Package printf("extract: CWD to %s\n", p->name); PUSHOUT(Directory); if (strcmp(p->name, ".")) { - if (!Fake && make_hierarchy(p->name) == FAIL) { + if (!Fake && make_hierarchy(p->name, TRUE) == FAIL) { cleanup(0); errx(2, "%s: unable to cwd to '%s'", __func__, p->name); } Modified: stable/8/usr.sbin/pkg_install/add/futil.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/futil.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/add/futil.c Tue Sep 18 20:20:29 2012 (r240674) @@ -31,7 +31,7 @@ __FBSDID("$FreeBSD$"); */ int -make_hierarchy(char *dir) +make_hierarchy(char *dir, Boolean set_perm) { char *cp1, *cp2; @@ -55,7 +55,8 @@ make_hierarchy(char *dir) *cp2 = '/'; return FAIL; } - apply_perms(NULL, dir); + if (set_perm) + apply_perms(NULL, dir); } /* Put it back */ if (cp2) { Modified: stable/8/usr.sbin/pkg_install/add/main.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/main.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/add/main.c Tue Sep 18 20:20:29 2012 (r240674) @@ -234,10 +234,17 @@ main(int argc, char **argv) remotepkg = temppackageroot; if (!((ptr = strrchr(remotepkg, '.')) && ptr[1] == 't' && (ptr[2] == 'b' || ptr[2] == 'g' || ptr[2] == 'x') && - ptr[3] == 'z' && !ptr[4])) - if (strlcat(remotepkg, ".tbz", - sizeof(temppackageroot)) >= sizeof(temppackageroot)) - errx(1, "package name too long"); + ptr[3] == 'z' && !ptr[4])) { + if (getenv("PACKAGESUFFIX")) { + if (strlcat(remotepkg, getenv("PACKAGESUFFIX"), + sizeof(temppackageroot)) >= sizeof(temppackageroot)) + errx(1, "package name too long"); + } else { + if (strlcat(remotepkg, ".tbz", + sizeof(temppackageroot)) >= sizeof(temppackageroot)) + errx(1, "package name too long"); + } + } } if (!strcmp(*argv, "-")) /* stdin? */ pkgs[ch] = (char *)"-"; Modified: stable/8/usr.sbin/pkg_install/add/perform.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/perform.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/add/perform.c Tue Sep 18 20:20:29 2012 (r240674) @@ -307,8 +307,12 @@ pkg_do(char *pkg) *sep = '\0'; strlcat(subpkg, "/All/", sizeof subpkg); strlcat(subpkg, p->name, sizeof subpkg); - if ((ext = strrchr(pkg, '.')) == NULL) - ext = ".tbz"; + if ((ext = strrchr(pkg, '.')) == NULL) { + if (getenv("PACKAGESUFFIX")) + ext = getenv("PACKAGESUFFIX"); + else + ext = ".tbz"; + } strlcat(subpkg, ext, sizeof subpkg); pkg_do(subpkg); } @@ -345,8 +349,13 @@ pkg_do(char *pkg) const char *ext; ext = strrchr(pkg_fullname, '.'); - if (ext == NULL) - ext = ".tbz"; + if (ext == NULL) { + if (getenv("PACKAGESUFFIX")) { + ext = getenv("PACKAGESUFFIX"); + } else { + ext = ".tbz"; + } + } snprintf(path, FILENAME_MAX, "%s/%s%s", getenv("_TOP"), p->name, ext); if (fexists(path)) cp = path; @@ -502,7 +511,7 @@ pkg_do(char *pkg) zapLogDir = 1; if (Verbose) printf("Attempting to record package into %s..\n", LogDir); - if (make_hierarchy(LogDir)) { + if (make_hierarchy(LogDir, FALSE)) { warnx("can't record package into '%s', you're on your own!", LogDir); bzero(LogDir, FILENAME_MAX); Modified: stable/8/usr.sbin/pkg_install/add/pkg_add.1 ============================================================================== --- stable/8/usr.sbin/pkg_install/add/pkg_add.1 Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/add/pkg_add.1 Tue Sep 18 20:20:29 2012 (r240674) @@ -553,6 +553,11 @@ The environment variable specifies an alternative location to save downloaded packages to when .Fl K option is used. +.Pp +The environment variable +.Ev PACKAGESUFFIX +specifies an alternative file extension to use when fetching remote +packages. Default is .tbz .Sh FILES .Bl -tag -width /var/db/pkg -compact .It Pa /var/tmp Modified: stable/8/usr.sbin/pkg_install/lib/exec.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/exec.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/lib/exec.c Tue Sep 18 20:20:29 2012 (r240674) @@ -47,6 +47,7 @@ vsystem(const char *fmt, ...) va_start(args, fmt); if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) { warnx("vsystem args are too long"); + va_end(args); return 1; } #ifdef DEBUG @@ -82,6 +83,7 @@ vpipe(const char *fmt, ...) va_start(args, fmt); if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) { warnx("vsystem args are too long"); + va_end(args); return NULL; } #ifdef DEBUG Modified: stable/8/usr.sbin/pkg_install/lib/file.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/file.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/lib/file.c Tue Sep 18 20:20:29 2012 (r240674) @@ -140,7 +140,7 @@ fileFindByPath(const char *base, const c { static char tmp[FILENAME_MAX]; char *cp; - const char *suffixes[] = {".tbz", ".tgz", ".tar", NULL}; + const char *suffixes[] = {".tbz", ".tgz", ".tar", ".txz", NULL}; int i; if (fexists(fname) && isfile(fname)) { Modified: stable/8/usr.sbin/pkg_install/lib/lib.h ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/lib.h Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/lib/lib.h Tue Sep 18 20:20:29 2012 (r240674) @@ -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 20100403 +#define PKG_INSTALL_VERSION 20120913 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" #define main(argc, argv) real_main(argc, argv) Modified: stable/8/usr.sbin/pkg_install/lib/msg.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/msg.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/lib/msg.c Tue Sep 18 20:20:29 2012 (r240674) @@ -71,5 +71,6 @@ y_or_n(Boolean def, const char *msg, ... ch = (def) ? 'Y' : 'N'; } fclose(tty) ; + va_end(args); return (ch == 'Y') ? TRUE : FALSE; } Modified: stable/8/usr.sbin/pkg_install/lib/url.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/url.c Tue Sep 18 19:08:07 2012 (r240673) +++ stable/8/usr.sbin/pkg_install/lib/url.c Tue Sep 18 20:20:29 2012 (r240674) @@ -73,7 +73,10 @@ fileGetURL(const char *base, const char *(cp + 1) = '\0'; strcat(cp, "All/"); strcat(cp, spec); - strcat(cp, ".tbz"); + if (getenv("PACKAGESUFFIX")) + strcat(cp, getenv("PACKAGESUFFIX")); + else + strcat(cp, ".tbz"); } else return NULL; @@ -85,7 +88,10 @@ fileGetURL(const char *base, const char */ strcpy(fname, hint); strcat(fname, spec); - strcat(fname, ".tbz"); + if (getenv("PACKAGESUFFIX")) + strcat(fname, getenv("PACKAGESUFFIX")); + else + strcat(fname, ".tbz"); } } else
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209182020.q8IKKT4q055880>