aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/sysinstall/package.c
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2002-04-30 22:40:06 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2002-04-30 22:40:06 +0000
commitee1c407b54d0303ac6154f5a5397127cb409b1b3 (patch)
tree04291a07fc7c8d7c5c9cdbcb74819128b46fc53c /usr.sbin/sysinstall/package.c
parent289f207c81e6c458d8c9131c79f7bfa34b2f098d (diff)
downloadsrc-ee1c407b54d0303ac6154f5a5397127cb409b1b3.tar.gz
src-ee1c407b54d0303ac6154f5a5397127cb409b1b3.zip
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.
Notes
Notes: svn path=/head/; revision=95825
Diffstat (limited to 'usr.sbin/sysinstall/package.c')
-rw-r--r--usr.sbin/sysinstall/package.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.sbin/sysinstall/package.c b/usr.sbin/sysinstall/package.c
index b067f63827f5..a160eb137917 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;