diff options
author | eik <eik@FreeBSD.org> | 2004-06-29 18:59:19 +0000 |
---|---|---|
committer | eik <eik@FreeBSD.org> | 2004-06-29 18:59:19 +0000 |
commit | 7a7a88ae41089ff6cb4d75e4c2271702d2fc40ba (patch) | |
tree | d736eb1b5c7ccb34088587a0c550492399691ef6 /usr.sbin/pkg_install/delete | |
parent | ffbd0ede95b92fdb9e9a5457126a4eeca1726352 (diff) | |
download | FreeBSD-src-7a7a88ae41089ff6cb4d75e4c2271702d2fc40ba.zip FreeBSD-src-7a7a88ae41089ff6cb4d75e4c2271702d2fc40ba.tar.gz |
- pkg_info: flag -r: (show packages this packages depends on (documentation change))
- pkg_info: new flag -j (show the requirements script)
- pkg_info: fix verbose output when used on packages
- better handling of corrupt entries in /var/db/pkg
- differ between corrupt entires and packages not installed
- various small fixes
PR: 56989, 57016, 57029, 26468
Diffstat (limited to 'usr.sbin/pkg_install/delete')
-rw-r--r-- | usr.sbin/pkg_install/delete/perform.c | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index c1bc803..76bb734 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -125,6 +125,7 @@ pkg_do(char *pkg) char *deporigin, **depnames, home[FILENAME_MAX]; PackingList p; int i, len; + int isinstalled; /* support for separate pre/post install scripts */ int new_m = 0; const char *pre_script = DEINSTALL_FNAME; @@ -141,9 +142,26 @@ pkg_do(char *pkg) if (Plist.head) free_plist(&Plist); - if (!isinstalledpkg(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)"); + 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 (!getcwd(home, FILENAME_MAX)) { @@ -151,8 +169,6 @@ pkg_do(char *pkg) errx(2, "%s: unable to get current working directory!", __func__); } - sprintf(LogDir, "%s/%s", LOG_DIR, pkg); - if (chdir(LogDir) == FAIL) { warnx("unable to change directory to %s! deinstall failed", LogDir); return 1; @@ -247,6 +263,30 @@ pkg_do(char *pkg) } } + for (p = Plist.head; p ; p = p->next) { + if (p->type != PLIST_PKGDEP) + continue; + deporigin = (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 (!Fake) { + depnames = (deporigin != NULL) ? matchbyorigin(deporigin, NULL) : + NULL; + if (depnames == NULL) { + depnames = alloca(sizeof(*depnames) * 2); + depnames[0] = p->name; + depnames[1] = NULL; + } + for (i = 0; depnames[i] != NULL; i++) + undepend(depnames[i], pkg); + } + } + if (chdir(home) == FAIL) { cleanup(0); errx(2, "%s: unable to return to working directory %s!", __func__, @@ -293,30 +333,6 @@ pkg_do(char *pkg) return 1; } } - - for (p = Plist.head; p ; p = p->next) { - if (p->type != PLIST_PKGDEP) - continue; - deporigin = (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 (!Fake) { - depnames = (deporigin != NULL) ? matchbyorigin(deporigin, NULL) : - NULL; - if (depnames == NULL) { - depnames = alloca(sizeof(*depnames) * 2); - depnames[0] = p->name; - depnames[1] = NULL; - } - for (i = 0; depnames[i] != NULL; i++) - undepend(depnames[i], pkg); - } - } return 0; } |