libxbps: some random bugfixes.
* libxbps: while running INSTALL/REMOVE scripts, do not fail if a script returns ENOENT but the script exists; that means the script did not match the expected action on its switch statement and the fact can be simply ignored. * libxbps: while upgrading packages and searching for obsolete files, do not remove the files that did not match previous SHA256 hash. Also, only remove obsolete dangling symlinks.
This commit is contained in:
parent
42af3ac533
commit
76ca32e76f
16
NEWS
16
NEWS
@ -1,4 +1,16 @@
|
||||
xbps-0.6.0 (2010-07-01):
|
||||
xbps-0.5.2 (2010-07-18):
|
||||
|
||||
* libxbps: while running INSTALL/REMOVE scripts, do not fail if a script
|
||||
returns ENOENT but the script exists; that means the script did not match
|
||||
the expected action on its switch statement and the fact can be simply
|
||||
ignored.
|
||||
|
||||
* libxbps: while upgrading packages and searching for obsolete files,
|
||||
do not remove the files that did not match previous SHA256 hash. Also,
|
||||
only remove obsolete dangling symlinks.
|
||||
|
||||
* xbps-repo(8): fixed the 'genindex' target to not return error if any
|
||||
package is already registered in the index.
|
||||
|
||||
* xbps-repo(8): improved the 'search' target to also match substrings in
|
||||
package/version tuples.
|
||||
@ -18,7 +30,7 @@ xbps-0.5.1 (2010-05-12):
|
||||
xbps-0.5.0 (2010-05-01):
|
||||
|
||||
* xbps-repo(8): fixed the 'search' target to also match patterns against
|
||||
its description, and not only from the package/version touple.
|
||||
its description, and not only from the package/version tuple.
|
||||
|
||||
* Cleaned up the code by using the LLVM's clang static analyzer, found
|
||||
two possible NULL pointer dereferences in error branches and dead code.
|
||||
|
@ -59,7 +59,7 @@ __BEGIN_DECLS
|
||||
* @def XBPS_RELVER
|
||||
* Current library release date.
|
||||
*/
|
||||
#define XBPS_RELVER "20100511"
|
||||
#define XBPS_RELVER "20100518:0.5.2"
|
||||
|
||||
/**
|
||||
* @def XBPS_META_PATH
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2010 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -150,8 +150,9 @@ xbps_configure_pkg(const char *pkgname, const char *version, bool check_state,
|
||||
}
|
||||
|
||||
if (access(buf, X_OK) == 0) {
|
||||
if ((rv = xbps_file_chdir_exec(rootdir, buf, "post",
|
||||
pkgname, lver, update ? "yes" : "no", NULL)) != 0) {
|
||||
rv = xbps_file_chdir_exec(rootdir, buf, "post",
|
||||
pkgname, lver, update ? "yes" : "no", NULL);
|
||||
if (rv != 0 && errno != ENOENT) {
|
||||
free(buf);
|
||||
fprintf(stderr, "%s: post INSTALL action "
|
||||
"returned: %s\n", pkgname, strerror(errno));
|
||||
|
@ -222,7 +222,7 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
|
||||
prepostf = true;
|
||||
rv = xbps_file_chdir_exec(rootdir, buf, "pre", pkgname,
|
||||
version, update ? "yes" : "no", NULL);
|
||||
if (rv != 0) {
|
||||
if (rv != 0 && errno != ENOENT) {
|
||||
fprintf(stderr,
|
||||
"%s: prerm action target error (%s)\n", pkgname,
|
||||
strerror(errno));
|
||||
@ -284,8 +284,9 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
|
||||
* and we aren't updating a package.
|
||||
*/
|
||||
if (update == false && prepostf) {
|
||||
if ((rv = xbps_file_chdir_exec(rootdir, buf, "post",
|
||||
pkgname, version, NULL)) != 0) {
|
||||
rv = xbps_file_chdir_exec(rootdir, buf, "post",
|
||||
pkgname, version, NULL);
|
||||
if (rv != 0 && errno != ENOENT) {
|
||||
fprintf(stderr,
|
||||
"%s: postrm action target error (%s)\n",
|
||||
pkgname, strerror(errno));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2010 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -23,11 +23,14 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
|
||||
@ -37,8 +40,10 @@ xbps_remove_obsoletes(prop_dictionary_t oldd, prop_dictionary_t newd)
|
||||
prop_object_iterator_t iter, iter2 = NULL;
|
||||
prop_object_t obj, obj2 = NULL;
|
||||
prop_string_t oldstr = NULL, newstr = NULL;
|
||||
struct stat st;
|
||||
const char *array_str = "files";
|
||||
char *buf = NULL;
|
||||
const char *oldhash = NULL;
|
||||
char *file = NULL;
|
||||
int rv = 0;
|
||||
bool found, dolinks = false;
|
||||
|
||||
@ -56,12 +61,47 @@ again:
|
||||
* the old package list not found in new package list.
|
||||
*/
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
rv = 0;
|
||||
found = false;
|
||||
oldstr = prop_dictionary_get(obj, "file");
|
||||
if (oldstr == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
file = xbps_xasprintf(".%s",
|
||||
prop_string_cstring_nocopy(oldstr));
|
||||
if (file == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
if (strcmp(array_str, "files") == 0) {
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"sha256", &oldhash);
|
||||
rv = xbps_check_file_hash(file, oldhash);
|
||||
if (rv == ENOENT || rv == ERANGE) {
|
||||
/*
|
||||
* Skip unexistent and files that do not
|
||||
* match the hash.
|
||||
*/
|
||||
free(file);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Only remove dangling symlinks.
|
||||
*/
|
||||
if (stat(file, &st) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
free(file);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
free(file);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while ((obj2 = prop_object_iterator_next(iter2))) {
|
||||
newstr = prop_dictionary_get(obj2, "file");
|
||||
if (newstr == NULL) {
|
||||
@ -74,29 +114,26 @@ again:
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(iter2);
|
||||
if (found)
|
||||
if (found) {
|
||||
free(file);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obsolete file found, remove it.
|
||||
*/
|
||||
buf = xbps_xasprintf(".%s", prop_string_cstring_nocopy(oldstr));
|
||||
if (buf == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
if (remove(buf) == -1) {
|
||||
if (remove(file) == -1) {
|
||||
fprintf(stderr,
|
||||
"WARNING: couldn't remove obsolete %s: %s\n",
|
||||
dolinks ? "link" : "file",
|
||||
prop_string_cstring_nocopy(oldstr));
|
||||
free(buf);
|
||||
free(file);
|
||||
continue;
|
||||
}
|
||||
printf("Removed obsolete %s: %s\n",
|
||||
dolinks ? "link" : "file",
|
||||
prop_string_cstring_nocopy(oldstr));
|
||||
free(buf);
|
||||
free(file);
|
||||
}
|
||||
if (!dolinks) {
|
||||
/*
|
||||
|
@ -183,9 +183,9 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
|
||||
}
|
||||
}
|
||||
|
||||
if ((rv = xbps_file_chdir_exec(rootdir, buf, "pre",
|
||||
pkgname, version, update ? "yes" : "no",
|
||||
NULL)) != 0) {
|
||||
rv = xbps_file_chdir_exec(rootdir, buf, "pre",
|
||||
pkgname, version, update ? "yes" : "no", NULL);
|
||||
if (rv != 0 && errno != ENOENT) {
|
||||
free(buf);
|
||||
fprintf(stderr,
|
||||
"%s: preinst action target error %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user