summaryrefslogtreecommitdiff
path: root/pkgadd.cc
diff options
context:
space:
mode:
authorjust_fun <just.the.real.fun@gmail.com>2017-06-18 14:30:15 +0300
committerFredrik Rinnestam <fredrik@crux.nu>2017-09-19 23:44:01 +0200
commita11b0048057f80b7a8a936b8f56be9f2fd121e7e (patch)
treeb7a647eaa7651397aa56ad2b1220923aaea11576 /pkgadd.cc
parent62e416b52cf328d675a8f2e28007f9e697be3025 (diff)
downloadpkgutils-a11b0048057f80b7a8a936b8f56be9f2fd121e7e.tar.gz
pkgutils-a11b0048057f80b7a8a936b8f56be9f2fd121e7e.tar.xz
pkgadd: avoid fake installations if unpacking fails
This patch aborts the package installation and remove the package from the database on any extraction error. This fixes FS#620. I don't know why the extraction errors were ignored (even documented). The initial commit already had this behaviour. Another odd thing is that the install status of the package was commited to the database before it was installed while there are exceptions used in pkg_install(): - archive open error - empty archive - archive read error Any of these errors will falsely mark the package as installed (maybe not a big problem with upgrades). To avoid breaking something (else), this fix kicks in only with fresh installs (not upgrades). Thanks Erich Eckner, for pointing out that the issue is reproductible with a read-only destination. Otherwise, I don't think I would have looked at this issue. A test case is presented with the FS issue, just in case someone who loves C++ enough to dig deeper or have more knowledge about the history of this program would take a closer look.
Diffstat (limited to 'pkgadd.cc')
-rw-r--r--pkgadd.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkgadd.cc b/pkgadd.cc
index 03cf0ec9..deeb50bc 100644
--- a/pkgadd.cc
+++ b/pkgadd.cc
@@ -103,7 +103,15 @@ void pkgadd::run(int argc, char** argv)
db_add_pkg(package.first, package.second);
db_commit();
- pkg_install(o_package, keep_list, non_install_files);
+ try {
+ pkg_install(o_package, keep_list, non_install_files, installed);
+ } catch (runtime_error&) {
+ if (!installed) {
+ db_rm_pkg(package.first);
+ db_commit();
+ throw runtime_error("failed");
+ }
+ }
ldconfig();
}
}

Generated by cgit