From owner-p4-projects@FreeBSD.ORG Sat Aug 16 13:37:17 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 86D271065674; Sat, 16 Aug 2008 13:37:17 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15A27106567D for ; Sat, 16 Aug 2008 13:37:17 +0000 (UTC) (envelope-from andenore@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F13B48FC08 for ; Sat, 16 Aug 2008 13:37:16 +0000 (UTC) (envelope-from andenore@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7GDbGhv017394 for ; Sat, 16 Aug 2008 13:37:16 GMT (envelope-from andenore@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7GDbGBY017392 for perforce@freebsd.org; Sat, 16 Aug 2008 13:37:16 GMT (envelope-from andenore@FreeBSD.org) Date: Sat, 16 Aug 2008 13:37:16 GMT Message-Id: <200808161337.m7GDbGBY017392@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to andenore@FreeBSD.org using -f From: Anders Nore To: Perforce Change Reviews Cc: Subject: PERFORCE change 147533 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Aug 2008 13:37:17 -0000 http://perforce.freebsd.org/chv.cgi?CH=147533 Change 147533 by andenore@andenore_laptop on 2008/08/16 13:36:26 Bugfixing and updating some manpages. Affected files ... .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/CHANGES#12 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/add/perform.c#10 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/Makefile#3 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/main.c#7 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/perform.c#6 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/pkg_delete.1#3 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/main.c#10 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/perform.c#11 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/pkg_info.1#7 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/database.c#13 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/lib.h#16 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/match.c#10 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/pen.c#3 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/plist.c#11 edit .. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/perform.c#7 edit Differences ... ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/CHANGES#12 (text+ko) ==== @@ -1,50 +1,61 @@ Changes made to pkg_install during SoC2008 by Anders Nore (andenore@FreeBSD.org) -Last modified: 2008 08 03 +Last modified: 2008 08 13 Converter: - - Added convert program that indexes information to PKG_DBCACHE_FILE - - Added some features to lookup keys and print them (or print whole db) - - Caches origin, installtime and which-files (files in package to pkgname) + - Added convert program that indexes information to PKG_DBCACHE_FILE + - Added some features to lookup keys and print them (or print whole db) + - Caches origin, installtime and which-files (files in package to pkgname) + - Caches installtime for packages without '@comment DATE:' using ctime for +COMMENT + Info: - - Improved performance for -W option using the dbcache - - Profiling showed that the default behavior for pkg_info was to read plist + - Improved performance for -W option using the dbcache + - Profiling showed that the default behavior for pkg_info was to read plist everytime even though not needed. Added check for this and speed improved significantly. - - Uses human readable output for -s (size option) I'm not sure if this breaks + - Uses human readable output for -s (size option) I'm not sure if this breaks things, but it looks Ok. (The old output is available via the -b option) - - Print installation date with -n (human readable) or -N (seconds since epoch) - - Added installtime comparison with the -M option, e.g, + - Print installation date with -n (human readable) or -N (seconds since epoch) + - Added installtime comparison with the -M option, e.g, "pkg_info -M '*>2008-07-18 18:30:21'" will list all packages installed after the date YYYY-MM-DD hh:mm:ss. Add: - - Indexes information to dbcache according to the add - - Added percentage progress for remote fetching ( -r option ) - - Fixes dependencies when installing (scans installed ports, checks @pkgdep + - Indexes information to dbcache according to the add + - Added percentage progress for remote fetching ( -r option ) + - Fixes dependencies when installing (scans installed ports, checks @pkgdep and adds matching dependency to the installing package's +REQUIRED_BY file) Delete: - - Deindexes information according to the delete - - Now supports range deletion with installdates, e.g., + - Deindexes information according to the delete + - Now supports range deletion with installdates, e.g., pkg_delete -i -M '*>=2008-07-14<2008-08' will delete all packages installed between dates 2008-07-14 and 2008-08, asking for y/n before the deletion. Lib: - - Changed methods in match.c to use cache if available (matchallbyorigin, ispkginstalled) - - Added global variable 'database' of type DB* (the database object) - - Added database helper functions - - Added function to cache a Packagelist (cache_plist()) - - The environment variable PKG_DBCAHE_FILE can be set to make the file + - Changed methods in match.c to use cache if available (matchallbyorigin, ispkginstalled) + - Added global variable 'database' of type DB* (the database object) + - Added database helper functions + - Added function to cache a Packagelist (cache_plist()) + - The environment variable PKG_DBCAHE_FILE can be set to make the file location different than the default /var/db/pkg/pkgcache.db - - pattern_match will compare dates as well as version numbers. + - pattern_match will compare dates as well as version numbers. Create: - - The -O option has been modified to cache information when installing ports + - The -O option has been modified to cache information when installing ports from /usr/ports/ Packinglist: - - A @comment DATE:YYYY-MM-DD hh:mm:ss has been added (affects add/create/info/lib)+ - A @comment DATE:YYYY-MM-DD hh:mm:ss has been added (affects add/create/info/lib) + + +Fixed bugs in -CURRENT: + - Fixed a bug with the oldstyle -W handling of empty @cwd's, which leads to a + number of files installed by packages not beeing recognized. + - pkg_add -r of two packages (or more I assume) where the first depends on + one or more packages which is not installed causes a "fatal error during + execution: getcwd" because it doesn't save previous working directories + correctly. ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/add/perform.c#10 (text+ko) ==== @@ -36,6 +36,7 @@ static int sanity_check(char *); static char LogDir[FILENAME_MAX]; static int zapLogDir; /* Should we delete LogDir? */ +char wd[FILENAME_MAX]; int pkg_perform(char **pkgs) @@ -45,6 +46,8 @@ signal(SIGINT, cleanup); signal(SIGHUP, cleanup); + getcwd(wd, sizeof(wd)); + if (AddMode == SLAVE) err_cnt = pkg_do(NULL); else { @@ -89,7 +92,10 @@ strcpy(playpen, FirstPen); inPlace = 0; - /* Are we coming in for a second pass, everything already extracted? */ + /* + * Are we coming in for a second pass, everything already extracted? + * Aka SLAVE mode. + */ if (!pkg) { fgets(playpen, FILENAME_MAX, stdin); playpen[strlen(playpen) - 1] = '\0'; /* pesky newline! */ @@ -289,9 +295,14 @@ /* Now check the packing list for dependencies */ for (p = Plist.head; p ; p = p->next) { char *deporigin; - + if (p->type != PLIST_PKGDEP) continue; + + /* We close the db later, and we reopen it here for each package */ + if (!Fake) + openDatabase(O_RDWR); + deporigin = (p->next->type == PLIST_DEPORIGIN) ? p->next->name : NULL; if (Verbose) { printf("Package '%s' depends on '%s'", Plist.name, p->name); @@ -305,6 +316,12 @@ char path[FILENAME_MAX], *cp = NULL; if (!Fake) { + /* + * We close the database so when calling pkg_add recursively it + * can open it and save to it. If we don't do this only the + * first package will be saved to the database. + */ + closeDatabase(); char prefixArg[2 + MAXPATHLEN]; /* "-P" + Prefix */ if (PrefixRecursive) { strlcpy(prefixArg, "-P", sizeof(prefixArg)); @@ -513,14 +530,17 @@ /* * Read through Plist, then index info to db cache - * And save dependencies + * And update dependendency packages +REQUIRED_BY file */ /* make sure we've opened the database */ if (openDatabase(O_CREAT | O_RDWR)) warn("Could not open database %s, may lead to inconsistency", DBCACHE_FILE); - else + else { + if (Verbose) + printf("Caching the Plist for: %s\n", Plist.name); cache_plist(&Plist, Verbose, FALSE); // cache information + } /* record dependency in the dependents +REQUIRED_BY file */ for (p = Plist.head; p ; p = p->next) { @@ -642,7 +662,6 @@ success: /* delete the packing list contents */ - free_plist(&Plist); leave_playpen(); return code; ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/Makefile#3 (text+ko) ==== @@ -3,7 +3,7 @@ PROG= pkg_delete SRCS= main.c perform.c -CFLAGS+= -I${.CURDIR}/../lib +CFLAGS+= -I${.CURDIR}/../lib -g WARNS?= 6 WFORMAT?= 1 ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/main.c#7 (text+ko) ==== @@ -50,6 +50,7 @@ { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "interactive",no_argument, NULL, 'i' }, + { "match-date" ,no_argument, NULL, 'M' }, { "prefix", required_argument, NULL, 'p' }, { "recursive", no_argument, NULL, 'r' }, { "regex", no_argument, NULL, 'x' }, @@ -183,6 +184,7 @@ if ((error = pkg_perform(start)) != 0) { if (Verbose) warnx("%d package deletion(s) failed", error); + return error; } else ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/perform.c#6 (text+ko) ==== @@ -41,7 +41,7 @@ struct reqr_by_head *rb_list; if (MatchType != MATCH_EXACT) { - matched = matchinstalled(MatchType * (DateMatch ? 10 : 1), pkgs, &errcode); + matched = matchinstalled(MatchType, pkgs, &errcode); if (errcode != 0) return 1; @@ -72,45 +72,45 @@ } } - err_cnt += sortdeps(pkgs); - for (i = 0; pkgs[i]; i++) { - if (Recursive == TRUE) { - errcode = requiredby(pkgs[i], &rb_list, FALSE, TRUE); + err_cnt += sortdeps(pkgs); + for (i = 0; pkgs[i]; i++) { + if (Recursive == TRUE) { + errcode = requiredby(pkgs[i], &rb_list, FALSE, TRUE); - if (errcode < 0) { - err_cnt++; - } else if (errcode > 0) { + if (errcode < 0) { + err_cnt++; + } else if (errcode > 0) { - /* - * Copy values from the rb_list queue into argv-like NULL - * terminated list because requiredby() uses some static - * storage, while pkg_do() below will call this function, - * thus blowing our rb_list away. - */ - rbtmp = rb = alloca((errcode + 1) * sizeof(*rb)); - if (rb == NULL) { - warnx("%s(): alloca() failed", __func__); - err_cnt++; - continue; - } - STAILQ_FOREACH(rb_entry, rb_list, link) { - *rbtmp = alloca(strlen(rb_entry->pkgname) + 1); - if (*rbtmp == NULL) { - warnx("%s(): alloca() failed", __func__); - err_cnt++; - continue; - } - strcpy(*rbtmp, rb_entry->pkgname); - rbtmp++; - } - *rbtmp = NULL; + /* + * Copy values from the rb_list queue into argv-like NULL + * terminated list because requiredby() uses some static + * storage, while pkg_do() below will call this function, + * thus blowing our rb_list away. + */ + rbtmp = rb = alloca((errcode + 1) * sizeof(*rb)); + if (rb == NULL) { + warnx("%s(): alloca() failed", __func__); + err_cnt++; + continue; + } + STAILQ_FOREACH(rb_entry, rb_list, link) { + *rbtmp = alloca(strlen(rb_entry->pkgname) + 1); + if (*rbtmp == NULL) { + warnx("%s(): alloca() failed", __func__); + err_cnt++; + continue; + } + strcpy(*rbtmp, rb_entry->pkgname); + rbtmp++; + } + *rbtmp = NULL; - err_cnt += sortdeps(rb); - for (j = 0; rb[j]; j++) - err_cnt += pkg_do(rb[j]); - } - } - err_cnt += pkg_do(pkgs[i]); + err_cnt += sortdeps(rb); + for (j = 0; rb[j]; j++) + err_cnt += pkg_do(rb[j]); + } + } + err_cnt += pkg_do(pkgs[i]); } return err_cnt; @@ -135,172 +135,172 @@ struct reqr_by_head *rb_list; - if (!pkg || !(len = strlen(pkg))) - return 1; - if (pkg[len - 1] == '/') - pkg[len - 1] = '\0'; + if (!pkg || !(len = strlen(pkg))) + return 1; + if (pkg[len - 1] == '/') + pkg[len - 1] = '\0'; - /* Reset some state */ - if (Plist.head) - free_plist(&Plist); + /* Reset some state */ + if (Plist.head) + free_plist(&Plist); - sprintf(LogDir, "%s/%s", LOG_DIR, pkg); + sprintf(LogDir, "%s/%s", LOG_DIR, pkg); - isinstalled = isinstalledpkg(pkg); - if (isinstalled == 0) { - warnx("no such package '%s' installed", pkg); - return 1; - } else if (isinstalled < 0) { - warnx("the package info for package '%s' is corrupt%s", - pkg, Force ? - " (but I'll delete it anyway)" : " (use -f to force removal)"); + isinstalled = isinstalledpkg(pkg); + if (isinstalled == 0) { + warnx("no such package '%s' installed", pkg); + return 1; + } else if (isinstalled < 0) { + warnx("the package info for package '%s' is corrupt%s", + pkg, Force ? + " (but I'll delete it anyway)" : " (use -f to force removal)"); - if (!Force) - return 1; + if (!Force) + return 1; - if (!Fake) { - if (vsystem("%s -rf %s", REMOVE_CMD, LogDir)) { - warnx("couldn't remove log entry in %s, deinstall failed", LogDir); - } else { - warnx("couldn't completely deinstall package '%s',\n" - "only the log entry in %s was removed", pkg, LogDir); - } - } - return 0; + if (!Fake) { + if (vsystem("%s -rf %s", REMOVE_CMD, LogDir)) { + warnx("couldn't remove log entry in %s, deinstall failed", LogDir); + } else { + warnx("couldn't completely deinstall package '%s',\n" + "only the log entry in %s was removed", pkg, LogDir); + } } + return 0; + } - if (!getcwd(home, FILENAME_MAX)) { - cleanup(0); - errx(2, "%s: unable to get current working directory!", __func__); - } + if (!getcwd(home, FILENAME_MAX)) { + cleanup(0); + errx(2, "%s: unable to get current working directory!", __func__); + } - if (chdir(LogDir) == FAIL) { - warnx("unable to change directory to %s! deinstall failed", LogDir); - return 1; - } + if (chdir(LogDir) == FAIL) { + warnx("unable to change directory to %s! deinstall failed", LogDir); + return 1; + } - if (Interactive == TRUE) { - int first, ch; + if (Interactive == TRUE) { + int first, ch; - (void)fprintf(stderr, "delete %s? ", pkg); - (void)fflush(stderr); - first = ch = getchar(); + (void)fprintf(stderr, "delete %s? ", pkg); + (void)fflush(stderr); + first = ch = getchar(); - while (ch != '\n' && ch != EOF) - ch = getchar(); + while (ch != '\n' && ch != EOF) + ch = getchar(); - if (first != 'y' && first != 'Y') - return 0; - } + if (first != 'y' && first != 'Y') + return 0; + } - if (requiredby(pkg, &rb_list, FALSE, TRUE) < 0) - return 1; + if (requiredby(pkg, &rb_list, FALSE, TRUE) < 0) + return 1; - if (!STAILQ_EMPTY(rb_list)) { - warnx("package '%s' is required by these other packages\n" - "and may not be deinstalled%s:", - pkg, Force ? " (but I'll delete it anyway)" : ""); + if (!STAILQ_EMPTY(rb_list)) { + warnx("package '%s' is required by these other packages\n" + "and may not be deinstalled%s:", + pkg, Force ? " (but I'll delete it anyway)" : ""); - STAILQ_FOREACH(rb_entry, rb_list, link) - fprintf(stderr, "\t%s\n", rb_entry->pkgname); + STAILQ_FOREACH(rb_entry, rb_list, link) + fprintf(stderr, "\t%s\n", rb_entry->pkgname); - if (!Force) - return 1; - } + if (!Force) + return 1; + } - sanity_check(LogDir); - cfile = fopen(CONTENTS_FNAME, "r"); + sanity_check(LogDir); + cfile = fopen(CONTENTS_FNAME, "r"); - if (!cfile) { - warnx("unable to open '%s' file", CONTENTS_FNAME); - return 1; - } + if (!cfile) { + warnx("unable to open '%s' file", CONTENTS_FNAME); + return 1; + } - /* If we have a prefix, add it now */ - if (Prefix) - add_plist(&Plist, PLIST_CWD, Prefix); + /* If we have a prefix, add it now */ + if (Prefix) + add_plist(&Plist, PLIST_CWD, Prefix); - read_plist(&Plist, cfile); - fclose(cfile); - p = find_plist(&Plist, PLIST_CWD); + read_plist(&Plist, cfile); + fclose(cfile); + p = find_plist(&Plist, PLIST_CWD); - if (!p) { - warnx("package '%s' doesn't have a prefix", pkg); - return 1; - } + if (!p) { + warnx("package '%s' doesn't have a prefix", pkg); + return 1; + } - setenv(PKG_PREFIX_VNAME, p->name, 1); + setenv(PKG_PREFIX_VNAME, p->name, 1); - if (fexists(REQUIRE_FNAME)) { - if (Verbose) - printf("Executing 'require' script.\n"); + if (fexists(REQUIRE_FNAME)) { + 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"); - if (!Force) - return 1; - } + 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"); + if (!Force) + return 1; } + } - /* - * Test whether to use the old method of passing tokens to deinstallation - * scripts, and set appropriate variables.. - */ + /* + * Test whether to use the old method of passing tokens to deinstallation + * scripts, and set appropriate variables.. + */ - if (fexists(POST_DEINSTALL_FNAME)) { - new_m = 1; - post_script = POST_DEINSTALL_FNAME; - pre_arg = post_arg = ""; - } else if (fexists(DEINSTALL_FNAME)) { - post_script = DEINSTALL_FNAME; - pre_arg = "DEINSTALL"; - post_arg = "POST-DEINSTALL"; - } else { - post_script = pre_arg = post_arg = NULL; - } + if (fexists(POST_DEINSTALL_FNAME)) { + new_m = 1; + post_script = POST_DEINSTALL_FNAME; + pre_arg = post_arg = ""; + } else if (fexists(DEINSTALL_FNAME)) { + post_script = DEINSTALL_FNAME; + pre_arg = "DEINSTALL"; + post_arg = "POST-DEINSTALL"; + } else { + post_script = pre_arg = post_arg = NULL; + } - if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) { - if (Fake) - printf("Would execute de-install script at this point.\n"); - else { - vsystem("/bin/chmod +x %s", pre_script); /* make sure */ - if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) { - warnx("deinstall script returned error status"); - if (!Force) - return 1; - } - } + if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) { + if (Fake) + printf("Would execute de-install script at this point.\n"); + else { + vsystem("/bin/chmod +x %s", pre_script); /* make sure */ + if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) { + warnx("deinstall script returned error status"); + if (!Force) + return 1; + } } + } - for (p = Plist.head; p ; p = p->next) { - if (p->type != PLIST_PKGDEP) - continue; + for (p = Plist.head; p ; p = p->next) { + if (p->type != PLIST_PKGDEP) + continue; - deporigin = (p->next != NULL && p->next->type == PLIST_DEPORIGIN) ? p->next->name : + deporigin = (p->next != NULL && p->next->type == PLIST_DEPORIGIN) ? p->next->name : NULL; - if (Verbose) { - printf("Trying to remove dependency on package '%s'", p->name); - if (deporigin != NULL) - printf(" with '%s' origin", deporigin); - printf(".\n"); - } + if (Verbose) { + printf("Trying to remove dependency on package '%s'", p->name); + if (deporigin != NULL) + printf(" with '%s' origin", deporigin); + printf(".\n"); + } - if (!Fake) { - if (deporigin) { - deporigins = realloc(deporigins, (dep_count + 2) * sizeof(*deporigins)); - depnames = realloc(depnames, (dep_count + 1) * sizeof(*depnames)); - deporigins[dep_count] = deporigin; - deporigins[dep_count + 1] = NULL; - depnames[dep_count] = p->name; - dep_count++; - } else { - undepend(p->name, pkg); - } - } + if (!Fake) { + if (deporigin) { + deporigins = realloc(deporigins, (dep_count + 2) * sizeof(*deporigins)); + depnames = realloc(depnames, (dep_count + 1) * sizeof(*depnames)); + deporigins[dep_count] = deporigin; + deporigins[dep_count + 1] = NULL; + depnames[dep_count] = p->name; + dep_count++; + } else { + undepend(p->name, pkg); + } } + } if (dep_count > 0) { /* Undepend all the dependencies at once */ @@ -320,128 +320,129 @@ } } - if (chdir(home) == FAIL) { - cleanup(0); - errx(2, "%s: unable to return to working directory %s!", __func__, - home); - } + if (chdir(home) == FAIL) { + cleanup(0); + errx(2, "%s: unable to return to working directory %s!", __func__, + home); + } - /* - * Some packages aren't packed right, so we need to just ignore - * delete_package()'s status. Ugh! :-( - */ - if (delete_package(FALSE, CleanDirs, &Plist) == FAIL) - warnx( - "couldn't entirely delete package (perhaps the packing list is\n" - "incorrectly specified?)"); + /* + * Some packages aren't packed right, so we need to just ignore + * delete_package()'s status. Ugh! :-( + */ + if (delete_package(FALSE, CleanDirs, &Plist) == FAIL) + warnx( + "couldn't entirely delete package (perhaps the packing list is\n" + "incorrectly specified?)"); - if (chdir(LogDir) == FAIL) { - warnx("unable to change directory to %s! deinstall failed", LogDir); - return 1; - } + if (chdir(LogDir) == FAIL) { + warnx("unable to change directory to %s! deinstall failed", LogDir); + return 1; + } - if (!NoDeInstall && post_script != NULL && fexists(post_script)) { - if (Fake) - printf("Would execute post-deinstall script at this point.\n"); - else { - vsystem("/bin/chmod +x %s", post_script); /* make sure */ - if (vsystem("./%s %s %s", post_script, pkg, post_arg)) { - warnx("post-deinstall script returned error status"); - if (!Force) - return 1; - } - } + if (!NoDeInstall && post_script != NULL && fexists(post_script)) { + if (Fake) + printf("Would execute post-deinstall script at this point.\n"); + else { + vsystem("/bin/chmod +x %s", post_script); /* make sure */ + if (vsystem("./%s %s %s", post_script, pkg, post_arg)) { + warnx("post-deinstall script returned error status"); + if (!Force) + return 1; + } } + } - if (chdir(home) == FAIL) { - cleanup(0); - errx(2, "%s: unable to return to working directory %s!", __func__, - home); - } + if (chdir(home) == FAIL) { + cleanup(0); + errx(2, "%s: unable to return to working directory %s!", __func__, + home); + } - if (!Fake) { - if (vsystem("%s -r%c %s", REMOVE_CMD, Force ? 'f' : ' ', LogDir)) { - warnx("couldn't remove log entry in %s, deinstall failed", LogDir); + if (!Fake) { + if (vsystem("%s -r%c %s", REMOVE_CMD, Force ? 'f' : ' ', LogDir)) { + warnx("couldn't remove log entry in %s, deinstall failed", LogDir); - if (!Force) - return 1; - } + if (!Force) + return 1; } - return 0; + } + + return 0; } static void sanity_check(char *pkg) { - if (!fexists(CONTENTS_FNAME)) { - cleanup(0); - errx(2, "%s: installed package %s has no %s file!", __func__, - pkg, CONTENTS_FNAME); - } + if (!fexists(CONTENTS_FNAME)) { + cleanup(0); + errx(2, "%s: installed package %s has no %s file!", __func__, + pkg, CONTENTS_FNAME); + } } void cleanup(int sig) { - if (sig) - exit(1); + if (sig) + exit(1); } /* Removes entry in p's +REQUIRED_BY file that equals pkgname */ static void undepend(char *p, char *pkgname) { - char fname[FILENAME_MAX], ftmp[FILENAME_MAX]; - FILE *fpwr; - int s; - struct reqr_by_entry *rb_entry; - struct reqr_by_head *rb_list; + char fname[FILENAME_MAX], ftmp[FILENAME_MAX]; + FILE *fpwr; + int s; + struct reqr_by_entry *rb_entry; + struct reqr_by_head *rb_list; - /* Get list of packages that require p */ - if (requiredby(p, &rb_list, Verbose, FALSE) <= 0) - return; + /* Get list of packages that require p */ + if (requiredby(p, &rb_list, Verbose, FALSE) <= 0) + return; - snprintf(fname, sizeof(fname), "%s/%s/%s", LOG_DIR, p, REQUIRED_BY_FNAME); - snprintf(ftmp, sizeof(ftmp), "%s.XXXXXX", fname); - s = mkstemp(ftmp); - if (s == -1) { - warnx("couldn't open temp file '%s'", ftmp); - return; - } + snprintf(fname, sizeof(fname), "%s/%s/%s", LOG_DIR, p, REQUIRED_BY_FNAME); + snprintf(ftmp, sizeof(ftmp), "%s.XXXXXX", fname); + s = mkstemp(ftmp); + if (s == -1) { + warnx("couldn't open temp file '%s'", ftmp); + return; + } - fpwr = fdopen(s, "w"); - if (fpwr == NULL) { - close(s); - warnx("couldn't fdopen temp file '%s'", ftmp); - goto cleanexit; - } + fpwr = fdopen(s, "w"); + if (fpwr == NULL) { + close(s); + warnx("couldn't fdopen temp file '%s'", ftmp); + goto cleanexit; + } - /* - * For every package that requires p, check if package equals pkgname - * if NOT put the name into the temporary file. This operation makes a - * new +REQUIRED_BY file for package p without pkgname in it, thus - * 'undepending' it. - */ - STAILQ_FOREACH(rb_entry, rb_list, link) - if (strcmp(rb_entry->pkgname, pkgname)) /* no match */ - fputs(rb_entry->pkgname, fpwr), putc('\n', fpwr); + /* + * For every package that requires p, check if package equals pkgname + * if NOT put the name into the temporary file. This operation makes a + * new +REQUIRED_BY file for package p without pkgname in it, thus + * 'undepending' it. + */ + STAILQ_FOREACH(rb_entry, rb_list, link) + if (strcmp(rb_entry->pkgname, pkgname)) /* no match */ + fputs(rb_entry->pkgname, fpwr), putc('\n', fpwr); - if (fchmod(s, 0644) == FAIL) { - warnx("error changing permission of temp file '%s'", ftmp); - fclose(fpwr); - goto cleanexit; - } + if (fchmod(s, 0644) == FAIL) { + warnx("error changing permission of temp file '%s'", ftmp); + fclose(fpwr); + goto cleanexit; + } - if (fclose(fpwr) == EOF) { - warnx("error closing temp file '%s'", ftmp); - goto cleanexit; - } + if (fclose(fpwr) == EOF) { + warnx("error closing temp file '%s'", ftmp); + goto cleanexit; + } - /* Make the temporary file the new +REQUIRED_BY file for package p */ - if (rename(ftmp, fname) == -1) - warnx("error renaming '%s' to '%s'", ftmp, fname); + /* Make the temporary file the new +REQUIRED_BY file for package p */ + if (rename(ftmp, fname) == -1) + warnx("error renaming '%s' to '%s'", ftmp, fname); cleanexit: - remove(ftmp); - return; + remove(ftmp); + return; } ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/delete/pkg_delete.1#3 (text+ko) ==== @@ -25,7 +25,7 @@ .Nd a utility for deleting previously installed software package distributions .Sh SYNOPSIS .Nm -.Op Fl dDfGinrvxX +.Op Fl dDfGiMnrvxX .Op Fl p Ar prefix .Ar pkg-name ... .Nm @@ -78,6 +78,16 @@ Request confirmation before attempting to delete each package, regardless whether or not the standard input device is a terminal. +.It Fl M , -match-date +Compare +.Ar pkg-name ... +using installdates instead of version numbers (default). +The format used is 'YYYY-MM-DD hh:mm:ss'. +For example, +.Pp +.Dl "pkg_delete -M '*>2008-08-11'" +.Pp +will match all packages installed after 2008-08-11, and try to delete them. .It Fl v , -verbose Turn on verbose output. .It Fl D , -no-script , -no-scripts ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/main.c#10 (text+ko) ==== @@ -52,6 +52,7 @@ { "extended", no_argument, NULL, 'e' }, { "help", no_argument, NULL, 'h' }, { "keep", no_argument, NULL, 'K' }, + { "match-date", no_argument, NULL, 'M' }, { "no-glob", no_argument, NULL, 'G' }, { "origin", required_argument, NULL, 'O' }, { "quiet", no_argument, NULL, 'q' }, ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/perform.c#11 (text+ko) ==== @@ -338,7 +338,7 @@ } /* - * Look through package dbs in LOG_DIR and find which + * Look through package dbs in LOG_DIR or dbcache and find which * packages installed the files in which_list. */ static int @@ -378,11 +378,12 @@ } /* If cache exists check database for the key (i.e., file absolute path) */ - if (CacheExists == TRUE) { + if (CacheExists) { + DBT tmp; TAILQ_FOREACH(wp, which_list, next) { if (wp->skip == TRUE) continue; - DBT tmp; + if (dbKeyExists(wp->file, &tmp)) strlcpy(wp->package, tmp.data, PATH_MAX); else { @@ -392,9 +393,9 @@ } } } else { -#ifdef DEBUG - printf("debug: not using cache; run pkg_convert\n"); -#endif + /* In case we don't have cache */ + printf("%s: not using cache; you should run pkg_convert(1)\n", __func__); + installed = matchinstalled(MATCH_ALL, NULL, &errcode); if (installed == NULL) return errcode; @@ -403,7 +404,7 @@ FILE *fp; Package pkg; PackingList itr; - char *cwd = NULL; + char *cwd = NULL, *prefix = NULL; char tmp[PATH_MAX]; snprintf(tmp, PATH_MAX, "%s/%s/%s", LOG_DIR, installed[i], @@ -419,7 +420,10 @@ fclose(fp); for (itr = pkg.head; itr != pkg.tail; itr = itr->next) { if (itr->type == PLIST_CWD) { - cwd = itr->name; + if (!prefix) + prefix = itr->name; + + cwd = itr->name ? itr->name : prefix; } else if (itr->type == PLIST_FILE) { TAILQ_FOREACH(wp, which_list, next) { if (wp->skip == TRUE) @@ -437,7 +441,6 @@ } free_plist(&pkg); } - } TAILQ_FOREACH(wp, which_list, next) { ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/pkg_info.1#7 (text+ko) ==== @@ -123,7 +123,7 @@ Show the .Xr mtree 8 file (if any) for each package. -.It Fl M +.It Fl M, -match-date Compare .Ar pkg-name ... using installdates instead of version numbers (default). ==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/lib/database.c#13 (text+ko) ==== @@ -17,18 +17,20 @@ * 12 August 2008 * * Various functions for use with berkeley-db (using non-relational btree). + * See also dbopen(3). */ #include "lib.h" #include #include -int compare_func(const DBT *, const DBT *); -DB *opendb(const char *, int); -int closedb(DB *db); -int dbput(const DB *db, DBT *key, DBT *data); -int dbget(const DB *db, DBT *key, DBT *data); -int dbscan(const DB *db, DBT *key, DBT *data); +int compare_func(const DBT *, const DBT *); +DB *opendb(const char *, int); +int closedb(DB *db); +int dbput(const DB *, DBT *, DBT *); +int dbget(const DB *, DBT *, DBT *); +int dbscan(const DB *, DBT *, DBT *); +int dbSync(void); /* * Btree information structure @@ -46,48 +48,50 @@ }; >>> TRUNCATED FOR MAIL (1000 lines) <<<