From b03a18ff845c519d95201ca7b686b4e273d43265 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 2 Dec 2009 06:31:03 +0100 Subject: [PATCH] xbps_unpack_binary_pkg: removed 2nd bool argument, look for a preserve object to not remove files in removal or upgrades. Bump XBPS_RELVER to 20091202. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091202053103-uby6hwu313pieafa --- bin/xbps-bin/install.c | 2 +- include/xbps_api.h | 4 ++-- lib/unpack.c | 24 +++++++++++++++--------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index 0b87301c..fc6ebcdb 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -620,7 +620,7 @@ exec_transaction(struct transaction *trans) * Unpack binary package. */ printf("Unpacking %s (from .../%s) ...\n", pkgver, filename); - if ((rv = xbps_unpack_binary_pkg(obj, essential)) != 0) { + if ((rv = xbps_unpack_binary_pkg(obj)) != 0) { printf("error: unpacking %s (%s)\n", pkgver, strerror(rv)); return rv; diff --git a/include/xbps_api.h b/include/xbps_api.h index 656a8e8b..6b450f0c 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -40,7 +40,7 @@ #include /* Current release version */ -#define XBPS_RELVER "20091128" +#define XBPS_RELVER "20091202" /* Default root PATH for xbps to store metadata info. */ #define XBPS_META_PATH "/var/db/xbps" @@ -249,7 +249,7 @@ int SYMEXPORT xbps_set_pkg_state_installed(const char *, pkg_state_t); int SYMEXPORT xbps_set_pkg_state_dictionary(prop_dictionary_t, pkg_state_t); /* From lib/unpack.c */ -int SYMEXPORT xbps_unpack_binary_pkg(prop_dictionary_t, bool); +int SYMEXPORT xbps_unpack_binary_pkg(prop_dictionary_t); /* From lib/util.c */ char SYMEXPORT *xbps_xasprintf(const char *, ...); diff --git a/lib/unpack.c b/lib/unpack.c index a444ff83..7d642591 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -32,11 +32,11 @@ #include -static int unpack_archive_fini(struct archive *, prop_dictionary_t, bool); +static int unpack_archive_fini(struct archive *, prop_dictionary_t); static void set_extract_flags(int *); int SYMEXPORT -xbps_unpack_binary_pkg(prop_dictionary_t pkg, bool essential) +xbps_unpack_binary_pkg(prop_dictionary_t pkg) { const char *pkgname, *repoloc; struct archive *ar = NULL; @@ -74,7 +74,7 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg, bool essential) ARCHIVE_READ_BLOCKSIZE)) != 0) goto out; - if ((rv = unpack_archive_fini(ar, pkg, essential)) == 0) { + if ((rv = unpack_archive_fini(ar, pkg)) == 0) { /* * If installation of package was successful, make sure * its files are written in storage (if possible). @@ -116,18 +116,19 @@ set_extract_flags(int *flags) * the consumer. */ static int -unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg, - bool essential) +unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) { prop_dictionary_t filesd = NULL, old_filesd = NULL; struct archive_entry *entry; const char *pkgname, *version, *rootdir, *entry_str; char *buf, *buf2; int rv = 0, flags, lflags; - bool actgt = false, skip_entry = false; + bool essential, preserve, actgt, skip_entry; assert(ar != NULL); assert(pkg != NULL); + + essential = preserve = actgt = skip_entry = false; rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); @@ -141,6 +142,11 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg, return errno; if (!prop_dictionary_get_cstring_nocopy(pkg, "version", &version)) return errno; + /* + * The following two objects are OPTIONAL. + */ + prop_dictionary_get_bool(pkg, "essential", &essential); + prop_dictionary_get_bool(pkg, "preserve", &preserve); while (archive_read_next_header(ar, &entry) == ARCHIVE_OK) { entry_str = archive_entry_pathname(entry); @@ -266,10 +272,10 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg, } /* * Check if files.plist exists and pkg is marked as - * essential, in that case we need to check for obsolete - * files and remove them if necessary. + * essential and NOT preserve, in that case we need to check + * for obsolete files and remove them if necessary. */ - if (essential && (access(buf2, R_OK) == 0)) { + if (!preserve && essential && (access(buf2, R_OK) == 0)) { old_filesd = prop_dictionary_internalize_from_file(buf2); if (old_filesd == NULL) {