Commit a62dcf37 authored by Timo Teräs's avatar Timo Teräs

apk: --force to overwrite files

parent 457943f8
......@@ -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)
......
......@@ -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); }
......
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment