libxbps: require a pointer to xbps_handle in functions that need it.
This removes 2 global vars from lib/initend.c and easier to know what functions require access to xbps_handle.
This commit is contained in:
@@ -42,7 +42,10 @@ struct checkpkg {
|
||||
};
|
||||
|
||||
static int
|
||||
cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
||||
cb_pkg_integrity(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct checkpkg *cpkg = arg;
|
||||
const char *pkgname, *version;
|
||||
@@ -54,7 +57,7 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
printf("[%zu/%zu] checking %s-%s ...\n",
|
||||
cpkg->npkgs, cpkg->totalpkgs, pkgname, version);
|
||||
if (check_pkg_integrity(obj, pkgname, false, &flush) != 0)
|
||||
if (check_pkg_integrity(xhp, obj, pkgname, false, &flush) != 0)
|
||||
cpkg->nbrokenpkgs++;
|
||||
else
|
||||
printf("\033[1A\033[K");
|
||||
@@ -67,20 +70,19 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
||||
}
|
||||
|
||||
int
|
||||
check_pkg_integrity_all(void)
|
||||
check_pkg_integrity_all(struct xbps_handle *xhp)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
struct checkpkg cpkg;
|
||||
int rv;
|
||||
|
||||
memset(&cpkg, 0, sizeof(cpkg));
|
||||
/* force an update to get total pkg count */
|
||||
(void)xbps_pkgdb_update(false);
|
||||
(void)xbps_pkgdb_update(xhp, false);
|
||||
cpkg.totalpkgs = prop_array_count(xhp->pkgdb);
|
||||
|
||||
(void)xbps_pkgdb_foreach_cb(cb_pkg_integrity, &cpkg);
|
||||
(void)xbps_pkgdb_foreach_cb(xhp, cb_pkg_integrity, &cpkg);
|
||||
if (cpkg.flush) {
|
||||
if ((rv = xbps_pkgdb_update(true)) != 0) {
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) {
|
||||
xbps_error_printf("failed to write pkgdb: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
@@ -92,7 +94,8 @@ check_pkg_integrity_all(void)
|
||||
}
|
||||
|
||||
int
|
||||
check_pkg_integrity(prop_dictionary_t pkgd,
|
||||
check_pkg_integrity(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *pkgname,
|
||||
bool flush,
|
||||
bool *setflush)
|
||||
@@ -105,11 +108,11 @@ check_pkg_integrity(prop_dictionary_t pkgd,
|
||||
|
||||
/* find real pkg by name */
|
||||
if (pkgd == NULL) {
|
||||
opkgd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||
opkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
if (opkgd == NULL) {
|
||||
/* find virtual pkg by name */
|
||||
opkgd = xbps_find_virtualpkg_dict_installed(pkgname,
|
||||
false);
|
||||
opkgd = xbps_find_virtualpkg_dict_installed(xhp,
|
||||
pkgname, false);
|
||||
}
|
||||
if (opkgd == NULL) {
|
||||
printf("Package %s is not installed.\n", pkgname);
|
||||
@@ -119,7 +122,7 @@ check_pkg_integrity(prop_dictionary_t pkgd,
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
propsd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
propsd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS);
|
||||
if (propsd == NULL) {
|
||||
xbps_error_printf("%s: unexistent %s or invalid metadata "
|
||||
"file.\n", pkgname, XBPS_PKGPROPS);
|
||||
@@ -134,7 +137,7 @@ check_pkg_integrity(prop_dictionary_t pkgd,
|
||||
/*
|
||||
* Check for files.plist metadata file.
|
||||
*/
|
||||
filesd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
filesd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
|
||||
if (filesd == NULL) {
|
||||
xbps_error_printf("%s: unexistent %s or invalid metadata "
|
||||
"file.\n", pkgname, XBPS_PKGFILES);
|
||||
@@ -147,9 +150,9 @@ check_pkg_integrity(prop_dictionary_t pkgd,
|
||||
goto out;
|
||||
}
|
||||
|
||||
#define RUN_PKG_CHECK(name, arg, arg2) \
|
||||
#define RUN_PKG_CHECK(x, name, arg, arg2) \
|
||||
do { \
|
||||
rv = check_pkg_##name(pkgname, arg, arg2); \
|
||||
rv = check_pkg_##name(x, pkgname, arg, arg2); \
|
||||
if (rv) \
|
||||
broken = true; \
|
||||
else if (rv == -1) { \
|
||||
@@ -160,14 +163,14 @@ do { \
|
||||
} while (0)
|
||||
|
||||
/* Execute pkg checks */
|
||||
RUN_PKG_CHECK(files, filesd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(symlinks, filesd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(rundeps, propsd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(requiredby, pkgd ? pkgd : opkgd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(autoinstall, pkgd ? pkgd : opkgd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(xhp, files, filesd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(xhp, symlinks, filesd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(xhp, rundeps, propsd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(xhp, requiredby, pkgd ? pkgd : opkgd, &pkgdb_update);
|
||||
RUN_PKG_CHECK(xhp, autoinstall, pkgd ? pkgd : opkgd, &pkgdb_update);
|
||||
|
||||
if (flush && pkgdb_update) {
|
||||
if (!xbps_pkgdb_replace_pkgd(opkgd, pkgname, false, true)) {
|
||||
if (!xbps_pkgdb_replace_pkgd(xhp, opkgd, pkgname, false, true)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -47,12 +47,16 @@
|
||||
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_autoinstall(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
check_pkg_autoinstall(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
void *arg,
|
||||
bool *pkgdb_update)
|
||||
{
|
||||
prop_dictionary_t pkgd = arg;
|
||||
prop_array_t reqby;
|
||||
bool autoinst = false;
|
||||
|
||||
(void)xhp;
|
||||
/*
|
||||
* Check if package has been installed manually but any other
|
||||
* package is currently depending on it; in that case the package
|
||||
|
||||
@@ -46,9 +46,11 @@
|
||||
* Return 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_files(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
check_pkg_files(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
void *arg,
|
||||
bool *pkgdb_update)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_array_t array;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
|
||||
@@ -43,7 +43,10 @@ struct check_reqby_data {
|
||||
};
|
||||
|
||||
static int
|
||||
check_reqby_pkg_cb(prop_object_t obj, void *arg, bool *done)
|
||||
check_reqby_pkg_cb(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct check_reqby_data *crd = arg;
|
||||
prop_array_t curpkg_rdeps, provides;
|
||||
@@ -63,7 +66,7 @@ check_reqby_pkg_cb(prop_object_t obj, void *arg, bool *done)
|
||||
* installed metadata directory.
|
||||
*/
|
||||
curpkg_propsd =
|
||||
xbps_dictionary_from_metadata_plist(curpkgn, XBPS_PKGPROPS);
|
||||
xbps_dictionary_from_metadata_plist(xhp, curpkgn, XBPS_PKGPROPS);
|
||||
if (curpkg_propsd == NULL) {
|
||||
xbps_error_printf("%s: missing %s metadata file!\n",
|
||||
curpkgn, XBPS_PKGPROPS);
|
||||
@@ -142,7 +145,8 @@ check_reqby_pkg_cb(prop_object_t obj, void *arg, bool *done)
|
||||
* Removes unused entries in pkg's requiredby array.
|
||||
*/
|
||||
static bool
|
||||
remove_stale_entries_in_reqby(struct check_reqby_data *crd)
|
||||
remove_stale_entries_in_reqby(struct xbps_handle *xhp,
|
||||
struct check_reqby_data *crd)
|
||||
{
|
||||
prop_array_t reqby;
|
||||
prop_dictionary_t pkgd;
|
||||
@@ -158,7 +162,7 @@ remove_stale_entries_in_reqby(struct check_reqby_data *crd)
|
||||
|
||||
for (i = 0; i < prop_array_count(reqby); i++) {
|
||||
prop_array_get_cstring_nocopy(reqby, i, &str);
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd_by_pkgver(str)) != NULL) {
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd_by_pkgver(xhp, str)) != NULL) {
|
||||
prop_object_release(pkgd);
|
||||
continue;
|
||||
}
|
||||
@@ -185,7 +189,10 @@ remove_stale_entries_in_reqby(struct check_reqby_data *crd)
|
||||
* Returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_requiredby(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
check_pkg_requiredby(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
void *arg,
|
||||
bool *pkgdb_update)
|
||||
{
|
||||
prop_dictionary_t pkgd = arg;
|
||||
struct check_reqby_data crd;
|
||||
@@ -198,7 +205,7 @@ check_pkg_requiredby(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &crd.pkgver);
|
||||
|
||||
/* missing reqby entries in pkgs */
|
||||
rv = xbps_pkgdb_foreach_cb(check_reqby_pkg_cb, &crd);
|
||||
rv = xbps_pkgdb_foreach_cb(xhp, check_reqby_pkg_cb, &crd);
|
||||
if (rv < 0) {
|
||||
return rv;
|
||||
} else if (rv == 1) {
|
||||
@@ -210,7 +217,7 @@ check_pkg_requiredby(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
printf("%s: requiredby fix done!\n\n", crd.pkgver);
|
||||
}
|
||||
/* remove stale entries in pkg's reqby */
|
||||
if (remove_stale_entries_in_reqby(&crd))
|
||||
if (remove_stale_entries_in_reqby(xhp, &crd))
|
||||
*pkgdb_update = true;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -45,7 +45,10 @@
|
||||
*/
|
||||
|
||||
int
|
||||
check_pkg_rundeps(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
check_pkg_rundeps(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
void *arg,
|
||||
bool *pkgdb_update)
|
||||
{
|
||||
prop_dictionary_t pkg_propsd = arg;
|
||||
prop_object_t obj;
|
||||
@@ -68,7 +71,7 @@ check_pkg_rundeps(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
prop_object_iterator_release(iter);
|
||||
return -1;
|
||||
}
|
||||
if (xbps_check_is_installed_pkg_by_pattern(reqpkg) <= 0) {
|
||||
if (xbps_check_is_installed_pkg_by_pattern(xhp, reqpkg) <= 0) {
|
||||
xbps_error_printf("%s: dependency not satisfied: %s\n",
|
||||
pkgname, reqpkg);
|
||||
test_broken = true;
|
||||
|
||||
@@ -45,9 +45,11 @@
|
||||
* returns 0 if test ran successfully, 1 otherwise and -1 on error.
|
||||
*/
|
||||
int
|
||||
check_pkg_symlinks(const char *pkgname, void *arg, bool *pkgdb_update)
|
||||
check_pkg_symlinks(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
void *arg,
|
||||
bool *pkgdb_update)
|
||||
{
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_array_t array;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <xbps_api.h>
|
||||
|
||||
#ifndef __UNCONST
|
||||
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||
#endif
|
||||
|
||||
struct xferstat {
|
||||
struct timeval start;
|
||||
struct timeval last;
|
||||
@@ -41,22 +45,26 @@ struct list_pkgver_cb {
|
||||
};
|
||||
|
||||
/* from transaction.c */
|
||||
int install_new_pkg(const char *, bool);
|
||||
int update_pkg(const char *);
|
||||
int remove_pkg(const char *, bool);
|
||||
int remove_pkg_orphans(bool, bool);
|
||||
int dist_upgrade(bool, bool, bool);
|
||||
int exec_transaction(bool, bool, bool);
|
||||
int install_new_pkg(struct xbps_handle *, const char *, bool);
|
||||
int update_pkg(struct xbps_handle *, const char *);
|
||||
int remove_pkg(struct xbps_handle *, const char *, bool);
|
||||
int remove_pkg_orphans(struct xbps_handle *, bool, bool);
|
||||
int dist_upgrade(struct xbps_handle *, bool, bool, bool);
|
||||
int exec_transaction(struct xbps_handle *, bool, bool, bool);
|
||||
|
||||
/* from remove.c */
|
||||
int remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
||||
|
||||
/* from check.c */
|
||||
int check_pkg_integrity(prop_dictionary_t, const char *, bool, bool *);
|
||||
int check_pkg_integrity_all(void);
|
||||
int check_pkg_integrity(struct xbps_handle *,
|
||||
prop_dictionary_t,
|
||||
const char *,
|
||||
bool,
|
||||
bool *);
|
||||
int check_pkg_integrity_all(struct xbps_handle *);
|
||||
|
||||
#define CHECK_PKG_DECL(type) \
|
||||
int check_pkg_##type (const char *, void *, bool *)
|
||||
int check_pkg_##type (struct xbps_handle *, const char *, void *, bool *)
|
||||
|
||||
CHECK_PKG_DECL(autoinstall);
|
||||
CHECK_PKG_DECL(files);
|
||||
@@ -65,43 +73,54 @@ CHECK_PKG_DECL(symlinks);
|
||||
CHECK_PKG_DECL(requiredby);
|
||||
|
||||
/* from show-deps.c */
|
||||
int show_pkg_deps(const char *);
|
||||
int show_pkg_reverse_deps(const char *);
|
||||
int show_pkg_deps(struct xbps_handle *, const char *);
|
||||
int show_pkg_reverse_deps(struct xbps_handle *, const char *);
|
||||
|
||||
/* from show-info-files.c */
|
||||
int show_pkg_info_from_metadir(const char *, const char *);
|
||||
int show_pkg_files_from_metadir(const char *);
|
||||
int show_pkg_info_from_metadir(struct xbps_handle *, const char *, const char *);
|
||||
int show_pkg_files_from_metadir(struct xbps_handle *, const char *);
|
||||
|
||||
/* from show-orphans.c */
|
||||
int show_orphans(void);
|
||||
int show_orphans(struct xbps_handle *);
|
||||
|
||||
/* from find-files.c */
|
||||
int find_files_in_packages(int, char **);
|
||||
int find_files_in_packages(struct xbps_handle *, int, char **);
|
||||
|
||||
/* from question.c */
|
||||
bool yesno(const char *, ...);
|
||||
bool noyes(const char *, ...);
|
||||
|
||||
/* from fetch_cb.c */
|
||||
void fetch_file_progress_cb(const struct xbps_fetch_cb_data *, void *);
|
||||
void fetch_file_progress_cb(struct xbps_handle *,
|
||||
struct xbps_fetch_cb_data *,
|
||||
void *);
|
||||
|
||||
/* from state_cb.c */
|
||||
void state_cb(const struct xbps_state_cb_data *, void *);
|
||||
void state_cb(struct xbps_handle *,
|
||||
struct xbps_state_cb_data *,
|
||||
void *);
|
||||
|
||||
/* from unpack_cb.c */
|
||||
void unpack_progress_cb_verbose(const struct xbps_unpack_cb_data *, void *);
|
||||
void unpack_progress_cb(const struct xbps_unpack_cb_data *, void *);
|
||||
void unpack_progress_cb_verbose(struct xbps_handle *,
|
||||
struct xbps_unpack_cb_data *,
|
||||
void *);
|
||||
void unpack_progress_cb(struct xbps_handle *,
|
||||
struct xbps_unpack_cb_data *,
|
||||
void *);
|
||||
|
||||
/* From util.c */
|
||||
int show_pkg_files(prop_dictionary_t);
|
||||
void show_pkg_info(prop_dictionary_t);
|
||||
void show_pkg_info_one(prop_dictionary_t, const char *);
|
||||
int list_strings_sep_in_array(prop_object_t, void *, bool *);
|
||||
size_t find_longest_pkgver(prop_object_t);
|
||||
int list_strings_sep_in_array(struct xbps_handle *,
|
||||
prop_object_t,
|
||||
void *,
|
||||
bool *);
|
||||
size_t find_longest_pkgver(struct xbps_handle *, prop_object_t);
|
||||
void print_package_line(const char *, bool);
|
||||
|
||||
/* from list.c */
|
||||
int list_pkgs_in_dict(prop_object_t, void *, bool *);
|
||||
int list_manual_pkgs(prop_object_t, void *, bool *);
|
||||
int list_pkgs_in_dict(struct xbps_handle *, prop_object_t, void *, bool *);
|
||||
int list_manual_pkgs(struct xbps_handle *, prop_object_t, void *, bool *);
|
||||
|
||||
#endif /* !_XBPS_BIN_DEFS_H_ */
|
||||
|
||||
@@ -61,7 +61,7 @@ get_time(struct timeval *tvp)
|
||||
* Compute and display ETA
|
||||
*/
|
||||
static const char *
|
||||
stat_eta(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
stat_eta(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
{
|
||||
struct xferstat *xfer = cbdata;
|
||||
static char str[16];
|
||||
@@ -100,7 +100,7 @@ compare_double(const double a, const double b)
|
||||
* Compute and display transfer rate
|
||||
*/
|
||||
static const char *
|
||||
stat_bps(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
stat_bps(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
{
|
||||
struct xferstat *xfer = cbdata;
|
||||
static char str[16];
|
||||
@@ -124,7 +124,7 @@ stat_bps(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
* Update the stats display
|
||||
*/
|
||||
static void
|
||||
stat_display(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
stat_display(struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
{
|
||||
struct xferstat *xfer = cbdata;
|
||||
struct timeval now;
|
||||
@@ -151,11 +151,15 @@ stat_display(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
}
|
||||
|
||||
void
|
||||
fetch_file_progress_cb(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
fetch_file_progress_cb(struct xbps_handle *xhp,
|
||||
struct xbps_fetch_cb_data *xfpd,
|
||||
void *cbdata)
|
||||
{
|
||||
struct xferstat *xfer = cbdata;
|
||||
char size[8];
|
||||
|
||||
(void)xhp;
|
||||
|
||||
if (xfpd->cb_start) {
|
||||
/* start transfer stats */
|
||||
get_time(&xfer->start);
|
||||
|
||||
@@ -75,9 +75,8 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd,
|
||||
}
|
||||
|
||||
int
|
||||
find_files_in_packages(int npatterns, char **patterns)
|
||||
find_files_in_packages(struct xbps_handle *xhp, int npatterns, char **patterns)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkg_filesd;
|
||||
prop_array_t files_keys;
|
||||
DIR *dirp;
|
||||
@@ -86,7 +85,6 @@ find_files_in_packages(int npatterns, char **patterns)
|
||||
int rv = 0;
|
||||
unsigned int i, count;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
path = xbps_xasprintf("%s/metadata", xhp->metadir);
|
||||
if (path == NULL)
|
||||
return -1;
|
||||
@@ -101,8 +99,8 @@ find_files_in_packages(int npatterns, char **patterns)
|
||||
(strcmp(dp->d_name, "..") == 0))
|
||||
continue;
|
||||
|
||||
pkg_filesd = xbps_dictionary_from_metadata_plist(dp->d_name,
|
||||
XBPS_PKGFILES);
|
||||
pkg_filesd = xbps_dictionary_from_metadata_plist(xhp,
|
||||
dp->d_name, XBPS_PKGFILES);
|
||||
if (pkg_filesd == NULL) {
|
||||
if (errno == ENOENT)
|
||||
continue;
|
||||
|
||||
@@ -33,7 +33,10 @@
|
||||
#include "compat.h"
|
||||
|
||||
int
|
||||
list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
|
||||
list_pkgs_in_dict(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
struct list_pkgver_cb *lpc = arg;
|
||||
const char *pkgver, *short_desc, *arch;
|
||||
@@ -42,6 +45,7 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
|
||||
size_t i = 0;
|
||||
bool chkarch;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
@@ -82,11 +86,15 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
|
||||
}
|
||||
|
||||
int
|
||||
list_manual_pkgs(prop_object_t obj, void *arg, bool *loop_done)
|
||||
list_manual_pkgs(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
const char *pkgver;
|
||||
bool automatic = false;
|
||||
|
||||
(void)xhp;
|
||||
(void)arg;
|
||||
(void)loop_done;
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
static void __attribute__((noreturn))
|
||||
usage(bool fail)
|
||||
{
|
||||
xbps_end();
|
||||
fprintf(stderr,
|
||||
"Usage: xbps-bin [options] target [arguments]\n\n"
|
||||
"[options]\n"
|
||||
@@ -100,7 +99,6 @@ usage(bool fail)
|
||||
static void __attribute__((noreturn))
|
||||
cleanup(int signum)
|
||||
{
|
||||
xbps_end();
|
||||
exit(signum);
|
||||
}
|
||||
|
||||
@@ -256,8 +254,8 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Find the longest pkgver string to pretty print the output.
|
||||
*/
|
||||
lpc.pkgver_len = find_longest_pkgver(NULL);
|
||||
rv = xbps_pkgdb_foreach_cb(list_pkgs_in_dict, &lpc);
|
||||
lpc.pkgver_len = find_longest_pkgver(&xh, NULL);
|
||||
rv = xbps_pkgdb_foreach_cb(&xh, list_pkgs_in_dict, &lpc);
|
||||
if (rv == ENOENT) {
|
||||
printf("No packages currently registered.\n");
|
||||
rv = 0;
|
||||
@@ -268,28 +266,28 @@ main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage(true);
|
||||
|
||||
if (sync && ((rv = xbps_rpool_sync(NULL)) != 0))
|
||||
if (sync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
||||
goto out;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = install_new_pkg(argv[i], reinstall)) != 0)
|
||||
if ((rv = install_new_pkg(&xh, argv[i], reinstall)) != 0)
|
||||
goto out;
|
||||
|
||||
rv = exec_transaction(yes, dry_run, show_download_pkglist_url);
|
||||
rv = exec_transaction(&xh, yes, dry_run, show_download_pkglist_url);
|
||||
|
||||
} else if (strcasecmp(argv[0], "update") == 0) {
|
||||
/* Update an installed package. */
|
||||
if (argc < 2)
|
||||
usage(true);
|
||||
|
||||
if (sync && ((rv = xbps_rpool_sync(NULL)) != 0))
|
||||
if (sync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
||||
goto out;
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = update_pkg(argv[i])) != 0)
|
||||
if ((rv = update_pkg(&xh, argv[i])) != 0)
|
||||
goto out;
|
||||
|
||||
rv = exec_transaction(yes, dry_run, show_download_pkglist_url);
|
||||
rv = exec_transaction(&xh, yes, dry_run, show_download_pkglist_url);
|
||||
|
||||
} else if (strcasecmp(argv[0], "remove") == 0) {
|
||||
/* Removes a package. */
|
||||
@@ -297,7 +295,7 @@ main(int argc, char **argv)
|
||||
usage(true);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
rv = remove_pkg(argv[i], recursive_rm);
|
||||
rv = remove_pkg(&xh, argv[i], recursive_rm);
|
||||
if (rv == 0)
|
||||
continue;
|
||||
else if (rv != EEXIST)
|
||||
@@ -309,14 +307,14 @@ main(int argc, char **argv)
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
rv = exec_transaction(yes, dry_run, false);
|
||||
rv = exec_transaction(&xh, yes, dry_run, false);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
/* Shows info about an installed binary package. */
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = show_pkg_info_from_metadir(argv[1], option);
|
||||
rv = show_pkg_info_from_metadir(&xh, argv[1], option);
|
||||
if (rv != 0) {
|
||||
printf("Package %s not installed.\n", argv[1]);
|
||||
goto out;
|
||||
@@ -327,7 +325,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = show_pkg_files_from_metadir(argv[1]);
|
||||
rv = show_pkg_files_from_metadir(&xh, argv[1]);
|
||||
if (rv != 0) {
|
||||
printf("Package %s not installed.\n", argv[1]);
|
||||
goto out;
|
||||
@@ -339,9 +337,9 @@ main(int argc, char **argv)
|
||||
usage(true);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = check_pkg_integrity_all();
|
||||
rv = check_pkg_integrity_all(&xh);
|
||||
else
|
||||
rv = check_pkg_integrity(NULL, argv[1], true, NULL);
|
||||
rv = check_pkg_integrity(&xh, NULL, argv[1], true, NULL);
|
||||
|
||||
} else if ((strcasecmp(argv[0], "dist-upgrade") == 0) ||
|
||||
(strcasecmp(argv[0], "autoupdate") == 0)) {
|
||||
@@ -351,10 +349,10 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage(true);
|
||||
|
||||
if (sync && ((rv = xbps_rpool_sync(NULL)) != 0))
|
||||
if (sync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
||||
goto out;
|
||||
|
||||
rv = dist_upgrade(yes, dry_run, show_download_pkglist_url);
|
||||
rv = dist_upgrade(&xh, yes, dry_run, show_download_pkglist_url);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show-orphans") == 0) {
|
||||
/*
|
||||
@@ -364,7 +362,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage(true);
|
||||
|
||||
rv = show_orphans();
|
||||
rv = show_orphans(&xh);
|
||||
|
||||
} else if ((strcasecmp(argv[0], "remove-orphans") == 0) ||
|
||||
(strcasecmp(argv[0], "autoremove") == 0)) {
|
||||
@@ -376,7 +374,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage(true);
|
||||
|
||||
rv = remove_pkg_orphans(yes, dry_run);
|
||||
rv = remove_pkg_orphans(&xh, yes, dry_run);
|
||||
|
||||
} else if (strcasecmp(argv[0], "reconfigure") == 0) {
|
||||
/*
|
||||
@@ -386,9 +384,9 @@ main(int argc, char **argv)
|
||||
usage(true);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = xbps_configure_packages(true);
|
||||
rv = xbps_configure_packages(&xh, true);
|
||||
else
|
||||
rv = xbps_configure_pkg(argv[1], true, false, true);
|
||||
rv = xbps_configure_pkg(&xh, argv[1], true, false, true);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show-deps") == 0) {
|
||||
/*
|
||||
@@ -397,7 +395,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = show_pkg_deps(argv[1]);
|
||||
rv = show_pkg_deps(&xh, argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "list-manual") == 0) {
|
||||
/*
|
||||
@@ -407,7 +405,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage(true);
|
||||
|
||||
rv = xbps_pkgdb_foreach_cb(list_manual_pkgs, NULL);
|
||||
rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show-revdeps") == 0) {
|
||||
/*
|
||||
@@ -416,7 +414,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = show_pkg_reverse_deps(argv[1]);
|
||||
rv = show_pkg_reverse_deps(&xh, argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "find-files") == 0) {
|
||||
/*
|
||||
@@ -426,13 +424,13 @@ main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage(true);
|
||||
|
||||
rv = find_files_in_packages(argc, argv);
|
||||
rv = find_files_in_packages(&xh, argc, argv);
|
||||
|
||||
} else {
|
||||
usage(true);
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end();
|
||||
xbps_end(&xh);
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "../xbps-repo/defs.h"
|
||||
|
||||
int
|
||||
show_pkg_deps(const char *pkgname)
|
||||
show_pkg_deps(struct xbps_handle *xhp, const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t propsd;
|
||||
int rv = 0;
|
||||
@@ -45,14 +45,15 @@ show_pkg_deps(const char *pkgname)
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
propsd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
propsd = xbps_dictionary_from_metadata_plist(xhp,
|
||||
pkgname, XBPS_PKGPROPS);
|
||||
if (propsd == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: unexistent %s metadata file.\n", pkgname,
|
||||
XBPS_PKGPROPS);
|
||||
return errno;
|
||||
}
|
||||
rv = xbps_callback_array_iter_in_dict(propsd, "run_depends",
|
||||
rv = xbps_callback_array_iter_in_dict(xhp, propsd, "run_depends",
|
||||
list_strings_sep_in_array, NULL);
|
||||
prop_object_release(propsd);
|
||||
|
||||
@@ -60,20 +61,20 @@ show_pkg_deps(const char *pkgname)
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_reverse_deps(const char *pkgname)
|
||||
show_pkg_reverse_deps(struct xbps_handle *xhp, const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
int rv = 0;
|
||||
|
||||
pkgd = xbps_find_virtualpkg_dict_installed(pkgname, false);
|
||||
pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false);
|
||||
if (pkgd == NULL) {
|
||||
pkgd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
if (pkgd == NULL) {
|
||||
printf("Package %s is not installed.\n", pkgname);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
rv = xbps_callback_array_iter_in_dict(pkgd, "requiredby",
|
||||
rv = xbps_callback_array_iter_in_dict(xhp, pkgd, "requiredby",
|
||||
list_strings_sep_in_array, NULL);
|
||||
prop_object_release(pkgd);
|
||||
|
||||
|
||||
@@ -35,11 +35,13 @@
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
show_pkg_info_from_metadir(const char *pkgname, const char *option)
|
||||
show_pkg_info_from_metadir(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *option)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
|
||||
d = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS);
|
||||
if (d == NULL)
|
||||
return EINVAL;
|
||||
|
||||
@@ -53,12 +55,12 @@ show_pkg_info_from_metadir(const char *pkgname, const char *option)
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_files_from_metadir(const char *pkgname)
|
||||
show_pkg_files_from_metadir(struct xbps_handle *xhp, const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
int rv = 0;
|
||||
|
||||
d = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
|
||||
if (d == NULL)
|
||||
return EINVAL;
|
||||
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
show_orphans(void)
|
||||
show_orphans(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_array_t orphans;
|
||||
prop_object_iterator_t iter;
|
||||
prop_object_t obj;
|
||||
const char *pkgver;
|
||||
|
||||
orphans = xbps_find_pkg_orphans(NULL);
|
||||
orphans = xbps_find_pkg_orphans(xhp, NULL);
|
||||
if (orphans == NULL)
|
||||
return EINVAL;
|
||||
|
||||
|
||||
@@ -31,9 +31,10 @@
|
||||
#include "defs.h"
|
||||
|
||||
void
|
||||
state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
state_cb(struct xbps_handle *xhp,
|
||||
struct xbps_state_cb_data *xscd,
|
||||
void *cbdata)
|
||||
{
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_dictionary_t pkgd;
|
||||
const char *version;
|
||||
bool syslog_enabled = false;
|
||||
@@ -85,7 +86,8 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
xscd->pkgname, xscd->version);
|
||||
break;
|
||||
case XBPS_STATE_UPDATE:
|
||||
pkgd = xbps_find_pkg_dict_installed(xscd->pkgname, false);
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp,
|
||||
xscd->pkgname, false);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
|
||||
prop_object_release(pkgd);
|
||||
printf("Updating `%s' (`%s' to `%s') ...\n", xscd->pkgname,
|
||||
@@ -152,7 +154,8 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata)
|
||||
syslog(LOG_ERR, "%s", xscd->desc);
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf("unknown state %d\n", xscd->state);
|
||||
xbps_dbg_printf(xhp,
|
||||
"unknown state %d\n", xscd->state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ show_actions(prop_object_iterator_t iter)
|
||||
}
|
||||
|
||||
static int
|
||||
show_binpkgs_url(prop_object_iterator_t iter)
|
||||
show_binpkgs_url(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
{
|
||||
prop_object_t obj;
|
||||
const char *repoloc, *trans;
|
||||
@@ -117,7 +117,7 @@ show_binpkgs_url(prop_object_iterator_t iter)
|
||||
if (!xbps_check_is_repository_uri_remote(repoloc))
|
||||
continue;
|
||||
|
||||
binfile = xbps_path_from_repository_uri(obj, repoloc);
|
||||
binfile = xbps_path_from_repository_uri(xhp, obj, repoloc);
|
||||
if (binfile == NULL)
|
||||
return errno;
|
||||
/*
|
||||
@@ -226,7 +226,10 @@ show_transaction_sizes(struct transaction *trans)
|
||||
}
|
||||
|
||||
int
|
||||
dist_upgrade(bool yes, bool dry_run, bool show_download_pkglist_url)
|
||||
dist_upgrade(struct xbps_handle *xhp,
|
||||
bool yes,
|
||||
bool dry_run,
|
||||
bool show_download_pkglist_url)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -234,7 +237,7 @@ dist_upgrade(bool yes, bool dry_run, bool show_download_pkglist_url)
|
||||
* Update all currently installed packages, aka
|
||||
* "xbps-bin autoupdate".
|
||||
*/
|
||||
if ((rv = xbps_transaction_update_packages()) != 0) {
|
||||
if ((rv = xbps_transaction_update_packages(xhp)) != 0) {
|
||||
if (rv == ENOENT) {
|
||||
printf("No packages currently registered.\n");
|
||||
return 0;
|
||||
@@ -251,15 +254,15 @@ dist_upgrade(bool yes, bool dry_run, bool show_download_pkglist_url)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return exec_transaction(yes, dry_run, show_download_pkglist_url);
|
||||
return exec_transaction(xhp, yes, dry_run, show_download_pkglist_url);
|
||||
}
|
||||
|
||||
int
|
||||
remove_pkg_orphans(bool yes, bool dry_run)
|
||||
remove_pkg_orphans(struct xbps_handle *xhp, bool yes, bool dry_run)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if ((rv = xbps_transaction_autoremove_pkgs()) != 0) {
|
||||
if ((rv = xbps_transaction_autoremove_pkgs(xhp)) != 0) {
|
||||
if (rv == ENOENT) {
|
||||
printf("No package orphans were found.\n");
|
||||
return 0;
|
||||
@@ -269,15 +272,15 @@ remove_pkg_orphans(bool yes, bool dry_run)
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
return exec_transaction(yes, dry_run, false);
|
||||
return exec_transaction(xhp, yes, dry_run, false);
|
||||
}
|
||||
|
||||
int
|
||||
install_new_pkg(const char *pkg, bool reinstall)
|
||||
install_new_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if ((rv = xbps_transaction_install_pkg(pkg, reinstall)) != 0) {
|
||||
if ((rv = xbps_transaction_install_pkg(xhp, pkg, reinstall)) != 0) {
|
||||
if (rv == EEXIST) {
|
||||
printf("Package `%s' already installed.\n", pkg);
|
||||
} else if (rv == ENOENT) {
|
||||
@@ -296,11 +299,11 @@ install_new_pkg(const char *pkg, bool reinstall)
|
||||
}
|
||||
|
||||
int
|
||||
update_pkg(const char *pkgname)
|
||||
update_pkg(struct xbps_handle *xhp, const char *pkgname)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = xbps_transaction_update_pkg(pkgname);
|
||||
rv = xbps_transaction_update_pkg(xhp, pkgname);
|
||||
if (rv == EEXIST)
|
||||
printf("Package '%s' is up to date.\n", pkgname);
|
||||
else if (rv == ENOENT)
|
||||
@@ -320,7 +323,7 @@ update_pkg(const char *pkgname)
|
||||
}
|
||||
|
||||
int
|
||||
remove_pkg(const char *pkgname, bool recursive)
|
||||
remove_pkg(struct xbps_handle *xhp, const char *pkgname, bool recursive)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t reqby;
|
||||
@@ -328,10 +331,10 @@ remove_pkg(const char *pkgname, bool recursive)
|
||||
size_t x;
|
||||
int rv;
|
||||
|
||||
rv = xbps_transaction_remove_pkg(pkgname, recursive);
|
||||
rv = xbps_transaction_remove_pkg(xhp, pkgname, recursive);
|
||||
if (rv == EEXIST) {
|
||||
/* pkg has revdeps */
|
||||
pkgd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||
pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||
prop_object_release(pkgd);
|
||||
@@ -358,18 +361,20 @@ remove_pkg(const char *pkgname, bool recursive)
|
||||
}
|
||||
|
||||
int
|
||||
exec_transaction(bool yes, bool dry_run, bool show_download_urls)
|
||||
exec_transaction(struct xbps_handle *xhp,
|
||||
bool yes,
|
||||
bool dry_run,
|
||||
bool show_download_urls)
|
||||
{
|
||||
prop_array_t mdeps, cflicts;
|
||||
struct transaction *trans;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
int rv = 0;
|
||||
|
||||
trans = calloc(1, sizeof(*trans));
|
||||
if (trans == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if ((rv = xbps_transaction_prepare()) != 0) {
|
||||
if ((rv = xbps_transaction_prepare(xhp)) != 0) {
|
||||
if (rv == ENODEV) {
|
||||
mdeps =
|
||||
prop_dictionary_get(xhp->transd, "missing_deps");
|
||||
@@ -382,12 +387,13 @@ exec_transaction(bool yes, bool dry_run, bool show_download_urls)
|
||||
show_conflicts(cflicts);
|
||||
goto out;
|
||||
}
|
||||
xbps_dbg_printf("Empty transaction dictionary: %s\n",
|
||||
xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n",
|
||||
strerror(errno));
|
||||
return rv;
|
||||
}
|
||||
xbps_dbg_printf("Dictionary before transaction happens:\n");
|
||||
xbps_dbg_printf_append("%s", prop_dictionary_externalize(xhp->transd));
|
||||
xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n");
|
||||
xbps_dbg_printf_append(xhp, "%s",
|
||||
prop_dictionary_externalize(xhp->transd));
|
||||
|
||||
trans->d = xhp->transd;
|
||||
trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages");
|
||||
@@ -408,7 +414,7 @@ exec_transaction(bool yes, bool dry_run, bool show_download_urls)
|
||||
* Only show URLs to download binary packages.
|
||||
*/
|
||||
if (show_download_urls) {
|
||||
rv = show_binpkgs_url(trans->iter);
|
||||
rv = show_binpkgs_url(xhp, trans->iter);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
@@ -426,7 +432,7 @@ exec_transaction(bool yes, bool dry_run, bool show_download_urls)
|
||||
/*
|
||||
* It's time to run the transaction!
|
||||
*/
|
||||
if ((rv = xbps_transaction_commit()) == 0) {
|
||||
if ((rv = xbps_transaction_commit(xhp)) == 0) {
|
||||
printf("\nxbps-bin: %u installed, %u updated, "
|
||||
"%u configured, %u removed.\n", trans->inst_pkgcnt,
|
||||
trans->up_pkgcnt, trans->cf_pkgcnt + trans->inst_pkgcnt,
|
||||
|
||||
@@ -30,8 +30,11 @@
|
||||
#include "defs.h"
|
||||
|
||||
void
|
||||
unpack_progress_cb_verbose(const struct xbps_unpack_cb_data *xpd, void *cbdata)
|
||||
unpack_progress_cb_verbose(struct xbps_handle *xhp,
|
||||
struct xbps_unpack_cb_data *xpd,
|
||||
void *cbdata)
|
||||
{
|
||||
(void)xhp;
|
||||
(void)cbdata;
|
||||
|
||||
if (xpd->entry == NULL || xpd->entry_total_count <= 0)
|
||||
@@ -44,8 +47,11 @@ unpack_progress_cb_verbose(const struct xbps_unpack_cb_data *xpd, void *cbdata)
|
||||
}
|
||||
|
||||
void
|
||||
unpack_progress_cb(const struct xbps_unpack_cb_data *xpd, void *cbdata)
|
||||
unpack_progress_cb(struct xbps_handle *xhp,
|
||||
struct xbps_unpack_cb_data *xpd,
|
||||
void *cbdata)
|
||||
{
|
||||
(void)xhp;
|
||||
(void)cbdata;
|
||||
|
||||
if (xpd->entry_total_count <= 0)
|
||||
|
||||
@@ -166,11 +166,15 @@ show_pkg_files(prop_dictionary_t filesd)
|
||||
}
|
||||
|
||||
static int
|
||||
_find_longest_pkgver_cb(prop_object_t obj, void *arg, bool *loop_done)
|
||||
_find_longest_pkgver_cb(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
size_t *len = arg;
|
||||
const char *pkgver;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
@@ -181,25 +185,29 @@ _find_longest_pkgver_cb(prop_object_t obj, void *arg, bool *loop_done)
|
||||
}
|
||||
|
||||
size_t
|
||||
find_longest_pkgver(prop_object_t o)
|
||||
find_longest_pkgver(struct xbps_handle *xhp, prop_object_t o)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
if (prop_object_type(o) == PROP_TYPE_ARRAY)
|
||||
(void)xbps_callback_array_iter(o,
|
||||
(void)xbps_callback_array_iter(xhp, o,
|
||||
_find_longest_pkgver_cb, &len);
|
||||
else
|
||||
(void)xbps_pkgdb_foreach_cb(
|
||||
(void)xbps_pkgdb_foreach_cb(xhp,
|
||||
_find_longest_pkgver_cb, &len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int
|
||||
list_strings_sep_in_array(prop_object_t obj, void *arg, bool *loop_done)
|
||||
list_strings_sep_in_array(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
const char *sep = arg;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
|
||||
|
||||
Reference in New Issue
Block a user