From c22dfa8d52873f0d61c38cb1f9fd4bcfe4edb061 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 17 May 2013 09:17:32 +0200 Subject: [PATCH] Make sure that pkg meta plist are always created, even in pkgs without files. --- lib/package_unpack.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/package_unpack.c b/lib/package_unpack.c index b1122e48..e8b2e18a 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -171,7 +171,7 @@ unpack_archive(struct xbps_handle *xhp, char *pkgname, *dname, *buf, *buf2, *p, *p2; int ar_rv, rv, entry_type, flags; bool preserve, update, conf_file, file_exists, skip_obsoletes; - bool softreplace, skip_extract, force; + bool softreplace, skip_extract, force, metafile; uid_t euid; assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY); @@ -179,7 +179,7 @@ unpack_archive(struct xbps_handle *xhp, propsd = filesd = old_filesd = NULL; force = preserve = update = conf_file = file_exists = false; - skip_obsoletes = softreplace = false; + skip_obsoletes = softreplace = metafile = false; prop_dictionary_get_bool(pkg_repod, "preserve", &preserve); prop_dictionary_get_bool(pkg_repod, "skip-obsoletes", &skip_obsoletes); @@ -293,9 +293,13 @@ unpack_archive(struct xbps_handle *xhp, rv = errno; goto out; } - /* - * Create the metaplist file before unpacking any real file. - */ + continue; + } + /* + * XXX: duplicate code. + * Create the metaplist file before unpacking any real file. + */ + if (propsd && filesd && !metafile) { rv = create_pkg_metaplist(xhp, pkgname, pkgver, propsd, filesd, instbuf, instbufsiz, rembuf, rembufsiz); @@ -306,7 +310,7 @@ unpack_archive(struct xbps_handle *xhp, pkgver, strerror(rv)); goto out; } - continue; + metafile = true; } /* * If XBPS_PKGFILES or XBPS_PKGPROPS weren't found @@ -541,6 +545,23 @@ unpack_archive(struct xbps_handle *xhp, } } } + /* + * XXX: duplicate code. + * Create the metaplist file if it wasn't created before. + */ + if (propsd && filesd && !metafile) { + rv = create_pkg_metaplist(xhp, pkgname, pkgver, + propsd, filesd, instbuf, instbufsiz, + rembuf, rembufsiz); + if (rv != 0) { + xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, + rv, pkgver, + "%s: [unpack] failed to create metaplist file: %s", + pkgver, strerror(rv)); + goto out; + } + metafile = true; + } /* * If there was any error extracting files from archive, error out. */