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 /src/database.c | |
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.
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 7 |
1 files changed, 6 insertions, 1 deletions
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); |