pkgdb: added "repository-origin" obj to know its origin repository.

This commit is contained in:
Juan RP 2014-05-11 10:03:17 +02:00
parent 26c1e80933
commit 4070255529
2 changed files with 15 additions and 1 deletions

7
NEWS
View File

@ -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.

View File

@ -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.