summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/lib
diff options
context:
space:
mode:
authoreik <eik@FreeBSD.org>2004-06-29 19:06:42 +0000
committereik <eik@FreeBSD.org>2004-06-29 19:06:42 +0000
commit3883d107114d126a28a9163c5bf67cb766ec7779 (patch)
tree1ab5b5afad8e17719ffc614e8b575ec26c5c8bd5 /usr.sbin/pkg_install/lib
parent338dc29a063a48607925d36ac38dd1f0263c2e8b (diff)
downloadFreeBSD-src-3883d107114d126a28a9163c5bf67cb766ec7779.zip
FreeBSD-src-3883d107114d126a28a9163c5bf67cb766ec7779.tar.gz
- pkg_add spawns itself as argv[0] when installing dependent packages, to
enable the use as a port on older systems - use absolute paths in all calls to external programs, to account for strange PATH settings - use INDEX or INDEX-5 depending on FreeBSD version, to enable the use on FreeBSD 4.x as a port. - conditionalize all 4.x/5.x differences on __FreeBSD_version, so that the pkg_install tools can be kept in sync on 4.x and 5.x - Bump PKG_INSTALL_VERSION Reviewed by: portmgr (bento run) MFC after: 4 weeks
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-rw-r--r--usr.sbin/pkg_install/lib/Makefile3
-rw-r--r--usr.sbin/pkg_install/lib/file.c19
-rw-r--r--usr.sbin/pkg_install/lib/lib.h12
-rw-r--r--usr.sbin/pkg_install/lib/match.c2
-rw-r--r--usr.sbin/pkg_install/lib/pen.c2
-rw-r--r--usr.sbin/pkg_install/lib/url.c22
6 files changed, 40 insertions, 20 deletions
diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile
index 2a79f71..0aba9a4 100644
--- a/usr.sbin/pkg_install/lib/Makefile
+++ b/usr.sbin/pkg_install/lib/Makefile
@@ -7,6 +7,7 @@ SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c match.c \
CFLAGS+= ${DEBUG}
-WARNS?= 2
+WARNS?= 6
+WFORMAT?= 1
.include <bsd.lib.mk>
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 107bb15..651c64b 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -269,9 +269,9 @@ copy_file(const char *dir, const char *fname, const char *to)
char cmd[FILENAME_MAX];
if (fname[0] == '/')
- snprintf(cmd, FILENAME_MAX, "cp -r %s %s", fname, to);
+ snprintf(cmd, FILENAME_MAX, "/bin/cp -r %s %s", fname, to);
else
- snprintf(cmd, FILENAME_MAX, "cp -r %s/%s %s", dir, fname, to);
+ snprintf(cmd, FILENAME_MAX, "/bin/cp -r %s/%s %s", dir, fname, to);
if (vsystem(cmd)) {
cleanup(0);
errx(2, "%s: could not perform '%s'", __func__, cmd);
@@ -284,9 +284,9 @@ move_file(const char *dir, const char *fname, const char *to)
char cmd[FILENAME_MAX];
if (fname[0] == '/')
- snprintf(cmd, FILENAME_MAX, "mv %s %s", fname, to);
+ snprintf(cmd, FILENAME_MAX, "/bin/mv %s %s", fname, to);
else
- snprintf(cmd, FILENAME_MAX, "mv %s/%s %s", dir, fname, to);
+ snprintf(cmd, FILENAME_MAX, "/bin/mv %s/%s %s", dir, fname, to);
if (vsystem(cmd)) {
cleanup(0);
errx(2, "%s: could not perform '%s'", __func__, cmd);
@@ -310,11 +310,11 @@ copy_hierarchy(const char *dir, const char *fname, Boolean to)
/* If absolute path, use it */
if (*fname == '/')
dir = "/";
- snprintf(cmd, FILENAME_MAX * 3, "tar cf - -C %s %s | tar xpf -",
+ snprintf(cmd, FILENAME_MAX * 3, "/usr/bin/tar cf - -C %s %s | /usr/bin/tar xpf -",
dir, fname);
}
else
- snprintf(cmd, FILENAME_MAX * 3, "tar cf - %s | tar xpf - -C %s",
+ snprintf(cmd, FILENAME_MAX * 3, "/usr/bin/tar cf - %s | /usr/bin/tar xpf - -C %s",
fname, dir);
#ifdef DEBUG
printf("Using '%s' to copy trees.\n", cmd);
@@ -350,9 +350,12 @@ unpack(const char *pkg, const char *flist)
}
}
else
- /* XXX: need to handle .tgz also */
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
comp = "-j";
- if (vsystem("tar -xp %s -f '%s' %s", comp, pkg, flist ? flist : "")) {
+#else
+ comp = "-z";
+#endif
+ if (vsystem("/usr/bin/tar -xp %s -f '%s' %s", comp, pkg, flist ? flist : "")) {
warnx("tar extract of %s failed!", pkg);
return 1;
}
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 109483c..c50a944 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -52,10 +52,10 @@
#define NO 1
/* Usually "rm", but often "echo" during debugging! */
-#define REMOVE_CMD "rm"
+#define REMOVE_CMD "/bin/rm"
/* Usually "rm", but often "echo" during debugging! */
-#define RMDIR_CMD "rmdir"
+#define RMDIR_CMD "/bin/rmdir"
/* Where we put logging information by default, else ${PKG_DBDIR} if set */
#define DEF_LOG_DIR "/var/db/pkg"
@@ -77,6 +77,12 @@
#define DISPLAY_FNAME "+DISPLAY"
#define MTREE_FNAME "+MTREE_DIRS"
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500036
+#define INDEX_FNAME "INDEX-5"
+#else
+#define INDEX_FNAME "INDEX"
+#endif
+
#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
/* The name of the "prefix" environment variable given to scripts */
@@ -86,7 +92,7 @@
* Version of the package tools - increase only when some
* functionality used by bsd.port.mk is changed, added or removed
*/
-#define PKG_INSTALL_VERSION 20030417
+#define PKG_INSTALL_VERSION 20040629
#define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf"
#define main(argc, argv) real_main(argc, argv)
diff --git a/usr.sbin/pkg_install/lib/match.c b/usr.sbin/pkg_install/lib/match.c
index 48d96cd..06e34cf 100644
--- a/usr.sbin/pkg_install/lib/match.c
+++ b/usr.sbin/pkg_install/lib/match.c
@@ -63,7 +63,7 @@ matchinstalled(match_t MatchType, char **patterns, int *retval)
static struct store *store = NULL;
FTS *ftsp;
FTSENT *f;
- Boolean *lmatched;
+ Boolean *lmatched = NULL;
store = storecreate(store);
if (store == NULL) {
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index eedda00..770235f 100644
--- a/usr.sbin/pkg_install/lib/pen.c
+++ b/usr.sbin/pkg_install/lib/pen.c
@@ -156,7 +156,7 @@ leave_playpen()
Previous[0] = '\0';
}
if (PenLocation[0]) {
- if (PenLocation[0] == '/' && vsystem("rm -rf %s", PenLocation))
+ if (PenLocation[0] == '/' && vsystem("/bin/rm -rf %s", PenLocation))
warnx("couldn't remove temporary dir '%s'", PenLocation);
popPen(PenLocation);
}
diff --git a/usr.sbin/pkg_install/lib/url.c b/usr.sbin/pkg_install/lib/url.c
index 5ee33f3..41017b4 100644
--- a/usr.sbin/pkg_install/lib/url.c
+++ b/usr.sbin/pkg_install/lib/url.c
@@ -39,7 +39,7 @@ fileGetURL(const char *base, const char *spec)
char buf[8192];
FILE *ftp;
pid_t tpid;
- int pfd[2], pstat, r, w;
+ int pfd[2], pstat, r, w = 0;
char *hint;
int fd;
@@ -69,8 +69,11 @@ fileGetURL(const char *base, const char *spec)
*(cp + 1) = '\0';
strcat(cp, "All/");
strcat(cp, spec);
- /* XXX: need to handle .tgz also */
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
strcat(cp, ".tbz");
+#else
+ strcat(cp, ".tgz");
+#endif
}
else
return NULL;
@@ -82,8 +85,11 @@ fileGetURL(const char *base, const char *spec)
*/
strcpy(fname, hint);
strcat(fname, spec);
- /* XXX: need to handle .tgz also */
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
strcat(fname, ".tbz");
+#else
+ strcat(fname, ".tgz");
+#endif
}
}
else
@@ -117,9 +123,13 @@ fileGetURL(const char *base, const char *spec)
dup2(pfd[0], 0);
for (fd = getdtablesize() - 1; fd >= 3; --fd)
close(fd);
- /* XXX: need to handle .tgz also */
- execl("/usr/bin/tar", "tar", Verbose ? "-xjvf" : "-xjf", "-",
- (char *)0);
+ execl("/usr/bin/tar", "tar",
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
+ Verbose ? "-xjvf" : "-xjf",
+#else
+ Verbose ? "-xzvf" : "-xzf",
+#endif
+ "-", (char *)0);
_exit(2);
}
close(pfd[0]);
OpenPOWER on IntegriCloud