From 3f1a9ab225f802a65a4d1b84a3db944e93f56f08 Mon Sep 17 00:00:00 2001 From: obrien Date: Sat, 20 Apr 2002 21:20:58 +0000 Subject: Improve the Bzip2 handling. Sponsored by: FreeBSD Mall, Inc. --- usr.sbin/pkg_install/create/create.h | 4 +++- usr.sbin/pkg_install/create/main.c | 11 ++++++++--- usr.sbin/pkg_install/create/perform.c | 24 +++++++++++++----------- usr.sbin/pkg_install/create/pkg_create.1 | 15 +++++++++++---- 4 files changed, 35 insertions(+), 19 deletions(-) (limited to 'usr.sbin/pkg_install') diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h index 17d8266..e7a18b9 100644 --- a/usr.sbin/pkg_install/create/create.h +++ b/usr.sbin/pkg_install/create/create.h @@ -42,7 +42,9 @@ extern char *InstalledPkg; extern char PlayPen[]; extern int Dereference; extern int PlistOnly; -extern int UseBzip2; + +enum zipper {NONE, GZIP, BZIP, BZIP2 }; +extern enum zipper Zipper; void check_list(const char *, Package *); int pkg_perform(char **); diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index 7b1248a..f309853 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -16,7 +16,7 @@ __FBSDID("$FreeBSD$"); #include "lib.h" #include "create.h" -static char Options[] = "YNOhvyf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:b:"; +static char Options[] = "YNOhjvyzf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:b:"; char *Prefix = NULL; char *Comment = NULL; @@ -37,7 +37,7 @@ char *InstalledPkg = NULL; char PlayPen[FILENAME_MAX]; int Dereference = FALSE; int PlistOnly = FALSE; -int UseBzip2 = FALSE; +enum zipper Zipper = GZIP; static void usage __P((void)); @@ -135,7 +135,12 @@ main(int argc, char **argv) break; case 'y': - UseBzip2 = TRUE; + case 'j': + Zipper = BZIP2; + break; + + case 'z': + Zipper = GZIP; break; case 'b': diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index bc2a391..87738d1 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -47,7 +47,7 @@ pkg_perform(char **pkgs) Package plist; int len; const char *suf; - int compress = TRUE; /* default is to compress packages */ + enum zipper Zipper = GZIP; /* default is to compress packages */ /* Preliminary setup */ if (InstalledPkg == NULL) @@ -59,24 +59,26 @@ pkg_perform(char **pkgs) len = strlen(pkg); if (len > 4) { if (!strcmp(&pkg[len - 4], ".tgz")) { - compress = TRUE; - UseBzip2 = FALSE; + Zipper = GZIP; pkg[len - 4] = '\0'; } else if (!strcmp(&pkg[len - 4], ".tar")) { - compress = FALSE; - UseBzip2 = FALSE; + Zipper = NONE; + pkg[len - 4] = '\0'; + } + else if (!strcmp(&pkg[len - 4], ".tbz")) { + Zipper = BZIP2; pkg[len - 4] = '\0'; } else if ((len > 5) && (!strcmp(&pkg[len - 5], ".tbz2"))) { - compress = FALSE; - UseBzip2 = TRUE; + Zipper = BZIP2; pkg[len - 5] = '\0'; } } - if (UseBzip2) + if (Zipper == BZIP2) { suf = "tbz2"; - else if (compress) { + setenv("BZIP2", "-9", 0); + } else if (Zipper == GZIP) { suf = "tgz"; setenv("GZIP", "-9", 0); } else @@ -291,8 +293,8 @@ make_dist(const char *homedir, const char *pkg, const char *suff, Package *plist args[nargs++] = "-f"; args[nargs++] = tball; if (strchr(suff, 'z')) { /* Compress/gzip/bzip2? */ - if (UseBzip2) { - args[nargs++] = "-y"; + if (Zipper == BZIP2) { + args[nargs++] = "-j"; cname = "bzip'd "; } else { diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index f476810..15be28e 100644 --- a/usr.sbin/pkg_install/create/pkg_create.1 +++ b/usr.sbin/pkg_install/create/pkg_create.1 @@ -31,7 +31,7 @@ .Nd a utility for creating software package distributions .Sh SYNOPSIS .Nm -.Op Fl YNOhvy +.Op Fl YNOhjvyz .Op Fl P Ar pkgs .Op Fl p Ar prefix .Op Fl f Ar contents @@ -260,20 +260,27 @@ as location of the port from which package has been created in the .Em "Ports Collection" . It should be in the form .Pa MASTERCATEGORY/PORTDIR . -.It Fl y +.It Fl j Use .Xr bzip2 1 utility to compress package tarball instead of .Xr gzip 1 . -Please note that this option is no-op if format of the resulting +Please note that this option is a NO-OP if format of the resulting archive is explicitly specified by the recognizeable suffix of .Ar pkg-filename . Currently .Nm recognizes the following suffixes: -.Pa .tgz , .tar +.Pa .tgz , .tar , .tbz and .Pa .tbz2 . +.It Fl y +Compatibility synonym for +.Fl j . +.It Fl z +Use +.Xr gzip 1 +utility to compress package tarball. .It Fl b Ar pkg-name Create package file from a locally installed package named .Ar pkg-name . -- cgit v1.1