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.
This commit is contained in:
Juan RP 2012-07-10 23:22:25 +02:00
parent 414fd67302
commit 34697e8022
3 changed files with 33 additions and 5 deletions

6
NEWS
View File

@ -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): xbps-0.16.3 (2012-07-04):
* libxbps: fixed a regression in 0.16.2. * libxbps: fixed a regression in 0.16.2.

View File

@ -56,8 +56,8 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.5" #define XBPS_PKGINDEX_VERSION "1.5"
#define XBPS_API_VERSION "20120704-1" #define XBPS_API_VERSION "20120710"
#define XBPS_VERSION "0.16.3" #define XBPS_VERSION "0.16.4"
/** /**
* @def XBPS_RELVER * @def XBPS_RELVER

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2011 Juan Romero Pardines. * Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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; prop_string_t oldstr, newstr;
struct stat st; struct stat st;
const char *array_str = "files"; const char *array_str = "files";
const char *oldhash; const char *oldhash, *hash;
char *file; char *file;
int rv = 0; int rv = 0;
bool found, dodirs = false, dolinks = false; bool found, dodirs = false, dolinks = false;
@ -118,16 +118,38 @@ again:
rv = errno; rv = errno;
goto out; goto out;
} }
/*
* Skip files with same path and/or hash.
*/
if (prop_string_equals(oldstr, newstr)) { if (prop_string_equals(oldstr, newstr)) {
found = true; found = true;
break; 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); prop_object_iterator_reset(iter2);
if (found) { if (found) {
free(file); free(file);
continue; 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. * Obsolete obj found, remove it.
*/ */
@ -143,7 +165,7 @@ again:
xbps_set_cb_state(xhp, xbps_set_cb_state(xhp,
XBPS_STATE_REMOVE_FILE_OBSOLETE, XBPS_STATE_REMOVE_FILE_OBSOLETE,
0, pkgname, version, 0, pkgname, version,
"Removed obsolete entry: %s", file); "%s: removed obsolete entry: %s", pkgver, file);
free(file); free(file);
} }
if (!dolinks) { if (!dolinks) {