summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-03-04 08:36:56 +0200
committerTimo Teras <timo.teras@iki.fi>2009-03-04 08:36:56 +0200
commita62dcf37c1d1ee2907e5e39759aa99259c458783 (patch)
tree501369316957cf772e291fb4e00918ebd09825b4
parent457943f83e21bde7e6858884d25bc89934344a52 (diff)
downloadapk-tools-a62dcf37c1d1ee2907e5e39759aa99259c458783.tar.gz
apk-tools-a62dcf37c1d1ee2907e5e39759aa99259c458783.tar.bz2
apk-tools-a62dcf37c1d1ee2907e5e39759aa99259c458783.tar.xz
apk-tools-a62dcf37c1d1ee2907e5e39759aa99259c458783.zip
apk: --force to overwrite files
-rw-r--r--src/apk.c5
-rw-r--r--src/apk_defines.h2
-rw-r--r--src/database.c14
3 files changed, 15 insertions, 6 deletions
diff --git a/src/apk.c b/src/apk.c
index 79a873a..8ad4200 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -24,7 +24,7 @@
const char *apk_root;
struct apk_repository_url apk_repository_list;
int apk_verbosity = 1, apk_progress = 0, apk_upgrade = 0;
-int apk_clean = 0;
+int apk_clean = 0, apk_force = 0;
int apk_cwd_fd;
void apk_log(const char *prefix, const char *format, ...)
@@ -111,7 +111,7 @@ static struct apk_repository_url *apk_repository_new(const char *url)
return r;
}
-#define NUM_GENERIC_OPTS 7
+#define NUM_GENERIC_OPTS 8
static struct option generic_options[32] = {
{ "root", required_argument, NULL, 'p' },
{ "repository", required_argument, NULL, 'X' },
@@ -120,6 +120,7 @@ static struct option generic_options[32] = {
{ "version", no_argument, NULL, 'V' },
{ "progress", no_argument, &apk_progress, 1 },
{ "clean-protected", no_argument, &apk_clean, 1 },
+ { "force", no_argument, &apk_force, 1 },
};
int main(int argc, char **argv)
diff --git a/src/apk_defines.h b/src/apk_defines.h
index c27d863..4a42b16 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -51,7 +51,7 @@ extern csum_t bad_checksum;
#endif
extern int apk_cwd_fd, apk_verbosity, apk_progress, apk_upgrade;
-extern int apk_clean;
+extern int apk_clean, apk_force;
#define apk_error(args...) apk_log("ERROR: ", args);
#define apk_warning(args...) if (apk_verbosity > 0) { apk_log("WARNING: ", args); }
diff --git a/src/database.c b/src/database.c
index 108c3ab..7e5b62e 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1053,9 +1053,17 @@ static int apk_db_install_archive_entry(void *_ctx,
if (file->diri != diri) {
opkg = file->diri->pkg;
if (opkg->name != pkg->name) {
- apk_error("%s: Trying to overwrite %s owned by %s.\n",
- pkg->name->name, ae->name, opkg->name->name);
- return -1;
+ if (!apk_force) {
+ apk_error("%s: Trying to overwrite %s "
+ "owned by %s.\n",
+ pkg->name->name, ae->name,
+ opkg->name->name);
+ return -1;
+ }
+ apk_warning("%s: Trying to overwrite %s "
+ "owned by %s.\n",
+ pkg->name->name, ae->name,
+ opkg->name->name);
}
apk_db_file_change_owner(db, file, diri,