svn commit: r213718 - in head/usr.sbin/pkg_install: . add create

Florent Thoumie flz at FreeBSD.org
Tue Oct 12 10:04:45 UTC 2010


Author: flz
Date: Tue Oct 12 10:04:44 2010
New Revision: 213718
URL: http://svn.freebsd.org/changeset/base/213718

Log:
  - 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

Modified:
  head/usr.sbin/pkg_install/Makefile.inc
  head/usr.sbin/pkg_install/add/main.c
  head/usr.sbin/pkg_install/create/create.h
  head/usr.sbin/pkg_install/create/main.c
  head/usr.sbin/pkg_install/create/perform.c
  head/usr.sbin/pkg_install/create/pkg_create.1

Modified: head/usr.sbin/pkg_install/Makefile.inc
==============================================================================
--- head/usr.sbin/pkg_install/Makefile.inc	Tue Oct 12 09:41:42 2010	(r213717)
+++ head/usr.sbin/pkg_install/Makefile.inc	Tue Oct 12 10:04:44 2010	(r213718)
@@ -2,7 +2,7 @@
 
 .include <bsd.own.mk>
 
-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}

Modified: head/usr.sbin/pkg_install/add/main.c
==============================================================================
--- head/usr.sbin/pkg_install/add/main.c	Tue Oct 12 09:41:42 2010	(r213717)
+++ head/usr.sbin/pkg_install/add/main.c	Tue Oct 12 10:04:44 2010	(r213718)
@@ -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");

Modified: head/usr.sbin/pkg_install/create/create.h
==============================================================================
--- head/usr.sbin/pkg_install/create/create.h	Tue Oct 12 09:41:42 2010	(r213717)
+++ head/usr.sbin/pkg_install/create/create.h	Tue Oct 12 10:04:44 2010	(r213718)
@@ -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 *);

Modified: head/usr.sbin/pkg_install/create/main.c
==============================================================================
--- head/usr.sbin/pkg_install/create/main.c	Tue Oct 12 09:41:42 2010	(r213717)
+++ head/usr.sbin/pkg_install/create/main.c	Tue Oct 12 10:04:44 2010	(r213718)
@@ -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) {

Modified: head/usr.sbin/pkg_install/create/perform.c
==============================================================================
--- head/usr.sbin/pkg_install/create/perform.c	Tue Oct 12 09:41:42 2010	(r213717)
+++ head/usr.sbin/pkg_install/create/perform.c	Tue Oct 12 10:04:44 2010	(r213718)
@@ -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 cha
 	    args[nargs++] = "-j";
 	    cname = "bzip'd ";
 	}
+	else if (Zipper == XZ) {
+	    args[nargs++] = "-J";
+	    cname = "xz'd ";
+	}
 	else {
 	    args[nargs++] = "-z";
 	    cname = "gzip'd ";

Modified: head/usr.sbin/pkg_install/create/pkg_create.1
==============================================================================
--- head/usr.sbin/pkg_install/create/pkg_create.1	Tue Oct 12 09:41:42 2010	(r213717)
+++ head/usr.sbin/pkg_install/create/pkg_create.1	Tue Oct 12 10:04:44 2010	(r213718)
@@ -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 r
 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 .


More information about the svn-src-head mailing list