summaryrefslogtreecommitdiff
path: root/src/state.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-04-15 13:19:36 +0300
committerTimo Teras <timo.teras@iki.fi>2009-04-15 13:20:35 +0300
commita9b6d18f7f979cf08f6f48f1f4c12d49689f51b9 (patch)
tree8923ea75d58b121b65842e138fcfeee76d532b30 /src/state.c
parent33da51c596237e8e813d6c18e064939e4ebef445 (diff)
downloadapk-tools-a9b6d18f7f979cf08f6f48f1f4c12d49689f51b9.tar.gz
apk-tools-a9b6d18f7f979cf08f6f48f1f4c12d49689f51b9.tar.bz2
apk-tools-a9b6d18f7f979cf08f6f48f1f4c12d49689f51b9.tar.xz
apk-tools-a9b6d18f7f979cf08f6f48f1f4c12d49689f51b9.zip
state: make package deletion safer
Refuse to delete explicitly specified top-level packages unless --force is specified.
Diffstat (limited to 'src/state.c')
-rw-r--r--src/state.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/state.c b/src/state.c
index c07c806..5b6b81c 100644
--- a/src/state.c
+++ b/src/state.c
@@ -170,8 +170,16 @@ int apk_state_lock_dependency(struct apk_state *state,
return -1;
if (ns_empty(state->name[name->id])) {
- if (dep->result_mask == APK_DEPMASK_CONFLICT)
+ if (dep->result_mask == APK_DEPMASK_CONFLICT) {
+ if ((name->flags & APK_NAME_TOPLEVEL) &&
+ !(apk_flags & APK_FORCE)) {
+ apk_error("Not deleting top level dependency "
+ "'%s'. Use -f to override.",
+ name->name);
+ return -1;
+ }
return apk_state_lock_name(state, name, NULL);
+ }
/* This name has not been visited yet.
* Construct list of candidates. */