tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg_add leaves files installed when POST-INSTALL fails



Hi,
I think there is a bug in pkg_add:

When an INSTALL script exits with failure during POST-INSTALL stage,
pkg_add will revert the installation, i.e. the  package directory in
pkgdb is removed, yet the files remain on the filesystem (and in
pkgdb/pkgdb.byfile.db), so an attempt to reinstall (any version of
that package) will fail.

A recovery in such situation is currently
$  pkg_admin rebuild

* How-To-Repeat:
Prepare a package which fails in INSTALL script:
   exit 1
then install such a package.

$ pkg_add -v pkg-N.tgz
pkg_add: install script returned error status
pkg_add: 1 package addition failed

Then try again:
$ pkg_add -v pkg-N.tgz
pkg_add: Conflicting PLIST with pkg-N: dir/filename

I think the patch below fixes it.
I created the Problem Report
https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=56458 and
also a pull request on github  (
https://github.com/NetBSD/pkgsrc/pull/95 )

Michal

diff --git a/pkgtools/pkg_install/files/add/perform.c
b/pkgtools/pkg_install/files/add/perform.c
index 2a1d99941df..52852de8a96 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -1545,7 +1545,7 @@ pkg_do(const char *pkgpath, int mark_automatic,
int top_level)
         goto nuke_pkg;

     if (run_install_script(pkg, "POST-INSTALL"))
-        goto nuke_pkgdb;
+        goto nuke_pkg;

     /* XXX keep +INSTALL_INFO for updates? */
     /* XXX keep +PRESERVE for updates? */


Home | Main Index | Thread Index | Old Index