xbps-rindex: [add] re-add all package objects to the index.
This commit is contained in:
parent
d3ffd0885b
commit
3ca442eb3d
@ -291,14 +291,10 @@ repo_show_pkg_info(struct xbps_handle *xhp,
|
|||||||
{
|
{
|
||||||
xbps_dictionary_t pkgd;
|
xbps_dictionary_t pkgd;
|
||||||
|
|
||||||
pkgd = xbps_rpool_get_pkg_plist(xhp, pattern, "./props.plist");
|
if (((pkgd = xbps_rpool_get_pkg(xhp, pattern)) == NULL) &&
|
||||||
if (pkgd == NULL) {
|
((pkgd = xbps_rpool_get_virtualpkg(xhp, pattern)) == NULL))
|
||||||
if (errno != ENOTSUP && errno != ENOENT) {
|
return errno;
|
||||||
fprintf(stderr, "Unexpected error: %s\n",
|
|
||||||
strerror(errno));
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (option)
|
if (option)
|
||||||
show_pkg_info_one(pkgd, option);
|
show_pkg_info_one(pkgd, option);
|
||||||
else
|
else
|
||||||
|
@ -41,12 +41,11 @@ int
|
|||||||
index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
||||||
{
|
{
|
||||||
xbps_array_t array, pkg_files, pkg_links, pkg_cffiles;
|
xbps_array_t array, pkg_files, pkg_links, pkg_cffiles;
|
||||||
xbps_dictionary_t idx, idxfiles, idxpkgd, binpkgd, pkg_filesd, curpkgd;
|
xbps_dictionary_t idx, idxfiles, binpkgd, pkg_filesd, curpkgd;
|
||||||
xbps_object_t obj, fileobj;
|
xbps_object_t obj, fileobj;
|
||||||
struct xbps_repo *repo;
|
struct xbps_repo *repo;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
uint64_t instsize;
|
const char *arch;
|
||||||
const char *arch, *desc;
|
|
||||||
char *sha256, *pkgver, *opkgver, *oarch, *pkgname, *tmprepodir, *repodir;
|
char *sha256, *pkgver, *opkgver, *oarch, *pkgname, *tmprepodir, *repodir;
|
||||||
int rv = 0, ret = 0;
|
int rv = 0, ret = 0;
|
||||||
bool flush = false, found = false;
|
bool flush = false, found = false;
|
||||||
@ -130,65 +129,6 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
|||||||
free(opkgver);
|
free(opkgver);
|
||||||
free(oarch);
|
free(oarch);
|
||||||
}
|
}
|
||||||
idxpkgd = xbps_dictionary_create();
|
|
||||||
assert(idxpkgd);
|
|
||||||
/*
|
|
||||||
* Only copy relevant objects from binpkg:
|
|
||||||
* - architecture
|
|
||||||
* - pkgver
|
|
||||||
* - short_desc
|
|
||||||
* - installed_size
|
|
||||||
* - run_depends
|
|
||||||
* - provides
|
|
||||||
* - replaces
|
|
||||||
* - shlib-requires
|
|
||||||
*/
|
|
||||||
if (!xbps_dictionary_set_cstring(idxpkgd, "architecture", arch)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
if (!xbps_dictionary_set_cstring(idxpkgd, "pkgver", pkgver)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
xbps_dictionary_get_cstring_nocopy(binpkgd, "short_desc", &desc);
|
|
||||||
if (!xbps_dictionary_set_cstring(idxpkgd, "short_desc", desc)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
xbps_dictionary_get_uint64(binpkgd, "installed_size", &instsize);
|
|
||||||
if (!xbps_dictionary_set_uint64(idxpkgd, "installed_size", instsize)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
array = xbps_dictionary_get(binpkgd, "run_depends");
|
|
||||||
if (xbps_array_count(array) && !xbps_dictionary_set(idxpkgd, "run_depends", array)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
array = xbps_dictionary_get(binpkgd, "provides");
|
|
||||||
if (xbps_array_count(array) && !xbps_dictionary_set(idxpkgd, "provides", array)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
array = xbps_dictionary_get(binpkgd, "replaces");
|
|
||||||
if (xbps_array_count(array) && !xbps_dictionary_set(idxpkgd, "replaces", array)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
array = xbps_dictionary_get(binpkgd, "shlib-requires");
|
|
||||||
if (xbps_array_count(array) && !xbps_dictionary_set(idxpkgd, "shlib-requires", array)) {
|
|
||||||
free(pkgver);
|
|
||||||
free(pkgname);
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Add additional objects for repository ops:
|
* Add additional objects for repository ops:
|
||||||
* - filename-size
|
* - filename-size
|
||||||
@ -199,7 +139,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
|||||||
free(pkgname);
|
free(pkgname);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
if (!xbps_dictionary_set_cstring(idxpkgd, "filename-sha256", sha256)) {
|
if (!xbps_dictionary_set_cstring(binpkgd, "filename-sha256", sha256)) {
|
||||||
free(pkgver);
|
free(pkgver);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
return errno;
|
return errno;
|
||||||
@ -209,21 +149,24 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
|
|||||||
free(pkgname);
|
free(pkgname);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
if (!xbps_dictionary_set_uint64(idxpkgd, "filename-size", (uint64_t)st.st_size)) {
|
if (!xbps_dictionary_set_uint64(binpkgd, "filename-size", (uint64_t)st.st_size)) {
|
||||||
free(pkgver);
|
free(pkgver);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
/* Remove unneeded objects */
|
||||||
|
xbps_dictionary_remove(binpkgd, "pkgname");
|
||||||
|
xbps_dictionary_remove(binpkgd, "version");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add new pkg dictionary into the index.
|
* Add new pkg dictionary into the index.
|
||||||
*/
|
*/
|
||||||
if (!xbps_dictionary_set(idx, pkgname, idxpkgd)) {
|
if (!xbps_dictionary_set(idx, pkgname, binpkgd)) {
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
flush = true;
|
flush = true;
|
||||||
printf("index: added `%s' (%s).\n", pkgver, arch);
|
printf("index: added `%s' (%s).\n", pkgver, arch);
|
||||||
xbps_object_release(idxpkgd);
|
|
||||||
xbps_object_release(binpkgd);
|
xbps_object_release(binpkgd);
|
||||||
free(pkgname);
|
free(pkgname);
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user