bin/147700: [patch] support xz format for packages
Garrett Cooper
yanefbsd at gmail.com
Tue Jun 8 20:50:03 UTC 2010
The following reply was made to PR bin/147700; it has been noted by GNATS.
From: Garrett Cooper <yanefbsd at gmail.com>
To: Bapt <baptiste.daroussin at gmail.com>
Cc: FreeBSD-gnats-submit at freebsd.org
Subject: Re: bin/147700: [patch] support xz format for packages
Date: Tue, 8 Jun 2010 13:46:26 -0700
On Tue, Jun 8, 2010 at 1:27 PM, Bapt <baptiste.daroussin at gmail.com> wrote:
>
>>Number: =A0 =A0 =A0 =A0 147700
>>Category: =A0 =A0 =A0 bin
>>Synopsis: =A0 =A0 =A0 [patch] support xz format for packages
>>Confidential: =A0 no
>>Severity: =A0 =A0 =A0 non-critical
>>Priority: =A0 =A0 =A0 low
>>Responsible: =A0 =A0freebsd-bugs
>>State: =A0 =A0 =A0 =A0 =A0open
>>Quarter:
>>Keywords:
>>Date-Required:
>>Class: =A0 =A0 =A0 =A0 =A0change-request
>>Submitter-Id: =A0 current-users
>>Arrival-Date: =A0 Tue Jun 08 20:30:11 UTC 2010
>>Closed-Date:
>>Last-Modified:
>>Originator: =A0 =A0 Bapt
>>Release: =A0 =A0 =A0 =A0FreeBSD 8.1-PRERELEASE amd64
>>Organization:
>>Environment:
> System: FreeBSD azathoth.lan 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #5 r20=
8894M: Tue Jun 8 11:03:27 CEST 2010 root at azathoth.lan:/usr/obj/usr/src/sys/=
AZATHOTH amd64
>
>
>
>>Description:
> =A0 =A0 =A0 =A0Now that xz and liblzma is in base here comes a patch to s=
upport xz archives in pkg_install (still default to bzip2) it uses --use-co=
mpress-program as the version of libarchive on stable still doesn't support=
-J and I don't have current to test.
>
> =A0 =A0 =A0 =A0to create txz package juste pkg_create -J -b your-packages
>
>>How-To-Repeat:
>
>>Fix:
>
>
>
> --- pkg_install-xz.patch begins here ---
> Index: create/main.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- create/main.c =A0 =A0 =A0 (r=E9vision 208906)
> +++ create/main.c =A0 =A0 =A0 (copie de travail)
> @@ -48,7 +48,7 @@
>
> =A0static void usage(void);
>
> -static char opts[] =3D "EGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:o=
:b:";
> +static char opts[] =3D "EJGYNnORhjvxyzf:p:P:C:c:d:i:I:k:K:r:t:X:D:m:s:S:=
o:b:";
> =A0static struct option longopts[] =3D {
> =A0 =A0 =A0 =A0{ "backup", =A0 =A0 required_argument, =A0 =A0 =A0NULL, =
=A0 =A0 =A0 =A0 =A0 'b' },
> =A0 =A0 =A0 =A0{ "extended", =A0 no_argument, =A0 =A0 =A0 =A0 =A0 =A0NULL=
, =A0 =A0 =A0 =A0 =A0 'E' },
> @@ -188,6 +188,10 @@
> =A0 =A0 =A0 =A0 =A0 =A0Zipper =3D GZIP;
> =A0 =A0 =A0 =A0 =A0 =A0break;
>
> + =A0 =A0 =A0 case 'J':
> + =A0 =A0 =A0 =A0 =A0 Zipper =3D XZ;
> + =A0 =A0 =A0 =A0 =A0 break;
> +
> =A0 =A0 =A0 =A0case 'b':
> =A0 =A0 =A0 =A0 =A0 =A0InstalledPkg =3D optarg;
> =A0 =A0 =A0 =A0 =A0 =A0while ((tmp =3D strrchr(optarg, (int)'/')) !=3D NU=
LL) {
> @@ -252,7 +256,7 @@
> =A0usage(void)
> =A0{
> =A0 =A0 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
> -"usage: pkg_create [-YNOhjnvyz] [-C conflicts] [-P pkgs] [-p prefix]",
> +"usage: pkg_create [-YNOJhjnvyz] [-C conflicts] [-P pkgs] [-p prefix]",
> =A0" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[-i iscript] [-I piscript] [-k ds=
cript] [-K pdscript]",
> =A0" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[-r rscript] [-s srcdir] [-S base=
dir]",
> =A0" =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0[-t template] [-X excludefile]",
> Index: create/create.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- create/create.h =A0 =A0 (r=E9vision 208906)
> +++ create/create.h =A0 =A0 (copie de travail)
> @@ -48,7 +48,7 @@
> =A0extern int =A0 =A0 Recursive;
> =A0extern int =A0 =A0 Regenerate;
>
> -enum zipper {NONE, GZIP, BZIP, BZIP2 };
> +enum zipper {NONE, GZIP, BZIP, BZIP2, XZ };
> =A0extern enum zipper =A0 =A0 Zipper;
>
> =A0void =A0 =A0 =A0 =A0 =A0 add_cksum(Package *, PackingList, const char =
*);
> Index: create/perform.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- create/perform.c =A0 =A0(r=E9vision 208906)
> +++ create/perform.c =A0 =A0(copie de travail)
> @@ -63,6 +63,10 @@
> =A0 =A0 =A0 =A0 =A0 =A0Zipper =3D BZIP2;
> =A0 =A0 =A0 =A0 =A0 =A0pkg[len - 4] =3D '\0';
> =A0 =A0 =A0 =A0}
> + =A0 =A0 =A0 else if (!strcmp(&pkg[len - 4], ".txz")) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 Zipper =3D XZ;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pkg[len - 4] =3D '\0';
> + =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0else if (!strcmp(&pkg[len - 4], ".tgz")) {
> =A0 =A0 =A0 =A0 =A0 =A0Zipper =3D GZIP;
> =A0 =A0 =A0 =A0 =A0 =A0pkg[len - 4] =3D '\0';
> @@ -72,7 +76,10 @@
> =A0 =A0 =A0 =A0 =A0 =A0pkg[len - 4] =3D '\0';
> =A0 =A0 =A0 =A0}
> =A0 =A0 }
> - =A0 =A0if (Zipper =3D=3D BZIP2) {
> + =A0 =A0 =A0 if (Zipper =3D=3D XZ ) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 suf =3D "txz";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 setenv("XZ", "-9", 0);
> + =A0 =A0 =A0 } else if (Zipper =3D=3D BZIP2) {
> =A0 =A0 =A0 =A0suf =3D "tbz";
> =A0 =A0 =A0 =A0setenv("BZIP2", "--best", 0);
> =A0 =A0 } else if (Zipper =3D=3D GZIP) {
> @@ -371,7 +378,11 @@
> =A0 =A0 args[nargs++] =3D "-f";
> =A0 =A0 args[nargs++] =3D tball;
> =A0 =A0 if (strchr(suff, 'z')) { =A0 /* Compress/gzip/bzip2? */
> - =A0 =A0 =A0 if (Zipper =3D=3D BZIP2) {
> +
> + =A0 =A0 =A0 if (Zipper =3D=3D XZ) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 args[nargs++] =3D "--use-compress-program=
=3Dxz";
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cname =3D "xz'd";
> + =A0 =A0 =A0 } else if (Zipper =3D=3D BZIP2) {
> =A0 =A0 =A0 =A0 =A0 =A0args[nargs++] =3D "-j";
> =A0 =A0 =A0 =A0 =A0 =A0cname =3D "bzip'd ";
> =A0 =A0 =A0 =A0}
> Index: lib/file.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- lib/file.c =A0(r=E9vision 208906)
> +++ lib/file.c =A0(copie de travail)
> @@ -137,7 +137,7 @@
> =A0{
> =A0 =A0 static char tmp[FILENAME_MAX];
> =A0 =A0 char *cp;
> - =A0 =A0const char *suffixes[] =3D {".tbz", ".tgz", ".tar", NULL};
> + =A0 =A0const char *suffixes[] =3D {".txz", ".tbz", ".tgz", ".tar", NULL=
};
> =A0 =A0 int i;
>
> =A0 =A0 if (fexists(fname) && isfile(fname)) {
> @@ -329,29 +329,7 @@
> =A0int
> =A0unpack(const char *pkg, const char *flist)
> =A0{
> - =A0 =A0const char *comp, *cp;
> - =A0 =A0char suff[80];
> -
> - =A0 =A0comp =3D "";
> - =A0 =A0/*
> - =A0 =A0 * Figure out by a crude heuristic whether this or not this is p=
robably
> - =A0 =A0 * compressed and whichever compression utility was used (gzip o=
r bzip2).
> - =A0 =A0 */
> - =A0 =A0if (strcmp(pkg, "-")) {
> - =A0 =A0 =A0 cp =3D strrchr(pkg, '.');
> - =A0 =A0 =A0 if (cp) {
> - =A0 =A0 =A0 =A0 =A0 strcpy(suff, cp + 1);
> - =A0 =A0 =A0 =A0 =A0 if (strchr(suff, 'z') || strchr(suff, 'Z')) {
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (strchr(suff, 'b'))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 comp =3D "-j";
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 comp =3D "-z";
> - =A0 =A0 =A0 =A0 =A0 }
> - =A0 =A0 =A0 }
> - =A0 =A0}
> - =A0 =A0else
> - =A0 =A0 =A0 comp =3D "-j";
> - =A0 =A0if (vsystem("/usr/bin/tar -xp %s -f '%s' %s", comp, pkg, flist ?=
flist : "")) {
> + =A0 =A0if (vsystem("/usr/bin/tar -xp -f '%s' %s", pkg, flist ? flist : =
"")) {
> =A0 =A0 =A0 =A0warnx("tar extract of %s failed!", pkg);
> =A0 =A0 =A0 =A0return 1;
> =A0 =A0 }
> --- pkg_install-xz.patch ends here ---
Please see talk to kimelto on IRC about integrating a patch into the
work that he's working on right now (that's based off the patches you
provided and the ones I ran with for archive(3) integration). This
patch would only serve to tie us down more in calling tar(1) directly,
which is not what we want.
Thanks,
-Garrett
More information about the freebsd-bugs
mailing list