aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/create
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2001-01-22 12:01:55 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2001-01-22 12:01:55 +0000
commitacf6a4418d46d059fb0adc9d87220b13d3bad5cd (patch)
tree6fdabb236292d0cceed81565d25a9551100f04a4 /usr.sbin/pkg_install/create
parentd8a8ae09ed6395e78d5f57f52b3771754e807d72 (diff)
downloadsrc-acf6a4418d46d059fb0adc9d87220b13d3bad5cd.tar.gz
src-acf6a4418d46d059fb0adc9d87220b13d3bad5cd.zip
- 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
Notes
Notes: svn path=/head/; revision=71373
Diffstat (limited to 'usr.sbin/pkg_install/create')
-rw-r--r--usr.sbin/pkg_install/create/create.h1
-rw-r--r--usr.sbin/pkg_install/create/main.c9
-rw-r--r--usr.sbin/pkg_install/create/perform.c28
-rw-r--r--usr.sbin/pkg_install/create/pkg_create.117
4 files changed, 48 insertions, 7 deletions
diff --git a/usr.sbin/pkg_install/create/create.h b/usr.sbin/pkg_install/create/create.h
index 63ab997876a2..1b7143236aab 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 5e069d30db2e..e8b29eece0b9 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 b87c55ac37ba..5307698f1eb5 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 df60d8290374..cbab9168cd6f 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