summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-03-04 08:27:06 +0200
committerTimo Teras <timo.teras@iki.fi>2009-03-04 08:27:06 +0200
commit457943f83e21bde7e6858884d25bc89934344a52 (patch)
tree32d04dd47fe34cb2cfef3541ebaf8b05ab9877d2 /src/database.c
parentb75ae58b78367ac095d43ab4391c903d0d6b5644 (diff)
downloadapk-tools-457943f83e21bde7e6858884d25bc89934344a52.tar.gz
apk-tools-457943f83e21bde7e6858884d25bc89934344a52.tar.bz2
apk-tools-457943f83e21bde7e6858884d25bc89934344a52.tar.xz
apk-tools-457943f83e21bde7e6858884d25bc89934344a52.zip
apk: --clean-protected option
So you will not get .apk-new files of the new configuration files.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/database.c b/src/database.c
index f6b66c4..108c3ab 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1066,19 +1066,17 @@ static int apk_db_install_archive_entry(void *_ctx,
printf("%s\n", ae->name);
if ((diri->dir->flags & APK_DBDIRF_PROTECTED) &&
- apk_file_get_info(ae->name, &fi) == 0) {
+ apk_file_get_info(ae->name, &fi) == 0 &&
+ (memcmp(file->csum, fi.csum, sizeof(csum_t)) == 0 ||
+ !csum_valid(file->csum))) {
/* Protected file. Extract to separate place */
- snprintf(alt_name, sizeof(alt_name),
- "%s/%s.apk-new",
- diri->dir->dirname, file->filename);
- r = apk_archive_entry_extract(ae, is, alt_name,
- extract_cb, ctx);
- if (memcmp(ae->csum, fi.csum, sizeof(csum_t)) == 0) {
- /* not modified locally. rename to original */
- if (rename(alt_name, ae->name) < 0)
- apk_warning("%s: %s", ae->name,
- strerror(errno));
- }
+ if (!apk_clean) {
+ snprintf(alt_name, sizeof(alt_name),
+ "%s/%s.apk-new",
+ diri->dir->dirname, file->filename);
+ r = apk_archive_entry_extract(ae, is, alt_name,
+ extract_cb, ctx);
+ }
} else {
r = apk_archive_entry_extract(ae, is, NULL,
extract_cb, ctx);