regpkgdb rototill: renamed to pkgdb, improve the public API.
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
@@ -38,6 +37,7 @@
|
||||
struct checkpkg {
|
||||
size_t npkgs;
|
||||
size_t nbrokenpkgs;
|
||||
bool flush;
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -45,15 +45,17 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
||||
{
|
||||
struct checkpkg *cpkg = arg;
|
||||
const char *pkgname, *version;
|
||||
bool flush = false;
|
||||
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
printf("Checking %s-%s ...\n", pkgname, version);
|
||||
if (check_pkg_integrity(obj, pkgname) != 0)
|
||||
if (check_pkg_integrity(obj, pkgname, false, &flush) != 0)
|
||||
cpkg->nbrokenpkgs++;
|
||||
|
||||
cpkg->flush = flush;
|
||||
cpkg->npkgs++;
|
||||
return 0;
|
||||
}
|
||||
@@ -61,26 +63,33 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
||||
int
|
||||
check_pkg_integrity_all(void)
|
||||
{
|
||||
struct checkpkg *cpkg;
|
||||
|
||||
cpkg = calloc(1, sizeof(*cpkg));
|
||||
if (cpkg == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
(void)xbps_regpkgdb_foreach_pkg_cb(cb_pkg_integrity, cpkg);
|
||||
printf("%zu package%s processed: %zu broken.\n", cpkg->npkgs,
|
||||
cpkg->npkgs == 1 ? "" : "s", cpkg->nbrokenpkgs);
|
||||
free(cpkg);
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
struct checkpkg cpkg;
|
||||
int rv;
|
||||
|
||||
memset(&cpkg, 0, sizeof(cpkg));
|
||||
(void)xbps_pkgdb_foreach_pkg_cb(cb_pkg_integrity, &cpkg);
|
||||
if (cpkg.flush) {
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) {
|
||||
xbps_error_printf("failed to write pkgdb: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
printf("%zu package%s processed: %zu broken.\n", cpkg.npkgs,
|
||||
cpkg.npkgs == 1 ? "" : "s", cpkg.nbrokenpkgs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
check_pkg_integrity(prop_dictionary_t pkgd, const char *pkgname)
|
||||
check_pkg_integrity(prop_dictionary_t pkgd,
|
||||
const char *pkgname,
|
||||
bool flush,
|
||||
bool *setflush)
|
||||
{
|
||||
prop_dictionary_t opkgd, propsd, filesd;
|
||||
int rv = 0;
|
||||
bool broken = false;
|
||||
bool pkgdb_update = false, broken = false;
|
||||
|
||||
propsd = filesd = opkgd = NULL;
|
||||
|
||||
@@ -101,7 +110,7 @@ check_pkg_integrity(prop_dictionary_t pkgd, const char *pkgname)
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
propsd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
if (prop_object_type(propsd) != PROP_TYPE_DICTIONARY) {
|
||||
if (propsd == NULL) {
|
||||
xbps_error_printf("%s: unexistent %s or invalid metadata "
|
||||
"file.\n", pkgname, XBPS_PKGPROPS);
|
||||
broken = true;
|
||||
@@ -116,7 +125,7 @@ check_pkg_integrity(prop_dictionary_t pkgd, const char *pkgname)
|
||||
* Check for files.plist metadata file.
|
||||
*/
|
||||
filesd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY) {
|
||||
if (filesd == NULL) {
|
||||
xbps_error_printf("%s: unexistent %s or invalid metadata "
|
||||
"file.\n", pkgname, XBPS_PKGFILES);
|
||||
broken = true;
|
||||
@@ -128,9 +137,9 @@ check_pkg_integrity(prop_dictionary_t pkgd, const char *pkgname)
|
||||
goto out;
|
||||
}
|
||||
|
||||
#define RUN_PKG_CHECK(name, arg) \
|
||||
#define RUN_PKG_CHECK(name, arg, arg2) \
|
||||
do { \
|
||||
rv = check_pkg_##name(pkgname, arg); \
|
||||
rv = check_pkg_##name(pkgname, arg, arg2); \
|
||||
if (rv) \
|
||||
broken = true; \
|
||||
else if (rv == -1) { \
|
||||
@@ -141,11 +150,20 @@ do { \
|
||||
} while (0)
|
||||
|
||||
/* Execute pkg checks */
|
||||
RUN_PKG_CHECK(requiredby, pkgd ? pkgd : opkgd);
|
||||
RUN_PKG_CHECK(autoinstall, pkgd ? pkgd : opkgd);
|
||||
RUN_PKG_CHECK(files, filesd);
|
||||
RUN_PKG_CHECK(symlinks, filesd);
|
||||
RUN_PKG_CHECK(rundeps, propsd);
|
||||
RUN_PKG_CHECK(requiredby, pkgd ? pkgd : opkgd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(autoinstall, pkgd ? pkgd : opkgd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(files, filesd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(symlinks, filesd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(rundeps, propsd, &pkgdb_update);
|
||||
|
||||
if (flush && pkgdb_update) {
|
||||
if (!xbps_pkgdb_replace_pkgd(opkgd, pkgname, false, true)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (pkgdb_update && setflush != NULL)
|
||||
*setflush = true;
|
||||
|
||||
#undef RUN_PKG_CHECK
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -47,12 +47,10 @@
|
||||
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_autoinstall(const char *pkgname, void *arg)
|
||||
check_pkg_autoinstall(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_dictionary_t pkgd = arg;
|
||||
prop_array_t array, reqby;
|
||||
int rv = 0;
|
||||
prop_array_t reqby;
|
||||
bool autoinst = false;
|
||||
|
||||
/*
|
||||
@@ -62,39 +60,14 @@ check_pkg_autoinstall(const char *pkgname, void *arg)
|
||||
*/
|
||||
if (prop_dictionary_get_bool(pkgd, "automatic-install", &autoinst)) {
|
||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||
if (((prop_object_type(reqby) == PROP_TYPE_ARRAY)) &&
|
||||
((prop_array_count(reqby) > 0) && !autoinst)) {
|
||||
|
||||
if (reqby != NULL && prop_array_count(reqby) && !autoinst) {
|
||||
/* pkg has reversedeps and was installed manually */
|
||||
prop_dictionary_set_bool(pkgd,
|
||||
"automatic-install", true);
|
||||
|
||||
array = prop_dictionary_get(xhp->regpkgdb, "packages");
|
||||
rv = xbps_array_replace_dict_by_name(array,
|
||||
pkgd, pkgname);
|
||||
if (rv != 0) {
|
||||
xbps_error_printf("%s: [1] failed to set "
|
||||
"automatic mode (%s)\n", pkgname,
|
||||
strerror(rv));
|
||||
return -1;
|
||||
}
|
||||
if (!prop_dictionary_set(xhp->regpkgdb,
|
||||
"packages", array)) {
|
||||
xbps_error_printf("%s: [2] failed to set "
|
||||
"automatic mode (%s)\n", pkgname,
|
||||
strerror(rv));
|
||||
return -1;
|
||||
}
|
||||
if ((rv = xbps_regpkgdb_update(xhp, true)) != 0) {
|
||||
xbps_error_printf("%s: failed to write "
|
||||
"regpkgdb plist: %s\n", pkgname,
|
||||
strerror(rv));
|
||||
return -1;
|
||||
}
|
||||
xbps_warn_printf("%s: was installed manually and has "
|
||||
"reverse dependencies (FIXED)\n", pkgname);
|
||||
*pkgdb_update = true;
|
||||
printf("%s: changed to automatic install mode.\n",
|
||||
pkgname);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
@@ -47,7 +46,7 @@
|
||||
* Return 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_files(const char *pkgname, void *arg)
|
||||
check_pkg_files(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_array_t array;
|
||||
@@ -59,9 +58,10 @@ check_pkg_files(const char *pkgname, void *arg)
|
||||
int rv = 0;
|
||||
bool broken = false, test_broken = false;
|
||||
|
||||
(void)pkgdb_update;
|
||||
|
||||
array = prop_dictionary_get(pkg_filesd, "files");
|
||||
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
|
||||
prop_array_count(array) > 0) {
|
||||
if (array != NULL && prop_array_count(array) > 0) {
|
||||
iter = xbps_array_iter_from_dict(pkg_filesd, "files");
|
||||
if (iter == NULL)
|
||||
return -1;
|
||||
@@ -109,8 +109,7 @@ check_pkg_files(const char *pkgname, void *arg)
|
||||
* Check for missing configuration files.
|
||||
*/
|
||||
array = prop_dictionary_get(pkg_filesd, "conf_files");
|
||||
if (array && prop_object_type(array) == PROP_TYPE_ARRAY &&
|
||||
prop_array_count(array) > 0) {
|
||||
if (array != NULL && prop_array_count(array) > 0) {
|
||||
iter = xbps_array_iter_from_dict(pkg_filesd, "conf_files");
|
||||
if (iter == NULL)
|
||||
return -1;
|
||||
|
||||
@@ -28,135 +28,152 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
|
||||
struct check_reqby_data {
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t pkgd_reqby;
|
||||
const char *pkgname;
|
||||
const char *pkgver;
|
||||
bool pkgdb_update;
|
||||
bool pkgd_reqby_alloc;
|
||||
};
|
||||
|
||||
static int
|
||||
check_reqby_pkg_cb(prop_object_t obj, void *arg, bool *done)
|
||||
{
|
||||
struct check_reqby_data *crd = arg;
|
||||
prop_array_t curpkg_rdeps, provides;
|
||||
prop_dictionary_t curpkg_propsd;
|
||||
prop_string_t curpkgver;
|
||||
const char *curpkgn;
|
||||
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &curpkgn);
|
||||
/* skip same pkg */
|
||||
if (strcmp(curpkgn, crd->pkgname) == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Internalize current pkg props dictionary from its
|
||||
* installed metadata directory.
|
||||
*/
|
||||
curpkg_propsd =
|
||||
xbps_dictionary_from_metadata_plist(curpkgn, XBPS_PKGPROPS);
|
||||
if (curpkg_propsd == NULL) {
|
||||
xbps_error_printf("%s: missing %s metadata file!\n",
|
||||
curpkgn, XBPS_PKGPROPS);
|
||||
return -1;
|
||||
}
|
||||
curpkg_rdeps =
|
||||
prop_dictionary_get(curpkg_propsd, "run_depends");
|
||||
if (curpkg_rdeps == NULL) {
|
||||
/* package has no rundeps, skip */
|
||||
prop_object_release(curpkg_propsd);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Check for pkgpattern match with real packages...
|
||||
*/
|
||||
if (!xbps_match_pkgdep_in_array(curpkg_rdeps, crd->pkgver)) {
|
||||
/*
|
||||
* ... otherwise check if package provides any virtual
|
||||
* package and is matched against any object in
|
||||
* run_depends.
|
||||
*/
|
||||
provides = prop_dictionary_get(obj, "provides");
|
||||
if (provides == NULL) {
|
||||
/* doesn't provide any virtual pkg */
|
||||
prop_object_release(curpkg_propsd);
|
||||
return 0;
|
||||
}
|
||||
if (!xbps_match_any_virtualpkg_in_rundeps(curpkg_rdeps,
|
||||
provides)) {
|
||||
/* doesn't match any virtual pkg */
|
||||
prop_object_release(curpkg_propsd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
crd->pkgd_reqby = prop_dictionary_get(crd->pkgd, "requiredby");
|
||||
curpkgver = prop_dictionary_get(curpkg_propsd, "pkgver");
|
||||
if (crd->pkgd_reqby != NULL) {
|
||||
/*
|
||||
* Now check that current pkgver has been registered into
|
||||
* its requiredby array.
|
||||
*/
|
||||
if (xbps_match_string_in_array(crd->pkgd_reqby,
|
||||
prop_string_cstring_nocopy(curpkgver))) {
|
||||
/*
|
||||
* Current package already requires our package,
|
||||
* this is good so skip it.
|
||||
*/
|
||||
prop_object_release(curpkg_propsd);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Missing requiredby array object, create it.
|
||||
*/
|
||||
crd->pkgd_reqby = prop_array_create();
|
||||
if (crd->pkgd_reqby == NULL) {
|
||||
prop_object_release(curpkg_propsd);
|
||||
return -1;
|
||||
}
|
||||
crd->pkgd_reqby_alloc = true;
|
||||
}
|
||||
/*
|
||||
* Added pkgdep into pkg's requiredby array.
|
||||
*/
|
||||
if (!prop_array_add(crd->pkgd_reqby, curpkgver)) {
|
||||
prop_object_release(curpkg_propsd);
|
||||
return -1;
|
||||
}
|
||||
printf("%s: added missing requiredby entry for %s.\n",
|
||||
crd->pkgname, prop_string_cstring_nocopy(curpkgver));
|
||||
prop_object_release(curpkg_propsd);
|
||||
crd->pkgdb_update = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks package integrity of an installed package.
|
||||
* The following task is accomplished in this file:
|
||||
*
|
||||
* o Check for missing reverse dependencies (aka requiredby)
|
||||
* entries in pkg's regpkgdb dictionary.
|
||||
* entries in pkg's pkgdb dictionary.
|
||||
*
|
||||
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_requiredby(const char *pkgname, void *arg)
|
||||
check_pkg_requiredby(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
{
|
||||
prop_array_t regpkgs, reqby, curpkg_rdeps, provides;
|
||||
prop_dictionary_t curpkg_propsd, pkgd = arg;
|
||||
prop_object_t obj;
|
||||
prop_string_t curpkgver;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *curpkgn, *pkgver;
|
||||
size_t i;
|
||||
struct check_reqby_data crd;
|
||||
int rv;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
crd.pkgd = arg;
|
||||
crd.pkgd_reqby = NULL;
|
||||
crd.pkgd_reqby_alloc = false;
|
||||
crd.pkgname = pkgname;
|
||||
crd.pkgdb_update = false;
|
||||
prop_dictionary_get_cstring_nocopy(crd.pkgd, "pkgver", &crd.pkgver);
|
||||
|
||||
regpkgs = prop_dictionary_get(xhp->regpkgdb, "packages");
|
||||
rv = xbps_pkgdb_foreach_pkg_cb(check_reqby_pkg_cb, &crd);
|
||||
*pkgdb_update = crd.pkgdb_update;
|
||||
|
||||
for (i = 0; i < prop_array_count(regpkgs); i++) {
|
||||
obj = prop_array_get(regpkgs, i);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &curpkgn);
|
||||
/* skip same pkg */
|
||||
if (strcmp(curpkgn, pkgname) == 0)
|
||||
continue;
|
||||
/*
|
||||
* Internalize current pkg props dictionary from its
|
||||
* installed metadata directory.
|
||||
*/
|
||||
curpkg_propsd =
|
||||
xbps_dictionary_from_metadata_plist(curpkgn, XBPS_PKGPROPS);
|
||||
if (curpkg_propsd == NULL) {
|
||||
xbps_error_printf("%s: missing %s metadata file!\n",
|
||||
curpkgn, XBPS_PKGPROPS);
|
||||
return -1;
|
||||
}
|
||||
curpkg_rdeps =
|
||||
prop_dictionary_get(curpkg_propsd, "run_depends");
|
||||
if (prop_object_type(curpkg_rdeps) != PROP_TYPE_ARRAY) {
|
||||
/* package has no rundeps, skip */
|
||||
prop_object_release(curpkg_propsd);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Check for pkgpattern match with real packages...
|
||||
*/
|
||||
if (!xbps_match_pkgdep_in_array(curpkg_rdeps, pkgver)) {
|
||||
/*
|
||||
* ... otherwise check if package provides any virtual
|
||||
* package and is matched against any object in
|
||||
* run_depends.
|
||||
*/
|
||||
provides = prop_dictionary_get(pkgd, "provides");
|
||||
if (prop_object_type(provides) != PROP_TYPE_ARRAY) {
|
||||
/* doesn't provide any virtual pkg */
|
||||
prop_object_release(curpkg_propsd);
|
||||
continue;
|
||||
}
|
||||
if (!xbps_match_any_virtualpkg_in_rundeps(curpkg_rdeps,
|
||||
provides)) {
|
||||
/* doesn't match any virtual pkg */
|
||||
prop_object_release(curpkg_propsd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||
curpkgver = prop_dictionary_get(curpkg_propsd, "pkgver");
|
||||
if (prop_object_type(reqby) == PROP_TYPE_ARRAY) {
|
||||
/*
|
||||
* Now check that current pkgver has been registered into
|
||||
* its requiredby array.
|
||||
*/
|
||||
if (xbps_match_string_in_array(reqby,
|
||||
prop_string_cstring_nocopy(curpkgver))) {
|
||||
/*
|
||||
* Current package already requires our package,
|
||||
* this is good so skip it.
|
||||
*/
|
||||
prop_object_release(curpkg_propsd);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Missing requiredby array object, create it.
|
||||
*/
|
||||
reqby = prop_array_create();
|
||||
if (reqby == NULL) {
|
||||
prop_object_release(curpkg_propsd);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Replace current obj in regpkgdb and write new plist
|
||||
* file to disk.
|
||||
*/
|
||||
prop_array_add(reqby, curpkgver);
|
||||
prop_dictionary_set(pkgd, "requiredby", reqby);
|
||||
rv = xbps_array_replace_dict_by_name(regpkgs, obj, curpkgn);
|
||||
if (rv != 0) {
|
||||
xbps_error_printf("%s: failed to replace pkgd: %s\n",
|
||||
curpkgn, strerror(rv));
|
||||
return -1;
|
||||
}
|
||||
if (!prop_dictionary_set(xhp->regpkgdb, "packages", regpkgs)) {
|
||||
xbps_error_printf("%s: failed to set new regpkgdb "
|
||||
"packages array: %s", curpkgn, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if ((rv = xbps_regpkgdb_update(xhp, true)) != 0) {
|
||||
xbps_error_printf("failed to write regpkgdb plist: "
|
||||
" %s\n", strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
printf("%s: added requiredby entry for %s.\n",
|
||||
pkgver, prop_string_cstring_nocopy(curpkgver));
|
||||
prop_object_release(curpkg_propsd);
|
||||
if (crd.pkgdb_update) {
|
||||
if (!prop_dictionary_set(crd.pkgd, "requiredby", crd.pkgd_reqby))
|
||||
rv = -1;
|
||||
if (crd.pkgd_reqby_alloc)
|
||||
prop_object_release(crd.pkgd_reqby);
|
||||
}
|
||||
if (rv != 0)
|
||||
*pkgdb_update = false;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
int
|
||||
check_pkg_rundeps(const char *pkgname, void *arg)
|
||||
check_pkg_rundeps(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
{
|
||||
prop_dictionary_t pkg_propsd = arg;
|
||||
prop_object_t obj;
|
||||
@@ -53,6 +53,8 @@ check_pkg_rundeps(const char *pkgname, void *arg)
|
||||
const char *reqpkg;
|
||||
bool test_broken = false;
|
||||
|
||||
(void)pkgdb_update;
|
||||
|
||||
if (!xbps_pkg_has_rundeps(pkg_propsd))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -45,7 +45,7 @@
|
||||
* returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_symlinks(const char *pkgname, void *arg)
|
||||
check_pkg_symlinks(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
{
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_array_t array;
|
||||
@@ -56,6 +56,8 @@ check_pkg_symlinks(const char *pkgname, void *arg)
|
||||
char *path, buf[PATH_MAX];
|
||||
bool broken = false, test_broken = false;
|
||||
|
||||
(void)pkgdb_update;
|
||||
|
||||
array = prop_dictionary_get(pkg_filesd, "links");
|
||||
if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
|
||||
prop_array_count(array) > 0) {
|
||||
|
||||
@@ -56,11 +56,11 @@ int exec_transaction(bool, bool);
|
||||
int remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
||||
|
||||
/* from check.c */
|
||||
int check_pkg_integrity(prop_dictionary_t, const char *);
|
||||
int check_pkg_integrity(prop_dictionary_t, const char *, bool, bool *);
|
||||
int check_pkg_integrity_all(void);
|
||||
|
||||
#define CHECK_PKG_DECL(type) \
|
||||
int check_pkg_##type (const char *, void *)
|
||||
int check_pkg_##type (const char *, void *, bool *)
|
||||
|
||||
CHECK_PKG_DECL(autoinstall);
|
||||
CHECK_PKG_DECL(files);
|
||||
|
||||
@@ -203,7 +203,7 @@ main(int argc, char **argv)
|
||||
* Find the longest pkgver string to pretty print the output.
|
||||
*/
|
||||
lpc.pkgver_len = find_longest_pkgver(NULL);
|
||||
rv = xbps_regpkgdb_foreach_pkg_cb(list_pkgs_in_dict, &lpc);
|
||||
rv = xbps_pkgdb_foreach_pkg_cb(list_pkgs_in_dict, &lpc);
|
||||
if (rv == ENOENT) {
|
||||
printf("No packages currently registered.\n");
|
||||
rv = 0;
|
||||
@@ -281,7 +281,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = check_pkg_integrity_all();
|
||||
else
|
||||
rv = check_pkg_integrity(NULL, argv[1]);
|
||||
rv = check_pkg_integrity(NULL, argv[1], true, NULL);
|
||||
|
||||
} else if (strcasecmp(argv[0], "autoupdate") == 0) {
|
||||
/*
|
||||
@@ -342,7 +342,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
rv = xbps_regpkgdb_foreach_pkg_cb(list_manual_pkgs, NULL);
|
||||
rv = xbps_pkgdb_foreach_pkg_cb(list_manual_pkgs, NULL);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show-revdeps") == 0) {
|
||||
/*
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
@@ -88,9 +87,6 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
|
||||
prop_object_t obj;
|
||||
char *key, *p, *saveptr;
|
||||
|
||||
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
|
||||
assert(keys != NULL);
|
||||
|
||||
if (strchr(keys, ',') == NULL) {
|
||||
obj = prop_dictionary_get(d, keys);
|
||||
if (obj == NULL)
|
||||
@@ -99,7 +95,8 @@ show_pkg_info_one(prop_dictionary_t d, const char *keys)
|
||||
return;
|
||||
}
|
||||
key = strdup(keys);
|
||||
assert(key != NULL);
|
||||
if (key == NULL)
|
||||
abort();
|
||||
for ((p = strtok_r(key, ",", &saveptr)); p;
|
||||
(p = strtok_r(NULL, ",", &saveptr))) {
|
||||
obj = prop_dictionary_get(d, p);
|
||||
@@ -118,9 +115,6 @@ show_pkg_info(prop_dictionary_t dict)
|
||||
const char *keyname;
|
||||
size_t i;
|
||||
|
||||
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
||||
assert(prop_dictionary_count(dict) != 0);
|
||||
|
||||
all_keys = prop_dictionary_all_keys(dict);
|
||||
for (i = 0; i < prop_array_count(all_keys); i++) {
|
||||
keysym = prop_array_get(all_keys, i);
|
||||
@@ -151,8 +145,7 @@ show_pkg_files(prop_dictionary_t filesd)
|
||||
continue;
|
||||
|
||||
array = prop_dictionary_get(filesd, keyname);
|
||||
if (prop_object_type(array) != PROP_TYPE_ARRAY ||
|
||||
prop_array_count(array) == 0)
|
||||
if (array == NULL || prop_array_count(array) == 0)
|
||||
continue;
|
||||
|
||||
for (x = 0; x < prop_array_count(array); x++) {
|
||||
@@ -194,7 +187,7 @@ find_longest_pkgver(prop_object_t o)
|
||||
(void)xbps_callback_array_iter(o,
|
||||
_find_longest_pkgver_cb, &len);
|
||||
else
|
||||
(void)xbps_regpkgdb_foreach_pkg_cb(
|
||||
(void)xbps_pkgdb_foreach_pkg_cb(
|
||||
_find_longest_pkgver_cb, &len);
|
||||
|
||||
return len;
|
||||
@@ -206,7 +199,6 @@ list_strings_in_array(prop_object_t obj, void *arg, bool *loop_done)
|
||||
(void)arg;
|
||||
(void)loop_done;
|
||||
|
||||
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||
print_package_line(prop_string_cstring_nocopy(obj), false);
|
||||
|
||||
return 0;
|
||||
@@ -219,7 +211,6 @@ list_strings_sep_in_array(prop_object_t obj, void *arg, bool *loop_done)
|
||||
|
||||
(void)loop_done;
|
||||
|
||||
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||
printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.Dd January 5, 2012
|
||||
.Dd January 19, 2012
|
||||
.Os Void GNU/Linux
|
||||
.Dt xbps-bin 8
|
||||
.Sh NAME
|
||||
@@ -254,8 +254,8 @@ XBPS global metadata directory.
|
||||
Installed package metadata list of files.
|
||||
.It Pa /var/db/xbps/metadata/<pkgname>/props.plist
|
||||
Installed package metadata properties.
|
||||
.It Pa /var/db/xbps/regpkgdb.plist
|
||||
XBPS master packages/properties database plist file.
|
||||
.It Pa /var/db/xbps/pkgdb.plist
|
||||
XBPS master package database plist file.
|
||||
.It Pa /var/cache/xbps
|
||||
XBPS cache directory for downloaded binary packages.
|
||||
.Sh EXAMPLES
|
||||
|
||||
Reference in New Issue
Block a user