diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-22 21:34:25 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-22 21:34:25 +0300 |
commit | 90aaa28a95f28206e6bf4ed0d5a798595165cb8c (patch) | |
tree | 67071fbc48be4d3748faf55b5570d197003c4652 | |
parent | 83ae16feb8bb6063ac26eb4cbbc6142bfb4057a4 (diff) | |
download | apk-tools-90aaa28a95f28206e6bf4ed0d5a798595165cb8c.tar.gz apk-tools-90aaa28a95f28206e6bf4ed0d5a798595165cb8c.tar.bz2 apk-tools-90aaa28a95f28206e6bf4ed0d5a798595165cb8c.tar.xz apk-tools-90aaa28a95f28206e6bf4ed0d5a798595165cb8c.zip |
apk: add --purge option (fixes #61)
and do not remove modified configuration files unless --purge is
specified.
-rw-r--r-- | src/apk.c | 5 | ||||
-rw-r--r-- | src/apk_defines.h | 1 | ||||
-rw-r--r-- | src/database.c | 7 |
3 files changed, 12 insertions, 1 deletions
@@ -43,6 +43,8 @@ static struct apk_option generic_options[] = { { 0x101, "progress", "Show a progress bar" }, { 0x102, "clean-protected", "Do not create .apk-new files to " "configuration dirs" }, + { 0x106, "purge", "Delete also modified configuration files on " + "package removal" }, { 0x103, "allow-untrusted", "Blindly install packages with untrusted " "signatures or no signature at all" }, { 0x104, "simulate", "Show what would be done without actually " @@ -359,6 +361,9 @@ int main(int argc, char **argv) case 0x104: apk_flags |= APK_SIMULATE; break; + case 0x106: + apk_flags |= APK_PURGE; + break; case 0x105: apk_wait = atoi(optarg); break; diff --git a/src/apk_defines.h b/src/apk_defines.h index 7e66ada..a7e13f9 100644 --- a/src/apk_defines.h +++ b/src/apk_defines.h @@ -60,6 +60,7 @@ extern unsigned int apk_flags; #define APK_PREFER_AVAILABLE 0x0040 #define APK_UPDATE_CACHE 0x0080 #define APK_ALLOW_UNTRUSTED 0x0100 +#define APK_PURGE 0x0200 #define apk_error(args...) do { apk_log("ERROR: ", args); } while (0) #define apk_warning(args...) do { if (apk_verbosity > 0) { apk_log("WARNING: ", args); } } while (0) diff --git a/src/database.c b/src/database.c index e171ca9..719a445 100644 --- a/src/database.c +++ b/src/database.c @@ -1425,6 +1425,7 @@ static void apk_db_purge_pkg(struct apk_database *db, struct apk_package *pkg, struct apk_db_dir_instance *diri; struct apk_db_file *file; struct apk_db_file_hash_key key; + struct apk_file_info fi; struct hlist_node *dc, *dn, *fc, *fn; unsigned long hash; char name[1024]; @@ -1439,7 +1440,11 @@ static void apk_db_purge_pkg(struct apk_database *db, struct apk_package *pkg, .filename = APK_BLOB_PTR_LEN(file->name, file->namelen), }; hash = apk_blob_hash_seed(key.filename, diri->dir->hash); - unlink(name); + if (!(diri->dir->flags & APK_DBDIRF_PROTECTED) || + (apk_flags & APK_PURGE) || + (apk_file_get_info(name, file->csum.type, &fi) == 0 && + apk_checksum_compare(&file->csum, &fi.csum) == 0)) + unlink(name); if (apk_verbosity > 1) printf("%s\n", name); __hlist_del(fc, &diri->owned_files.first); |