apk: add --purge option (fixes #61)
and do not remove modified configuration files unless --purge is specified.cute-signatures
parent
83ae16feb8
commit
90aaa28a95
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue