diff --git a/NEWS b/NEWS index 7af5152e..53f47565 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ xbps-0.37 (???): + * A new object is now recorded in the pkgdb to see the origin repository of + which a package was installed from, i.e: + + $ xbps-query --property=repository-origin pkg + ... + $ + * xbps-remove(8): the -n,--dry-run option does not acquire the pkgdb file lock anymore, so that any user can use this mode even without write permission to the target pkgdb. diff --git a/lib/package_register.c b/lib/package_register.c index 6dee6003..19d66204 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -39,7 +39,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) char outstr[64]; time_t t; struct tm *tmp; - const char *desc, *pkgver; + const char *desc, *pkgver, *repo; char *pkgname = NULL, *buf, *sha256; int rv = 0; bool autoinst = false; @@ -48,6 +48,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) xbps_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); + xbps_dictionary_get_cstring_nocopy(pkgrd, "repository", &repo); xbps_dictionary_get_bool(pkgrd, "automatic-install", &autoinst); provides = xbps_dictionary_get(pkgrd, "provides"); rundeps = xbps_dictionary_get(pkgrd, "run_depends"); @@ -118,6 +119,12 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) rv = EINVAL; goto out; } + /* Save the repository origin which was used to install the pkg from */ + if (!xbps_dictionary_set_cstring(pkgd, "repository-origin", repo)) { + xbps_dbg_printf(xhp, "%s: repository-origin set failed!\n", pkgver); + rv = EINVAL; + goto out; + } /* * Create a hash for the pkg's metafile.