diff --git a/lib/transaction_files.c b/lib/transaction_files.c index 61b24cc4..c9e15518 100644 --- a/lib/transaction_files.c +++ b/lib/transaction_files.c @@ -139,6 +139,16 @@ typestr(enum type typ) } } +static bool +match_preserved_file(struct xbps_handle *xhp, const char *file) +{ + if (xhp->preserved_files == NULL) + return false; + + assert(file && *file == '.'); + return xbps_match_string_in_array(xhp->preserved_files, file+1); +} + static bool can_delete_directory(struct xbps_handle *xhp, const char *file, size_t len, size_t max) { @@ -232,6 +242,11 @@ collect_obsoletes(struct xbps_handle *xhp) item = items[i]; + if (match_preserved_file(xhp, item->file)) { + xbps_dbg_printf(xhp, "[obsoletes] %s: file exists on disk" + " and must be preserved: %s\n", item->old.pkgver, item->file); + continue; + } if (item->new.type == 0) { /*