From eb885bbcc200ccf6ba8d394369816a013ab2f859 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 9 Dec 2009 16:14:35 +0100 Subject: [PATCH] When executing the INSTALL/REMOVE scripts, always pass the UPDATE value to them. Bump XBPS_RELVER to 20091209. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091209151435-1yy9f7k2880tswz7 --- bin/xbps-bin/install.c | 13 ++++++++++--- bin/xbps-bin/main.c | 2 +- include/xbps_api.h | 4 ++-- lib/configure.c | 8 +++++--- lib/unpack.c | 12 ++++++++---- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index fc6ebcdb..253824f3 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -482,14 +482,14 @@ exec_transaction(struct transaction *trans) prop_object_iterator_t replaces_iter; const char *pkgname, *version, *pkgver, *instver, *filename, *tract; int rv = 0; - bool essential, autoinst; + bool update, essential, autoinst; pkg_state_t state = 0; assert(trans != NULL); assert(trans->dict != NULL); assert(trans->iter != NULL); - essential = autoinst = false; + update = essential = autoinst = false; /* * Show download/installed size for the transaction. */ @@ -646,7 +646,14 @@ exec_transaction(struct transaction *trans) if (!prop_dictionary_get_cstring_nocopy(obj, "version", &version)) return errno; - if ((rv = xbps_configure_pkg(pkgname, version, false)) != 0) { + if (!prop_dictionary_get_cstring_nocopy(obj, + "trans-action", &tract)) + return errno; + update = false; + if (strcmp(tract, "update") == 0) + update = true; + rv = xbps_configure_pkg(pkgname, version, false, update); + if (rv != 0) { printf("Error configuring package %s (%s)\n", pkgname, strerror(rv)); return rv; diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 7d39bfd3..3f8aaf80 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -280,7 +280,7 @@ main(int argc, char **argv) if (strcasecmp(argv[1], "all") == 0) rv = xbps_configure_all_pkgs(); else - rv = xbps_configure_pkg(argv[1], NULL, true); + rv = xbps_configure_pkg(argv[1], NULL, true, false); } else if (strcasecmp(argv[0], "show-deps") == 0) { /* diff --git a/include/xbps_api.h b/include/xbps_api.h index 29776be2..367ce1ba 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -40,7 +40,7 @@ #include /* Current release version */ -#define XBPS_RELVER "20091207" +#define XBPS_RELVER "20091209" /* Default root PATH for xbps to store metadata info. */ #define XBPS_META_PATH "/var/db/xbps" @@ -102,7 +102,7 @@ int xbps_config_file_from_archive_entry(prop_dictionary_t, bool *); /* From lib/configure.c */ -int SYMEXPORT xbps_configure_pkg(const char *, const char *, bool); +int SYMEXPORT xbps_configure_pkg(const char *, const char *, bool, bool); int SYMEXPORT xbps_configure_all_pkgs(void); /* from lib/cmpver.c */ diff --git a/lib/configure.c b/lib/configure.c index 7ae0ffda..af5a3973 100644 --- a/lib/configure.c +++ b/lib/configure.c @@ -67,7 +67,8 @@ xbps_configure_all_pkgs(void) break; if (state != XBPS_PKG_STATE_UNPACKED) continue; - if ((rv = xbps_configure_pkg(pkgname, version, false)) != 0) + if ((rv = xbps_configure_pkg(pkgname, version, + false, false)) != 0) break; } prop_object_iterator_release(iter); @@ -83,7 +84,8 @@ out: * to installed. */ int SYMEXPORT -xbps_configure_pkg(const char *pkgname, const char *version, bool check_state) +xbps_configure_pkg(const char *pkgname, const char *version, bool check_state, + bool update) { prop_dictionary_t pkgd; const char *rootdir, *lver; @@ -141,7 +143,7 @@ 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, NULL)) != 0) { + pkgname, lver, update ? "yes" : "no", NULL)) != 0) { free(buf); printf("%s: post INSTALL action returned: %s\n", pkgname, strerror(errno)); diff --git a/lib/unpack.c b/lib/unpack.c index 4df47b89..5d6d9741 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -124,13 +124,13 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) const char *pkgname, *version, *rootdir, *entry_str; char *buf, *buf2; int rv = 0, flags, lflags; - bool essential, preserve, actgt, skip_entry; + bool essential, preserve, actgt, skip_entry, update; bool props_plist_found, files_plist_found; assert(ar != NULL); assert(pkg != NULL); - essential = preserve = actgt = skip_entry = false; + essential = preserve = actgt = skip_entry = update = false; props_plist_found = files_plist_found = false; rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); @@ -151,6 +151,9 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) prop_dictionary_get_bool(pkg, "essential", &essential); prop_dictionary_get_bool(pkg, "preserve", &preserve); + if (xbps_check_is_installed_pkgname(pkgname)) + update = true; + while (archive_read_next_header(ar, &entry) == ARCHIVE_OK) { if (entry_idx >= 5) { /* @@ -194,9 +197,10 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) return rv; } } - + if ((rv = xbps_file_chdir_exec(rootdir, buf, "pre", - pkgname, version, NULL)) != 0) { + pkgname, version, update ? "yes" : "no", + NULL)) != 0) { free(buf); printf("%s: preinst action target error %s\n", pkgname, strerror(errno));