Date: Tue, 08 Jun 2010 22:27:12 +0200 From: Bapt <baptiste.daroussin@gmail.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/147700: [patch] support xz format for packages Message-ID: <cf123@azathoth.lan> Resent-Message-ID: <201006082030.o58KUB53072600@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 147700 >Category: bin >Synopsis: [patch] support xz format for packages >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Jun 08 20:30:11 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Bapt >Release: FreeBSD 8.1-PRERELEASE amd64 >Organization: >Environment: System: FreeBSD azathoth.lan 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #5 r208894M: Tue Jun 8 11:03:27 CEST 2010 root@azathoth.lan:/usr/obj/usr/src/sys/AZATHOTH amd64 >Description: Now that xz and liblzma is in base here comes a patch to support xz archives in pkg_install (still default to bzip2) it uses --use-compress-program as the version of libarchive on stable still doesn't support -J and I don't have current to test. to create txz package juste pkg_create -J -b your-packages >How-To-Repeat: >Fix: --- pkg_install-xz.patch begins here --- Index: create/main.c =================================================================== --- create/main.c (révision 208906) +++ create/main.c (copie de travail) @@ -48,7 +48,7 @@ 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[] = "EJGYNnORhjvxyzf: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' }, @@ -188,6 +188,10 @@ Zipper = GZIP; break; + case 'J': + Zipper = XZ; + break; + case 'b': InstalledPkg = optarg; while ((tmp = strrchr(optarg, (int)'/')) != NULL) { @@ -252,7 +256,7 @@ usage(void) { 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]", " [-i iscript] [-I piscript] [-k dscript] [-K pdscript]", " [-r rscript] [-s srcdir] [-S basedir]", " [-t template] [-X excludefile]", Index: create/create.h =================================================================== --- create/create.h (révision 208906) +++ create/create.h (copie de travail) @@ -48,7 +48,7 @@ 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 *); Index: create/perform.c =================================================================== --- create/perform.c (révision 208906) +++ create/perform.c (copie de travail) @@ -63,6 +63,10 @@ Zipper = BZIP2; pkg[len - 4] = '\0'; } + else if (!strcmp(&pkg[len - 4], ".txz")) { + Zipper = XZ; + pkg[len - 4] = '\0'; + } else if (!strcmp(&pkg[len - 4], ".tgz")) { Zipper = GZIP; pkg[len - 4] = '\0'; @@ -72,7 +76,10 @@ pkg[len - 4] = '\0'; } } - if (Zipper == BZIP2) { + if (Zipper == XZ ) { + suf = "txz"; + setenv("XZ", "-9", 0); + } else if (Zipper == BZIP2) { suf = "tbz"; setenv("BZIP2", "--best", 0); } else if (Zipper == GZIP) { @@ -371,7 +378,11 @@ args[nargs++] = "-f"; args[nargs++] = tball; if (strchr(suff, 'z')) { /* Compress/gzip/bzip2? */ - if (Zipper == BZIP2) { + + if (Zipper == XZ) { + args[nargs++] = "--use-compress-program=xz"; + cname = "xz'd"; + } else if (Zipper == BZIP2) { args[nargs++] = "-j"; cname = "bzip'd "; } Index: lib/file.c =================================================================== --- lib/file.c (révision 208906) +++ lib/file.c (copie de travail) @@ -137,7 +137,7 @@ { static char tmp[FILENAME_MAX]; char *cp; - const char *suffixes[] = {".tbz", ".tgz", ".tar", NULL}; + const char *suffixes[] = {".txz", ".tbz", ".tgz", ".tar", NULL}; int i; if (fexists(fname) && isfile(fname)) { @@ -329,29 +329,7 @@ int unpack(const char *pkg, const char *flist) { - const char *comp, *cp; - char suff[80]; - - comp = ""; - /* - * Figure out by a crude heuristic whether this or not this is probably - * compressed and whichever compression utility was used (gzip or bzip2). - */ - if (strcmp(pkg, "-")) { - cp = strrchr(pkg, '.'); - if (cp) { - strcpy(suff, cp + 1); - if (strchr(suff, 'z') || strchr(suff, 'Z')) { - if (strchr(suff, 'b')) - comp = "-j"; - else - comp = "-z"; - } - } - } - else - comp = "-j"; - if (vsystem("/usr/bin/tar -xp %s -f '%s' %s", comp, pkg, flist ? flist : "")) { + if (vsystem("/usr/bin/tar -xp -f '%s' %s", pkg, flist ? flist : "")) { warnx("tar extract of %s failed!", pkg); return 1; } --- pkg_install-xz.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?cf123>