Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Jan 2010 23:19:33 +0000 (UTC)
From:      Florent Thoumie <flz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org
Subject:   svn commit: r202842 - in stable/6/usr.sbin/pkg_install: add create delete info lib updating version
Message-ID:  <201001222319.o0MNJXDj019603@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: flz
Date: Fri Jan 22 23:19:33 2010
New Revision: 202842
URL: http://svn.freebsd.org/changeset/base/202842

Log:
  Synchronize pkg_install with HEAD.

Modified:
  stable/6/usr.sbin/pkg_install/add/main.c
  stable/6/usr.sbin/pkg_install/add/perform.c
  stable/6/usr.sbin/pkg_install/create/main.c
  stable/6/usr.sbin/pkg_install/create/perform.c
  stable/6/usr.sbin/pkg_install/delete/Makefile
  stable/6/usr.sbin/pkg_install/delete/main.c
  stable/6/usr.sbin/pkg_install/info/Makefile
  stable/6/usr.sbin/pkg_install/info/main.c
  stable/6/usr.sbin/pkg_install/info/perform.c
  stable/6/usr.sbin/pkg_install/lib/lib.h
  stable/6/usr.sbin/pkg_install/lib/pen.c
  stable/6/usr.sbin/pkg_install/lib/plist.c
  stable/6/usr.sbin/pkg_install/lib/url.c
  stable/6/usr.sbin/pkg_install/updating/Makefile
  stable/6/usr.sbin/pkg_install/version/Makefile
  stable/6/usr.sbin/pkg_install/version/main.c

Modified: stable/6/usr.sbin/pkg_install/add/main.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/add/main.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/add/main.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -81,13 +81,16 @@ struct {
 	{ 604000, 604099, "/packages-6.4-release" },
 	{ 700000, 700099, "/packages-7.0-release" },
 	{ 701000, 701099, "/packages-7.1-release" },
+	{ 702000, 702099, "/packages-7.2-release" },
+	{ 800000, 800499, "/packages-8.0-release" },
 	{ 300000, 399000, "/packages-3-stable" },
 	{ 400000, 499000, "/packages-4-stable" },
 	{ 502100, 502128, "/packages-5-current" },
 	{ 503100, 599000, "/packages-5-stable" },
 	{ 600100, 699000, "/packages-6-stable" },
 	{ 700100, 799000, "/packages-7-stable" },
-	{ 800000, 899000, "/packages-8-current" },
+	{ 800500, 899000, "/packages-8-stable" },
+	{ 900000, 999000, "/packages-9-current" },
 	{ 0, 9999999, "/packages-current" },
 	{ 0, 0, NULL }
 };
@@ -341,7 +344,7 @@ getpackagesite(void)
 }
 
 static void
-usage()
+usage(void)
 {
     fprintf(stderr, "%s\n%s\n",
 	"usage: pkg_add [-viInfFrRMSK] [-t template] [-p prefix] [-P prefix] [-C chrootdir]",

Modified: stable/6/usr.sbin/pkg_install/add/perform.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/add/perform.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/add/perform.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -52,9 +52,6 @@ pkg_perform(char **pkgs)
     return err_cnt;
 }
 
-static Package Plist;
-static char *Home;
-
 /*
  * This is seriously ugly code following.  Written very fast!
  * [And subsequently made even worse..  Sigh!  This code was just born
@@ -63,10 +60,12 @@ static char *Home;
 static int
 pkg_do(char *pkg)
 {
+    Package Plist;
     char pkg_fullname[FILENAME_MAX];
     char playpen[FILENAME_MAX];
     char extract_contents[FILENAME_MAX];
-    char *where_to, *extract;
+    char *extract;
+    const char *where_to;
     FILE *cfile;
     int code;
     PackingList p;
@@ -87,6 +86,8 @@ pkg_do(char *pkg)
     strcpy(playpen, FirstPen);
     inPlace = 0;
 
+    memset(&Plist, '\0', sizeof(Plist));
+
     /* Are we coming in for a second pass, everything already extracted? */
     if (!pkg) {
 	fgets(playpen, FILENAME_MAX, stdin);
@@ -102,11 +103,10 @@ pkg_do(char *pkg)
     else {
 	/* Is it an ftp://foo.bar.baz/file.t[bg]z specification? */
 	if (isURL(pkg)) {
-	    if (!(Home = fileGetURL(NULL, pkg, KeepPackage))) {
+	    if (!(where_to = fileGetURL(NULL, pkg, KeepPackage))) {
 		warnx("unable to fetch '%s' by URL", pkg);
 		return 1;
 	    }
-	    where_to = Home;
 	    strcpy(pkg_fullname, pkg);
 	    cfile = fopen(CONTENTS_FNAME, "r");
 	    if (!cfile) {
@@ -135,13 +135,11 @@ pkg_do(char *pkg)
 		extract = NULL;
 		sb.st_size = 100000;	/* Make up a plausible average size */
 	    }
-	    Home = make_playpen(playpen, sb.st_size * 4);
-	    if (!Home)
+	    if (!(where_to = make_playpen(playpen, sb.st_size * 4)))
 		errx(1, "unable to make playpen for %lld bytes", (long long)sb.st_size * 4);
-	    where_to = Home;
 	    /* Since we can call ourselves recursively, keep notes on where we came from */
 	    if (!getenv("_TOP"))
-		setenv("_TOP", Home, 1);
+		setenv("_TOP", where_to, 1);
 	    if (unpack(pkg_fullname, extract)) {
 		warnx(
 	"unable to extract table of contents file from '%s' - not a package?",
@@ -280,6 +278,44 @@ pkg_do(char *pkg)
 	    warnx("-f specified; proceeding anyway");
     }
 
+#if ENSURE_THAT_ALL_REQUIREMENTS_ARE_MET
+    /*
+     * Before attempting to do the slave mode bit, ensure that we've
+     * downloaded & processed everything we need.
+     * It's possible that we haven't already installed all of our
+     * dependencies if the dependency list was misgenerated due to
+     * other dynamic dependencies or if a dependency was added to a
+     * package without all REQUIRED_BY packages being regenerated.
+     */
+    for (p = pkg ? Plist.head : NULL; p; p = p->next) {
+	const char *ext;
+	char *deporigin;
+
+	if (p->type != PLIST_PKGDEP)
+	    continue;
+	deporigin = (p->next->type == PLIST_DEPORIGIN) ? p->next->name : NULL;
+
+	if (isinstalledpkg(p->name) <= 0 &&
+	    !(deporigin != NULL && matchbyorigin(deporigin, NULL) != NULL)) {
+	    char subpkg[FILENAME_MAX], *sep;
+
+	    strlcpy(subpkg, pkg, sizeof subpkg);
+	    if ((sep = strrchr(subpkg, '/')) != NULL) {
+		*sep = '\0';
+		if ((sep = strrchr(subpkg, '/')) != NULL) {
+		    *sep = '\0';
+		    strlcat(subpkg, "/All/", sizeof subpkg);
+		    strlcat(subpkg, p->name, sizeof subpkg);
+		    if ((ext = strrchr(pkg, '.')) == NULL)
+			ext = ".tbz";
+		    strlcat(subpkg, ext, sizeof subpkg);
+		    pkg_do(subpkg);
+		}
+	    }
+	}
+    }
+#endif
+
     /* Now check the packing list for dependencies */
     for (p = Plist.head; p ; p = p->next) {
 	char *deporigin;
@@ -295,7 +331,8 @@ pkg_do(char *pkg)
 	}
 	if (isinstalledpkg(p->name) <= 0 &&
 	    !(deporigin != NULL && matchbyorigin(deporigin, NULL) != NULL)) {
-	    char path[FILENAME_MAX], *cp = NULL;
+	    char path[FILENAME_MAX];
+	    const char *cp = NULL;
 
 	    if (!Fake) {
 		char prefixArg[2 + MAXPATHLEN]; /* "-P" + Prefix */
@@ -333,7 +370,7 @@ pkg_do(char *pkg)
 		}
 		else if ((cp = fileGetURL(pkg, p->name, KeepPackage)) != NULL) {
 		    if (Verbose)
-			printf("Finished loading %s over FTP.\n", p->name);
+			printf("Finished loading %s via a URL\n", p->name);
 		    if (!fexists("+CONTENTS")) {
 			warnx("autoloaded package %s has no +CONTENTS file?",
 				p->name);
@@ -645,7 +682,8 @@ cleanup(int sig)
 	    printf("Signal %d received, cleaning up..\n", sig);
     	if (!Fake && zapLogDir && LogDir[0])
 	    vsystem("%s -rf %s", REMOVE_CMD, LogDir);
-    	leave_playpen();
+    	while (leave_playpen())
+	    ;
     }
     if (sig)
 	exit(1);

Modified: stable/6/usr.sbin/pkg_install/create/main.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/create/main.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/create/main.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -249,7 +249,7 @@ main(int argc, char **argv)
 }
 
 static void
-usage()
+usage(void)
 {
     fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
 "usage: pkg_create [-YNOhjnvyz] [-C conflicts] [-P pkgs] [-p prefix]",

Modified: stable/6/usr.sbin/pkg_install/create/perform.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/create/perform.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/create/perform.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -39,11 +39,10 @@ static void make_dist(const char *, cons
 static int create_from_installed_recursive(const char *, const char *);
 static int create_from_installed(const char *, const char *, const char *);
 
-static char *home;
-
 int
 pkg_perform(char **pkgs)
 {
+    static const char *home;
     char *pkg = *pkgs;		/* Only one arg to create */
     char *cp;
     FILE *pkg_in, *fp;

Modified: stable/6/usr.sbin/pkg_install/delete/Makefile
==============================================================================
--- stable/6/usr.sbin/pkg_install/delete/Makefile	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/delete/Makefile	Fri Jan 22 23:19:33 2010	(r202842)
@@ -5,7 +5,6 @@ SRCS=	main.c perform.c
 
 CFLAGS+= -I${.CURDIR}/../lib
 
-WARNS?=	6
 WFORMAT?=	1
 
 DPADD=	${LIBINSTALL} ${LIBMD}

Modified: stable/6/usr.sbin/pkg_install/delete/main.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/delete/main.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/delete/main.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -170,7 +170,7 @@ main(int argc, char **argv)
 }
 
 static void
-usage()
+usage(void)
 {
     fprintf(stderr, "%s\n%s\n",
 	"usage: pkg_delete [-dDfGinrvxX] [-p prefix] pkg-name ...",

Modified: stable/6/usr.sbin/pkg_install/info/Makefile
==============================================================================
--- stable/6/usr.sbin/pkg_install/info/Makefile	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/info/Makefile	Fri Jan 22 23:19:33 2010	(r202842)
@@ -5,7 +5,6 @@ SRCS=	main.c perform.c show.c
 
 CFLAGS+= -I${.CURDIR}/../lib
 
-WARNS?=	6
 WFORMAT?=	1
 
 DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}

Modified: stable/6/usr.sbin/pkg_install/info/main.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/info/main.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/info/main.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -282,7 +282,7 @@ main(int argc, char **argv)
 }
 
 static void
-usage()
+usage(void)
 {
     fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
 	"usage: pkg_info [-bcdDEfgGiIjkKLmopPqQrRsvVxX] [-e package] [-l prefix]",

Modified: stable/6/usr.sbin/pkg_install/info/perform.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/info/perform.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/info/perform.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -85,8 +85,6 @@ pkg_perform(char **pkgs)
     return err_cnt;
 }
 
-static char *Home;
-
 static int
 pkg_do(char *pkg)
 {
@@ -96,7 +94,7 @@ pkg_do(char *pkg)
     Package plist;
     FILE *fp;
     struct stat sb;
-    char *cp = NULL;
+    const char *cp = NULL;
     int code = 0;
 
     if (isURL(pkg)) {
@@ -138,7 +136,7 @@ pkg_do(char *pkg)
 	        code = 1;
 	        goto bail;
 	    }
-	    Home = make_playpen(PlayPen, sb.st_size / 2);
+	    make_playpen(PlayPen, sb.st_size / 2);
 	    if (unpack(fname, "'+*'")) {
 		warnx("error during unpacking, no info for '%s' available", pkg);
 		code = 1;

Modified: stable/6/usr.sbin/pkg_install/lib/lib.h
==============================================================================
--- stable/6/usr.sbin/pkg_install/lib/lib.h	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/lib/lib.h	Fri Jan 22 23:19:33 2010	(r202842)
@@ -84,14 +84,14 @@
 #define DISPLAY_FNAME		"+DISPLAY"
 #define MTREE_FNAME		"+MTREE_DIRS"
 
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
+#define INDEX_FNAME		"INDEX-9"
+#elif defined(__FreeBSD_version) && __FreeBSD_version >= 800000
 #define INDEX_FNAME		"INDEX-8"
 #elif defined(__FreeBSD_version) && __FreeBSD_version >= 700000
 #define INDEX_FNAME		"INDEX-7"
 #elif defined(__FreeBSD_version) && __FreeBSD_version >= 600000
 #define INDEX_FNAME		"INDEX-6"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 500036
-#define INDEX_FNAME		"INDEX-5"
 #else
 #define INDEX_FNAME		"INDEX"
 #endif
@@ -102,10 +102,10 @@
 #define PKG_PREFIX_VNAME	"PKG_PREFIX"
 
 /*
- * Version of the package tools - increase only when some
- * functionality used by bsd.port.mk is changed, added or removed
+ * Version of the package tools - increase whenever you make a change
+ * in the code that is not cosmetic only.
  */
-#define PKG_INSTALL_VERSION	20080708
+#define PKG_INSTALL_VERSION	20090902
 
 #define PKG_WRAPCONF_FNAME	"/var/db/pkg_install.conf"
 #define main(argc, argv)	real_main(argc, argv)
@@ -159,9 +159,9 @@ STAILQ_HEAD(reqr_by_head, reqr_by_entry)
 int		vsystem(const char *, ...);
 char		*vpipe(const char *, ...);
 void		cleanup(int);
-char		*make_playpen(char *, off_t);
+const char	*make_playpen(char *, off_t);
 char		*where_playpen(void);
-void		leave_playpen(void);
+int		leave_playpen(void);
 off_t		min_free(const char *);
 
 /* String */
@@ -183,7 +183,7 @@ Boolean		isfile(const char *);
 Boolean		isempty(const char *);
 Boolean		issymlink(const char *);
 Boolean		isURL(const char *);
-char		*fileGetURL(const char *, const char *, int);
+const char	*fileGetURL(const char *, const char *, int);
 char		*fileFindByPath(const char *, const char *);
 char		*fileGetContents(const char *);
 void		write_file(const char *, const char *);

Modified: stable/6/usr.sbin/pkg_install/lib/pen.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/lib/pen.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/lib/pen.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 
 /* For keeping track of where we are */
 static char PenLocation[FILENAME_MAX];
-static char Previous[FILENAME_MAX];
 
 char *
 where_playpen(void)
@@ -76,12 +75,14 @@ find_play_pen(char *pen, off_t sz)
 static char *pstack[MAX_STACK];
 static int pdepth = -1;
 
-static void
+static const char *
 pushPen(const char *pen)
 {
     if (++pdepth == MAX_STACK)
 	errx(2, "%s: stack overflow.\n", __func__);
     pstack[pdepth] = strdup(pen);
+
+    return pstack[pdepth];
 }
 
 static void
@@ -99,10 +100,11 @@ popPen(char *pen)
  * Make a temporary directory to play in and chdir() to it, returning
  * pathname of previous working directory.
  */
-char *
+const char *
 make_playpen(char *pen, off_t sz)
 {
     char humbuf1[6], humbuf2[6];
+    char cwd[FILENAME_MAX];
 
     if (!find_play_pen(pen, sz))
 	return NULL;
@@ -134,7 +136,7 @@ make_playpen(char *pen, off_t sz)
 	     "with more space and\ntry the command again", __func__, pen);
     }
 
-    if (!getcwd(Previous, FILENAME_MAX)) {
+    if (!getcwd(cwd, FILENAME_MAX)) {
 	upchuck("getcwd");
 	return NULL;
     }
@@ -144,34 +146,35 @@ make_playpen(char *pen, off_t sz)
 	errx(2, "%s: can't chdir to '%s'", __func__, pen);
     }
 
-    if (PenLocation[0])
-	pushPen(PenLocation);
-
     strcpy(PenLocation, pen);
-    return Previous;
+    return pushPen(cwd);
 }
 
 /* Convenience routine for getting out of playpen */
-void
+int
 leave_playpen()
 {
+    static char left[FILENAME_MAX];
     void (*oldsig)(int);
 
+    if (!PenLocation[0])
+	return 0;
+
     /* Don't interrupt while we're cleaning up */
     oldsig = signal(SIGINT, SIG_IGN);
-    if (Previous[0]) {
-	if (chdir(Previous) == FAIL) {
-	    cleanup(0);
-	    errx(2, "%s: can't chdir back to '%s'", __func__, Previous);
-	}
-	Previous[0] = '\0';
-    }
-    if (PenLocation[0]) {
-	if (PenLocation[0] == '/' && vsystem("/bin/rm -rf %s", PenLocation))
-	    warnx("couldn't remove temporary dir '%s'", PenLocation);
-	popPen(PenLocation);
+    strcpy(left, PenLocation);
+    popPen(PenLocation);
+
+    if (chdir(PenLocation) == FAIL) {
+	cleanup(0);
+	errx(2, "%s: can't chdir back to '%s'", __func__, PenLocation);
     }
+
+    if (left[0] == '/' && vsystem("/bin/rm -rf %s", left))
+	warnx("couldn't remove temporary dir '%s'", left);
     signal(SIGINT, oldsig);
+
+    return 1;
 }
 
 off_t

Modified: stable/6/usr.sbin/pkg_install/lib/plist.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/lib/plist.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/lib/plist.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -285,6 +285,10 @@ read_plist(Package *pkg, FILE *fp)
 	}
 	if (*cp == '\0') {
 	    cp = NULL;
+	    if (cmd == PLIST_PKGDEP) {
+		warnx("corrupted record (pkgdep line without argument), ignoring");
+		cmd = FAIL;
+	    }
 	    goto bottom;
 	}
 	if (cmd == PLIST_COMMENT && sscanf(cp, "PKG_FORMAT_REVISION:%d.%d\n",

Modified: stable/6/usr.sbin/pkg_install/lib/url.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/lib/url.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/lib/url.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -32,10 +32,11 @@ __FBSDID("$FreeBSD$");
  * Try and fetch a file by URL, returning the directory name for where
  * it's unpacked, if successful.
  */
-char *
+const char *
 fileGetURL(const char *base, const char *spec, int keep_package)
 {
-    char *cp, *rp, *tmp;
+    const char *rp;
+    char *cp, *tmp;
     char fname[FILENAME_MAX];
     char pen[FILENAME_MAX];
     char pkg[FILENAME_MAX];
@@ -105,7 +106,7 @@ fileGetURL(const char *base, const char 
 
     fetchDebug = (Verbose > 0);
     if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) {
-	printf("Error: FTP Unable to get %s: %s\n",
+	printf("Error: Unable to get %s: %s\n",
 	       fname, fetchLastErrString);
 	return NULL;
     }

Modified: stable/6/usr.sbin/pkg_install/updating/Makefile
==============================================================================
--- stable/6/usr.sbin/pkg_install/updating/Makefile	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/updating/Makefile	Fri Jan 22 23:19:33 2010	(r202842)
@@ -5,7 +5,6 @@ SRCS=	main.c
 
 CFLAGS+= -I${.CURDIR}/../lib
 
-WARNS?=	6
 WFORMAT?= 1
 
 DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}

Modified: stable/6/usr.sbin/pkg_install/version/Makefile
==============================================================================
--- stable/6/usr.sbin/pkg_install/version/Makefile	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/version/Makefile	Fri Jan 22 23:19:33 2010	(r202842)
@@ -5,7 +5,6 @@ SRCS=	main.c perform.c
 
 CFLAGS+= -I${.CURDIR}/../lib
 
-WARNS?=	6
 WFORMAT?=	1
 
 DPADD=	${LIBINSTALL} ${LIBFETCH} ${LIBMD}

Modified: stable/6/usr.sbin/pkg_install/version/main.c
==============================================================================
--- stable/6/usr.sbin/pkg_install/version/main.c	Fri Jan 22 23:17:07 2010	(r202841)
+++ stable/6/usr.sbin/pkg_install/version/main.c	Fri Jan 22 23:19:33 2010	(r202842)
@@ -127,7 +127,7 @@ main(int argc, char **argv)
 }
 
 static void
-usage()
+usage(void)
 {
     fprintf(stderr, "%s\n%s\n%s\n",
 	"usage: pkg_version [-hIoqv] [-l limchar] [-L limchar] [[-X] -s string] [-O origin] [index]",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001222319.o0MNJXDj019603>