Improve the Bzip2 handling.

Sponsored by:	FreeBSD Mall, Inc.
This commit is contained in:
David E. O'Brien 2002-04-20 21:20:58 +00:00
parent 01fa0604af
commit 2d37eb657e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95161
4 changed files with 35 additions and 19 deletions

View File

@ -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 **);

View File

@ -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':

View File

@ -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 {

View File

@ -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 .