Fix a couple of miscellaneous bugs and make pkg_add also support reading

from stdin.
This commit is contained in:
Jordan K. Hubbard 1996-03-12 06:12:43 +00:00
parent b079435208
commit 1c3f12fd44
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=14582
4 changed files with 34 additions and 20 deletions

View file

@ -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 */

View file

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

View file

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

View file

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