1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

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 #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 #endif
/* /*
@ -113,7 +113,9 @@ main(int argc, char **argv)
/* Get all the remaining package names, if any */ /* Get all the remaining package names, if any */
for (ch = 0; *argv; ch++, argv++) { 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); pkgs[ch] = strcpy(pkgnames[ch], *argv);
else { /* expand all pathnames to fullnames */ else { /* expand all pathnames to fullnames */
if (fexists(*argv)) /* refers to a file directly */ if (fexists(*argv)) /* refers to a file directly */

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
@ -63,7 +63,7 @@ pkg_do(char *pkg)
char pkg_fullname[FILENAME_MAX]; char pkg_fullname[FILENAME_MAX];
char playpen[FILENAME_MAX]; char playpen[FILENAME_MAX];
char extract_contents[FILENAME_MAX]; char extract_contents[FILENAME_MAX];
char *where_to, *tmp; char *where_to, *tmp, *extract;
FILE *cfile; FILE *cfile;
int code; int code;
PackingList p; PackingList p;
@ -107,17 +107,22 @@ pkg_do(char *pkg)
fclose(cfile); fclose(cfile);
} }
else { else {
strcpy(pkg_fullname,pkg); /* copy for sanity's sake, could remove pkg_fullname */ strcpy(pkg_fullname, pkg); /* copy for sanity's sake, could remove pkg_fullname */
if (stat(pkg_fullname, &sb) == FAIL) { if (strcmp(pkg, "-")) {
whinge("Can't stat package file '%s'.", pkg_fullname); if (stat(pkg_fullname, &sb) == FAIL) {
goto bomb; 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); Home = make_playpen(playpen, sb.st_size * 4);
if (!Home) if (!Home)
whinge("Unable to make playpen for %d bytes.\n", sb.st_size * 4); whinge("Unable to make playpen for %d bytes.\n", sb.st_size * 4);
where_to = Home; where_to = Home;
sprintf(extract_contents, "--fast-read %s", CONTENTS_FNAME); if (unpack(pkg_fullname, extract)) {
if (unpack(pkg_fullname, extract_contents)) {
whinge("Unable to extract table of contents file from `%s' - not a package?.", pkg_fullname); whinge("Unable to extract table of contents file from `%s' - not a package?.", pkg_fullname);
goto bomb; goto bomb;
} }
@ -160,7 +165,7 @@ pkg_do(char *pkg)
* compress an average of 75%, so multiply by 4 for good measure. * 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" whinge("Projected size of %d exceeds available free space.\n"
"Please set your PKG_TMPDIR variable to point to a location with more\n" "Please set your PKG_TMPDIR variable to point to a location with more\n"
"free space and try again.", sb.st_size * 4); "free space and try again.", sb.st_size * 4);
@ -178,6 +183,7 @@ pkg_do(char *pkg)
goto bomb; goto bomb;
} }
} }
/* Check for sanity and dependencies */ /* Check for sanity and dependencies */
if (sanity_check(pkg)) if (sanity_check(pkg))
goto bomb; goto bomb;

View File

@ -66,8 +66,10 @@ command to examine the package file.
.Sh OPTIONS .Sh OPTIONS
The following command line arguments are supported. The following command line arguments are supported.
.Bl -tag -width indent .Bl -tag -width indent
.It Ar pkg-name ... .It Ar pkg-name [... pkg-name]
Packages in the named files are installed. The named packages are installed. A package name of - will cause
.Nm
to read from stdin.
.It Fl v .It Fl v
Turns on verbose output. Turns on verbose output.
.Em "Optional." .Em "Optional."

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
@ -432,17 +432,21 @@ unpack(char *pkg, char *flist)
{ {
char args[10], suffix[80], *cp; char args[10], suffix[80], *cp;
args[0] = '\0';
/* /*
* Figure out by a crude heuristic whether this or not this is probably * Figure out by a crude heuristic whether this or not this is probably
* compressed. * compressed.
*/ */
args[0] = '\0'; if (strcmp(pkg, "-")) {
cp = rindex(pkg, '.'); cp = rindex(pkg, '.');
if (cp) { if (cp) {
strcpy(suffix, cp + 1); strcpy(suffix, cp + 1);
if (index(suffix, 'z') || index(suffix, 'Z')) if (index(suffix, 'z') || index(suffix, 'Z'))
strcpy(args, "-z"); strcpy(args, "-z");
}
} }
else
strcpy(args, "z");
strcat(args, "xpf"); strcat(args, "xpf");
if (vsystem("tar %s %s %s", args, pkg, flist ? flist : "")) { if (vsystem("tar %s %s %s", args, pkg, flist ? flist : "")) {
whinge("Tar extract of %s failed!", pkg); whinge("Tar extract of %s failed!", pkg);