svn commit: r236333 - in head/usr.sbin/pkg_install: add lib
Author: jpaetzel Date: Wed May 30 21:01:06 2012 New Revision: 236333 URL: http://svn.freebsd.org/changeset/base/236333 Log: Let pkg_add use the ENV variable PACKAGESUFFIX. This can be used to override the default .tbz package extension to .txz .tgz or .tar Submitted by: kmoore Obtained from:PC-BSD Sponsored by: iXsystems MFC after:3 days Modified: head/usr.sbin/pkg_install/add/main.c head/usr.sbin/pkg_install/add/perform.c head/usr.sbin/pkg_install/add/pkg_add.1 head/usr.sbin/pkg_install/lib/file.c head/usr.sbin/pkg_install/lib/url.c Modified: head/usr.sbin/pkg_install/add/main.c == --- head/usr.sbin/pkg_install/add/main.cWed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/add/main.cWed May 30 21:01:06 2012 (r236333) @@ -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: head/usr.sbin/pkg_install/add/perform.c == --- head/usr.sbin/pkg_install/add/perform.c Wed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/add/perform.c Wed May 30 21:01:06 2012 (r236333) @@ -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; Modified: head/usr.sbin/pkg_install/add/pkg_add.1 == --- head/usr.sbin/pkg_install/add/pkg_add.1 Wed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/add/pkg_add.1 Wed May 30 21:01:06 2012 (r236333) @@ -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: head/usr.sbin/pkg_install/lib/file.c == --- head/usr.sbin/pkg_install/lib/file.cWed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/lib/file.cWed May 30 21:01:06 2012 (r236333) @@ -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: head/usr.sbin/pkg_install/lib/url.c
Re: svn commit: r236333 - in head/usr.sbin/pkg_install: add lib
On Wed, May 30, 2012 at 09:01:06PM +, Josh Paetzel wrote: Author: jpaetzel Date: Wed May 30 21:01:06 2012 New Revision: 236333 URL: http://svn.freebsd.org/changeset/base/236333 Log: Let pkg_add use the ENV variable PACKAGESUFFIX. This can be used to override the default .tbz package extension to .txz .tgz or .tar Submitted by: kmoore Obtained from: PC-BSD Sponsored by: iXsystems MFC after: 3 days Modified: head/usr.sbin/pkg_install/add/main.c head/usr.sbin/pkg_install/add/perform.c head/usr.sbin/pkg_install/add/pkg_add.1 head/usr.sbin/pkg_install/lib/file.c head/usr.sbin/pkg_install/lib/url.c Modified: head/usr.sbin/pkg_install/add/main.c == --- head/usr.sbin/pkg_install/add/main.c Wed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/add/main.c Wed May 30 21:01:06 2012 (r236333) @@ -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: head/usr.sbin/pkg_install/add/perform.c == --- head/usr.sbin/pkg_install/add/perform.c Wed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/add/perform.c Wed May 30 21:01:06 2012 (r236333) @@ -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; Modified: head/usr.sbin/pkg_install/add/pkg_add.1 == --- head/usr.sbin/pkg_install/add/pkg_add.1 Wed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/add/pkg_add.1 Wed May 30 21:01:06 2012 (r236333) @@ -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: head/usr.sbin/pkg_install/lib/file.c == --- head/usr.sbin/pkg_install/lib/file.c Wed May 30 20:56:07 2012 (r236332) +++ head/usr.sbin/pkg_install/lib/file.c Wed May 30 21:01:06 2012 (r236333) @@ -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: