diff options
author | sobomax <sobomax@FreeBSD.org> | 2001-01-22 12:01:55 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2001-01-22 12:01:55 +0000 |
commit | a7de4cce1e28921c722fdccf2f24511ec678495b (patch) | |
tree | f2539182bfa7ba8a4c86df0c29b19631ee81e850 /usr.sbin/pkg_install | |
parent | 89713f84c08b61c141e23082609746852881b17c (diff) | |
download | FreeBSD-src-a7de4cce1e28921c722fdccf2f24511ec678495b.zip FreeBSD-src-a7de4cce1e28921c722fdccf2f24511ec678495b.tar.gz |
- Add ability to handle bzip2-compressed packages;
- fix cosmetics to shut-up compiler in -pedantic mode (axe several unused vars
and provide default clause in several switch() statements).
No response from: -ports
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r-- | usr.sbin/pkg_install/add/extract.c | 3 | ||||
-rw-r--r-- | usr.sbin/pkg_install/add/main.c | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/create.h | 1 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/main.c | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/perform.c | 28 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/pkg_create.1 | 17 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/file.c | 42 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/plist.c | 3 |
8 files changed, 79 insertions, 26 deletions
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c index b3770eb..f331c03 100644 --- a/usr.sbin/pkg_install/add/extract.c +++ b/usr.sbin/pkg_install/add/extract.c @@ -249,6 +249,9 @@ extract_plist(char *home, Package *pkg) case PLIST_IGNORE: p = p->next; break; + + default: + break; } p = p->next; } diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index 3e01b19..78c4c11 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -168,7 +168,7 @@ main(int argc, char **argv) usage(); } /* Make sure the sub-execs we invoke get found */ - setenv("PATH", "/sbin:/usr/sbin:/bin:/usr/bin", 1); + setenv("PATH", "/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin", 1); /* Set a reasonable umask */ umask(022); diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h index 63ab997..1b71432 100644 --- a/usr.sbin/pkg_install/create/create.h +++ b/usr.sbin/pkg_install/create/create.h @@ -41,6 +41,7 @@ extern char *Origin; extern char PlayPen[]; extern int Dereference; extern int PlistOnly; +extern int UseBzip2; void check_list(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 5e069d3..e8b29ee 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -18,7 +18,7 @@ static const char rcsid[] = #include "lib.h" #include "create.h" -static char Options[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:"; +static char Options[] = "YNOhvyf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:"; char *Prefix = NULL; char *Comment = NULL; @@ -38,6 +38,7 @@ char *Origin = NULL; char PlayPen[FILENAME_MAX]; int Dereference = FALSE; int PlistOnly = FALSE; +int UseBzip2 = FALSE; static void usage __P((void)); @@ -134,6 +135,10 @@ main(int argc, char **argv) Origin = optarg; break; + case 'y': + UseBzip2 = FALSE; + break; + case '?': default: usage(); @@ -167,7 +172,7 @@ static void usage() { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", -"usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]", +"usage: pkg_create [-YNOhvy] [-P pkgs] [-p prefix] [-f contents] [-i iscript]", " [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ", " [-t template] [-X excludefile] [-D displayfile] ", " [-m mtreefile] [-o origin] -c comment -d description ", diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index b87c55a..5307698 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -70,14 +70,23 @@ pkg_perform(char **pkgs) if (len > 4) { if (!strcmp(&pkg[len - 4], ".tgz")) { compress = TRUE; + UseBzip2 = FALSE; pkg[len - 4] = '\0'; } else if (!strcmp(&pkg[len - 4], ".tar")) { compress = FALSE; + UseBzip2 = FALSE; pkg[len - 4] = '\0'; } + else if ((len > 5) && (!strcmp(&pkg[len - 5], ".tbz2"))) { + compress = FALSE; + UseBzip2 = TRUE; + pkg[len - 5] = '\0'; + } } - if (compress) + if (UseBzip2) + suf = "tbz2"; + else if (compress) suf = "tgz"; else suf = "tar"; @@ -225,6 +234,7 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist) int pipefds[2]; FILE *totar; pid_t pid; + char *cname; args[nargs++] = "tar"; /* argv[0] */ @@ -236,8 +246,18 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist) args[nargs++] = "-c"; args[nargs++] = "-f"; args[nargs++] = tball; - if (strchr(suffix, 'z')) /* Compress/gzip? */ - args[nargs++] = "-z"; + if (strchr(suffix, 'z')) { /* Compress/gzip/bzip2? */ + if (UseBzip2) { + args[nargs++] = "-y"; + cname = "bzip'd "; + } + else { + args[nargs++] = "-z"; + cname = "gzip'd "; + } + } else { + cname = ""; + } if (Dereference) args[nargs++] = "-h"; if (ExcludeFrom) { @@ -249,7 +269,7 @@ make_dist(char *home, char *pkg, char *suffix, Package *plist) args[nargs] = NULL; if (Verbose) - printf("Creating gzip'd tar ball in '%s'\n", tball); + printf("Creating %star ball in '%s'\n", cname, tball); /* Set up a pipe for passing the filenames, and fork off a tar process. */ if (pipe(pipefds) == -1) { diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index df60d82..cbab916 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 YNOhv +.Op Fl YNOhvy .Op Fl P Ar pkgs .Op Fl p Ar prefix .Op Fl f Ar contents @@ -252,6 +252,21 @@ 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 +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 +archive is explicitly specified by the recognizeable suffix of +.Ar pkg-name . +Currently +.Nm +recognizes the following suffixes: +.Dq .tgz , +.Dq .tar +and +.Dq .tbz2 . .El .Pp .Sh PACKING LIST DETAILS diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c index 4c4e9c2..7817fc8 100644 --- a/usr.sbin/pkg_install/lib/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -142,16 +142,13 @@ isURL(char *fname) char * fileGetURL(char *base, char *spec) { - char host[HOSTNAME_MAX], file[FILENAME_MAX]; - char pword[HOSTNAME_MAX + 40], *uname, *cp, *rp; + char *cp, *rp; char fname[FILENAME_MAX]; char pen[FILENAME_MAX]; char buf[8192]; - struct passwd *pw; FILE *ftp; pid_t tpid; int pfd[2], pstat; - int i, status; size_t r, w; char *hint; @@ -248,6 +245,8 @@ fileFindByPath(char *base, char *fname) { static char tmp[FILENAME_MAX]; char *cp; + char *suffixes[] = {".tgz", ".tar", ".tbz2", NULL}; + int i; if (fexists(fname) && isfile(fname)) { strcpy(tmp, fname); @@ -261,23 +260,26 @@ fileFindByPath(char *base, char *fname) *cp = '\0'; /* chop name */ cp = strrchr(tmp, '/'); } - if (cp) { - *(cp + 1) = '\0'; - strcat(cp, "All/"); - strcat(cp, fname); - strcat(cp, ".tgz"); - if (fexists(tmp)) - return tmp; - } + if (cp) + for (i = 0; suffixes[i] != NULL; i++) { + *(cp + 1) = '\0'; + strcat(cp, "All/"); + strcat(cp, fname); + strcat(cp, suffixes[i]); + if (fexists(tmp)) + return tmp; + } } cp = getenv("PKG_PATH"); while (cp) { char *cp2 = strsep(&cp, ":"); - snprintf(tmp, FILENAME_MAX, "%s/%s.tgz", cp2 ? cp2 : cp, fname); - if (fexists(tmp) && isfile(tmp)) - return tmp; + for (i = 0; suffixes[i] != NULL; i++) { + snprintf(tmp, FILENAME_MAX, "%s/%s%s", cp2 ? cp2 : cp, fname, suffixes[i]); + if (fexists(tmp) && isfile(tmp)) + return tmp; + } } return NULL; } @@ -438,14 +440,18 @@ unpack(char *pkg, char *flist) args[0] = '\0'; /* * Figure out by a crude heuristic whether this or not this is probably - * compressed. + * compressed and whichever compression utility was used (gzip or bzip2). */ if (strcmp(pkg, "-")) { cp = strrchr(pkg, '.'); if (cp) { strcpy(suffix, cp + 1); - if (strchr(suffix, 'z') || strchr(suffix, 'Z')) - strcpy(args, "-z"); + if (strchr(suffix, 'z') || strchr(suffix, 'Z')) { + if (strchr(suffix, 'b')) + strcpy(args, "-y"); + else + strcpy(args, "-z"); + } } } else diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index 0e6da6e..5beacd2 100644 --- a/usr.sbin/pkg_install/lib/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -447,6 +447,9 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg) } last_file = p->name; break; + + default: + break; } } return fail; |