summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkgadd.cc10
-rw-r--r--pkgutil.cc7
-rw-r--r--pkgutil.h2
3 files changed, 15 insertions, 4 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();
}
}
diff --git a/pkgutil.cc b/pkgutil.cc
index 87a4ffcc..926418cc 100644
--- a/pkgutil.cc
+++ b/pkgutil.cc
@@ -383,7 +383,7 @@ pair<string, pkgutil::pkginfo_t> pkgutil::pkg_open(const string& filename) const
return result;
}
-void pkgutil::pkg_install(const string& filename, const set<string>& keep_list, const set<string>& non_install_list) const
+void pkgutil::pkg_install(const string& filename, const set<string>& keep_list, const set<string>& non_install_list, bool upgrade) const
{
struct archive* archive;
struct archive_entry* entry;
@@ -435,9 +435,12 @@ void pkgutil::pkg_install(const string& filename, const set<string>& keep_list,
if (archive_read_extract(archive, entry, flags) != ARCHIVE_OK) {
// If a file fails to install we just print an error message and
- // continue trying to install the rest of the package.
+ // continue trying to install the rest of the package,
+ // unless this is not an upgrade.
const char* msg = archive_error_string(archive);
cerr << utilname << ": could not install " + archive_filename << ": " << msg << endl;
+ if (!upgrade)
+ throw runtime_error("extract error: " + archive_filename + ": " + msg);
continue;
}
diff --git a/pkgutil.h b/pkgutil.h
index 4a4cabff..ce58f807 100644
--- a/pkgutil.h
+++ b/pkgutil.h
@@ -71,7 +71,7 @@ protected:
// Tar.gz
pair<string, pkginfo_t> pkg_open(const string& filename) const;
- void pkg_install(const string& filename, const set<string>& keep_list, const set<string>& non_install_files) const;
+ void pkg_install(const string& filename, const set<string>& keep_list, const set<string>& non_install_files, bool upgrade) const;
void pkg_footprint(string& filename) const;
void ldconfig() const;

Generated by cgit