From 3d8bf84cbf70fa40334e388f4e9c15ca880861f3 Mon Sep 17 00:00:00 2001 From: flz Date: Tue, 12 Oct 2010 10:04:44 +0000 Subject: - Add support for xz compression to pkg_create, bzip2 remains the default compression algorithm. - Bump PKG_INSTALL_VERSION to 20101012. Submitted by: mm MFC after: 1 month --- usr.sbin/pkg_install/Makefile.inc | 2 +- usr.sbin/pkg_install/add/main.c | 6 +++--- usr.sbin/pkg_install/create/create.h | 2 +- usr.sbin/pkg_install/create/main.c | 6 +++++- usr.sbin/pkg_install/create/perform.c | 10 ++++++++++ usr.sbin/pkg_install/create/pkg_create.1 | 18 ++++++++++++++++-- 6 files changed, 36 insertions(+), 8 deletions(-) (limited to 'usr.sbin/pkg_install') diff --git a/usr.sbin/pkg_install/Makefile.inc b/usr.sbin/pkg_install/Makefile.inc index 5c9e266..d929f24 100644 --- a/usr.sbin/pkg_install/Makefile.inc +++ b/usr.sbin/pkg_install/Makefile.inc @@ -2,7 +2,7 @@ .include -CFLAGS+= -DPKG_INSTALL_VERSION=20100423 +CFLAGS+= -DPKG_INSTALL_VERSION=20101012 CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE DPADD+= ${LIBPKG} diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index c8339db..759a479 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -227,9 +227,9 @@ main(int argc, char **argv) >= sizeof(temppackageroot)) errx(1, "package name too long"); remotepkg = temppackageroot; - if (!((ptr = strrchr(remotepkg, '.')) && ptr[1] == 't' && - (ptr[2] == 'b' || ptr[2] == 'g') && ptr[3] == 'z' && - !ptr[4])) + 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"); diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h index 310aba0..cbade82 100644 --- a/usr.sbin/pkg_install/create/create.h +++ b/usr.sbin/pkg_install/create/create.h @@ -48,7 +48,7 @@ extern int PlistOnly; extern int Recursive; extern int Regenerate; -enum zipper {NONE, GZIP, BZIP, BZIP2 }; +enum zipper {NONE, GZIP, BZIP, BZIP2, XZ }; extern enum zipper Zipper; void add_cksum(Package *, PackingList, const char *); diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index e463d1f..5e999da 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -48,7 +48,7 @@ enum zipper Zipper = BZIP2; static void usage(void); -static char opts[] = "EGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:"; +static char opts[] = "EGYNnORhjJvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o:b:"; static struct option longopts[] = { { "backup", required_argument, NULL, 'b' }, { "extended", no_argument, NULL, 'E' }, @@ -190,6 +190,10 @@ main(int argc, char **argv) Zipper = GZIP; break; + case 'J': + Zipper = XZ; + break; + case 'b': InstalledPkg = optarg; while ((tmp = strrchr(optarg, (int)'/')) != NULL) { diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 0e14095..149bcbd 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -67,6 +67,10 @@ pkg_perform(char **pkgs) Zipper = GZIP; pkg[len - 4] = '\0'; } + else if (!strcmp(&pkg[len - 4], ".txz")) { + Zipper = XZ; + pkg[len - 4] = '\0'; + } else if (!strcmp(&pkg[len - 4], ".tar")) { Zipper = NONE; pkg[len - 4] = '\0'; @@ -78,6 +82,8 @@ pkg_perform(char **pkgs) } else if (Zipper == GZIP) { suf = "tgz"; setenv("GZIP", "-9", 0); + } else if (Zipper == XZ) { + suf = "txz"; } else suf = "tar"; @@ -375,6 +381,10 @@ make_dist(const char *homedir, const char *pkg, const char *suff, Package *plist args[nargs++] = "-j"; cname = "bzip'd "; } + else if (Zipper == XZ) { + args[nargs++] = "-J"; + cname = "xz'd "; + } else { args[nargs++] = "-z"; cname = "gzip'd "; diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index a567fc4..5b46374 100644 --- a/usr.sbin/pkg_install/create/pkg_create.1 +++ b/usr.sbin/pkg_install/create/pkg_create.1 @@ -23,7 +23,7 @@ .\" [jkh] Took John's changes back and made some additional extensions for .\" better integration with FreeBSD's new ports collection. .\" -.Dd May 30, 2008 +.Dd Oct 12, 2010 .Dt PKG_CREATE 1 .Os .Sh NAME @@ -315,7 +315,7 @@ archive is explicitly specified by the recognizable suffix of Currently .Nm recognizes the following suffixes: -.Pa .tbz , .tgz +.Pa .tbz , .tgz, .txz and .Pa .tar . .It Fl y @@ -325,6 +325,20 @@ Compatibility synonym for Use .Xr gzip 1 utility to compress package tarball. +.It Fl J +Use +.Xr xz 1 +utility to compress package tarball instead of +.Xr gzip 1 . +Please note that this option is a NO-OP if the format of the resulting +archive is explicitly specified by the recognizable suffix of +.Ar pkg-filename . +Currently +.Nm +recognizes the following suffixes: +.Pa .tbz , .tgz, .txz +and +.Pa .tar . .It Fl b , -backup Ar pkg-name Create package file from a locally installed package named .Ar pkg-name . -- cgit v1.1