From 34697e80228f8100c724c364d2fe24fa5bf24bd9 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 10 Jul 2012 23:22:25 +0200 Subject: [PATCH] libxbps: improve matching obsolete files, skip matches by hash and filename. Don't remove top level symlinks (/bin, /sbin and /lib) if they were found as obsoletes. This is a workaround for the system transition to /usr. --- NEWS | 6 ++++++ include/xbps_api.h | 4 ++-- lib/package_remove_obsoletes.c | 28 +++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 591bd926..2b3ee5ab 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +xbps-0.16.4 (???): + + * libxbps: when finding obsolete files also match against sha256, not + just the filename. Also ignore symlinks found in rootfs to make + the system transition to /usr fully work. + xbps-0.16.3 (2012-07-04): * libxbps: fixed a regression in 0.16.2. diff --git a/include/xbps_api.h b/include/xbps_api.h index 6398c611..f105541a 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -56,8 +56,8 @@ */ #define XBPS_PKGINDEX_VERSION "1.5" -#define XBPS_API_VERSION "20120704-1" -#define XBPS_VERSION "0.16.3" +#define XBPS_API_VERSION "20120710" +#define XBPS_VERSION "0.16.4" /** * @def XBPS_RELVER diff --git a/lib/package_remove_obsoletes.c b/lib/package_remove_obsoletes.c index 8009a4b3..8626900d 100644 --- a/lib/package_remove_obsoletes.c +++ b/lib/package_remove_obsoletes.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2011 Juan Romero Pardines. + * Copyright (c) 2009-2012 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ xbps_remove_obsoletes(struct xbps_handle *xhp, prop_string_t oldstr, newstr; struct stat st; const char *array_str = "files"; - const char *oldhash; + const char *oldhash, *hash; char *file; int rv = 0; bool found, dodirs = false, dolinks = false; @@ -118,16 +118,38 @@ again: rv = errno; goto out; } + /* + * Skip files with same path and/or hash. + */ if (prop_string_equals(oldstr, newstr)) { found = true; break; } + + hash = NULL; + prop_dictionary_get_cstring_nocopy(obj2, + "sha256", &hash); + if (hash && strcmp(hash, oldhash) == 0) { + found = true; + break; + } } prop_object_iterator_reset(iter2); if (found) { free(file); continue; } + /* + * Do not remove required symlinks for the + * system transition to /usr. + */ + if ((strcmp(file, "./bin") == 0) || + (strcmp(file, "./sbin") == 0) || + (strcmp(file, "./lib") == 0) || + (strcmp(file, "./lib64") == 0)) { + free(file); + continue; + } /* * Obsolete obj found, remove it. */ @@ -143,7 +165,7 @@ again: xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FILE_OBSOLETE, 0, pkgname, version, - "Removed obsolete entry: %s", file); + "%s: removed obsolete entry: %s", pkgver, file); free(file); } if (!dolinks) {