xbps-bin: simplify and make 'check' target work after regpkgdb flush changes.
This commit is contained in:
@ -128,9 +128,9 @@ check_pkg_integrity(prop_dictionary_t pkgd, const char *pkgname)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RUN_PKG_CHECK(name) \
|
#define RUN_PKG_CHECK(name, arg) \
|
||||||
do { \
|
do { \
|
||||||
rv = check_pkg_##name(pkgd ? pkgd : opkgd, propsd, filesd); \
|
rv = check_pkg_##name(pkgname, arg); \
|
||||||
if (rv) \
|
if (rv) \
|
||||||
broken = true; \
|
broken = true; \
|
||||||
else if (rv == -1) { \
|
else if (rv == -1) { \
|
||||||
@ -141,11 +141,11 @@ do { \
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Execute pkg checks */
|
/* Execute pkg checks */
|
||||||
RUN_PKG_CHECK(autoinstall);
|
RUN_PKG_CHECK(requiredby, pkgd);
|
||||||
RUN_PKG_CHECK(files);
|
RUN_PKG_CHECK(autoinstall, pkgd);
|
||||||
RUN_PKG_CHECK(symlinks);
|
RUN_PKG_CHECK(files, filesd);
|
||||||
RUN_PKG_CHECK(rundeps);
|
RUN_PKG_CHECK(symlinks, filesd);
|
||||||
RUN_PKG_CHECK(requiredby);
|
RUN_PKG_CHECK(rundeps, propsd);
|
||||||
|
|
||||||
#undef RUN_PKG_CHECK
|
#undef RUN_PKG_CHECK
|
||||||
|
|
||||||
|
@ -47,70 +47,50 @@
|
|||||||
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
check_pkg_autoinstall(prop_dictionary_t pkgd_regpkgdb,
|
check_pkg_autoinstall(const char *pkgname, void *arg)
|
||||||
prop_dictionary_t pkg_propsd,
|
|
||||||
prop_dictionary_t pkg_filesd)
|
|
||||||
{
|
{
|
||||||
const struct xbps_handle *xhp = xbps_handle_get();
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t pkgd = arg;
|
||||||
prop_array_t array, reqby;
|
prop_array_t array, reqby;
|
||||||
const char *pkgname;
|
|
||||||
char *path;
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
bool autoinst = false;
|
bool autoinst = false;
|
||||||
|
|
||||||
(void)pkg_propsd;
|
|
||||||
(void)pkg_filesd;
|
|
||||||
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd_regpkgdb, "pkgname", &pkgname);
|
|
||||||
/*
|
/*
|
||||||
* Check if package has been installed manually but any other
|
* Check if package has been installed manually but any other
|
||||||
* package is currently depending on it; in that case the package
|
* package is currently depending on it; in that case the package
|
||||||
* must be in automatic mode.
|
* must be in automatic mode.
|
||||||
*/
|
*/
|
||||||
if (prop_dictionary_get_bool(pkgd_regpkgdb,
|
if (prop_dictionary_get_bool(pkgd, "automatic-install", &autoinst)) {
|
||||||
"automatic-install", &autoinst)) {
|
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||||
reqby = prop_dictionary_get(pkgd_regpkgdb, "requiredby");
|
|
||||||
if (((prop_object_type(reqby) == PROP_TYPE_ARRAY)) &&
|
if (((prop_object_type(reqby) == PROP_TYPE_ARRAY)) &&
|
||||||
((prop_array_count(reqby) > 0) && !autoinst)) {
|
((prop_array_count(reqby) > 0) && !autoinst)) {
|
||||||
path = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
|
|
||||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
|
||||||
assert(path != NULL);
|
|
||||||
|
|
||||||
/* pkg has reversedeps and was installed manually */
|
/* pkg has reversedeps and was installed manually */
|
||||||
prop_dictionary_set_bool(pkgd_regpkgdb,
|
prop_dictionary_set_bool(pkgd,
|
||||||
"automatic-install", true);
|
"automatic-install", true);
|
||||||
|
|
||||||
dict = prop_dictionary_internalize_from_zfile(path);
|
array = prop_dictionary_get(xhp->regpkgdb, "packages");
|
||||||
if (dict == NULL) {
|
|
||||||
xbps_error_printf("%s: [0] failed to set "
|
|
||||||
"automatic mode (%s)\n", pkgname,
|
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
array = prop_dictionary_get(dict, "packages");
|
|
||||||
rv = xbps_array_replace_dict_by_name(array,
|
rv = xbps_array_replace_dict_by_name(array,
|
||||||
pkgd_regpkgdb, pkgname);
|
pkgd, pkgname);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
xbps_error_printf("%s: [1] failed to set "
|
xbps_error_printf("%s: [1] failed to set "
|
||||||
"automatic mode (%s)\n", pkgname,
|
"automatic mode (%s)\n", pkgname,
|
||||||
strerror(rv));
|
strerror(rv));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!prop_dictionary_set(dict, "packages", array)) {
|
if (!prop_dictionary_set(xhp->regpkgdb,
|
||||||
|
"packages", array)) {
|
||||||
xbps_error_printf("%s: [2] failed to set "
|
xbps_error_printf("%s: [2] failed to set "
|
||||||
"automatic mode (%s)\n", pkgname,
|
"automatic mode (%s)\n", pkgname,
|
||||||
strerror(rv));
|
strerror(rv));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!prop_dictionary_externalize_to_zfile(dict, path)) {
|
if ((rv = xbps_regpkgdb_update(xhp, true)) != 0) {
|
||||||
xbps_error_printf("%s: [3] failed to set "
|
xbps_error_printf("%s: failed to write "
|
||||||
"automatic mode (%s)\n", pkgname,
|
"regpkgdb plist: %s\n", pkgname,
|
||||||
strerror(errno));
|
strerror(rv));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
free(path);
|
|
||||||
path = NULL;
|
|
||||||
xbps_warn_printf("%s: was installed manually and has "
|
xbps_warn_printf("%s: was installed manually and has "
|
||||||
"reverse dependencies (FIXED)\n", pkgname);
|
"reverse dependencies (FIXED)\n", pkgname);
|
||||||
}
|
}
|
||||||
|
@ -47,22 +47,18 @@
|
|||||||
* Return 0 if test ran successfully, 1 otherwise and -1 on error.
|
* Return 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
check_pkg_files(prop_dictionary_t pkgd_regpkgdb,
|
check_pkg_files(const char *pkgname, void *arg)
|
||||||
prop_dictionary_t pkg_propsd,
|
|
||||||
prop_dictionary_t pkg_filesd)
|
|
||||||
{
|
{
|
||||||
struct xbps_handle *xhp = xbps_handle_get();
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
const char *pkgname, *file, *sha256;
|
prop_dictionary_t pkg_filesd = arg;
|
||||||
|
const char *file, *sha256;
|
||||||
char *path;
|
char *path;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
bool broken = false, test_broken = false;
|
bool broken = false, test_broken = false;
|
||||||
|
|
||||||
(void)pkg_propsd;
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd_regpkgdb, "pkgname", &pkgname);
|
|
||||||
|
|
||||||
array = prop_dictionary_get(pkg_filesd, "files");
|
array = prop_dictionary_get(pkg_filesd, "files");
|
||||||
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
|
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
|
||||||
prop_array_count(array) > 0) {
|
prop_array_count(array) > 0) {
|
||||||
|
@ -45,25 +45,18 @@
|
|||||||
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
check_pkg_requiredby(prop_dictionary_t pkgd_regpkgdb,
|
check_pkg_requiredby(const char *pkgname, void *arg)
|
||||||
prop_dictionary_t pkg_propsd,
|
|
||||||
prop_dictionary_t pkg_filesd)
|
|
||||||
{
|
{
|
||||||
prop_array_t regpkgs, reqby, curpkg_rdeps, provides;
|
prop_array_t regpkgs, reqby, curpkg_rdeps, provides;
|
||||||
prop_dictionary_t curpkg_propsd;
|
prop_dictionary_t curpkg_propsd, pkgd = arg;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_string_t curpkgver;
|
prop_string_t curpkgver;
|
||||||
struct xbps_handle *xhp = xbps_handle_get();
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
const char *curpkgn, *pkgname, *pkgver;
|
const char *curpkgn, *pkgver;
|
||||||
size_t i;
|
size_t i;
|
||||||
int rv;
|
int rv;
|
||||||
bool pkg_fixed = false;
|
|
||||||
|
|
||||||
(void)pkg_propsd;
|
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||||
(void)pkg_filesd;
|
|
||||||
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd_regpkgdb, "pkgname", &pkgname);
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd_regpkgdb, "pkgver", &pkgver);
|
|
||||||
|
|
||||||
regpkgs = prop_dictionary_get(xhp->regpkgdb, "packages");
|
regpkgs = prop_dictionary_get(xhp->regpkgdb, "packages");
|
||||||
|
|
||||||
@ -100,7 +93,7 @@ check_pkg_requiredby(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
* package and is matched against any object in
|
* package and is matched against any object in
|
||||||
* run_depends.
|
* run_depends.
|
||||||
*/
|
*/
|
||||||
provides = prop_dictionary_get(pkgd_regpkgdb, "provides");
|
provides = prop_dictionary_get(pkgd, "provides");
|
||||||
if (prop_object_type(provides) != PROP_TYPE_ARRAY) {
|
if (prop_object_type(provides) != PROP_TYPE_ARRAY) {
|
||||||
/* doesn't provide any virtual pkg */
|
/* doesn't provide any virtual pkg */
|
||||||
prop_object_release(curpkg_propsd);
|
prop_object_release(curpkg_propsd);
|
||||||
@ -113,7 +106,7 @@ check_pkg_requiredby(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reqby = prop_dictionary_get(pkgd_regpkgdb, "requiredby");
|
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||||
curpkgver = prop_dictionary_get(curpkg_propsd, "pkgver");
|
curpkgver = prop_dictionary_get(curpkg_propsd, "pkgver");
|
||||||
if (prop_object_type(reqby) == PROP_TYPE_ARRAY) {
|
if (prop_object_type(reqby) == PROP_TYPE_ARRAY) {
|
||||||
/*
|
/*
|
||||||
@ -144,7 +137,7 @@ check_pkg_requiredby(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
* file to disk.
|
* file to disk.
|
||||||
*/
|
*/
|
||||||
prop_array_add(reqby, curpkgver);
|
prop_array_add(reqby, curpkgver);
|
||||||
prop_dictionary_set(pkgd_regpkgdb, "requiredby", reqby);
|
prop_dictionary_set(pkgd, "requiredby", reqby);
|
||||||
rv = xbps_array_replace_dict_by_name(regpkgs, obj, curpkgn);
|
rv = xbps_array_replace_dict_by_name(regpkgs, obj, curpkgn);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
xbps_error_printf("%s: failed to replace pkgd: %s\n",
|
xbps_error_printf("%s: failed to replace pkgd: %s\n",
|
||||||
@ -156,19 +149,14 @@ check_pkg_requiredby(prop_dictionary_t pkgd_regpkgdb,
|
|||||||
"packages array: %s", curpkgn, strerror(errno));
|
"packages array: %s", curpkgn, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pkg_fixed = true;
|
|
||||||
printf("%s: added requiredby entry for %s.\n",
|
|
||||||
pkgver, prop_string_cstring_nocopy(curpkgver));
|
|
||||||
prop_object_release(curpkg_propsd);
|
|
||||||
}
|
|
||||||
if (pkg_fixed == false)
|
|
||||||
return rv;
|
|
||||||
|
|
||||||
if ((rv = xbps_regpkgdb_update(xhp, true)) != 0) {
|
if ((rv = xbps_regpkgdb_update(xhp, true)) != 0) {
|
||||||
xbps_error_printf("failed to write regpkgdb plist: "
|
xbps_error_printf("failed to write regpkgdb plist: "
|
||||||
" %s\n", strerror(rv));
|
" %s\n", strerror(rv));
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
printf("%s: added requiredby entry for %s.\n",
|
||||||
|
pkgver, prop_string_cstring_nocopy(curpkgver));
|
||||||
|
prop_object_release(curpkg_propsd);
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -45,18 +45,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
check_pkg_rundeps(prop_dictionary_t pkgd_regpkgdb,
|
check_pkg_rundeps(const char *pkgname, void *arg)
|
||||||
prop_dictionary_t pkg_propsd,
|
|
||||||
prop_dictionary_t pkg_filesd)
|
|
||||||
{
|
{
|
||||||
|
prop_dictionary_t pkg_propsd = arg;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
const char *reqpkg, *pkgname;
|
const char *reqpkg;
|
||||||
bool test_broken = false;
|
bool test_broken = false;
|
||||||
|
|
||||||
(void)pkg_filesd;
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd_regpkgdb, "pkgname", &pkgname);
|
|
||||||
|
|
||||||
if (!xbps_pkg_has_rundeps(pkg_propsd))
|
if (!xbps_pkg_has_rundeps(pkg_propsd))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -45,21 +45,17 @@
|
|||||||
* returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
* returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
check_pkg_symlinks(prop_dictionary_t pkgd_regpkgdb,
|
check_pkg_symlinks(const char *pkgname, void *arg)
|
||||||
prop_dictionary_t pkg_propsd,
|
|
||||||
prop_dictionary_t pkg_filesd)
|
|
||||||
{
|
{
|
||||||
const struct xbps_handle *xhp = xbps_handle_get();
|
const struct xbps_handle *xhp = xbps_handle_get();
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
const char *pkgname, *file, *tgt = NULL;
|
prop_dictionary_t pkg_filesd = arg;
|
||||||
|
const char *file, *tgt = NULL;
|
||||||
char *path, buf[PATH_MAX];
|
char *path, buf[PATH_MAX];
|
||||||
bool broken = false, test_broken = false;
|
bool broken = false, test_broken = false;
|
||||||
|
|
||||||
(void)pkg_propsd;
|
|
||||||
prop_dictionary_get_cstring_nocopy(pkgd_regpkgdb, "pkgname", &pkgname);
|
|
||||||
|
|
||||||
array = prop_dictionary_get(pkg_filesd, "links");
|
array = prop_dictionary_get(pkg_filesd, "links");
|
||||||
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
|
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
|
||||||
prop_array_count(array) > 0) {
|
prop_array_count(array) > 0) {
|
||||||
|
@ -60,7 +60,7 @@ int check_pkg_integrity(prop_dictionary_t, const char *);
|
|||||||
int check_pkg_integrity_all(void);
|
int check_pkg_integrity_all(void);
|
||||||
|
|
||||||
#define CHECK_PKG_DECL(type) \
|
#define CHECK_PKG_DECL(type) \
|
||||||
int check_pkg_##type (prop_dictionary_t, prop_dictionary_t, prop_dictionary_t)
|
int check_pkg_##type (const char *, void *)
|
||||||
|
|
||||||
CHECK_PKG_DECL(autoinstall);
|
CHECK_PKG_DECL(autoinstall);
|
||||||
CHECK_PKG_DECL(files);
|
CHECK_PKG_DECL(files);
|
||||||
|
Reference in New Issue
Block a user