From owner-svn-src-stable-8@FreeBSD.ORG Mon May 21 13:05:42 2012 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B66DA106566B; Mon, 21 May 2012 13:05:42 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CEF48FC12; Mon, 21 May 2012 13:05:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4LD5g1R059222; Mon, 21 May 2012 13:05:42 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4LD5g3M059208; Mon, 21 May 2012 13:05:42 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205211305.q4LD5g3M059208@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 21 May 2012 13:05:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235721 - in stable/8/usr.sbin/pkg_install: add delete lib updating version X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2012 13:05:42 -0000 Author: bapt Date: Mon May 21 13:05:41 2012 New Revision: 235721 URL: http://svn.freebsd.org/changeset/base/235721 Log: MFC: r201226, r202844, r206043, r206132, r206133, r212029, r225610, r226708, r228670 - Add support for UPDATING remote fetching. - Reorganize EXAMPLES section in pkg_updating(1). - Style fixes. - Replace hardcoded INDEX version. [1] - Fix a buffer overlap. [2] - Remove empty package when fetching fails and -K is used. [3] - Remove useless chmod2() after mkdtemp(3). [4] - Replace mkdir(1) call with mkdir(2). [5] - Get rid of some vsystem() calls. - Switch from lstat(2) to open(2) in fexists(). - Try rename(2) in move_file() first. - Fix pkg_delete, check if the file we're trying to delete is a symlink before complaining that it doesn't exist. Typical case would be a leftover library symlink that's left over after the actual library has been removed. - Print the package name on deletion errors. - Staticify elide_root() - In usr.sbin/pkg_install/updating/main.c, use the size of the destination buffer as size argument to strlcpy(), not the length of the source PR: bin/145101 [1], bin/139492 [2], bin/144919 [3] bin/144920 [4], bin/144921 [5] Submitted by: gcooper [1,2,3,4,5] Approved by: des (mentor) Modified: stable/8/usr.sbin/pkg_install/add/futil.c stable/8/usr.sbin/pkg_install/add/main.c stable/8/usr.sbin/pkg_install/add/perform.c stable/8/usr.sbin/pkg_install/delete/perform.c stable/8/usr.sbin/pkg_install/lib/file.c stable/8/usr.sbin/pkg_install/lib/lib.h stable/8/usr.sbin/pkg_install/lib/match.c stable/8/usr.sbin/pkg_install/lib/pen.c stable/8/usr.sbin/pkg_install/lib/plist.c stable/8/usr.sbin/pkg_install/lib/url.c stable/8/usr.sbin/pkg_install/updating/main.c stable/8/usr.sbin/pkg_install/updating/pkg_updating.1 stable/8/usr.sbin/pkg_install/version/perform.c Directory Properties: stable/8/usr.sbin/ (props changed) stable/8/usr.sbin/pkg_install/ (props changed) stable/8/usr.sbin/pkg_install/add/ (props changed) stable/8/usr.sbin/pkg_install/info/ (props changed) Modified: stable/8/usr.sbin/pkg_install/add/futil.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/futil.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/add/futil.c Mon May 21 13:05:41 2012 (r235721) @@ -50,7 +50,7 @@ make_hierarchy(char *dir) } } else { - if (vsystem("/bin/mkdir %s", dir)) { + if (mkdir(dir, 0777) < 0) { if (cp2) *cp2 = '/'; return FAIL; Modified: stable/8/usr.sbin/pkg_install/add/main.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/main.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/add/main.c Mon May 21 13:05:41 2012 (r235721) @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include #include @@ -306,7 +306,9 @@ getpackagesite(void) { int reldate, i; static char sitepath[MAXPATHLEN]; - struct utsname u; + int archmib[] = { CTL_HW, HW_MACHINE_ARCH }; + char arch[64]; + size_t archlen = sizeof(arch); if (getenv("PACKAGESITE")) { if (strlcpy(sitepath, getenv("PACKAGESITE"), sizeof(sitepath)) @@ -329,8 +331,10 @@ getpackagesite(void) >= sizeof(sitepath)) return NULL; - uname(&u); - if (strlcat(sitepath, u.machine, sizeof(sitepath)) >= sizeof(sitepath)) + if (sysctl(archmib, 2, arch, &archlen, NULL, 0) == -1) + return NULL; + arch[archlen-1] = 0; + if (strlcat(sitepath, arch, sizeof(sitepath)) >= sizeof(sitepath)) return NULL; reldate = getosreldate(); Modified: stable/8/usr.sbin/pkg_install/add/perform.c ============================================================================== --- stable/8/usr.sbin/pkg_install/add/perform.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/add/perform.c Mon May 21 13:05:41 2012 (r235721) @@ -78,6 +78,7 @@ pkg_do(char *pkg) char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX]; char *conflict[2]; char **matched; + int fd; conflictsfound = 0; code = 0; @@ -408,8 +409,10 @@ pkg_do(char *pkg) goto bomb; /* Look for the requirements file */ - if (fexists(REQUIRE_FNAME)) { - vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */ + if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Running requirements file first for %s..\n", Plist.name); if (!Fake && vsystem("./%s %s INSTALL", REQUIRE_FNAME, Plist.name)) { @@ -441,8 +444,10 @@ pkg_do(char *pkg) } /* If we're really installing, and have an installation file, run it */ - if (!NoInstall && fexists(pre_script)) { - vsystem("/bin/chmod +x %s", pre_script); /* make sure */ + if (!NoInstall && (fd = open(pre_script, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Running pre-install for %s..\n", Plist.name); if (!Fake && vsystem("./%s %s %s", pre_script, Plist.name, pre_arg)) { @@ -470,8 +475,10 @@ pkg_do(char *pkg) } /* Run the installation script one last time? */ - if (!NoInstall && fexists(post_script)) { - vsystem("/bin/chmod +x %s", post_script); /* make sure */ + if (!NoInstall && (fd = open(post_script, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Running post-install for %s..\n", Plist.name); if (!Fake && vsystem("./%s %s %s", post_script, Plist.name, post_arg)) { @@ -503,7 +510,10 @@ pkg_do(char *pkg) goto success; /* close enough for government work */ } /* Make sure pkg_info can read the entry */ - vsystem("/bin/chmod a+rx %s", LogDir); + fd = open(LogDir, O_RDWR); + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IRALL | S_IXALL); /* be sure, chmod a+rx */ + close(fd); move_file(".", DESC_FNAME, LogDir); move_file(".", COMMENT_FNAME, LogDir); if (fexists(INSTALL_FNAME)) Modified: stable/8/usr.sbin/pkg_install/delete/perform.c ============================================================================== --- stable/8/usr.sbin/pkg_install/delete/perform.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/delete/perform.c Mon May 21 13:05:41 2012 (r235721) @@ -132,6 +132,8 @@ pkg_do(char *pkg) const char *post_script, *pre_arg, *post_arg; struct reqr_by_entry *rb_entry; struct reqr_by_head *rb_list; + int fd; + struct stat sb; if (!pkg || !(len = strlen(pkg))) return 1; @@ -221,10 +223,12 @@ pkg_do(char *pkg) setenv(PKG_PREFIX_VNAME, p->name, 1); - if (fexists(REQUIRE_FNAME)) { + if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Executing 'require' script.\n"); - vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */ if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) { warnx("package %s fails requirements %s", pkg, Force ? "" : "- not deleted"); @@ -250,11 +254,13 @@ pkg_do(char *pkg) post_script = pre_arg = post_arg = NULL; } - if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) { + if (!NoDeInstall && pre_script != NULL && (fd = open(pre_script, O_RDWR)) != -1) { if (Fake) printf("Would execute de-install script at this point.\n"); else { - vsystem("/bin/chmod +x %s", pre_script); /* make sure */ + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) { warnx("deinstall script returned error status"); if (!Force) @@ -326,11 +332,13 @@ pkg_do(char *pkg) return 1; } - if (!NoDeInstall && post_script != NULL && fexists(post_script)) { + if (!NoDeInstall && post_script != NULL && (fd = open(post_script, O_RDWR)) != -1) { if (Fake) printf("Would execute post-deinstall script at this point.\n"); else { - vsystem("/bin/chmod +x %s", post_script); /* make sure */ + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (vsystem("./%s %s %s", post_script, pkg, post_arg)) { warnx("post-deinstall script returned error status"); if (!Force) Modified: stable/8/usr.sbin/pkg_install/lib/file.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/file.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/lib/file.c Mon May 21 13:05:41 2012 (r235721) @@ -31,10 +31,13 @@ __FBSDID("$FreeBSD$"); Boolean fexists(const char *fname) { - struct stat dummy; - if (!lstat(fname, &dummy)) - return TRUE; - return FALSE; + int fd; + + if ((fd = open(fname, O_RDONLY)) == -1) + return FALSE; + + close(fd); + return TRUE; } /* Quick check to see if something is a directory or symlink to a directory */ @@ -279,17 +282,23 @@ copy_file(const char *dir, const char *f } void -move_file(const char *dir, const char *fname, const char *to) +move_file(const char *dir, const char *fname, const char *tdir) { - char cmd[FILENAME_MAX]; + char from[FILENAME_MAX]; + char to[FILENAME_MAX]; if (fname[0] == '/') - snprintf(cmd, FILENAME_MAX, "/bin/mv %s %s", fname, to); + strncpy(from, fname, FILENAME_MAX); else - 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); + snprintf(from, FILENAME_MAX, "%s/%s", dir, fname); + + snprintf(to, FILENAME_MAX, "%s/%s", tdir, fname); + + if (rename(from, to) == -1) { + if (vsystem("/bin/mv %s %s", from, to)) { + cleanup(0); + errx(2, "%s: could not move '%s' to '%s'", __func__, from, to); + } } } Modified: stable/8/usr.sbin/pkg_install/lib/lib.h ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/lib.h Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/lib/lib.h Mon May 21 13:05:41 2012 (r235721) @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,11 @@ #define YES 2 #define NO 1 +/* Some more stat macros. */ +#define S_IRALL 0000444 +#define S_IWALL 0000222 +#define S_IXALL 0000111 + /* Usually "rm", but often "echo" during debugging! */ #define REMOVE_CMD "/bin/rm" @@ -84,18 +90,6 @@ #define DISPLAY_FNAME "+DISPLAY" #define MTREE_FNAME "+MTREE_DIRS" -#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" -#else -#define INDEX_FNAME "INDEX" -#endif - #define CMD_CHAR '@' /* prefix for extended PLIST cmd */ /* The name of the "prefix" environment variable given to scripts */ @@ -105,7 +99,7 @@ * Version of the package tools - increase whenever you make a change * in the code that is not cosmetic only. */ -#define PKG_INSTALL_VERSION 20101002 +#define PKG_INSTALL_VERSION 20100403 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" #define main(argc, argv) real_main(argc, argv) Modified: stable/8/usr.sbin/pkg_install/lib/match.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/match.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/lib/match.c Mon May 21 13:05:41 2012 (r235721) @@ -267,7 +267,7 @@ matchallbyorigin(const char **origins, i */ if (isemptydir(tmp)) continue; - snprintf(tmp, PATH_MAX, "%s/%s", tmp, CONTENTS_FNAME); + strncat(tmp, "/" CONTENTS_FNAME, PATH_MAX); fp = fopen(tmp, "r"); if (fp == NULL) { warnx("the package info for package '%s' is corrupt", installed[i]); Modified: stable/8/usr.sbin/pkg_install/lib/pen.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/pen.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/lib/pen.c Mon May 21 13:05:41 2012 (r235721) @@ -113,10 +113,6 @@ make_playpen(char *pen, off_t sz) cleanup(0); errx(2, "%s: can't mktemp '%s'", __func__, pen); } - if (chmod(pen, 0700) == FAIL) { - cleanup(0); - errx(2, "%s: can't mkdir '%s'", __func__, pen); - } if (Verbose) { if (sz) { Modified: stable/8/usr.sbin/pkg_install/lib/plist.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/plist.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/lib/plist.c Mon May 21 13:05:41 2012 (r235721) @@ -551,7 +551,7 @@ delete_hierarchy(const char *dir, Boolea char *cp1, *cp2; cp1 = cp2 = strdup(dir); - if (!fexists(dir)) { + if (!fexists(dir) && !issymlink(dir)) { if (!ign_err) warnx("%s '%s' doesn't exist", isdir(dir) ? "directory" : "file", dir); Modified: stable/8/usr.sbin/pkg_install/lib/url.c ============================================================================== --- stable/8/usr.sbin/pkg_install/lib/url.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/lib/url.c Mon May 21 13:05:41 2012 (r235721) @@ -108,6 +108,10 @@ fileGetURL(const char *base, const char if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) { printf("Error: Unable to get %s: %s\n", fname, fetchLastErrString); + /* If the fetch fails, yank the package. */ + if (keep_package && unlink(pkg) < 0 && Verbose) { + warnx("failed to remove partially fetched package: %s", pkg); + } return NULL; } Modified: stable/8/usr.sbin/pkg_install/updating/main.c ============================================================================== --- stable/8/usr.sbin/pkg_install/updating/main.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/updating/main.c Mon May 21 13:05:41 2012 (r235721) @@ -10,7 +10,11 @@ #include __FBSDID("$FreeBSD$"); + +#include +#include #include +#include #include #include #include @@ -115,10 +119,10 @@ main(int argc, char *argv[]) if (argc != 0) { pflag = 1; while (*argv) { - if((curr = (INSTALLEDPORT *) + if ((curr = (INSTALLEDPORT *) malloc(sizeof(INSTALLEDPORT))) == NULL) (void)exit(EXIT_FAILURE); - strlcpy (curr->name, *argv, strlen(*argv) + 1); + strlcpy(curr->name, *argv, strlen(*argv) + 1); curr->next = head; head = curr; (void)*argv++; @@ -131,22 +135,22 @@ main(int argc, char *argv[]) */ if (pflag == 0) { /* Open /var/db/pkg and search for all installed ports. */ - if((dir = opendir(pkgdbpath)) != NULL) { + if ((dir = opendir(pkgdbpath)) != NULL) { while ((pkgdbdir = readdir(dir)) != NULL) { if (strcmp(pkgdbdir->d_name, ".") != 0 && - strcmp(pkgdbdir->d_name, "..") !=0) { + strcmp(pkgdbdir->d_name, "..") != 0) { /* Create path to +CONTENTS file for each installed port */ - n = strlcpy(tmp_file, pkgdbpath, strlen(pkgdbpath)+1); + n = strlcpy(tmp_file, pkgdbpath, sizeof(tmp_file)); n = strlcpy(tmp_file + n, "/", sizeof(tmp_file) - n); n = strlcat(tmp_file + n, pkgdbdir->d_name, sizeof(tmp_file) - n); - if(stat(tmp_file, &attribute) == -1) { + if (stat(tmp_file, &attribute) == -1) { fprintf(stderr, "can't open %s: %s\n", tmp_file, strerror(errno)); return EXIT_FAILURE; } - if(attribute.st_mode & S_IFREG) + if (attribute.st_mode & S_IFREG) continue; (void)strlcat(tmp_file + n, "/", sizeof(tmp_file) - n); @@ -155,7 +159,7 @@ main(int argc, char *argv[]) /* Open +CONTENT file */ fd = fopen(tmp_file, "r"); - if(fd == NULL) { + if (fd == NULL) { fprintf(stderr, "warning: can't open %s: %s\n", tmp_file, strerror(errno)); continue; @@ -165,25 +169,25 @@ main(int argc, char *argv[]) * Parses +CONTENT for ORIGIN line and * put element into linked list. */ - while(fgets(originline, maxcharperline, fd) != NULL) { + while (fgets(originline, maxcharperline, fd) != NULL) { tmpline1 = strstr(originline, origin); - if( tmpline1 != NULL ) { + if (tmpline1 != NULL) { /* Tmp variable to store port name. */ char *pname; pname = strrchr(originline, (int)':'); pname++; - if((curr = (INSTALLEDPORT *) + if ((curr = (INSTALLEDPORT *) malloc(sizeof(INSTALLEDPORT))) == NULL) (void)exit(EXIT_FAILURE); if (pname[strlen(pname) - 1] == '\n') pname[strlen(pname) - 1] = '\0'; - strlcpy (curr->name, pname, strlen(pname)+1); + strlcpy (curr->name, pname, sizeof(curr->name)); curr->next = head; head = curr; } } - if(ferror(fd)) { + if (ferror(fd)) { fprintf(stderr, "error reading input\n"); exit(EX_IOERR); } @@ -195,32 +199,41 @@ main(int argc, char *argv[]) } } - /* Open UPDATING file */ - fd = fopen(updatingfile, "r"); - if(fd == NULL) { + /* Fetch UPDATING file if needed and open file */ + if (isURL(updatingfile)) { + if ((fd = fetchGetURL(updatingfile, "")) == NULL) { + fprintf(stderr, "Error: Unable to get %s: %s\n", + updatingfile, fetchLastErrString); + exit(EX_UNAVAILABLE); + } + } + else { + fd = fopen(updatingfile, "r"); + } + if (fd == NULL) { fprintf(stderr, "can't open %s: %s\n", - updatingfile, strerror(errno)); + updatingfile, strerror(errno)); exit(EX_UNAVAILABLE); } /* Parse opened UPDATING file. */ - while(fgets(updatingline, maxcharperline, fd) != NULL) { + while (fgets(updatingline, maxcharperline, fd) != NULL) { /* No entry is found so far */ if (found == 0) { /* Search for AFFECTS line to parse the portname. */ tmpline1 = strstr(updatingline, affects); - if( tmpline1 != NULL ) { + if (tmpline1 != NULL) { curr = head; - while(curr != NULL) { + while (curr != NULL) { tmpline2 = strstr(updatingline, curr->name); - if( tmpline2 != NULL ) + if (tmpline2 != NULL) break; curr = curr->next; } - if( tmpline2 != NULL ) { + if (tmpline2 != NULL) { /* If -d is set, check if entry is newer than the date. */ - if ( (dflag == 1) && (strncmp(dateline, date, 8) < 0)) + if ((dflag == 1) && (strncmp(dateline, date, 8) < 0)) continue; printf("%s", dateline); printf("%s", updatingline); @@ -231,7 +244,7 @@ main(int argc, char *argv[]) /* Search for the end of an entry, if not found print the line. */ else { tmpline1 = strstr(updatingline, end); - if( tmpline1 == NULL ) + if (tmpline1 == NULL) printf("%s", updatingline); else { linelength = strlen(updatingline); @@ -245,7 +258,7 @@ main(int argc, char *argv[]) dateline = strdup(updatingline); } - if(ferror(fd)) { + if (ferror(fd)) { fprintf(stderr, "error reading input\n"); exit(EX_IOERR); } Modified: stable/8/usr.sbin/pkg_install/updating/pkg_updating.1 ============================================================================== --- stable/8/usr.sbin/pkg_install/updating/pkg_updating.1 Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/updating/pkg_updating.1 Mon May 21 13:05:41 2012 (r235721) @@ -45,26 +45,31 @@ Print help message. .El .Sh EXAMPLES .Bl -tag -width indent -.Dl pkg_updating +Shows all entries of all installed ports: .Pp -Shows all entries of all installed ports. +.Dl % pkg_updating .Pp -.Dl pkg_updating -d 20070101 +Shows all entries of all installed ports since 2007-01-01: .Pp -Shows all entries of all installed ports since 2007-01-01. +.Dl % pkg_updating -d 20070101 .Pp -.Dl pkg_updating apache mysql +Shows all entries for all apache and mysql ports: .Pp -Shows all entries for all apache and mysql ports. +.Dl % pkg_updating apache mysql .Pp -.Dl pkg_updating -d 20060101 apache +Shows all apache entries since 2006-01-01: .Pp -Shows all apache entries since 2006-01-01. -.Pp -.Dl pkg_updating -f /tmp/UPDATING +.Dl % pkg_updating -d 20060101 apache .Pp Defines that the UPDATING file is in /tmp and shows all entries of all -installed ports +installed ports: +.Pp +.Dl % pkg_updating -f /tmp/UPDATING +.Pp +Fetch UPDATING file from ftp mirror and show all entries of all +installed ports: +.Pp +.Dl % pkg_updating -f ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/UPDATING .Pp .El .Sh ENVIRONMENT Modified: stable/8/usr.sbin/pkg_install/version/perform.c ============================================================================== --- stable/8/usr.sbin/pkg_install/version/perform.c Mon May 21 08:10:42 2012 (r235720) +++ stable/8/usr.sbin/pkg_install/version/perform.c Mon May 21 13:05:41 2012 (r235721) @@ -35,28 +35,41 @@ static int pkg_do(char *); static void show_version(Package, const char *, const char *); /* - * This is the traditional pkg_perform, except that the argument is _not_ - * a list of packages. It is the index file from the command line. + * This is the traditional pkg_perform, except that the argument is _not_ a + * list of packages. It is the index file from the command line. * - * We loop over the installed packages, matching them with the -s flag - * if needed and calling pkg_do(). Before hand we set up a few things, - * and after we tear them down... + * We loop over the installed packages, matching them with the -s flag if + * needed and calling pkg_do(). Beforehand we set up a few things, and after + * we tear them down... + * + * Returns 0 on success, non-zero on failure, corresponding to the number of + * failed attempts to access the INDEX. */ int pkg_perform(char **indexarg) { char **pkgs, *pat[2], **patterns; struct index_entry *ie; - int i, err_cnt = 0; + int i, err_cnt = 0, rel_major_ver; int MatchType; + struct utsname u; + + if (uname(&u) == -1) { + warn("%s(): failed to determine uname information", __func__); + return 1; + } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) { + + } + /* * Try to find and open the INDEX. We only check IndexFile != NULL * later, if we actually need the INDEX. */ - if (*indexarg == NULL) - snprintf(IndexPath, sizeof(IndexPath), "%s/%s", PORTS_DIR, INDEX_FNAME); - else + if (*indexarg == NULL) { + snprintf(IndexPath, sizeof(IndexPath), "%s/INDEX-%d", PORTS_DIR, + rel_major_ver); + } else strlcpy(IndexPath, *indexarg, sizeof(IndexPath)); if (isURL(IndexPath)) IndexFile = fetchGetURL(IndexPath, "");