From rv@fore.com Tue Dec 8 07:07:22 1998 Received: from fore.com ([169.144.32.20]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA03261 for ; Tue, 8 Dec 1998 07:07:21 -0800 (PST) (envelope-from rv@fore.com) Received: (from rv@localhost) by linux.eng.fore.com (8.9.1/8.9.1) id TAA09536; Mon, 7 Dec 1998 19:12:42 -0500 (EST) (envelope-from rv) Message-Id: <199812080012.TAA09536@linux.eng.fore.com> Date: Mon, 7 Dec 1998 19:12:42 -0500 (EST) From: rv@fore.com Reply-To: rv@fore.com To: FreeBSD-gnats-submit@freebsd.org Subject: pkg_delete is insufficient - doesnot support post-install script X-Send-Pr-Version: 3.2 >Number: 9013 >Category: bin >Synopsis: pkg_delete is insufficient - doesnot support post-install script >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: closed >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Dec 8 07:10:01 PST 1998 >Closed-Date: Tue Dec 8 08:01:25 PST 1998 >Last-Modified: Tue Dec 8 08:01:51 PST 1998 >Originator: Rajesh Vaidheeswarran >Release: FreeBSD 3.0-CURRENT i386 >Organization: >Environment: FreeBSD freebsd.eng.fore.com 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Thu Nov 12 10:46:44 EST 1998 rv@freebsd.eng.fore.com:/usr/src/sys/compile/FB30 i386 >Description: pkg_delete doesn't handle post-deinstall functionality. It only handles pre-deinstall functionality (using the keyword DEINSTALL passed to the script). While it would be ideal to have completely different scripts for preinstall, postinstall, preremove and postremove (aka solaris pkgadd/ pkgrm facilities), I would atleast be very happy to see POST-DEINSTALL facility also provided using the keyword passing mechanisms since there are some packages that will have to clean up after themselves. >How-To-Repeat: >Fix: I have a patch for this. It also contains a little bit of general indentation cleanup. If the powers-that-be let me, I'd be more than glad to submit another patch which creates the preinstall/postinstall/preremove/postremove functionality using completely separate scripts. diff -cr /usr/src/usr.sbin/pkg_install/add/perform.c pkg_install/add/perform.c *** /usr/src/usr.sbin/pkg_install/add/perform.c Fri Sep 11 03:26:54 1998 --- pkg_install/add/perform.c Mon Dec 7 18:02:38 1998 *************** *** 322,328 **** if (!NoInstall && fexists(INSTALL_FNAME)) { vsystem("chmod +x %s", INSTALL_FNAME); /* make sure */ if (Verbose) ! printf("Running install with PRE-INSTALL for %s..\n", PkgName); if (!Fake && vsystem("./%s %s PRE-INSTALL", INSTALL_FNAME, PkgName)) { warnx("install script returned error status"); unlink(INSTALL_FNAME); --- 322,329 ---- if (!NoInstall && fexists(INSTALL_FNAME)) { vsystem("chmod +x %s", INSTALL_FNAME); /* make sure */ if (Verbose) ! printf("Running %s with PRE-INSTALL for %s..\n", INSTALL_FNAME, ! PkgName); if (!Fake && vsystem("./%s %s PRE-INSTALL", INSTALL_FNAME, PkgName)) { warnx("install script returned error status"); unlink(INSTALL_FNAME); *************** *** 351,357 **** /* Run the installation script one last time? */ if (!NoInstall && fexists(INSTALL_FNAME)) { if (Verbose) ! printf("Running install with POST-INSTALL for %s..\n", PkgName); if (!Fake && vsystem("./%s %s POST-INSTALL", INSTALL_FNAME, PkgName)) { warnx("install script returned error status"); unlink(INSTALL_FNAME); --- 352,359 ---- /* Run the installation script one last time? */ if (!NoInstall && fexists(INSTALL_FNAME)) { if (Verbose) ! printf("Running %s with POST-INSTALL for %s..\n", INSTALL_FNAME, ! PkgName); if (!Fake && vsystem("./%s %s POST-INSTALL", INSTALL_FNAME, PkgName)) { warnx("install script returned error status"); unlink(INSTALL_FNAME); diff -cr /usr/src/usr.sbin/pkg_install/delete/perform.c pkg_install/delete/perform.c *** /usr/src/usr.sbin/pkg_install/delete/perform.c Wed Nov 11 18:18:25 1998 --- pkg_install/delete/perform.c Mon Dec 7 18:17:23 1998 *************** *** 21,26 **** --- 21,29 ---- * * This is the main body of the delete module. * + * Modification History: + * Dec 07 1998 - Rajesh Vaidheeswarran (rv@fore.com) added POST-DEINSTALL + * capability. */ #include *************** *** 70,83 **** --- 73,89 ---- warnx("no such package '%s' installed", pkg); return 1; } + if (!getcwd(home, FILENAME_MAX)) { cleanup(0); errx(2, "unable to get current working directory!"); } + if (chdir(LogDir) == FAIL) { warnx("unable to change directory to %s! deinstall failed", LogDir); return 1; } + if (!isemptyfile(REQUIRED_BY_FNAME)) { char buf[512]; warnx("package `%s' is required by these other packages\n" *************** *** 93,115 **** --- 99,128 ---- if (!Force) return 1; } + sanity_check(LogDir); cfile = fopen(CONTENTS_FNAME, "r"); + 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); + 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; } + setenv(PKG_PREFIX_VNAME, p->name, 1); + if (fexists(REQUIRE_FNAME)) { if (Verbose) printf("Executing 'require' script.\n"); *************** *** 121,154 **** return 1; } } if (!NoDeInstall && fexists(DEINSTALL_FNAME)) { if (Fake) ! printf("Would execute de-install script at this point.\n"); else { vsystem("chmod +x %s", DEINSTALL_FNAME); /* make sure */ if (vsystem("./%s %s DEINSTALL", DEINSTALL_FNAME, pkg)) { ! warnx("deinstall script returned error status"); if (!Force) return 1; } } } if (chdir(home) == FAIL) { cleanup(0); errx(2, "Toto! This doesn't look like Kansas anymore!"); } if (!Fake) { /* 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 (vsystem("%s -r %s", REMOVE_CMD, LogDir)) { warnx("couldn't remove log entry in %s, deinstall failed", LogDir); if (!Force) return 1; } } for (p = Plist.head; p ; p = p->next) { if (p->type != PLIST_PKGDEP) continue; --- 134,197 ---- return 1; } } + if (!NoDeInstall && fexists(DEINSTALL_FNAME)) { if (Fake) ! printf("Would execute de-install script with DEINSTALL at this point.\n"); else { vsystem("chmod +x %s", DEINSTALL_FNAME); /* make sure */ if (vsystem("./%s %s DEINSTALL", DEINSTALL_FNAME, pkg)) { ! warnx("de-install script returned error status"); if (!Force) return 1; } } } + if (chdir(home) == FAIL) { cleanup(0); errx(2, "Toto! This doesn't look like Kansas anymore!"); } + if (!Fake) { /* 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 (!NoDeInstall && fexists(DEINSTALL_FNAME)) { + if (Fake) + printf("Would execute de-install script with POST-DEINSTALL at this point.\n"); + else { + vsystem("chmod +x %s", DEINSTALL_FNAME); /* make sure */ + if (vsystem("./%s %s POST-DEINSTALL", DEINSTALL_FNAME, pkg)) { + warnx("de-install script returned error status"); + if (!Force) + return 1; + } + } + } + + if (chdir(home) == FAIL) { + cleanup(0); + errx(2, "Toto! This doesn't look like Kansas anymore!"); + } + + if (!Fake) { if (vsystem("%s -r %s", REMOVE_CMD, LogDir)) { warnx("couldn't remove log entry in %s, deinstall failed", LogDir); if (!Force) return 1; } } + for (p = Plist.head; p ; p = p->next) { if (p->type != PLIST_PKGDEP) continue; diff -cr /usr/src/usr.sbin/pkg_install/delete/pkg_delete.1 pkg_install/delete/pkg_delete.1 *** /usr/src/usr.sbin/pkg_install/delete/pkg_delete.1 Mon Mar 23 03:27:25 1998 --- pkg_install/delete/pkg_delete.1 Mon Dec 7 18:23:39 1998 *************** *** 131,137 **** .Pp If a .Cm deinstall ! script exists for the package, it is executed before any files are removed. It is this script's responsibility to clean up any additional messy details around the package's installation, since all .Nm --- 131,137 ---- .Pp If a .Cm deinstall ! script exists for the package, it is executed before and after any files are removed. It is this script's responsibility to clean up any additional messy details around the package's installation, since all .Nm *************** *** 142,153 **** .Bd -filled -offset indent -compact .Cm deinstall .Ar ! .Ar DEINSTALL .Ed Passing the keyword .Ar DEINSTALL lets you potentially write only one program/script that handles all ! aspects of installation and deletion. .Pp All scripts are called with the environment variable .Ev PKG_PREFIX --- 142,158 ---- .Bd -filled -offset indent -compact .Cm deinstall .Ar ! .Ar [DEINSTALL|POST-DEINSTALL] .Ed Passing the keyword .Ar DEINSTALL lets you potentially write only one program/script that handles all ! aspects of installation and pre-deinstall check. ! ! Passing the keyword ! .Ar POST-DEINSTALL ! lets you potentially write only one program/script that handles all ! aspects of installation and post-deinstall cleanup. .Pp All scripts are called with the environment variable .Ev PKG_PREFIX diff -cr /usr/src/usr.sbin/pkg_install/lib/plist.c pkg_install/lib/plist.c *** /usr/src/usr.sbin/pkg_install/lib/plist.c Fri Sep 11 03:26:58 1998 --- pkg_install/lib/plist.c Mon Dec 7 17:52:51 1998 *************** *** 391,398 **** last_file = p->name; sprintf(tmp, "%s/%s", Where, p->name); if (isdir(tmp) && fexists(tmp)) { ! warnx("cannot delete specified file `%s' - it is a directory!\n" ! "this packing list is incorrect - ignoring delete request", tmp); } else { if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) { --- 391,400 ---- last_file = p->name; sprintf(tmp, "%s/%s", Where, p->name); if (isdir(tmp) && fexists(tmp)) { ! warnx("cannot delete specified file `%s' " ! "- it is a directory!\n" ! "this packing list is incorrect - " ! "ignoring delete request", tmp); } else { if (p->next && p->next->type == PLIST_COMMENT && !strncmp(p->next->name, "MD5:", 4)) { >Release-Note: >Audit-Trail: From: Rajesh Vaidheeswarran To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org Cc: Subject: Re: bin/9013: pkg_delete is insufficient - doesnot support post-install script Date: Tue, 08 Dec 1998 10:14:18 -0500 Please close this as duplicate. This was a bug report generated by gnats that didn't go through because of some sendmail configuration issues. I then went ahead and submitted one through the web interface (bin/9005). Apparently, fixing the sendmail.cf problems seems to have cleaned up the entire spool (!). rv -- using MH template repl.format -- In a previous message, FreeBSD-gnats-submit@freebsd.org writes: > Thank you very much for your problem report. > It has the internal identification `bin/9013'. > The individual assigned to look at your > report is: freebsd-bugs. > > >Category: bin > >Responsible: freebsd-bugs > >Synopsis: pkg_delete is insufficient - doesnot support post-install sc > ript > >Arrival-Date: Tue Dec 8 07:10:01 PST 1998 > State-Changed-From-To: open->closed State-Changed-By: steve State-Changed-When: Tue Dec 8 08:01:25 PST 1998 State-Changed-Why: Duplicate of PR# 9005. >Unformatted: