summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-03-12 06:12:43 +0000
committerjkh <jkh@FreeBSD.org>1996-03-12 06:12:43 +0000
commit48236277c1f77ddd9cda6e7eb41539473aeb3cac (patch)
tree6fffba09e8c18c06746d8341febb872dbc4b0867 /usr.sbin/pkg_install
parent0ac561df4815ac33db6c810777c626ea7458d1e0 (diff)
downloadFreeBSD-src-48236277c1f77ddd9cda6e7eb41539473aeb3cac.zip
FreeBSD-src-48236277c1f77ddd9cda6e7eb41539473aeb3cac.tar.gz
Fix a couple of miscellaneous bugs and make pkg_add also support reading
from stdin.
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/add/main.c6
-rw-r--r--usr.sbin/pkg_install/add/perform.c24
-rw-r--r--usr.sbin/pkg_install/add/pkg_add.16
-rw-r--r--usr.sbin/pkg_install/lib/file.c18
4 files changed, 34 insertions, 20 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 26e5e30..4dd9109 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -1,5 +1,5 @@
#ifndef lint
-static char *rcsid = "$Id: main.c,v 1.8 1995/10/25 15:37:47 jkh Exp $";
+static char *rcsid = "$Id: main.c,v 1.9 1995/11/12 04:55:19 jkh Exp $";
#endif
/*
@@ -113,7 +113,9 @@ main(int argc, char **argv)
/* Get all the remaining package names, if any */
for (ch = 0; *argv; ch++, argv++) {
- if (isURL(*argv)) /* preserve URLs */
+ if (!strcmp(*argv, "-")) /* stdin? */
+ pkgs[ch] = "-";
+ else if (isURL(*argv)) /* preserve URLs */
pkgs[ch] = strcpy(pkgnames[ch], *argv);
else { /* expand all pathnames to fullnames */
if (fexists(*argv)) /* refers to a file directly */
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 156de99..1267d0e 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: perform.c,v 1.31 1995/10/31 20:30:15 jkh Exp $";
+static const char *rcsid = "$Id: perform.c,v 1.32 1995/11/12 04:55:23 jkh Exp $";
#endif
/*
@@ -63,7 +63,7 @@ pkg_do(char *pkg)
char pkg_fullname[FILENAME_MAX];
char playpen[FILENAME_MAX];
char extract_contents[FILENAME_MAX];
- char *where_to, *tmp;
+ char *where_to, *tmp, *extract;
FILE *cfile;
int code;
PackingList p;
@@ -107,17 +107,22 @@ pkg_do(char *pkg)
fclose(cfile);
}
else {
- strcpy(pkg_fullname,pkg); /* copy for sanity's sake, could remove pkg_fullname */
- if (stat(pkg_fullname, &sb) == FAIL) {
- whinge("Can't stat package file '%s'.", pkg_fullname);
- goto bomb;
+ strcpy(pkg_fullname, pkg); /* copy for sanity's sake, could remove pkg_fullname */
+ if (strcmp(pkg, "-")) {
+ if (stat(pkg_fullname, &sb) == FAIL) {
+ whinge("Can't stat package file '%s'.", pkg_fullname);
+ goto bomb;
+ }
+ sprintf(extract_contents, "--fast-read %s", CONTENTS_FNAME);
+ extract = extract_contents;
}
+ else
+ extract = NULL;
Home = make_playpen(playpen, sb.st_size * 4);
if (!Home)
whinge("Unable to make playpen for %d bytes.\n", sb.st_size * 4);
where_to = Home;
- sprintf(extract_contents, "--fast-read %s", CONTENTS_FNAME);
- if (unpack(pkg_fullname, extract_contents)) {
+ if (unpack(pkg_fullname, extract)) {
whinge("Unable to extract table of contents file from `%s' - not a package?.", pkg_fullname);
goto bomb;
}
@@ -160,7 +165,7 @@ pkg_do(char *pkg)
* compress an average of 75%, so multiply by 4 for good measure.
*/
- if (min_free(playpen) < sb.st_size * 4) {
+ if (!inPlace && min_free(playpen) < sb.st_size * 4) {
whinge("Projected size of %d exceeds available free space.\n"
"Please set your PKG_TMPDIR variable to point to a location with more\n"
"free space and try again.", sb.st_size * 4);
@@ -178,6 +183,7 @@ pkg_do(char *pkg)
goto bomb;
}
}
+
/* Check for sanity and dependencies */
if (sanity_check(pkg))
goto bomb;
diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1
index 0358048..8e4a0f7 100644
--- a/usr.sbin/pkg_install/add/pkg_add.1
+++ b/usr.sbin/pkg_install/add/pkg_add.1
@@ -66,8 +66,10 @@ command to examine the package file.
.Sh OPTIONS
The following command line arguments are supported.
.Bl -tag -width indent
-.It Ar pkg-name ...
-Packages in the named files are installed.
+.It Ar pkg-name [... pkg-name]
+The named packages are installed. A package name of - will cause
+.Nm
+to read from stdin.
.It Fl v
Turns on verbose output.
.Em "Optional."
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index bddebab..19ce013 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -1,5 +1,5 @@
#ifndef lint
-static const char *rcsid = "$Id: file.c,v 1.19 1995/11/12 04:55:38 jkh Exp $";
+static const char *rcsid = "$Id: file.c,v 1.20 1996/02/19 02:35:56 mpp Exp $";
#endif
/*
@@ -432,17 +432,21 @@ unpack(char *pkg, char *flist)
{
char args[10], suffix[80], *cp;
+ args[0] = '\0';
/*
* Figure out by a crude heuristic whether this or not this is probably
* compressed.
*/
- args[0] = '\0';
- cp = rindex(pkg, '.');
- if (cp) {
- strcpy(suffix, cp + 1);
- if (index(suffix, 'z') || index(suffix, 'Z'))
- strcpy(args, "-z");
+ if (strcmp(pkg, "-")) {
+ cp = rindex(pkg, '.');
+ if (cp) {
+ strcpy(suffix, cp + 1);
+ if (index(suffix, 'z') || index(suffix, 'Z'))
+ strcpy(args, "-z");
+ }
}
+ else
+ strcpy(args, "z");
strcat(args, "xpf");
if (vsystem("tar %s %s %s", args, pkg, flist ? flist : "")) {
whinge("Tar extract of %s failed!", pkg);
OpenPOWER on IntegriCloud