From 04d211effa8d65020887112ee30c7b3b0fc28ad3 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sun, 9 Apr 2017 20:42:01 -0400 Subject: add --overwrite option to ignore file conflicts Allows for safer, more fine-grained control for overwriting files than --force's all-or-nothing approach. Implements FS#31549. Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- src/pacman/conf.c | 2 ++ src/pacman/conf.h | 2 ++ src/pacman/pacman.c | 6 ++++++ 3 files changed, 10 insertions(+) (limited to 'src/pacman') diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 49b21366..261c8213 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -783,6 +783,8 @@ static int setup_libalpm(void) alpm_option_set_cachedirs(handle, config->cachedirs); } + alpm_option_set_overwrite_files(handle, config->overwrite_files); + alpm_option_set_default_siglevel(handle, config->siglevel); config->localfilesiglevel = merge_siglevel(config->siglevel, diff --git a/src/pacman/conf.h b/src/pacman/conf.h index bd8cd77a..e67f7c51 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -123,6 +123,7 @@ typedef struct __config_t { alpm_list_t *assumeinstalled; alpm_list_t *noupgrade; alpm_list_t *noextract; + alpm_list_t *overwrite_files; char *xfercommand; /* our connection to libalpm */ @@ -172,6 +173,7 @@ enum { OP_GPGDIR, OP_DBONLY, OP_FORCE, + OP_OVERWRITE_FILES, OP_COLOR, OP_DBPATH, OP_CASCADE, diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fe96cb3b..e0e7d01d 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -190,6 +190,8 @@ static void usage(int op, const char * const myname) case PM_OP_SYNC: case PM_OP_UPGRADE: addlist(_(" --force force install, overwrite conflicting files\n")); + addlist(_(" --overwrite \n" + " overwrite conflicting files (can be used more than once)\n")); addlist(_(" --asdeps install packages as non-explicitly installed\n")); addlist(_(" --asexplicit install packages as explicitly installed\n")); addlist(_(" --ignore ignore a package upgrade (can be used more than once)\n")); @@ -708,6 +710,9 @@ static int parsearg_upgrade(int opt) case OP_FORCE: config->flags |= ALPM_TRANS_FLAG_FORCE; break; + case OP_OVERWRITE_FILES: + parsearg_util_addlist(&(config->overwrite_files)); + break; case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break; @@ -929,6 +934,7 @@ static int parseargs(int argc, char *argv[]) {"assume-installed", required_argument, 0, OP_ASSUMEINSTALLED}, {"debug", optional_argument, 0, OP_DEBUG}, {"force", no_argument, 0, OP_FORCE}, + {"overwrite", required_argument, 0, OP_OVERWRITE_FILES}, {"noprogressbar", no_argument, 0, OP_NOPROGRESSBAR}, {"noscriptlet", no_argument, 0, OP_NOSCRIPTLET}, {"ask", required_argument, 0, OP_ASK}, -- cgit v1.2.3-70-g09d2