summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/add
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/add
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/add')
-rw-r--r--usr.sbin/pkg_install/add/Makefile3
-rw-r--r--usr.sbin/pkg_install/add/add.h2
-rw-r--r--usr.sbin/pkg_install/add/extract.c4
-rw-r--r--usr.sbin/pkg_install/add/futil.c10
-rw-r--r--usr.sbin/pkg_install/add/main.c19
-rw-r--r--usr.sbin/pkg_install/add/perform.c18
6 files changed, 37 insertions, 19 deletions
diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile
index b72511a..5f7d653 100644
--- a/usr.sbin/pkg_install/add/Makefile
+++ b/usr.sbin/pkg_install/add/Makefile
@@ -5,7 +5,8 @@ SRCS= main.c perform.c futil.c extract.c
CFLAGS+= ${DEBUG} -I${.CURDIR}/../lib
-WARNS?= 2
+WARNS?= 6
+WFORMAT?= 1
DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
LDADD= ${LIBINSTALL} -lfetch -lmd
diff --git a/usr.sbin/pkg_install/add/add.h b/usr.sbin/pkg_install/add/add.h
index b64cef7..d27877a 100644
--- a/usr.sbin/pkg_install/add/add.h
+++ b/usr.sbin/pkg_install/add/add.h
@@ -28,12 +28,12 @@ typedef enum { NORMAL, MASTER, SLAVE } add_mode_t;
extern char *Prefix;
extern Boolean NoInstall;
extern Boolean NoRecord;
-extern Boolean Force;
extern char *Mode;
extern char *Owner;
extern char *Group;
extern char *Directory;
extern char *PkgName;
+extern char *PkgAddCmd;
extern char FirstPen[];
extern add_mode_t AddMode;
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c
index 4793dc2..0e31e06 100644
--- a/usr.sbin/pkg_install/add/extract.c
+++ b/usr.sbin/pkg_install/add/extract.c
@@ -27,14 +27,14 @@ __FBSDID("$FreeBSD$");
#include "add.h"
-#define STARTSTRING "tar cf -"
+#define STARTSTRING "/usr/bin/tar cf -"
#define TOOBIG(str) \
(((int)strlen(str) + FILENAME_MAX + where_count > maxargs) ||\
((int)strlen(str) + FILENAME_MAX + perm_count > maxargs))
#define PUSHOUT(todir) /* push out string */ \
if (where_count > (int)sizeof(STARTSTRING)-1) { \
- strcat(where_args, "|tar --unlink -xpf - -C "); \
+ strcat(where_args, "|/usr/bin/tar --unlink -xpf - -C "); \
strcat(where_args, todir); \
if (system(where_args)) { \
cleanup(0); \
diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c
index 66ff738..e097140 100644
--- a/usr.sbin/pkg_install/add/futil.c
+++ b/usr.sbin/pkg_install/add/futil.c
@@ -50,7 +50,7 @@ make_hierarchy(char *dir)
}
}
else {
- if (vsystem("mkdir %s", dir)) {
+ if (vsystem("/bin/mkdir %s", dir)) {
if (cp2)
*cp2 = '/';
return FAIL;
@@ -78,20 +78,20 @@ apply_perms(const char *dir, const char *arg)
cd_to = dir;
if (Mode)
- if (vsystem("cd %s && chmod -R %s %s", cd_to, Mode, arg))
+ if (vsystem("cd %s && /bin/chmod -R %s %s", cd_to, Mode, arg))
warnx("couldn't change modes of '%s' to '%s'", arg, Mode);
if (Owner && Group) {
- if (vsystem("cd %s && chown -R %s:%s %s", cd_to, Owner, Group, arg))
+ if (vsystem("cd %s && /usr/sbin/chown -R %s:%s %s", cd_to, Owner, Group, arg))
warnx("couldn't change owner/group of '%s' to '%s:%s'",
arg, Owner, Group);
return;
}
if (Owner) {
- if (vsystem("cd %s && chown -R %s %s", cd_to, Owner, arg))
+ if (vsystem("cd %s && /usr/sbin/chown -R %s %s", cd_to, Owner, arg))
warnx("couldn't change owner of '%s' to '%s'", arg, Owner);
return;
} else if (Group)
- if (vsystem("cd %s && chgrp -R %s %s", cd_to, Group, arg))
+ if (vsystem("cd %s && /usr/bin/chgrp -R %s %s", cd_to, Group, arg))
warnx("couldn't change group of '%s' to '%s'", arg, Group);
}
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index 3ce0099..6463bc5 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -39,6 +39,7 @@ char *Mode = NULL;
char *Owner = NULL;
char *Group = NULL;
char *PkgName = NULL;
+char *PkgAddCmd = NULL;
char *Directory = NULL;
char FirstPen[FILENAME_MAX];
add_mode_t AddMode = NORMAL;
@@ -63,10 +64,12 @@ struct {
{ 480000, 480099, "/packages-4.8-release" },
{ 490000, 490099, "/packages-4.9-release" },
{ 491000, 491099, "/packages-4.10-release" },
+ { 492000, 492099, "/packages-4.11-release" },
{ 500000, 500099, "/packages-5.0-release" },
{ 501000, 501099, "/packages-5.1-release" },
{ 502000, 502009, "/packages-5.2-release" },
{ 502010, 502099, "/packages-5.2.1-release" },
+ { 503000, 503099, "/packages-5.3-release" },
{ 300000, 399000, "/packages-3-stable" },
{ 400000, 499000, "/packages-4-stable" },
{ 502100, 599000, "/packages-5-current" },
@@ -86,6 +89,12 @@ main(int argc, char **argv)
char **start;
char *cp, *packagesite = NULL, *remotepkg = NULL, *ptr;
static char temppackageroot[MAXPATHLEN];
+ static char pkgaddpath[MAXPATHLEN];
+
+ if (*argv[0] != '/' && strchr(argv[0], '/') != NULL)
+ PkgAddCmd = realpath(argv[0], pkgaddpath);
+ else
+ PkgAddCmd = argv[0];
start = argv;
while ((ch = getopt(argc, argv, Options)) != -1) {
@@ -168,9 +177,13 @@ main(int argc, char **argv)
if (!((ptr = strrchr(remotepkg, '.')) && ptr[1] == 't' &&
(ptr[2] == 'b' || ptr[2] == 'g') && ptr[3] == 'z' &&
!ptr[4]))
- /* XXX: need to handle .tgz also */
- if (strlcat(remotepkg, ".tbz", sizeof(temppackageroot))
- >= sizeof(temppackageroot))
+ if (strlcat(remotepkg,
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
+ ".tbz",
+#else
+ ".tgz",
+#endif
+ sizeof(temppackageroot)) >= sizeof(temppackageroot))
errx(1, "package name too long");
}
if (!strcmp(*argv, "-")) /* stdin? */
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 8af962c..1399bd9 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -167,7 +167,7 @@ pkg_do(char *pkg)
if (!isdir(p->name) && !Fake) {
if (Verbose)
printf("Desired prefix of %s does not exist, creating..\n", p->name);
- vsystem("mkdir -p %s", p->name);
+ vsystem("/bin/mkdir -p %s", p->name);
if (chdir(p->name) == -1) {
warn("unable to change directory to '%s'", p->name);
goto bomb;
@@ -302,7 +302,11 @@ pkg_do(char *pkg)
ext = strrchr(pkg_fullname, '.');
if (ext == NULL)
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 500039
ext = ".tbz";
+#else
+ ext = ".tgz";
+#endif
snprintf(path, FILENAME_MAX, "%s/%s%s", getenv("_TOP"), p->name, ext);
if (fexists(path))
cp = path;
@@ -311,7 +315,7 @@ pkg_do(char *pkg)
if (cp) {
if (Verbose)
printf("Loading it from %s.\n", cp);
- if (vsystem("pkg_add %s'%s'", Verbose ? "-v " : "", cp)) {
+ if (vsystem("%s %s'%s'", PkgAddCmd, Verbose ? "-v " : "", cp)) {
warnx("autoload of dependency '%s' failed%s",
cp, Force ? " (proceeding anyway)" : "!");
if (!Force)
@@ -334,7 +338,7 @@ pkg_do(char *pkg)
if (!Force)
++code;
}
- else if (vsystem("(pwd; cat +CONTENTS) | pkg_add %s-S", Verbose ? "-v " : "")) {
+ else if (vsystem("(pwd; /bin/cat +CONTENTS) | %s %s-S", PkgAddCmd, Verbose ? "-v " : "")) {
warnx("pkg_add of dependency '%s' failed%s",
p->name, Force ? " (proceeding anyway)" : "!");
if (!Force)
@@ -365,7 +369,7 @@ pkg_do(char *pkg)
/* Look for the requirements file */
if (fexists(REQUIRE_FNAME)) {
- vsystem("chmod +x %s", REQUIRE_FNAME); /* be sure */
+ vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */
if (Verbose)
printf("Running requirements file first for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s INSTALL", REQUIRE_FNAME, Plist.name)) {
@@ -398,7 +402,7 @@ pkg_do(char *pkg)
/* If we're really installing, and have an installation file, run it */
if (!NoInstall && fexists(pre_script)) {
- vsystem("chmod +x %s", pre_script); /* make sure */
+ vsystem("/bin/chmod +x %s", pre_script); /* make sure */
if (Verbose)
printf("Running pre-install for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s %s", pre_script, Plist.name, pre_arg)) {
@@ -427,7 +431,7 @@ pkg_do(char *pkg)
/* Run the installation script one last time? */
if (!NoInstall && fexists(post_script)) {
- vsystem("chmod +x %s", post_script); /* make sure */
+ vsystem("/bin/chmod +x %s", post_script); /* make sure */
if (Verbose)
printf("Running post-install for %s..\n", Plist.name);
if (!Fake && vsystem("./%s %s %s", post_script, Plist.name, post_arg)) {
@@ -457,7 +461,7 @@ pkg_do(char *pkg)
goto success; /* close enough for government work */
}
/* Make sure pkg_info can read the entry */
- vsystem("chmod a+rx %s", LogDir);
+ vsystem("/bin/chmod a+rx %s", LogDir);
move_file(".", DESC_FNAME, LogDir);
move_file(".", COMMENT_FNAME, LogDir);
if (fexists(INSTALL_FNAME))
OpenPOWER on IntegriCloud