diff options
author | obrien <obrien@FreeBSD.org> | 2002-04-30 22:40:06 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-04-30 22:40:06 +0000 |
commit | 451e89b13e6de1a22c9029acdbe0565ca18f560b (patch) | |
tree | 04291a07fc7c8d7c5c9cdbcb74819128b46fc53c /usr.sbin/sysinstall | |
parent | 968fe15c4ddd29119f7160321c6530f8df1bd320 (diff) | |
download | FreeBSD-src-451e89b13e6de1a22c9029acdbe0565ca18f560b.zip FreeBSD-src-451e89b13e6de1a22c9029acdbe0565ca18f560b.tar.gz |
Add the ability to use Bzip'ed packages.
Also add the ability to use Bzip'ed distributions -- but this is exclusive
of being able to use Gzip'ed distributions.
Sponsored by: FreeBSD Mall, Inc.
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r-- | usr.sbin/sysinstall/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/sysinstall/dist.c | 7 | ||||
-rw-r--r-- | usr.sbin/sysinstall/media.c | 20 | ||||
-rw-r--r-- | usr.sbin/sysinstall/package.c | 20 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 6 |
5 files changed, 37 insertions, 18 deletions
diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile index 96b976d..1c4f221 100644 --- a/usr.sbin/sysinstall/Makefile +++ b/usr.sbin/sysinstall/Makefile @@ -15,7 +15,7 @@ SRCS+= pccard.c .endif CFLAGS+= -I${.CURDIR}/../../gnu/lib/libdialog -I. -CFLAGS+= -DX_AS_PKG +CFLAGS+= -DX_AS_PKG -DUSE_GZIP=1 .if ${MACHINE} == "pc98" CFLAGS+= -DPC98 .endif diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index 722fe67..cea0f09 100644 --- a/usr.sbin/sysinstall/dist.c +++ b/usr.sbin/sysinstall/dist.c @@ -641,10 +641,11 @@ distExtract(char *parent, Distribution *me) } else { /* Try to get the distribution as a single file */ - snprintf(buf, sizeof buf, "%s/%s.tgz", path, dist); + snprintf(buf, sizeof buf, "%s/%s.%s", path, dist, + USE_GZIP ? "tgz" : "tbz"); /* - * Passing TRUE as 3rd parm to get routine makes this a "probing" get, for which errors - * are not considered too significant. + * Passing TRUE as 3rd parm to get routine makes this a "probing" + * get, for which errors are not considered too significant. */ getsingle: fp = DEVICE_GET(mediaDevice, buf, TRUE); diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index 7577aac..26e5f46 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -604,7 +604,8 @@ mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid) pipe(qfd); *zpid = fork(); if (!*zpid) { - char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip"; + char *unzipper = RunningAsInit ? "/stand/" UNZIPPER + : "/usr/bin/" UNZIPPER; dup2(qfd[0], 0); close(qfd[0]); dup2(pfd[1], 1); close(pfd[1]); @@ -616,9 +617,9 @@ mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid) } close(qfd[1]); close(pfd[0]); - i = execl(gunzip, gunzip, (char *)0); + i = execl(unzipper, unzipper, (char *)0); if (isDebug()) - msgDebug("%s command returns %d status\n", gunzip, i); + msgDebug("%s command returns %d status\n", unzipper, i); exit(i); } *fd = qfd[1]; @@ -660,7 +661,8 @@ mediaExtractDistEnd(int zpid, int cpid) /* Don't check exit status - gunzip seems to return a bogus one! */ if (i < 0) { if (isDebug()) - msgDebug("wait for gunzip returned status of %d!\n", i); + msgDebug("wait for %s returned status of %d!\n", + USE_GZIP ? "gunzip" : "bunzip2", i); return FALSE; } i = waitpid(cpid, &j, 0); @@ -689,7 +691,8 @@ mediaExtractDist(char *dir, char *dist, FILE *fp) pipe(qfd); /* write end */ zpid = fork(); if (!zpid) { - char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip"; + char *unzipper = RunningAsInit ? "/stand/" UNZIPPER + : "/usr/bin/" UNZIPPER; fclose(fp); close(qfd[1]); @@ -704,9 +707,9 @@ mediaExtractDist(char *dir, char *dist, FILE *fp) close(2); open("/dev/null", O_WRONLY); } - i = execl(gunzip, gunzip, (char *)0); + i = execl(unzipper, unzipper, (char *)0); if (isDebug()) - msgDebug("%s command returns %d status\n", gunzip, i); + msgDebug("%s command returns %d status\n", unzipper, i); exit(i); } cpid = fork(); @@ -775,7 +778,8 @@ mediaExtractDist(char *dir, char *dist, FILE *fp) /* Don't check exit status - gunzip seems to return a bogus one! */ if (i < 0) { if (isDebug()) - msgDebug("wait for gunzip returned status of %d!\n", i); + msgDebug("wait for %s returned status of %d!\n", + USE_GZIP ? "gunzip" : "bunzip2", i); return FALSE; } i = waitpid(cpid, &j, 0); diff --git a/usr.sbin/sysinstall/package.c b/usr.sbin/sysinstall/package.c index b067f63..a160eb1 100644 --- a/usr.sbin/sysinstall/package.c +++ b/usr.sbin/sysinstall/package.c @@ -114,10 +114,13 @@ package_exists(char *name) int package_extract(Device *dev, char *name, Boolean depended) { - char path[511]; - int ret, last_msg = 0; + char path[MAXPATHLEN]; + const char *PkgExts[] = { "", ".tbz", ".tbz2", ".tgz" }; + int ext, last_msg, pathend, ret; FILE *fp; + last_msg = 0; + /* Check to make sure it's not already there */ if (package_exists(name)) return DITEM_SUCCESS; @@ -145,15 +148,20 @@ package_extract(Device *dev, char *name, Boolean depended) if (!index(name, '/')) { if (!strpbrk(name, "-_")) - sprintf(path, "packages/Latest/%s.tgz", name); + pathend = snprintf(path, sizeof path, "packages/Latest/%s", name); else - sprintf(path, "packages/All/%s%s", name, strstr(name, ".tgz") ? "" : ".tgz"); + pathend = snprintf(path, sizeof path, "packages/All/%s", name); } else - sprintf(path, "%s%s", name, strstr(name, ".tgz") ? "" : ".tgz"); + pathend = snprintf(path, sizeof path, "%s", name); /* We have a path, call the device strategy routine to get the file */ - fp = DEVICE_GET(dev, path, TRUE); + for (ext = 0 ; ext < sizeof PkgExts / sizeof PkgExts[0]; ++ext) { + strlcpy(path + pathend, PkgExts[ext], sizeof path - pathend); + if ((fp = DEVICE_GET(dev, path, TRUE))) + break; + } + if (fp) { int i = 0, tot, pfd[2]; pid_t pid; diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 7c9d9d6..eb989d1 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -803,5 +803,11 @@ extern void slice_wizard(Disk *d); #define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL) #define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0) +#ifdef USE_GZIP +#define UNZIPPER "gunzip" +#else +#define UNZIPPER "bunzip2" +#endif + #endif /* _SYSINSTALL_H_INCLUDE */ |