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:
parent
a3adbcda95
commit
3e9e87fc2a
@ -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));
|
||||
|
@ -94,7 +94,6 @@ die(const char *fmt, ...)
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, " (%s)\n", strerror(save_errno));
|
||||
va_end(ap);
|
||||
xbps_end();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -357,7 +356,8 @@ parse_array_in_pkg_dictionary(FILE *f, prop_dictionary_t plistd,
|
||||
}
|
||||
|
||||
static void
|
||||
create_dot_graph(FILE *f,
|
||||
create_dot_graph(struct xbps_handle *xhp,
|
||||
FILE *f,
|
||||
prop_dictionary_t plistd,
|
||||
prop_dictionary_t confd,
|
||||
bool revdeps)
|
||||
@ -422,7 +422,7 @@ create_dot_graph(FILE *f,
|
||||
* list file, aka XBPS_META_PATH/XBPS_PKGDB.
|
||||
*/
|
||||
if (revdeps) {
|
||||
regpkgd = xbps_find_pkg_dict_installed(pkgn, false);
|
||||
regpkgd = xbps_find_pkg_dict_installed(xhp, pkgn, false);
|
||||
if (regpkgd == NULL)
|
||||
die("cannot find '%s' dictionary on %s!",
|
||||
pkgn, XBPS_PKGDB);
|
||||
@ -515,7 +515,7 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Internalize the plist file of the target installed package.
|
||||
*/
|
||||
plistd = xbps_dictionary_from_metadata_plist(argv[0], XBPS_PKGPROPS);
|
||||
plistd = xbps_dictionary_from_metadata_plist(&xh, argv[0], XBPS_PKGPROPS);
|
||||
if (plistd == NULL)
|
||||
die("cannot internalize %s from %s", XBPS_PKGPROPS, argv[0]);
|
||||
|
||||
@ -528,10 +528,11 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Create the dot(1) graph!
|
||||
*/
|
||||
create_dot_graph(f, plistd, confd, revdeps);
|
||||
create_dot_graph(&xh, f, plistd, confd, revdeps);
|
||||
|
||||
prop_object_release(plistd);
|
||||
prop_object_release(confd);
|
||||
xbps_end(&xh);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -34,10 +34,9 @@
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
cachedir_clean(void)
|
||||
cachedir_clean(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_dictionary_t pkg_propsd, repo_pkgd;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
const char *pkgver, *rsha256;
|
||||
@ -78,7 +77,7 @@ cachedir_clean(void)
|
||||
* Remove binary pkg if it's not registered in any repository
|
||||
* or if hash doesn't match.
|
||||
*/
|
||||
repo_pkgd = xbps_rpool_find_pkg_exact(pkgver);
|
||||
repo_pkgd = xbps_rpool_find_pkg_exact(xhp, pkgver);
|
||||
if (repo_pkgd) {
|
||||
prop_dictionary_get_cstring_nocopy(repo_pkgd,
|
||||
"filename-sha256", &rsha256);
|
||||
|
@ -35,25 +35,36 @@ struct repo_search_data {
|
||||
};
|
||||
|
||||
/* From index.c */
|
||||
int repo_genindex(const char *);
|
||||
int repo_genindex(struct xbps_handle *, const char *);
|
||||
|
||||
/* From index-files.c */
|
||||
int repo_genindex_files(const char *);
|
||||
int repo_genindex_files(struct xbps_handle *, const char *);
|
||||
|
||||
/* From find-files.c */
|
||||
int repo_find_files_in_packages(int, char **);
|
||||
int repo_find_files_in_packages(struct xbps_handle *, int, char **);
|
||||
|
||||
/* From list.c */
|
||||
int repo_pkg_list_cb(struct xbps_rpool_index *, void *, bool *);
|
||||
int repo_list_uri_cb(struct xbps_rpool_index *, void *, bool *);
|
||||
int repo_search_pkgs_cb(struct xbps_rpool_index *, void *, bool *);
|
||||
int repo_pkg_list_cb(struct xbps_handle *,
|
||||
struct xbps_rpool_index *,
|
||||
void *,
|
||||
bool *);
|
||||
int repo_list_uri_cb(struct xbps_handle *,
|
||||
struct xbps_rpool_index *,
|
||||
void *,
|
||||
bool *);
|
||||
int repo_search_pkgs_cb(struct xbps_handle *,
|
||||
struct xbps_rpool_index *,
|
||||
void *,
|
||||
bool *);
|
||||
|
||||
/* From show.c */
|
||||
int show_pkg_info_from_repolist(const char *, const char *);
|
||||
int show_pkg_deps_from_repolist(const char *);
|
||||
int show_pkg_namedesc(prop_object_t, void *, bool *);
|
||||
int show_pkg_info_from_repolist(struct xbps_handle *,
|
||||
const char *,
|
||||
const char *);
|
||||
int show_pkg_deps_from_repolist(struct xbps_handle *, const char *);
|
||||
int show_pkg_namedesc(struct xbps_handle *, prop_object_t, void *, bool *);
|
||||
|
||||
/* From clean.c */
|
||||
int cachedir_clean(void);
|
||||
int cachedir_clean(struct xbps_handle *);
|
||||
|
||||
#endif /* !_XBPS_REPO_DEFS_H_ */
|
||||
|
@ -66,7 +66,10 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, struct ffdata *ffd)
|
||||
}
|
||||
|
||||
static int
|
||||
find_files_in_package(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
find_files_in_package(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
prop_array_t idxfiles;
|
||||
struct ffdata *ffd = arg;
|
||||
@ -75,7 +78,7 @@ find_files_in_package(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
|
||||
(void)done;
|
||||
|
||||
if ((plist = xbps_pkg_index_files_plist(rpi->uri)) == NULL)
|
||||
if ((plist = xbps_pkg_index_files_plist(xhp, rpi->uri)) == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if ((idxfiles = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||
@ -98,12 +101,14 @@ find_files_in_package(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
}
|
||||
|
||||
int
|
||||
repo_find_files_in_packages(int npatterns, char **patterns)
|
||||
repo_find_files_in_packages(struct xbps_handle *xhp,
|
||||
int npatterns,
|
||||
char **patterns)
|
||||
{
|
||||
struct ffdata ffd;
|
||||
|
||||
ffd.npatterns = npatterns;
|
||||
ffd.patterns = patterns;
|
||||
|
||||
return xbps_rpool_foreach(find_files_in_package, &ffd);
|
||||
return xbps_rpool_foreach(xhp, find_files_in_package, &ffd);
|
||||
}
|
||||
|
@ -42,12 +42,16 @@ struct index_files_data {
|
||||
};
|
||||
|
||||
static int
|
||||
rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
rmobsoletes_files_cb(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct index_files_data *ifd = arg;
|
||||
const char *pkgver, *arch;
|
||||
char *str;
|
||||
|
||||
(void)xhp;
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
@ -70,7 +74,10 @@ rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
}
|
||||
|
||||
static int
|
||||
genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
genindex_files_cb(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
prop_object_t obj2, fileobj;
|
||||
prop_dictionary_t pkg_filesd, pkgd;
|
||||
@ -81,6 +88,7 @@ genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
bool found = false;
|
||||
size_t i;
|
||||
|
||||
(void)xhp;
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &binpkg);
|
||||
@ -211,7 +219,7 @@ genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
* Create the index files cache for all packages in repository.
|
||||
*/
|
||||
int
|
||||
repo_genindex_files(const char *pkgdir)
|
||||
repo_genindex_files(struct xbps_handle *xhp, const char *pkgdir)
|
||||
{
|
||||
prop_array_t idx;
|
||||
struct index_files_data *ifd = NULL;
|
||||
@ -220,7 +228,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
char *plist, *pkgver;
|
||||
int rv;
|
||||
|
||||
plist = xbps_pkg_index_plist(pkgdir);
|
||||
plist = xbps_pkg_index_plist(xhp, pkgdir);
|
||||
if (plist == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
@ -233,7 +241,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
free(plist);
|
||||
|
||||
/* internalize repository index-files plist (if exists) */
|
||||
plist = xbps_pkg_index_files_plist(pkgdir);
|
||||
plist = xbps_pkg_index_files_plist(xhp, pkgdir);
|
||||
if (plist == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
@ -255,7 +263,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
|
||||
/* remove obsolete pkg entries */
|
||||
if (!ifd->new) {
|
||||
rv = xbps_callback_array_iter(ifd->idxfiles,
|
||||
rv = xbps_callback_array_iter(xhp, ifd->idxfiles,
|
||||
rmobsoletes_files_cb, ifd);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
@ -281,7 +289,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
}
|
||||
}
|
||||
/* iterate over index.plist array */
|
||||
if ((rv = xbps_callback_array_iter(idx, genindex_files_cb, ifd)) != 0)
|
||||
if ((rv = xbps_callback_array_iter(xhp, idx, genindex_files_cb, ifd)) != 0)
|
||||
goto out;
|
||||
|
||||
if (!ifd->flush)
|
||||
|
@ -47,7 +47,7 @@ static const char *archs[] = { "noarch", "i686", "x86_64" };
|
||||
* binary package cannot be read (unavailable, not enough perms, etc).
|
||||
*/
|
||||
static int
|
||||
remove_missing_binpkg_entries(const char *repodir)
|
||||
remove_missing_binpkg_entries(struct xbps_handle *xhp, const char *repodir)
|
||||
{
|
||||
prop_array_t array;
|
||||
prop_dictionary_t pkgd;
|
||||
@ -57,7 +57,7 @@ remove_missing_binpkg_entries(const char *repodir)
|
||||
int rv = 0;
|
||||
bool found = false;
|
||||
|
||||
plist = xbps_pkg_index_plist(repodir);
|
||||
plist = xbps_pkg_index_plist(xhp, repodir);
|
||||
if (plist == NULL)
|
||||
return -1;
|
||||
|
||||
@ -104,7 +104,7 @@ again:
|
||||
}
|
||||
|
||||
static prop_array_t
|
||||
repoidx_get(const char *pkgdir)
|
||||
repoidx_get(struct xbps_handle *xhp, const char *pkgdir)
|
||||
{
|
||||
prop_array_t array;
|
||||
char *plist;
|
||||
@ -113,10 +113,10 @@ repoidx_get(const char *pkgdir)
|
||||
* Remove entries in repositories index for unexistent
|
||||
* packages, i.e dangling entries.
|
||||
*/
|
||||
if ((rv = remove_missing_binpkg_entries(pkgdir)) != 0)
|
||||
if ((rv = remove_missing_binpkg_entries(xhp, pkgdir)) != 0)
|
||||
return NULL;
|
||||
|
||||
plist = xbps_pkg_index_plist(pkgdir);
|
||||
plist = xbps_pkg_index_plist(xhp, pkgdir);
|
||||
if (plist == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -297,7 +297,7 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
repo_genindex(const char *pkgdir)
|
||||
repo_genindex(struct xbps_handle *xhp, const char *pkgdir)
|
||||
{
|
||||
prop_array_t idx = NULL;
|
||||
struct dirent *dp;
|
||||
@ -311,11 +311,11 @@ repo_genindex(const char *pkgdir)
|
||||
/*
|
||||
* Create or read existing package index plist file.
|
||||
*/
|
||||
idx = repoidx_get(pkgdir);
|
||||
idx = repoidx_get(xhp, pkgdir);
|
||||
if (idx == NULL)
|
||||
return errno;
|
||||
|
||||
plist = xbps_pkg_index_plist(pkgdir);
|
||||
plist = xbps_pkg_index_plist(xhp, pkgdir);
|
||||
if (plist == NULL) {
|
||||
prop_object_release(idx);
|
||||
return errno;
|
||||
|
@ -35,7 +35,10 @@
|
||||
#include "../xbps-bin/defs.h"
|
||||
|
||||
int
|
||||
repo_pkg_list_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_pkg_list_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct list_pkgver_cb lpc;
|
||||
const char *repo = arg;
|
||||
@ -46,18 +49,22 @@ repo_pkg_list_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
|
||||
lpc.check_state = false;
|
||||
lpc.state = 0;
|
||||
lpc.pkgver_len = find_longest_pkgver(rpi->repo);
|
||||
lpc.pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
||||
|
||||
if (arg == NULL)
|
||||
printf("From %s repository ...\n", rpi->uri);
|
||||
|
||||
(void)xbps_callback_array_iter(rpi->repo, list_pkgs_in_dict, &lpc);
|
||||
(void)xbps_callback_array_iter(xhp, rpi->repo, list_pkgs_in_dict, &lpc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
repo_list_uri_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_list_uri_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
(void)xhp;
|
||||
(void)arg;
|
||||
(void)done;
|
||||
|
||||
@ -68,14 +75,17 @@ repo_list_uri_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
}
|
||||
|
||||
int
|
||||
repo_search_pkgs_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_search_pkgs_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_search_data *rsd = arg;
|
||||
(void)done;
|
||||
|
||||
rsd->pkgver_len = find_longest_pkgver(rpi->repo);
|
||||
rsd->pkgver_len = find_longest_pkgver(xhp, rpi->repo);
|
||||
|
||||
printf("From %s repository ...\n", rpi->uri);
|
||||
(void)xbps_callback_array_iter(rpi->repo, show_pkg_namedesc, rsd);
|
||||
(void)xbps_callback_array_iter(xhp, rpi->repo, show_pkg_namedesc, rsd);
|
||||
return 0;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@
|
||||
static void __attribute__((noreturn))
|
||||
usage(bool fail)
|
||||
{
|
||||
xbps_end();
|
||||
fprintf(stderr,
|
||||
"Usage: xbps-repo [options] target [arguments]\n\n"
|
||||
"[options]\n"
|
||||
@ -151,7 +150,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage(true);
|
||||
|
||||
rv = xbps_rpool_foreach(repo_list_uri_cb, NULL);
|
||||
rv = xbps_rpool_foreach(&xh, repo_list_uri_cb, NULL);
|
||||
if (rv == ENOTSUP)
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
"currently registered!\n");
|
||||
@ -165,7 +164,7 @@ main(int argc, char **argv)
|
||||
if (argc < 1 || argc > 2)
|
||||
usage(true);
|
||||
|
||||
rv = xbps_rpool_foreach(repo_pkg_list_cb, argv[1]);
|
||||
rv = xbps_rpool_foreach(&xh, repo_pkg_list_cb, argv[1]);
|
||||
if (rv == ENOTSUP)
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
"currently registered!\n");
|
||||
@ -187,7 +186,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
rsd->npatterns = argc;
|
||||
rsd->patterns = argv;
|
||||
rv = xbps_rpool_foreach(repo_search_pkgs_cb, rsd);
|
||||
rv = xbps_rpool_foreach(&xh, repo_search_pkgs_cb, rsd);
|
||||
free(rsd);
|
||||
if (rv == ENOTSUP)
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
@ -200,7 +199,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = show_pkg_info_from_repolist(argv[1], option);
|
||||
rv = show_pkg_info_from_repolist(&xh, argv[1], option);
|
||||
if (rv == ENOENT) {
|
||||
xbps_error_printf("Unable to locate package "
|
||||
"`%s' in repository pool.\n", argv[1]);
|
||||
@ -216,7 +215,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = show_pkg_deps_from_repolist(argv[1]);
|
||||
rv = show_pkg_deps_from_repolist(&xh, argv[1]);
|
||||
if (rv == ENOENT) {
|
||||
xbps_error_printf("Unable to locate package "
|
||||
"`%s' in repository pool.\n", argv[1]);
|
||||
@ -232,7 +231,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
pkgd = xbps_rpool_dictionary_metadata_plist(argv[1],
|
||||
pkgd = xbps_rpool_dictionary_metadata_plist(&xh, argv[1],
|
||||
"./files.plist");
|
||||
if (pkgd == NULL) {
|
||||
if (errno == ENOTSUP) {
|
||||
@ -256,7 +255,7 @@ main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage(true);
|
||||
|
||||
rv = repo_find_files_in_packages(argc, argv);
|
||||
rv = repo_find_files_in_packages(&xh, argc, argv);
|
||||
if (rv == ENOTSUP) {
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
"currently registered!\n");
|
||||
@ -266,16 +265,16 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage(true);
|
||||
|
||||
rv = repo_genindex(argv[1]);
|
||||
rv = repo_genindex(&xh, argv[1]);
|
||||
if (rv == 0)
|
||||
rv = repo_genindex_files(argv[1]);
|
||||
rv = repo_genindex_files(&xh, argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "sync") == 0) {
|
||||
/* Syncs the pkg index for all registered remote repos */
|
||||
if (argc < 1 || argc > 2)
|
||||
usage(true);
|
||||
|
||||
rv = xbps_rpool_sync(argv[1]);
|
||||
rv = xbps_rpool_sync(&xh, argv[1]);
|
||||
if (rv == ENOTSUP) {
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
"currently registered!\n");
|
||||
@ -285,12 +284,12 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage(true);
|
||||
|
||||
rv = cachedir_clean();
|
||||
rv = cachedir_clean(&xh);
|
||||
} else {
|
||||
usage(true);
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end();
|
||||
xbps_end(&xh);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -44,14 +44,16 @@
|
||||
#include "defs.h"
|
||||
|
||||
int
|
||||
show_pkg_info_from_repolist(const char *pattern, const char *option)
|
||||
show_pkg_info_from_repolist(struct xbps_handle *xhp,
|
||||
const char *pattern,
|
||||
const char *option)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
if (xbps_pkgpattern_version(pattern))
|
||||
pkgd = xbps_rpool_find_pkg(pattern, true, false);
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, true, false);
|
||||
else
|
||||
pkgd = xbps_rpool_find_pkg(pattern, false, true);
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, false, true);
|
||||
|
||||
if (pkgd == NULL)
|
||||
return errno;
|
||||
@ -67,15 +69,15 @@ show_pkg_info_from_repolist(const char *pattern, const char *option)
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_deps_from_repolist(const char *pattern)
|
||||
show_pkg_deps_from_repolist(struct xbps_handle *xhp, const char *pattern)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
const char *ver, *repoloc;
|
||||
|
||||
if (xbps_pkgpattern_version(pattern))
|
||||
pkgd = xbps_rpool_find_pkg(pattern, true, false);
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, true, false);
|
||||
else
|
||||
pkgd = xbps_rpool_find_pkg(pattern, false, true);
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, false, true);
|
||||
|
||||
if (pkgd == NULL)
|
||||
return errno;
|
||||
@ -84,7 +86,7 @@ show_pkg_deps_from_repolist(const char *pattern)
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
|
||||
|
||||
printf("Repository %s [pkgver: %s]\n", repoloc, ver);
|
||||
(void)xbps_callback_array_iter_in_dict(pkgd,
|
||||
(void)xbps_callback_array_iter_in_dict(xhp, pkgd,
|
||||
"run_depends", list_strings_sep_in_array, NULL);
|
||||
|
||||
prop_object_release(pkgd);
|
||||
@ -92,13 +94,17 @@ show_pkg_deps_from_repolist(const char *pattern)
|
||||
}
|
||||
|
||||
int
|
||||
show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
|
||||
show_pkg_namedesc(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
struct repo_search_data *rsd = arg;
|
||||
const char *pkgver, *pkgname, *desc, *arch;
|
||||
char *tmp = NULL;
|
||||
size_t i, x;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
|
@ -60,7 +60,6 @@ write_plist_file(prop_dictionary_t dict, const char *file)
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
{
|
||||
xbps_end();
|
||||
fprintf(stderr,
|
||||
"usage: xbps-uhelper [options] [action] [args]\n"
|
||||
"\n"
|
||||
@ -192,7 +191,7 @@ main(int argc, char **argv)
|
||||
assert(tmp != NULL);
|
||||
prop_dictionary_set_cstring_nocopy(dict, "pkgver", tmp);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(argv[1], false);
|
||||
pkgd = xbps_pkgdb_get_pkgd(&xh, argv[1], false);
|
||||
if (pkgd != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgname", &pkgn);
|
||||
@ -204,12 +203,12 @@ main(int argc, char **argv)
|
||||
in_chroot ? "[chroot] " : "",
|
||||
pkgn, version, MSG_RESET);
|
||||
} else {
|
||||
rv = xbps_set_pkg_state_installed(argv[1], argv[2],
|
||||
rv = xbps_set_pkg_state_installed(&xh, argv[1], argv[2],
|
||||
XBPS_PKG_STATE_INSTALLED);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
|
||||
rv = xbps_register_pkg(dict, true);
|
||||
rv = xbps_register_pkg(&xh, dict, true);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "%s%s=> couldn't register %s-%s "
|
||||
"(%s).%s\n", MSG_ERROR,
|
||||
@ -227,7 +226,7 @@ main(int argc, char **argv)
|
||||
if (argc != 3)
|
||||
usage();
|
||||
|
||||
rv = xbps_unregister_pkg(argv[1], argv[2], true);
|
||||
rv = xbps_unregister_pkg(&xh, argv[1], argv[2], true);
|
||||
if (rv == ENOENT) {
|
||||
fprintf(stderr, "%s=> ERROR: %s not registered "
|
||||
"in database.%s\n", MSG_WARN, argv[1], MSG_RESET);
|
||||
@ -245,7 +244,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
dict = xbps_pkgdb_get_pkgd(argv[1], false);
|
||||
dict = xbps_pkgdb_get_pkgd(&xh, argv[1], false);
|
||||
if (dict == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
@ -356,7 +355,7 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
rv = xbps_fetch_file(argv[i], ".", false, "v");
|
||||
rv = xbps_fetch_file(&xh, argv[i], ".", false, "v");
|
||||
if (rv == -1) {
|
||||
printf("%s: %s\n", argv[1],
|
||||
xbps_fetch_error_string());
|
||||
@ -385,7 +384,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
xh.pkgdb = prop_array_copy(array);
|
||||
prop_object_release(dict);
|
||||
rv = xbps_pkgdb_update(true);
|
||||
rv = xbps_pkgdb_update(&xh, true);
|
||||
if (rv == 0) {
|
||||
printf("Migrated regpkgdb to pkgdb "
|
||||
"successfully.\n");
|
||||
@ -398,6 +397,6 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
}
|
||||
out:
|
||||
xbps_end();
|
||||
xbps_end(&xh);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||
|
||||
#define XBPS_API_VERSION "20120611"
|
||||
#define XBPS_API_VERSION "20120614"
|
||||
#define XBPS_VERSION "0.16"
|
||||
|
||||
/**
|
||||
@ -201,11 +201,6 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void xbps_dbg_printf(const char *, ...);
|
||||
void xbps_dbg_printf_append(const char *, ...);
|
||||
void xbps_error_printf(const char *, ...);
|
||||
void xbps_warn_printf(const char *, ...);
|
||||
|
||||
/** @addtogroup initend */
|
||||
/*@{*/
|
||||
|
||||
@ -478,7 +473,7 @@ struct xbps_handle {
|
||||
* Pointer to the supplifed function callback to be used
|
||||
* in the XBPS possible states.
|
||||
*/
|
||||
void (*state_cb)(const struct xbps_state_cb_data *, void *);
|
||||
void (*state_cb)(struct xbps_handle *, struct xbps_state_cb_data *, void *);
|
||||
/**
|
||||
* Pointer to user supplied data to be passed as argument to
|
||||
* the \a xbps_state_cb function callback.
|
||||
@ -488,7 +483,7 @@ struct xbps_handle {
|
||||
* Pointer to the supplied function callback to be used in
|
||||
* xbps_unpack_binary_pkg().
|
||||
*/
|
||||
void (*unpack_cb)(const struct xbps_unpack_cb_data *, void *);
|
||||
void (*unpack_cb)(struct xbps_handle *, struct xbps_unpack_cb_data *, void *);
|
||||
/**
|
||||
* Pointer to user supplied data to be passed as argument to
|
||||
* the \a xbps_unpack_cb function callback.
|
||||
@ -498,7 +493,7 @@ struct xbps_handle {
|
||||
* Pointer to the supplied function callback to be used in
|
||||
* xbps_fetch_file().
|
||||
*/
|
||||
void (*fetch_cb)(const struct xbps_fetch_cb_data *, void *);
|
||||
void (*fetch_cb)(struct xbps_handle *, struct xbps_fetch_cb_data *, void *);
|
||||
/**
|
||||
* @var fetch_cb_data
|
||||
*
|
||||
@ -568,6 +563,11 @@ struct xbps_handle {
|
||||
int flags;
|
||||
};
|
||||
|
||||
void xbps_dbg_printf(struct xbps_handle *, const char *, ...);
|
||||
void xbps_dbg_printf_append(struct xbps_handle *, const char *, ...);
|
||||
void xbps_error_printf(const char *, ...);
|
||||
void xbps_warn_printf(const char *, ...);
|
||||
|
||||
/**
|
||||
* Initialize the XBPS library with the following steps:
|
||||
*
|
||||
@ -584,15 +584,10 @@ int xbps_init(struct xbps_handle *xhp);
|
||||
|
||||
/**
|
||||
* Releases all resources used by libxbps.
|
||||
*/
|
||||
void xbps_end(void);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the xbps_handle structure passed to xbps_init().
|
||||
*
|
||||
* @return A pointer the struct xbps_handle passed to xbps_init().
|
||||
* @param[in] xhp Pointer to an xbps_handle strcucture.
|
||||
*/
|
||||
struct xbps_handle *xbps_handle_get(void);
|
||||
void xbps_end(struct xbps_handle *xhp);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -602,6 +597,7 @@ struct xbps_handle *xbps_handle_get(void);
|
||||
/**
|
||||
* Configure (or force reconfiguration of) a package.
|
||||
*
|
||||
* @param[in] xhp Pointer to an xbps_handle strcucture.
|
||||
* @param[in] pkgname Package name to configure.
|
||||
* @param[in] check_state Set it to true to check that package is
|
||||
* in unpacked state.
|
||||
@ -610,18 +606,21 @@ struct xbps_handle *xbps_handle_get(void);
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_configure_pkg(const char *pkgname,
|
||||
int xbps_configure_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
bool check_state,
|
||||
bool update,
|
||||
bool flush);
|
||||
|
||||
/**
|
||||
* Configure (or force reconfiguration of) all packages.
|
||||
*
|
||||
* @param[in] xhp Pointer to an xbps_handle strcucture.
|
||||
* @param[in] flush Set it to true to flush state to pkgdb.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_configure_packages(bool flush);
|
||||
int xbps_configure_packages(struct xbps_handle *xhp, bool flush);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -632,6 +631,7 @@ int xbps_configure_packages(bool flush);
|
||||
/**
|
||||
* Download a file from a remote URL.
|
||||
*
|
||||
* @param[in] xhp Pointer to an xbps_handle strcucture.
|
||||
* @param[in] uri Remote URI string.
|
||||
* @param[in] outputdir Directory string to store downloaded file.
|
||||
* @param[in] refetch If true and local/remote size/mtime do not match,
|
||||
@ -641,7 +641,8 @@ int xbps_configure_packages(bool flush);
|
||||
* @return -1 on error, 0 if not downloaded (because local/remote size/mtime
|
||||
* do not match) and 1 if downloaded successfully.
|
||||
**/
|
||||
int xbps_fetch_file(const char *uri,
|
||||
int xbps_fetch_file(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *outputdir,
|
||||
bool refetch,
|
||||
const char *flags);
|
||||
@ -660,13 +661,14 @@ const char *xbps_fetch_error_string(void);
|
||||
*
|
||||
* Finds all package orphans currently installed.
|
||||
*
|
||||
* @param[in] xhp Pointer to an xbps_handle strcucture.
|
||||
* @param[in] orphans Proplib array of strings with package names of
|
||||
* packages that should be treated as they were already removed (optional).
|
||||
*
|
||||
* @return A proplib array of dictionaries with all orphans found,
|
||||
* on error NULL is returned and errno is set appropiately.
|
||||
*/
|
||||
prop_array_t xbps_find_pkg_orphans(prop_array_t orphans);
|
||||
prop_array_t xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans);
|
||||
|
||||
/** @addtogroup pkgdb */
|
||||
/*@{*/
|
||||
@ -675,19 +677,22 @@ prop_array_t xbps_find_pkg_orphans(prop_array_t orphans);
|
||||
* Executes a function callback per a package dictionary registered
|
||||
* in master package database (pkgdb) plist (downwards).
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] fn Function callback to run for any pkg dictionary.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the function callback.
|
||||
*/
|
||||
int xbps_pkgdb_foreach_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
int xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Executes a function callback per a package dictionary registered
|
||||
* in master package database (pkgdb) plist, in reverse order (upwards).
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] fn Function callback to run for any pkg dictionary.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
@ -695,13 +700,15 @@ int xbps_pkgdb_foreach_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
* the value returned by the funcion callback.
|
||||
*/
|
||||
int xbps_pkgdb_foreach_reverse_cb(
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Returns a package dictionary from master package database (pkgdb) plist,
|
||||
* matching pkgname or pkgver object in \a pkg.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package name or name-version to match.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
@ -710,24 +717,29 @@ int xbps_pkgdb_foreach_reverse_cb(
|
||||
* with \a prop_dictionary_copy() so it must be released when not required
|
||||
* anymore with prop_object_release(). NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_pkgdb_get_pkgd(const char *pkg, bool bypattern);
|
||||
prop_dictionary_t xbps_pkgdb_get_pkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
|
||||
/**
|
||||
* Returns a package dictionary from master package database (pkgdb) plist,
|
||||
* matching the pkgver object in \a pkg dictionary.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgver Package name-version to match, i.e 'foo-1.0'.
|
||||
*
|
||||
* @return The matching proplib package dictionary from pkgdb copied
|
||||
* with \a prop_dictionary_copy() so it must be released when not required
|
||||
* anymore with prop_object_release(). NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(const char *pkgver);
|
||||
prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp,
|
||||
const char *pkgver);
|
||||
|
||||
/**
|
||||
* Removes a package dictionary from master package database (pkgdb) plist,
|
||||
* matching pkgname or pkgver object in \a pkg.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package name or pattern to match in a package dictionary.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
@ -736,12 +748,16 @@ prop_dictionary_t xbps_pkgdb_get_pkgd_by_pkgver(const char *pkgver);
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
bool xbps_pkgdb_remove_pkgd(const char *pkg, bool bypattern, bool flush);
|
||||
bool xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush);
|
||||
|
||||
/**
|
||||
* Replaces a package dictionary with \a dict in the master package database
|
||||
* (pkgdb) plist, matching pkgname or pkgver object.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgd Proplib dictionary to be added into pkgdb.
|
||||
* @param[in] pkg Package name or pattern to match in a package dictionary.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
@ -751,7 +767,8 @@ bool xbps_pkgdb_remove_pkgd(const char *pkg, bool bypattern, bool flush);
|
||||
*
|
||||
* @return true on success, false otherwise.
|
||||
*/
|
||||
bool xbps_pkgdb_replace_pkgd(prop_dictionary_t pkgd,
|
||||
bool xbps_pkgdb_replace_pkgd(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush);
|
||||
@ -760,12 +777,13 @@ bool xbps_pkgdb_replace_pkgd(prop_dictionary_t pkgd,
|
||||
* Updates the master package database (pkgdb) plist with new contents from
|
||||
* disk to the cached copy in memory.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] flush If true the pkgdb plist contents in memory will
|
||||
* be flushed atomically to storage.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_pkgdb_update(bool flush);
|
||||
int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -810,9 +828,10 @@ bool xbps_add_obj_to_array(prop_array_t array, prop_object_t obj);
|
||||
* @return 0 on success, otherwise the value returned by the function
|
||||
* callback.
|
||||
*/
|
||||
int xbps_callback_array_iter(prop_array_t array,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
int xbps_callback_array_iter(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Executes a function callback specified in \a fn with \a arg passed
|
||||
@ -827,9 +846,10 @@ int xbps_callback_array_iter(prop_array_t array,
|
||||
* @return 0 on success, otherwise the value returned by the function
|
||||
* callback.
|
||||
*/
|
||||
int xbps_callback_array_iter_reverse(prop_array_t array,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
int xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Executes a function callback into the array associated with key \a key,
|
||||
@ -846,10 +866,11 @@ int xbps_callback_array_iter_reverse(prop_array_t array,
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the function callback.
|
||||
*/
|
||||
int xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
int xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Executes a function callback (in reverse order) into the array
|
||||
@ -866,10 +887,12 @@ int xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the function callback.
|
||||
*/
|
||||
int xbps_callback_array_iter_reverse_in_dict(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
int xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by looking
|
||||
* it via its name in a proplib dictionary.
|
||||
@ -957,6 +980,7 @@ prop_dictionary_t xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t d,
|
||||
* Finds a package's dictionary searching in the registered packages
|
||||
* database by using a package name or a package pattern.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] str Package name or package pattern.
|
||||
* @param[in] bypattern Set it to true to find the package dictionary
|
||||
* by using a package pattern. If false, \a str is assumed to be a package name.
|
||||
@ -966,7 +990,8 @@ prop_dictionary_t xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t d,
|
||||
* @note When returned dictionary is no longer needed, it must be released
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_dict_installed(const char *str,
|
||||
prop_dictionary_t xbps_find_pkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern);
|
||||
|
||||
|
||||
@ -974,6 +999,7 @@ prop_dictionary_t xbps_find_pkg_dict_installed(const char *str,
|
||||
* Finds a virtual package's dictionary searching in the registered packages
|
||||
* database by using a package name or a package pattern.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] str Virtual package name or package pattern to match.
|
||||
* @param[in] bypattern Set it to true to find the package dictionary
|
||||
* by using a package pattern. If false, \a str is assumed to be a package name.
|
||||
@ -983,7 +1009,8 @@ prop_dictionary_t xbps_find_pkg_dict_installed(const char *str,
|
||||
* @note When returned dictionary is no longer needed, it must be released
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_find_virtualpkg_dict_installed(const char *str,
|
||||
prop_dictionary_t xbps_find_virtualpkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern);
|
||||
|
||||
/**
|
||||
@ -1141,13 +1168,15 @@ prop_object_iterator_t xbps_array_iter_from_dict(prop_dictionary_t dict,
|
||||
* Returns a proplib object dictionary associated with the installed package
|
||||
* \a pkgname, by internalizing its plist file defined in \a plist.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgname Package name of installed package.
|
||||
* @param[in] plist Package metadata property list file.
|
||||
*
|
||||
* @return The proplib object dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
prop_dictionary_t xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *plist);
|
||||
|
||||
/**
|
||||
@ -1256,6 +1285,7 @@ int xbps_array_replace_dict_by_pattern(prop_array_t array,
|
||||
/**
|
||||
* Register a package into the installed packages database.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkg_dict A dictionary with the following objects:
|
||||
* \a pkgname, \a version, \a pkgver, \a short_desc (string),
|
||||
* \a automatic-install (bool) and optionally \a provides (array of strings).
|
||||
@ -1264,11 +1294,14 @@ int xbps_array_replace_dict_by_pattern(prop_array_t array,
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_register_pkg(prop_dictionary_t pkg_dict, bool flush);
|
||||
int xbps_register_pkg(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkg_dict,
|
||||
bool flush);
|
||||
|
||||
/**
|
||||
* Unregister a package from the package database.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgname Package name.
|
||||
* @param[in] version Package version.
|
||||
* @param[in] flush Set to true to make sure that pkgdb plist
|
||||
@ -1276,7 +1309,10 @@ int xbps_register_pkg(prop_dictionary_t pkg_dict, bool flush);
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_unregister_pkg(const char *pkgname, const char *version, bool flush);
|
||||
int xbps_unregister_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
bool flush);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -1286,6 +1322,7 @@ int xbps_unregister_pkg(const char *pkgname, const char *version, bool flush);
|
||||
/**
|
||||
* Remove an installed package.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] pkgname Package name to match.
|
||||
* @param[in] version Package version associated.
|
||||
* @param[in] update If true, some steps will be skipped. See in the
|
||||
@ -1295,13 +1332,17 @@ int xbps_unregister_pkg(const char *pkgname, const char *version, bool flush);
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
int xbps_remove_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
bool update,
|
||||
bool soft_replace);
|
||||
|
||||
/**
|
||||
* Remove files defined in a proplib array as specified by \a key
|
||||
* of an installed package.
|
||||
*
|
||||
* @param[in] xhp The pointer to the xbps_handle struct.
|
||||
* @param[in] dict Proplib dictionary internalized from package's
|
||||
* <b>XBPS_PKGFILES</b> definition in package's metadata directory.
|
||||
* The image in Detailed description shows off its structure.
|
||||
@ -1312,7 +1353,8 @@ int xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
int xbps_remove_pkg_files(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pkgver);
|
||||
|
||||
@ -1327,9 +1369,10 @@ int xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
* package version in repository pool will be queued, otherwise the first
|
||||
* repository matching the package pattern wins.
|
||||
*
|
||||
* @param pkg Package name, package/version or package pattern to match, i.e
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package name, package/version or package pattern to match, i.e
|
||||
* `foo', `foo-1.0' or `foo>=1.2'.
|
||||
* @param reinstall If true, package will be queued (if \a str matches)
|
||||
* @param[in] reinstall If true, package will be queued (if \a str matches)
|
||||
* even if package is already installed.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
@ -1338,7 +1381,9 @@ int xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
* @retval ENOTSUP No repositories are available.
|
||||
* @retval EINVAL Any other error ocurred in the process.
|
||||
*/
|
||||
int xbps_transaction_install_pkg(const char *pkg, bool reinstall);
|
||||
int xbps_transaction_install_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool reinstall);
|
||||
|
||||
/**
|
||||
* Marks a package as "going to be updated" in the transaction dictionary.
|
||||
@ -1346,25 +1391,28 @@ int xbps_transaction_install_pkg(const char *pkg, bool reinstall);
|
||||
* available will be enqueued if it's greater than current installed
|
||||
* version.
|
||||
*
|
||||
* @param pkgname The package name to update.
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkgname The package name to update.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_transaction_update_pkg(const char *pkgname);
|
||||
int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname);
|
||||
|
||||
/**
|
||||
* Finds newer versions for all installed packages by looking at the
|
||||
* repository pool. If a newer version exists, package will be enqueued
|
||||
* into the transaction dictionary.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_transaction_update_packages(void);
|
||||
int xbps_transaction_update_packages(struct xbps_handle *xhp);
|
||||
|
||||
/**
|
||||
* Removes a package currently installed. The package dictionary will
|
||||
* be added into the transaction dictionary.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkgname Package name to be removed.
|
||||
* @param[in] recursive If true, all packages that are currently depending
|
||||
* on the package to be removed, and if they are orphans, will be added.
|
||||
@ -1375,25 +1423,30 @@ int xbps_transaction_update_packages(void);
|
||||
* @retval EINVAL
|
||||
* @retval ENXIO A problem ocurred in the process.
|
||||
*/
|
||||
int xbps_transaction_remove_pkg(const char *pkgname,
|
||||
int xbps_transaction_remove_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
bool recursive);
|
||||
|
||||
/**
|
||||
* Finds all package orphans currently installed and adds them into
|
||||
* the transaction dictionary.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
*
|
||||
* @retval 0 success.
|
||||
* @retval ENOENT No package orphans were found.
|
||||
* @retval ENXIO
|
||||
* @retval EINVAL A problem ocurred in the process.
|
||||
*/
|
||||
int xbps_transaction_autoremove_pkgs(void);
|
||||
int xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp);
|
||||
|
||||
/**
|
||||
* Returns the transaction dictionary, as shown above in the image.
|
||||
* Before returning the package list is sorted in the correct order
|
||||
* and total installed/download size for the transaction is computed.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
*
|
||||
* @retval 0 success.
|
||||
* @retval ENXIO if transaction dictionary and missing deps array were not created,
|
||||
* due to xbps_transaction_install_pkg() or xbps_transaction_update_pkg() not
|
||||
@ -1403,16 +1456,17 @@ int xbps_transaction_autoremove_pkgs(void);
|
||||
* @retval EINVAL There was an error sorting packages or computing the transaction
|
||||
* sizes.
|
||||
*/
|
||||
int xbps_transaction_prepare(void);
|
||||
int xbps_transaction_prepare(struct xbps_handle *xhp);
|
||||
|
||||
/**
|
||||
* Commit a transaction. The transaction dictionary in xhp->transd contains all
|
||||
* steps to be executed in the transaction, as prepared by
|
||||
* xbps_transaction_prepare().
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_transaction_commit(void);
|
||||
int xbps_transaction_commit(struct xbps_handle *xhp);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -1466,12 +1520,13 @@ struct xbps_rpool_index {
|
||||
* as specified in the configuration file or if \a uri argument is
|
||||
* set, just sync the index file for that repository.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] uri Repository URI to match for sync (optional).
|
||||
*
|
||||
* @return 0 on success, ENOTSUP if no repositories were found in
|
||||
* the configuration file.
|
||||
*/
|
||||
int xbps_rpool_sync(const char *uri);
|
||||
int xbps_rpool_sync(struct xbps_handle *xhp, const char *uri);
|
||||
|
||||
/**
|
||||
* Iterates over the repository pool and executes the \a fn function
|
||||
@ -1480,6 +1535,7 @@ int xbps_rpool_sync(const char *uri);
|
||||
* set to true, otherwise it will only be stopped if it returns a
|
||||
* non-zero value.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] fn Function callback to execute for every repository registered in
|
||||
* the pool.
|
||||
* @param[in] arg Opaque data passed in to the \a fn function callback for
|
||||
@ -1487,13 +1543,16 @@ int xbps_rpool_sync(const char *uri);
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *arg);
|
||||
int xbps_rpool_foreach(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, struct xbps_rpool_index *, void *, bool *),
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in the repository pool by specifying a
|
||||
* package pattern or a package name. This function does not take into
|
||||
* account virtual packages, just matches real packages.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Package pattern or name.
|
||||
* @param[in] bypattern Set it to true if \a pkg is a pkgpattern (foo>=0),
|
||||
* false if it is a pkgname.
|
||||
@ -1504,24 +1563,30 @@ int xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), voi
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_pkg(const char *pkg, bool bypattern, bool best);
|
||||
prop_dictionary_t xbps_rpool_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool best);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by matching its \a pkgver
|
||||
* object.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_pkg_exact(const char *pkgver);
|
||||
prop_dictionary_t xbps_rpool_find_pkg_exact(struct xbps_handle *xhp,
|
||||
const char *pkgver);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by specifying a
|
||||
* virtual package pattern or a package name.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Virtual package pattern or name to match.
|
||||
* @param[in] bypattern Set it to true if \a pkg is a pkgpattern (foo>=0),
|
||||
* false if it is a pkgname.
|
||||
@ -1530,13 +1595,16 @@ prop_dictionary_t xbps_rpool_find_pkg_exact(const char *pkgver);
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_virtualpkg(const char *pkg, bool bypattern);
|
||||
prop_dictionary_t xbps_rpool_find_virtualpkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by specifying a
|
||||
* package pattern or a package name. Only virtual packages set in
|
||||
* configuration file will be matched.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pkg Virtual package pattern or name to match.
|
||||
* @param[in] bypattern Set it to true if \a pkg is a pkgpattern (foo>=0),
|
||||
* false if it is a pkgname.
|
||||
@ -1545,7 +1613,9 @@ prop_dictionary_t xbps_rpool_find_virtualpkg(const char *pkg, bool bypattern);
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_find_virtualpkg_conf(const char *pkg, bool bypattern);
|
||||
prop_dictionary_t xbps_rpool_find_virtualpkg_conf(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern);
|
||||
|
||||
/**
|
||||
* Iterate over the the repository pool and search for a metadata plist
|
||||
@ -1555,6 +1625,7 @@ prop_dictionary_t xbps_rpool_find_virtualpkg_conf(const char *pkg, bool bypatter
|
||||
* When \a pattern is a pkgname, the newest package available in repositories
|
||||
* will be used. Otherwise the first repository matching \a pattern.
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] pattern Package name or package pattern to match, i.e `foo>=1.0'.
|
||||
* @param[in] plistf Plist file name to match, i.e XBPS_PKGPROPS or XBPS_PKGFILES.
|
||||
*
|
||||
@ -1565,7 +1636,8 @@ prop_dictionary_t xbps_rpool_find_virtualpkg_conf(const char *pkg, bool bypatter
|
||||
* binary package file has been found but the plist file could not
|
||||
* be found.
|
||||
*/
|
||||
prop_dictionary_t xbps_rpool_dictionary_metadata_plist(const char *pattern,
|
||||
prop_dictionary_t xbps_rpool_dictionary_metadata_plist(struct xbps_handle *xhp,
|
||||
const char *pattern,
|
||||
const char *plistf);
|
||||
|
||||
/*@}*/
|
||||
@ -1577,6 +1649,7 @@ prop_dictionary_t xbps_rpool_dictionary_metadata_plist(const char *pattern,
|
||||
* Syncs the package index file for a remote repository as specified
|
||||
* by the \a uri argument (if necessary).
|
||||
*
|
||||
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||
* @param[in] uri URI to a remote repository.
|
||||
* @param[in] plistf Plist file to sync.
|
||||
*
|
||||
@ -1584,7 +1657,9 @@ prop_dictionary_t xbps_rpool_dictionary_metadata_plist(const char *pattern,
|
||||
* not necessary (local/remote size/mtime matched) or 1 if
|
||||
* downloaded successfully.
|
||||
*/
|
||||
int xbps_repository_sync_pkg_index(const char *uri, const char *plistf);
|
||||
int xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *plistf);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -1622,12 +1697,15 @@ typedef enum pkg_state {
|
||||
* Gets package state from package \a pkgname, and sets its state
|
||||
* into \a state.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkgname Package name.
|
||||
* @param[out] state Package state returned.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_pkg_state_installed(const char *pkgname, pkg_state_t *state);
|
||||
int xbps_pkg_state_installed(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
pkg_state_t *state);
|
||||
|
||||
/**
|
||||
* Gets package state from a package dictionary \a dict, and sets its
|
||||
@ -1643,13 +1721,15 @@ int xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state);
|
||||
/**
|
||||
* Sets package state \a state in package \a pkgname.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkgname Package name.
|
||||
* @param[in] version Package version.
|
||||
* @param[in] state Package state to be set.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_set_pkg_state_installed(const char *pkgname,
|
||||
int xbps_set_pkg_state_installed(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
pkg_state_t state);
|
||||
|
||||
@ -1732,13 +1812,15 @@ int xbps_file_hash_check(const char *file, const char *sha256);
|
||||
* Checks if \a file matches the sha256 hash specified in the array
|
||||
* with key \a key in the proplib dictionary \a d.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] d Proplib dictionary to look in.
|
||||
* @param[in] key Proplib array key to match for file.
|
||||
* @param[in] file Pathname to a file.
|
||||
*
|
||||
* @return 0 if hash is matched, -1 on error and 1 if no match.
|
||||
*/
|
||||
int xbps_file_hash_check_dictionary(prop_dictionary_t d,
|
||||
int xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file);
|
||||
|
||||
@ -1746,22 +1828,26 @@ int xbps_file_hash_check_dictionary(prop_dictionary_t d,
|
||||
* Checks if a package is currently installed by matching a package
|
||||
* pattern string.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkg Package pattern used to find the package.
|
||||
*
|
||||
* @return -1 on error (errno set appropiately), 0 if package pattern
|
||||
* didn't match installed package, 1 if \a pkg pattern fully
|
||||
* matched installed package.
|
||||
*/
|
||||
int xbps_check_is_installed_pkg_by_pattern(const char *pkg);
|
||||
int xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
|
||||
const char *pkg);
|
||||
|
||||
/**
|
||||
* Checks if package \a pkgname is currently installed.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkgname Package name.
|
||||
*
|
||||
* @return True if \a pkgname is installed, false otherwise.
|
||||
*/
|
||||
bool xbps_check_is_installed_pkg_by_name(const char *pkgname);
|
||||
bool xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp,
|
||||
const char *pkgname);
|
||||
|
||||
/**
|
||||
* Checks if the URI specified by \a uri is remote or local.
|
||||
@ -1777,6 +1863,7 @@ bool xbps_check_is_repository_uri_remote(const char *uri);
|
||||
* package dictionary from a repository in \a pkgd, by looking at the
|
||||
* repository location object "repository" in its dictionary.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] pkgd Package dictionary stored in a transaction dictionary.
|
||||
* @param[in] repoloc Repository URL location string.
|
||||
*
|
||||
@ -1784,31 +1871,35 @@ bool xbps_check_is_repository_uri_remote(const char *uri);
|
||||
* errno is set appropiately. The pointer should be free(3)d when it's
|
||||
* no longer needed.
|
||||
*/
|
||||
char *xbps_path_from_repository_uri(prop_dictionary_t pkgd, const char *repoloc);
|
||||
char *xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *repoloc);
|
||||
|
||||
/**
|
||||
* Gets the full path to a repository package index plist file, as
|
||||
* specified by \a uri.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] uri Repository URI.
|
||||
*
|
||||
* @return A pointer to a malloc(3)d string, NULL otherwise and
|
||||
* errno is set appropiately. The pointer should be free(3)d when it's
|
||||
* no longer needed.
|
||||
*/
|
||||
char *xbps_pkg_index_plist(const char *uri);
|
||||
char *xbps_pkg_index_plist(struct xbps_handle *xhp, const char *uri);
|
||||
|
||||
/**
|
||||
* Returns the full path to a repository package index files plist file,
|
||||
* as specified by \a uri.
|
||||
*
|
||||
* @param[in] xhp The pointer to an xbps_handle struct.
|
||||
* @param[in] uri Repository URI.
|
||||
*
|
||||
* @return A pointer to a malloc(3)ed string, NULL otherwise and
|
||||
* errno is set appropiately. The pointer should be free(3)d when it's
|
||||
* no longer needded.
|
||||
*/
|
||||
char *xbps_pkg_index_files_plist(const char *uri);
|
||||
char *xbps_pkg_index_files_plist(struct xbps_handle *xhp, const char *uri);
|
||||
|
||||
/**
|
||||
* Gets the name of a package string. Package strings are composed
|
||||
|
@ -90,7 +90,8 @@ void HIDDEN xbps_fetch_unset_cache_connection(void);
|
||||
* From lib/package_config_files.c
|
||||
*/
|
||||
int HIDDEN xbps_entry_is_a_conf_file(prop_dictionary_t, const char *);
|
||||
int HIDDEN xbps_entry_install_conf_file(prop_dictionary_t,
|
||||
int HIDDEN xbps_entry_install_conf_file(struct xbps_handle *,
|
||||
prop_dictionary_t,
|
||||
struct archive_entry *,
|
||||
const char *,
|
||||
const char *,
|
||||
@ -107,7 +108,8 @@ prop_dictionary_t HIDDEN
|
||||
* @private
|
||||
* From lib/package_remove_obsoletes.c
|
||||
*/
|
||||
int HIDDEN xbps_remove_obsoletes(const char *,
|
||||
int HIDDEN xbps_remove_obsoletes(struct xbps_handle *xhp,
|
||||
const char *,
|
||||
const char *,
|
||||
const char *,
|
||||
prop_dictionary_t,
|
||||
@ -125,16 +127,20 @@ int HIDDEN xbps_repository_find_pkg_deps(struct xbps_handle *,
|
||||
* From lib/package_requiredby.c
|
||||
*/
|
||||
int HIDDEN xbps_requiredby_pkg_add(struct xbps_handle *, prop_dictionary_t);
|
||||
int HIDDEN xbps_requiredby_pkg_remove(const char *);
|
||||
int HIDDEN xbps_requiredby_pkg_remove(struct xbps_handle *, const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/plist_find.c
|
||||
*/
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(prop_array_t, const char *);
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(struct xbps_handle *,
|
||||
prop_array_t,
|
||||
const char *);
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t, const char *);
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(struct xbps_handle *,
|
||||
prop_array_t,
|
||||
const char *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@ -158,28 +164,28 @@ char HIDDEN *xbps_get_remote_repo_string(const char *);
|
||||
* @private
|
||||
* From lib/external/fexec.c
|
||||
*/
|
||||
int HIDDEN xbps_file_exec(const char *, ...);
|
||||
int HIDDEN xbps_file_exec(struct xbps_handle *, const char *, ...);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/transaction_package_replace.c
|
||||
*/
|
||||
int HIDDEN xbps_transaction_package_replace(prop_dictionary_t);
|
||||
int HIDDEN xbps_transaction_package_replace(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/cb_util.c
|
||||
*/
|
||||
void HIDDEN xbps_set_cb_fetch(off_t, off_t, off_t, const char *,
|
||||
bool, bool, bool);
|
||||
void HIDDEN xbps_set_cb_state(xbps_state_t, int, const char *,
|
||||
const char *, const char *, ...);
|
||||
void HIDDEN xbps_set_cb_fetch(struct xbps_handle *, off_t, off_t, off_t,
|
||||
const char *, bool, bool, bool);
|
||||
void HIDDEN xbps_set_cb_state(struct xbps_handle *, xbps_state_t, int,
|
||||
const char *, const char *, const char *, ...);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/package_unpack.c
|
||||
*/
|
||||
int HIDDEN xbps_unpack_binary_pkg(prop_dictionary_t);
|
||||
int HIDDEN xbps_unpack_binary_pkg(struct xbps_handle *, prop_dictionary_t);
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
@ -41,7 +41,8 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
void HIDDEN
|
||||
xbps_set_cb_fetch(off_t file_size,
|
||||
xbps_set_cb_fetch(struct xbps_handle *xhp,
|
||||
off_t file_size,
|
||||
off_t file_offset,
|
||||
off_t file_dloaded,
|
||||
const char *file_name,
|
||||
@ -49,7 +50,6 @@ xbps_set_cb_fetch(off_t file_size,
|
||||
bool cb_update,
|
||||
bool cb_end)
|
||||
{
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
struct xbps_fetch_cb_data xfcd;
|
||||
|
||||
if (xhp->fetch_cb == NULL)
|
||||
@ -62,11 +62,12 @@ xbps_set_cb_fetch(off_t file_size,
|
||||
xfcd.cb_start = cb_start;
|
||||
xfcd.cb_update = cb_update;
|
||||
xfcd.cb_end = cb_end;
|
||||
(*xhp->fetch_cb)(&xfcd, xhp->fetch_cb_data);
|
||||
(*xhp->fetch_cb)(xhp, &xfcd, xhp->fetch_cb_data);
|
||||
}
|
||||
|
||||
void HIDDEN
|
||||
xbps_set_cb_state(xbps_state_t state,
|
||||
xbps_set_cb_state(struct xbps_handle *xhp,
|
||||
xbps_state_t state,
|
||||
int err,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
@ -74,7 +75,6 @@ xbps_set_cb_state(xbps_state_t state,
|
||||
...)
|
||||
{
|
||||
struct xbps_state_cb_data xscd;
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
char *buf = NULL;
|
||||
va_list va;
|
||||
int retval;
|
||||
@ -95,7 +95,7 @@ xbps_set_cb_state(xbps_state_t state,
|
||||
else
|
||||
xscd.desc = buf;
|
||||
}
|
||||
(*xhp->state_cb)(&xscd, xhp->fetch_cb_data);
|
||||
(*xhp->state_cb)(xhp, &xscd, xhp->fetch_cb_data);
|
||||
if (buf != NULL)
|
||||
free(buf);
|
||||
}
|
||||
|
@ -88,12 +88,12 @@ xbps_fetch_error_string(void)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_fetch_file(const char *uri,
|
||||
xbps_fetch_file(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *outputdir,
|
||||
bool refetch,
|
||||
const char *flags)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
struct stat st;
|
||||
struct url *url = NULL;
|
||||
struct url_stat url_st;
|
||||
@ -110,7 +110,6 @@ xbps_fetch_file(const char *uri,
|
||||
|
||||
fetchLastErrCode = 0;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
fetchTimeout = xhp->fetch_timeout;
|
||||
/*
|
||||
* Get the filename specified in URI argument.
|
||||
@ -196,20 +195,20 @@ xbps_fetch_file(const char *uri,
|
||||
}
|
||||
|
||||
/* debug stuff */
|
||||
xbps_dbg_printf("st.st_size: %zd\n", (ssize_t)st.st_size);
|
||||
xbps_dbg_printf("st.st_atime: %s\n", print_time(&st.st_atime));
|
||||
xbps_dbg_printf("st.st_mtime: %s\n", print_time(&st.st_mtime));
|
||||
xbps_dbg_printf("url->scheme: %s\n", url->scheme);
|
||||
xbps_dbg_printf("url->host: %s\n", url->host);
|
||||
xbps_dbg_printf("url->port: %d\n", url->port);
|
||||
xbps_dbg_printf("url->doc: %s\n", url->doc);
|
||||
xbps_dbg_printf("url->offset: %zd\n", (ssize_t)url->offset);
|
||||
xbps_dbg_printf("url->length: %zu\n", url->length);
|
||||
xbps_dbg_printf("url->last_modified: %s\n",
|
||||
xbps_dbg_printf(xhp, "st.st_size: %zd\n", (ssize_t)st.st_size);
|
||||
xbps_dbg_printf(xhp, "st.st_atime: %s\n", print_time(&st.st_atime));
|
||||
xbps_dbg_printf(xhp, "st.st_mtime: %s\n", print_time(&st.st_mtime));
|
||||
xbps_dbg_printf(xhp, "url->scheme: %s\n", url->scheme);
|
||||
xbps_dbg_printf(xhp, "url->host: %s\n", url->host);
|
||||
xbps_dbg_printf(xhp, "url->port: %d\n", url->port);
|
||||
xbps_dbg_printf(xhp, "url->doc: %s\n", url->doc);
|
||||
xbps_dbg_printf(xhp, "url->offset: %zd\n", (ssize_t)url->offset);
|
||||
xbps_dbg_printf(xhp, "url->length: %zu\n", url->length);
|
||||
xbps_dbg_printf(xhp, "url->last_modified: %s\n",
|
||||
print_time(&url->last_modified));
|
||||
xbps_dbg_printf("url_stat.size: %zd\n", (ssize_t)url_st.size);
|
||||
xbps_dbg_printf("url_stat.atime: %s\n", print_time(&url_st.atime));
|
||||
xbps_dbg_printf("url_stat.mtime: %s\n", print_time(&url_st.mtime));
|
||||
xbps_dbg_printf(xhp, "url_stat.size: %zd\n", (ssize_t)url_st.size);
|
||||
xbps_dbg_printf(xhp, "url_stat.atime: %s\n", print_time(&url_st.atime));
|
||||
xbps_dbg_printf(xhp, "url_stat.mtime: %s\n", print_time(&url_st.mtime));
|
||||
|
||||
if (fio == NULL && fetchLastErrCode != FETCH_OK) {
|
||||
if (!refetch && restart && fetchLastErrCode == FETCH_UNAVAIL) {
|
||||
@ -226,7 +225,7 @@ xbps_fetch_file(const char *uri,
|
||||
goto out;
|
||||
}
|
||||
if (url_st.size == -1) {
|
||||
xbps_dbg_printf("Remote file size is unknown, resume "
|
||||
xbps_dbg_printf(xhp, "Remote file size is unknown, resume "
|
||||
"not possible...\n");
|
||||
restart = false;
|
||||
} else if (st.st_size > url_st.size) {
|
||||
@ -234,7 +233,7 @@ xbps_fetch_file(const char *uri,
|
||||
* Remove local file if bigger than remote, and refetch the
|
||||
* whole shit again.
|
||||
*/
|
||||
xbps_dbg_printf("Local file %s is greater than remote, "
|
||||
xbps_dbg_printf(xhp, "Local file %s is greater than remote, "
|
||||
"removing local file and refetching...\n", filename);
|
||||
(void)remove(destfile);
|
||||
} else if (restart && url_st.mtime && url_st.size &&
|
||||
@ -259,7 +258,7 @@ xbps_fetch_file(const char *uri,
|
||||
* and let the user know that the transfer is going to start
|
||||
* immediately.
|
||||
*/
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, url->offset,
|
||||
xbps_set_cb_fetch(xhp, url_st.size, url->offset, url->offset,
|
||||
filename, true, false, false);
|
||||
/*
|
||||
* Start fetching requested file.
|
||||
@ -267,7 +266,7 @@ xbps_fetch_file(const char *uri,
|
||||
while ((bytes_read = fetchIO_read(fio, buf, sizeof(buf))) > 0) {
|
||||
bytes_written = write(fd, buf, (size_t)bytes_read);
|
||||
if (bytes_written != bytes_read) {
|
||||
xbps_dbg_printf("Couldn't write to %s!\n", destfile);
|
||||
xbps_dbg_printf(xhp, "Couldn't write to %s!\n", destfile);
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
@ -276,11 +275,12 @@ xbps_fetch_file(const char *uri,
|
||||
* Let the fetch progress callback know that
|
||||
* we are sucking more bytes from it.
|
||||
*/
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, url->offset + bytes_dload,
|
||||
xbps_set_cb_fetch(xhp, url_st.size, url->offset,
|
||||
url->offset + bytes_dload,
|
||||
filename, false, true, false);
|
||||
}
|
||||
if (bytes_read == -1) {
|
||||
xbps_dbg_printf("IO error while fetching %s: %s\n", filename,
|
||||
xbps_dbg_printf(xhp, "IO error while fetching %s: %s\n", filename,
|
||||
fetchLastErrString);
|
||||
errno = EIO;
|
||||
rv = -1;
|
||||
@ -294,7 +294,7 @@ xbps_fetch_file(const char *uri,
|
||||
* Let the fetch progress callback know that the file
|
||||
* has been fetched.
|
||||
*/
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, bytes_dload,
|
||||
xbps_set_cb_fetch(xhp, url_st.size, url->offset, bytes_dload,
|
||||
filename, false, false, true);
|
||||
/*
|
||||
* Update mtime in local file to match remote file if transfer
|
||||
|
19
lib/external/dewey.c
vendored
19
lib/external/dewey.c
vendored
@ -137,19 +137,12 @@ mkcomponent(arr_t *ap, const char *num)
|
||||
if (ap->c == ap->size) {
|
||||
if (ap->size == 0) {
|
||||
ap->size = 62;
|
||||
if ((ap->v = malloc(ap->size * sizeof(int))) == NULL) {
|
||||
xbps_dbg_printf("%s: malloc ENOMEM\n",
|
||||
__func__);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ap->v = malloc(ap->size * sizeof(int));
|
||||
assert(ap->v != NULL);
|
||||
} else {
|
||||
ap->size *= 2;
|
||||
ap->v = realloc(ap->v, ap->size * sizeof(int));
|
||||
if (ap->v == NULL) {
|
||||
xbps_dbg_printf("%s: realloc ENOMEM\n",
|
||||
__func__);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
assert(ap->v != NULL);
|
||||
}
|
||||
}
|
||||
if (isdigit((unsigned char)*num)) {
|
||||
@ -177,10 +170,8 @@ mkcomponent(arr_t *ap, const char *num)
|
||||
cp = strchr(alphas, tolower((unsigned char)*num));
|
||||
if (ap->c == ap->size) {
|
||||
ap->size *= 2;
|
||||
if ((ap->v = realloc(ap->v, ap->size * sizeof(int))) == NULL) {
|
||||
xbps_dbg_printf("%s: ENOMEM!\n", __func__);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ap->v = realloc(ap->v, ap->size * sizeof(int));
|
||||
assert(ap->v != NULL);
|
||||
}
|
||||
ap->v[ap->c++] = (int)(cp - alphas) + 1;
|
||||
return 1;
|
||||
|
12
lib/external/fexec.c
vendored
12
lib/external/fexec.c
vendored
@ -38,9 +38,8 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
static int
|
||||
pfcexec(const char *file, const char **argv)
|
||||
pfcexec(struct xbps_handle *xhp, const char *file, const char **argv)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
pid_t child;
|
||||
int status;
|
||||
|
||||
@ -53,7 +52,6 @@ pfcexec(const char *file, const char **argv)
|
||||
*
|
||||
* It's assumed that cwd is the target rootdir.
|
||||
*/
|
||||
xhp = xbps_handle_get();
|
||||
if (strcmp(xhp->rootdir, "/")) {
|
||||
if (getuid() == 0 && access("bin/sh", X_OK) == 0) {
|
||||
if (chroot(xhp->rootdir) == -1)
|
||||
@ -81,7 +79,7 @@ pfcexec(const char *file, const char **argv)
|
||||
}
|
||||
|
||||
static int
|
||||
vfcexec(const char *arg, va_list ap)
|
||||
vfcexec(struct xbps_handle *xhp, const char *arg, va_list ap)
|
||||
{
|
||||
const char **argv;
|
||||
size_t argv_size, argc;
|
||||
@ -111,20 +109,20 @@ vfcexec(const char *arg, va_list ap)
|
||||
|
||||
} while (arg != NULL);
|
||||
|
||||
retval = pfcexec(argv[0], argv);
|
||||
retval = pfcexec(xhp, argv[0], argv);
|
||||
free(argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int HIDDEN
|
||||
xbps_file_exec(const char *arg, ...)
|
||||
xbps_file_exec(struct xbps_handle *xhp, const char *arg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
|
||||
va_start(ap, arg);
|
||||
result = vfcexec(arg, ap);
|
||||
result = vfcexec(xhp, arg, ap);
|
||||
va_end(ap);
|
||||
|
||||
return result;
|
||||
|
@ -39,9 +39,7 @@
|
||||
* Use these functions to initialize some parameters before start
|
||||
* using libxbps and finalize usage to release resources at the end.
|
||||
*/
|
||||
static bool debug;
|
||||
static bool xbps_initialized;
|
||||
static struct xbps_handle *xhp;
|
||||
|
||||
static char *
|
||||
set_cachedir(struct xbps_handle *xh)
|
||||
@ -89,7 +87,7 @@ cb_validate_virtual(cfg_t *cfg, cfg_opt_t *opt)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_init(struct xbps_handle *xh)
|
||||
xbps_init(struct xbps_handle *xhp)
|
||||
{
|
||||
cfg_opt_t vpkg_opts[] = {
|
||||
CFG_STR_LIST(__UNCONST("targets"), NULL, CFGF_NONE),
|
||||
@ -119,11 +117,7 @@ xbps_init(struct xbps_handle *xh)
|
||||
int rv, cc, cch;
|
||||
bool syslog_enabled = false;
|
||||
|
||||
assert(xh != NULL);
|
||||
|
||||
xhp = xh;
|
||||
if (xhp->flags & XBPS_FLAG_DEBUG)
|
||||
debug = true;
|
||||
assert(xhp != NULL);
|
||||
|
||||
if (xhp->conffile == NULL)
|
||||
xhp->conffile = XBPS_CONF_DEF;
|
||||
@ -150,7 +144,7 @@ xbps_init(struct xbps_handle *xh)
|
||||
return ENOTSUP;
|
||||
}
|
||||
}
|
||||
xbps_dbg_printf("Configuration file: %s\n",
|
||||
xbps_dbg_printf(xhp, "Configuration file: %s\n",
|
||||
xhp->conffile ? xhp->conffile : "not found");
|
||||
/*
|
||||
* Respect client setting in struct xbps_handle for {root,cache}dir;
|
||||
@ -196,14 +190,14 @@ xbps_init(struct xbps_handle *xh)
|
||||
|
||||
xbps_fetch_set_cache_connection(cc, cch);
|
||||
|
||||
xbps_dbg_printf("Rootdir=%s\n", xhp->rootdir);
|
||||
xbps_dbg_printf("Metadir=%s\n", xhp->metadir);
|
||||
xbps_dbg_printf("Cachedir=%s\n", xhp->cachedir);
|
||||
xbps_dbg_printf("FetchTimeout=%u\n", xhp->fetch_timeout);
|
||||
xbps_dbg_printf("FetchCacheconn=%u\n", cc);
|
||||
xbps_dbg_printf("FetchCacheconnHost=%u\n", cch);
|
||||
xbps_dbg_printf("Syslog=%u\n", syslog_enabled);
|
||||
xbps_dbg_printf("TransactionFrequencyFlush=%u\n",
|
||||
xbps_dbg_printf(xhp, "Rootdir=%s\n", xhp->rootdir);
|
||||
xbps_dbg_printf(xhp, "Metadir=%s\n", xhp->metadir);
|
||||
xbps_dbg_printf(xhp, "Cachedir=%s\n", xhp->cachedir);
|
||||
xbps_dbg_printf(xhp, "FetchTimeout=%u\n", xhp->fetch_timeout);
|
||||
xbps_dbg_printf(xhp, "FetchCacheconn=%u\n", cc);
|
||||
xbps_dbg_printf(xhp, "FetchCacheconnHost=%u\n", cch);
|
||||
xbps_dbg_printf(xhp, "Syslog=%u\n", syslog_enabled);
|
||||
xbps_dbg_printf(xhp, "TransactionFrequencyFlush=%u\n",
|
||||
xhp->transaction_frequency_flush);
|
||||
|
||||
xbps_initialized = true;
|
||||
@ -212,7 +206,7 @@ xbps_init(struct xbps_handle *xh)
|
||||
}
|
||||
|
||||
void
|
||||
xbps_end(void)
|
||||
xbps_end(struct xbps_handle *xhp)
|
||||
{
|
||||
if (!xbps_initialized)
|
||||
return;
|
||||
@ -232,12 +226,6 @@ xbps_end(void)
|
||||
xbps_initialized = false;
|
||||
}
|
||||
|
||||
struct xbps_handle *
|
||||
xbps_handle_get(void)
|
||||
{
|
||||
return xhp;
|
||||
}
|
||||
|
||||
static void
|
||||
common_printf(FILE *f, const char *msg, const char *fmt, va_list ap)
|
||||
{
|
||||
@ -248,11 +236,11 @@ common_printf(FILE *f, const char *msg, const char *fmt, va_list ap)
|
||||
}
|
||||
|
||||
void
|
||||
xbps_dbg_printf_append(const char *fmt, ...)
|
||||
xbps_dbg_printf_append(struct xbps_handle *xhp, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (!debug)
|
||||
if ((xhp->flags & XBPS_FLAG_DEBUG) == 0)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
@ -261,11 +249,11 @@ xbps_dbg_printf_append(const char *fmt, ...)
|
||||
}
|
||||
|
||||
void
|
||||
xbps_dbg_printf(const char *fmt, ...)
|
||||
xbps_dbg_printf(struct xbps_handle *xhp, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (!debug)
|
||||
if ((xhp->flags & XBPS_FLAG_DEBUG) == 0)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
@ -76,7 +76,8 @@ out:
|
||||
* Returns 1 if entry should be installed, 0 if don't or -1 on error.
|
||||
*/
|
||||
int HIDDEN
|
||||
xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
||||
prop_dictionary_t filesd,
|
||||
struct archive_entry *entry,
|
||||
const char *entry_pname,
|
||||
const char *pkgname,
|
||||
@ -103,12 +104,12 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
* Get original hash for the file from current
|
||||
* installed package.
|
||||
*/
|
||||
xbps_dbg_printf("%s: processing conf_file %s\n",
|
||||
xbps_dbg_printf(xhp, "%s: processing conf_file %s\n",
|
||||
pkgname, entry_pname);
|
||||
|
||||
forigd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
forigd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
|
||||
if (forigd == NULL) {
|
||||
xbps_dbg_printf("%s: conf_file %s not currently installed\n",
|
||||
xbps_dbg_printf(xhp, "%s: conf_file %s not currently installed\n",
|
||||
pkgname, entry_pname);
|
||||
rv = 1;
|
||||
goto out;
|
||||
@ -141,7 +142,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
* First case: original hash not found, install new file.
|
||||
*/
|
||||
if (sha256_orig == NULL) {
|
||||
xbps_dbg_printf("%s: conf_file %s unknown orig sha256\n",
|
||||
xbps_dbg_printf(xhp, "%s: conf_file %s unknown orig sha256\n",
|
||||
pkgname, entry_pname);
|
||||
rv = 1;
|
||||
goto out;
|
||||
@ -170,7 +171,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
/*
|
||||
* File not installed, install new one.
|
||||
*/
|
||||
xbps_dbg_printf("%s: conf_file %s not "
|
||||
xbps_dbg_printf(xhp, "%s: conf_file %s not "
|
||||
"installed\n", pkgname, entry_pname);
|
||||
rv = 1;
|
||||
break;
|
||||
@ -187,7 +188,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
if ((strcmp(sha256_orig, sha256_cur) == 0) &&
|
||||
(strcmp(sha256_orig, sha256_new) == 0) &&
|
||||
(strcmp(sha256_cur, sha256_new) == 0)) {
|
||||
xbps_dbg_printf("%s: conf_file %s orig = X,"
|
||||
xbps_dbg_printf(xhp, "%s: conf_file %s orig = X,"
|
||||
"cur = X, new = X\n", pkgname, entry_pname);
|
||||
rv = 1;
|
||||
break;
|
||||
@ -199,7 +200,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
} else if ((strcmp(sha256_orig, sha256_cur) == 0) &&
|
||||
(strcmp(sha256_orig, sha256_new)) &&
|
||||
(strcmp(sha256_cur, sha256_new))) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIG_FILE,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
|
||||
0, pkgname, version,
|
||||
"Updating configuration file `%s' provided "
|
||||
"by version `%s'.", cffile, version);
|
||||
@ -212,7 +213,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
} else if ((strcmp(sha256_orig, sha256_new) == 0) &&
|
||||
(strcmp(sha256_cur, sha256_new)) &&
|
||||
(strcmp(sha256_orig, sha256_cur))) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIG_FILE,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
|
||||
0, pkgname, version,
|
||||
"Keeping modified configuration file `%s'.",
|
||||
cffile);
|
||||
@ -225,7 +226,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
} else if ((strcmp(sha256_cur, sha256_new) == 0) &&
|
||||
(strcmp(sha256_orig, sha256_new)) &&
|
||||
(strcmp(sha256_orig, sha256_cur))) {
|
||||
xbps_dbg_printf("%s: conf_file %s orig = X,"
|
||||
xbps_dbg_printf(xhp, "%s: conf_file %s orig = X,"
|
||||
"cur = Y, new = Y\n", pkgname, entry_pname);
|
||||
rv = 0;
|
||||
break;
|
||||
@ -242,7 +243,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIG_FILE,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
|
||||
0, pkgname, version,
|
||||
"Installing new configuration file to "
|
||||
"`%s.new-%s'.", cffile, version);
|
||||
@ -261,7 +262,7 @@ out:
|
||||
|
||||
prop_object_iterator_release(iter);
|
||||
|
||||
xbps_dbg_printf("%s: conf_file %s returned %d\n",
|
||||
xbps_dbg_printf(xhp, "%s: conf_file %s returned %d\n",
|
||||
pkgname, entry_pname, rv);
|
||||
|
||||
return rv;
|
||||
|
@ -47,9 +47,8 @@
|
||||
* state is XBPS_PKG_STATE_INSTALLED.
|
||||
*/
|
||||
int
|
||||
xbps_configure_packages(bool flush)
|
||||
xbps_configure_packages(struct xbps_handle *xhp, bool flush)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_object_t obj;
|
||||
const char *pkgname;
|
||||
size_t i;
|
||||
@ -61,23 +60,23 @@ xbps_configure_packages(bool flush)
|
||||
for (i = 0; i < prop_array_count(xhp->pkgdb); i++) {
|
||||
obj = prop_array_get(xhp->pkgdb, i);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
rv = xbps_configure_pkg(pkgname, true, false, false);
|
||||
rv = xbps_configure_pkg(xhp, pkgname, true, false, false);
|
||||
if (rv != 0)
|
||||
break;
|
||||
}
|
||||
if (flush)
|
||||
rv = xbps_pkgdb_update(true);
|
||||
rv = xbps_pkgdb_update(xhp, true);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
xbps_configure_pkg(const char *pkgname,
|
||||
xbps_configure_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
bool check_state,
|
||||
bool update,
|
||||
bool flush)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *version, *pkgver;
|
||||
char *buf;
|
||||
@ -85,9 +84,8 @@ xbps_configure_pkg(const char *pkgname,
|
||||
pkg_state_t state = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
@ -96,9 +94,9 @@ xbps_configure_pkg(const char *pkgname,
|
||||
|
||||
if (check_state) {
|
||||
rv = xbps_pkg_state_dictionary(pkgd, &state);
|
||||
xbps_dbg_printf("%s: state %d rv %d\n", pkgname, state, rv);
|
||||
xbps_dbg_printf(xhp, "%s: state %d rv %d\n", pkgname, state, rv);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf("%s: [configure] failed to get "
|
||||
xbps_dbg_printf(xhp, "%s: [configure] failed to get "
|
||||
"pkg state: %s\n", pkgname, strerror(rv));
|
||||
prop_object_release(pkgd);
|
||||
return EINVAL;
|
||||
@ -115,7 +113,7 @@ xbps_configure_pkg(const char *pkgname,
|
||||
}
|
||||
}
|
||||
prop_object_release(pkgd);
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE, 0, pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE, 0, pkgname, version, NULL);
|
||||
|
||||
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
||||
XBPS_META_PATH, pkgname);
|
||||
@ -123,8 +121,8 @@ xbps_configure_pkg(const char *pkgname,
|
||||
return ENOMEM;
|
||||
|
||||
if (chdir(xhp->rootdir) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, errno,
|
||||
pkgname, version,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [configure] failed to chdir to rootdir `%s': %s",
|
||||
pkgver, xhp->rootdir, strerror(errno));
|
||||
free(buf);
|
||||
@ -132,11 +130,11 @@ xbps_configure_pkg(const char *pkgname,
|
||||
}
|
||||
|
||||
if (access(buf, X_OK) == 0) {
|
||||
if (xbps_file_exec(buf, "post",
|
||||
if (xbps_file_exec(xhp, buf, "post",
|
||||
pkgname, version, update ? "yes" : "no",
|
||||
xhp->conffile, NULL) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, errno,
|
||||
pkgname, version,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [configure] INSTALL script failed to execute "
|
||||
"the post ACTION: %s", pkgver, strerror(errno));
|
||||
free(buf);
|
||||
@ -144,8 +142,8 @@ xbps_configure_pkg(const char *pkgname,
|
||||
}
|
||||
} else {
|
||||
if (errno != ENOENT) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, errno,
|
||||
pkgname, version,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [configure] INSTALL script cannot be "
|
||||
"executed: %s", pkgver, strerror(errno));
|
||||
free(buf);
|
||||
@ -153,17 +151,17 @@ xbps_configure_pkg(const char *pkgname,
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
rv = xbps_set_pkg_state_installed(pkgname, version,
|
||||
rv = xbps_set_pkg_state_installed(xhp, pkgname, version,
|
||||
XBPS_PKG_STATE_INSTALLED);
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, rv,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL, rv,
|
||||
pkgname, version,
|
||||
"%s: [configure] failed to set state to installed: %s",
|
||||
pkgver, strerror(rv));
|
||||
}
|
||||
if (flush) {
|
||||
if ((rv = xbps_pkgdb_update(true)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIGURE_FAIL, rv,
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL, rv,
|
||||
pkgname, version,
|
||||
"%s: [configure] failed to update pkgdb: %s\n",
|
||||
pkgver, strerror(rv));
|
||||
|
@ -52,7 +52,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Check if current pkg conflicts with an installed package.
|
||||
*/
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd(cfpkg, true))) {
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd(xhp, cfpkg, true))) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
buf = xbps_xasprintf("%s conflicts with "
|
||||
|
@ -65,7 +65,10 @@ struct orphan_data {
|
||||
};
|
||||
|
||||
static int
|
||||
find_orphan_pkg(prop_object_t obj, void *arg, bool *loop_done)
|
||||
find_orphan_pkg(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
struct orphan_data *od = arg;
|
||||
prop_array_t reqby;
|
||||
@ -79,6 +82,7 @@ find_orphan_pkg(prop_object_t obj, void *arg, bool *loop_done)
|
||||
int rv = 0;
|
||||
pkg_state_t state;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
/*
|
||||
* Skip packages that were not installed automatically.
|
||||
@ -164,7 +168,7 @@ find_orphan_pkg(prop_object_t obj, void *arg, bool *loop_done)
|
||||
}
|
||||
|
||||
prop_array_t
|
||||
xbps_find_pkg_orphans(prop_array_t orphans_user)
|
||||
xbps_find_pkg_orphans(struct xbps_handle *xhp, prop_array_t orphans_user)
|
||||
{
|
||||
prop_array_t array = NULL;
|
||||
struct orphan_data od;
|
||||
@ -180,7 +184,7 @@ xbps_find_pkg_orphans(prop_array_t orphans_user)
|
||||
* order in which packages were installed.
|
||||
*/
|
||||
od.orphans_user = orphans_user;
|
||||
rv = xbps_pkgdb_foreach_reverse_cb(find_orphan_pkg, &od);
|
||||
rv = xbps_pkgdb_foreach_reverse_cb(xhp, find_orphan_pkg, &od);
|
||||
if (rv != 0) {
|
||||
errno = rv;
|
||||
prop_object_release(od.array);
|
||||
|
@ -40,9 +40,8 @@
|
||||
*/
|
||||
|
||||
int
|
||||
xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
||||
xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd, bool flush)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
prop_array_t provides, reqby;
|
||||
const char *pkgname, *version, *desc, *pkgver;
|
||||
@ -51,8 +50,6 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
||||
|
||||
assert(prop_object_type(pkgrd) == PROP_TYPE_DICTIONARY);
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version);
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
|
||||
@ -61,38 +58,42 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
||||
provides = prop_dictionary_get(pkgrd, "provides");
|
||||
reqby = prop_dictionary_get(pkgrd, "requiredby");
|
||||
|
||||
xbps_set_cb_state(XBPS_STATE_REGISTER, 0, pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REGISTER, 0, pkgname, version, NULL);
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(version != NULL);
|
||||
assert(desc != NULL);
|
||||
assert(pkgver != NULL);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
if (pkgd == NULL) {
|
||||
rv = ENOENT;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
||||
"version", version)) {
|
||||
xbps_dbg_printf("%s: invalid version for %s\n", __func__, pkgname);
|
||||
xbps_dbg_printf(xhp, "%s: invalid version for %s\n",
|
||||
__func__, pkgname);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
||||
"pkgver", pkgver)) {
|
||||
xbps_dbg_printf("%s: invalid pkgver for %s\n", __func__, pkgname);
|
||||
xbps_dbg_printf(xhp, "%s: invalid pkgver for %s\n",
|
||||
__func__, pkgname);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
||||
"short_desc", desc)) {
|
||||
xbps_dbg_printf("%s: invalid short_desc for %s\n", __func__, pkgname);
|
||||
xbps_dbg_printf(xhp, "%s: invalid short_desc for %s\n",
|
||||
__func__, pkgname);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (reqby && !prop_dictionary_set(pkgd, "requiredby", reqby)) {
|
||||
xbps_dbg_printf("%s: invalid requiredby for %s\n", __func__, pkgname);
|
||||
xbps_dbg_printf(xhp, "%s: invalid requiredby for %s\n",
|
||||
__func__, pkgname);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@ -104,13 +105,15 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
||||
|
||||
if (!prop_dictionary_set_bool(pkgd,
|
||||
"automatic-install", autoinst)) {
|
||||
xbps_dbg_printf("%s: invalid autoinst for %s\n", __func__, pkgname);
|
||||
xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n",
|
||||
__func__, pkgname);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (provides) {
|
||||
if (!prop_dictionary_set(pkgd, "provides", provides)) {
|
||||
xbps_dbg_printf("%s: invalid provides for %s\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: invalid provides for %s\n",
|
||||
__func__, pkgname);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
@ -121,13 +124,15 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
||||
*/
|
||||
if (pkgrd && xbps_pkg_has_rundeps(pkgrd)) {
|
||||
if ((rv = xbps_requiredby_pkg_add(xhp, pkgrd)) != 0) {
|
||||
xbps_dbg_printf("%s: requiredby add failed for %s\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: requiredby add failed for %s\n",
|
||||
__func__, pkgname);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if (!xbps_pkgdb_replace_pkgd(pkgd, pkgname, false, flush)) {
|
||||
xbps_dbg_printf("%s: failed to replace pkgd dict for %s\n",
|
||||
if (!xbps_pkgdb_replace_pkgd(xhp, pkgd, pkgname, false, flush)) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: failed to replace pkgd dict for %s\n",
|
||||
__func__, pkgname);
|
||||
goto out;
|
||||
}
|
||||
@ -136,7 +141,7 @@ out:
|
||||
prop_object_release(pkgd);
|
||||
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_REGISTER_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REGISTER_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: failed to register package: %s",
|
||||
pkgver, strerror(rv));
|
||||
@ -146,14 +151,17 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_unregister_pkg(const char *pkgname, const char *version, bool flush)
|
||||
xbps_unregister_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
bool flush)
|
||||
{
|
||||
assert(pkgname != NULL);
|
||||
|
||||
xbps_set_cb_state(XBPS_STATE_UNREGISTER, 0, pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNREGISTER, 0, pkgname, version, NULL);
|
||||
|
||||
if (!xbps_pkgdb_remove_pkgd(pkgname, false, flush)) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNREGISTER_FAIL,
|
||||
if (!xbps_pkgdb_remove_pkgd(xhp, pkgname, false, flush)) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNREGISTER_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: failed to unregister package: %s",
|
||||
pkgname, strerror(errno));
|
||||
|
@ -74,10 +74,10 @@
|
||||
* data type is specified on its edge, i.e string, array, integer, dictionary.
|
||||
*/
|
||||
static int
|
||||
remove_pkg_metadata(const char *pkgname,
|
||||
remove_pkg_metadata(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
const char *pkgver,
|
||||
const char *rootdir)
|
||||
const char *pkgver)
|
||||
{
|
||||
struct dirent *dp;
|
||||
DIR *dirp;
|
||||
@ -85,9 +85,8 @@ remove_pkg_metadata(const char *pkgname,
|
||||
int rv = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(rootdir != NULL);
|
||||
|
||||
metadir = xbps_xasprintf("%s/%s/metadata/%s", rootdir,
|
||||
metadir = xbps_xasprintf("%s/%s/metadata/%s", xhp->rootdir,
|
||||
XBPS_META_PATH, pkgname);
|
||||
if (metadir == NULL)
|
||||
return ENOMEM;
|
||||
@ -111,7 +110,7 @@ remove_pkg_metadata(const char *pkgname,
|
||||
}
|
||||
|
||||
if (unlink(path) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_PURGE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_PURGE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [purge] failed to remove metafile `%s': %s",
|
||||
pkgver, path, strerror(errno));
|
||||
@ -128,11 +127,11 @@ remove_pkg_metadata(const char *pkgname,
|
||||
}
|
||||
|
||||
int
|
||||
xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
xbps_remove_pkg_files(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pkgver)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
struct stat st;
|
||||
prop_array_t array;
|
||||
prop_object_iterator_t iter;
|
||||
@ -144,7 +143,6 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
|
||||
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
||||
assert(key != NULL);
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
array = prop_dictionary_get(dict, key);
|
||||
if ((prop_object_type(array) != PROP_TYPE_ARRAY) ||
|
||||
@ -186,7 +184,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
rv = xbps_file_hash_check(path, sha256);
|
||||
if (rv == ENOENT) {
|
||||
/* missing file, ignore it */
|
||||
xbps_set_cb_state(
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_REMOVE_FILE_HASH_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: failed to check hash for %s `%s': %s",
|
||||
@ -198,7 +196,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
rv = 0;
|
||||
if ((xhp->flags &
|
||||
XBPS_FLAG_FORCE_REMOVE_FILES) == 0) {
|
||||
xbps_set_cb_state(
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_REMOVE_FILE_HASH_FAIL,
|
||||
0, pkgname, version,
|
||||
"%s: %s `%s' SHA256 mismatch, "
|
||||
@ -207,7 +205,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
free(path);
|
||||
continue;
|
||||
} else {
|
||||
xbps_set_cb_state(
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_REMOVE_FILE_HASH_FAIL,
|
||||
0, pkgname, version,
|
||||
"%s: %s `%s' SHA256 mismatch, "
|
||||
@ -215,7 +213,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
curobj, file);
|
||||
}
|
||||
} else if (rv != 0 && rv != ERANGE) {
|
||||
xbps_set_cb_state(
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_REMOVE_FILE_HASH_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [remove] failed to check hash for "
|
||||
@ -245,14 +243,14 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
* Remove the object if possible.
|
||||
*/
|
||||
if (remove(path) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FILE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FILE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: failed to remove %s `%s': %s", pkgver,
|
||||
curobj, file, strerror(errno));
|
||||
errno = 0;
|
||||
} else {
|
||||
/* success */
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FILE,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FILE,
|
||||
0, pkgname, version,
|
||||
"Removed %s `%s'", curobj, file);
|
||||
}
|
||||
@ -266,10 +264,12 @@ xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
}
|
||||
|
||||
int
|
||||
xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
xbps_remove_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
bool update,
|
||||
bool soft_replace)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
char *buf = NULL, *pkgver = NULL;
|
||||
int rv = 0;
|
||||
@ -279,8 +279,6 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
assert(pkgname != NULL);
|
||||
assert(version != NULL);
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
buf = xbps_xasprintf("%s/metadata/%s/REMOVE",
|
||||
XBPS_META_PATH, pkgname);
|
||||
if (buf == NULL) {
|
||||
@ -294,15 +292,15 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((rv = xbps_pkg_state_installed(pkgname, &state)) != 0)
|
||||
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0)
|
||||
goto out;
|
||||
|
||||
if (!update)
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE, 0, pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE, 0, pkgname, version, NULL);
|
||||
|
||||
if (chdir(xhp->rootdir) == -1) {
|
||||
rv = errno;
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [remove] failed to chdir to rootdir `%s': %s",
|
||||
pkgver, xhp->rootdir, strerror(rv));
|
||||
@ -316,9 +314,9 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
*/
|
||||
if (access(buf, X_OK) == 0) {
|
||||
rmfile_exists = true;
|
||||
if (xbps_file_exec(buf, "pre", pkgname, version,
|
||||
if (xbps_file_exec(xhp, buf, "pre", pkgname, version,
|
||||
update ? "yes" : "no", xhp->conffile, NULL) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [remove] REMOVE script failed to "
|
||||
"execute pre ACTION: %s",
|
||||
@ -328,7 +326,7 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
}
|
||||
} else {
|
||||
if (errno != ENOENT) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [remove] REMOVE script failed to "
|
||||
"execute pre ACTION: %s",
|
||||
@ -345,7 +343,7 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
if (update) {
|
||||
free(pkgver);
|
||||
free(buf);
|
||||
return xbps_requiredby_pkg_remove(pkgname);
|
||||
return xbps_requiredby_pkg_remove(xhp, pkgname);
|
||||
} else if (soft_replace) {
|
||||
/*
|
||||
* Soft replace a package. Do not remove its files, but
|
||||
@ -355,19 +353,19 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
goto softreplace;
|
||||
}
|
||||
|
||||
pkgd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
pkgd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
|
||||
if (pkgd) {
|
||||
/* Remove regular files */
|
||||
if ((rv = xbps_remove_pkg_files(pkgd, "files", pkgver)) != 0)
|
||||
if ((rv = xbps_remove_pkg_files(xhp, pkgd, "files", pkgver)) != 0)
|
||||
goto out;
|
||||
/* Remove configuration files */
|
||||
if ((rv = xbps_remove_pkg_files(pkgd, "conf_files", pkgver)) != 0)
|
||||
if ((rv = xbps_remove_pkg_files(xhp, pkgd, "conf_files", pkgver)) != 0)
|
||||
goto out;
|
||||
/* Remove links */
|
||||
if ((rv = xbps_remove_pkg_files(pkgd, "links", pkgver)) != 0)
|
||||
if ((rv = xbps_remove_pkg_files(xhp, pkgd, "links", pkgver)) != 0)
|
||||
goto out;
|
||||
/* Remove dirs */
|
||||
if ((rv = xbps_remove_pkg_files(pkgd, "dirs", pkgver)) != 0)
|
||||
if ((rv = xbps_remove_pkg_files(xhp, pkgd, "dirs", pkgver)) != 0)
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
@ -375,9 +373,9 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
* updating the package.
|
||||
*/
|
||||
if (rmfile_exists &&
|
||||
((rv = xbps_file_exec(buf, "post", pkgname, version, "no",
|
||||
((rv = xbps_file_exec(xhp, buf, "post", pkgname, version, "no",
|
||||
xhp->conffile, NULL)) != 0)) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [remove] REMOVE script failed to execute "
|
||||
"post ACTION: %s", pkgver, strerror(rv));
|
||||
@ -386,8 +384,8 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update,
|
||||
/*
|
||||
* Update the requiredby array of all required dependencies.
|
||||
*/
|
||||
if ((rv = xbps_requiredby_pkg_remove(pkgname)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
if ((rv = xbps_requiredby_pkg_remove(xhp, pkgname)) != 0) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [remove] failed to remove requiredby entries: %s",
|
||||
pkgver, strerror(rv));
|
||||
@ -398,10 +396,10 @@ softreplace:
|
||||
/*
|
||||
* Set package state to "half-removed".
|
||||
*/
|
||||
rv = xbps_set_pkg_state_installed(pkgname, version,
|
||||
rv = xbps_set_pkg_state_installed(xhp, pkgname, version,
|
||||
XBPS_PKG_STATE_HALF_REMOVED);
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [remove] failed to set state to half-removed: %s",
|
||||
pkgver, strerror(rv));
|
||||
@ -413,9 +411,9 @@ purge:
|
||||
* Execute the purge REMOVE action if file exists.
|
||||
*/
|
||||
if (access(buf, X_OK) == 0) {
|
||||
if ((rv = xbps_file_exec(buf, "purge", pkgname, version, "no",
|
||||
if ((rv = xbps_file_exec(xhp, buf, "purge", pkgname, version, "no",
|
||||
xhp->conffile, NULL)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: REMOVE script failed to execute "
|
||||
"purge ACTION: %s", pkgver, strerror(rv));
|
||||
@ -425,9 +423,9 @@ purge:
|
||||
/*
|
||||
* Remove package metadata directory.
|
||||
*/
|
||||
rv = remove_pkg_metadata(pkgname, version, pkgver, xhp->rootdir);
|
||||
rv = remove_pkg_metadata(xhp, pkgname, version, pkgver);
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: failed to remove metadata files: %s",
|
||||
pkgver, strerror(rv));
|
||||
@ -437,10 +435,10 @@ purge:
|
||||
/*
|
||||
* Unregister package from pkgdb.
|
||||
*/
|
||||
if ((rv = xbps_unregister_pkg(pkgname, version, false)) != 0)
|
||||
if ((rv = xbps_unregister_pkg(xhp, pkgname, version, false)) != 0)
|
||||
goto out;
|
||||
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_DONE,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_DONE,
|
||||
0, pkgname, version, NULL);
|
||||
|
||||
out:
|
||||
|
@ -36,7 +36,8 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
int HIDDEN
|
||||
xbps_remove_obsoletes(const char *pkgname,
|
||||
xbps_remove_obsoletes(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
const char *pkgver,
|
||||
prop_dictionary_t oldd,
|
||||
@ -131,14 +132,16 @@ again:
|
||||
* Obsolete obj found, remove it.
|
||||
*/
|
||||
if (remove(file) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_REMOVE_FILE_OBSOLETE_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: failed to remove obsolete entry `%s': %s",
|
||||
pkgver, file, strerror(errno));
|
||||
free(file);
|
||||
continue;
|
||||
}
|
||||
xbps_set_cb_state(XBPS_STATE_REMOVE_FILE_OBSOLETE,
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_REMOVE_FILE_OBSOLETE,
|
||||
0, pkgname, version,
|
||||
"Removed obsolete entry: %s", file);
|
||||
free(file);
|
||||
|
@ -32,7 +32,9 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
static int
|
||||
add_pkg_into_reqby(prop_dictionary_t pkgd, const char *pkgver)
|
||||
add_pkg_into_reqby(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *pkgver)
|
||||
{
|
||||
prop_array_t reqby;
|
||||
prop_string_t reqstr;
|
||||
@ -57,7 +59,7 @@ add_pkg_into_reqby(prop_dictionary_t pkgd, const char *pkgver)
|
||||
|
||||
if (xbps_match_pkgname_in_array(reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(reqby, pkgname)) {
|
||||
xbps_dbg_printf("%s: failed to remove %s reqby entry: "
|
||||
xbps_dbg_printf(xhp, "%s: failed to remove %s reqby entry: "
|
||||
"%s\n", __func__, pkgname, strerror(errno));
|
||||
free(pkgname);
|
||||
return EINVAL;
|
||||
@ -95,11 +97,15 @@ add_pkg_into_reqby(prop_dictionary_t pkgd, const char *pkgver)
|
||||
}
|
||||
|
||||
static int
|
||||
remove_pkg_from_reqby(prop_object_t obj, void *arg, bool *loop_done)
|
||||
remove_pkg_from_reqby(struct xbps_handle *xhp,
|
||||
prop_object_t obj,
|
||||
void *arg,
|
||||
bool *loop_done)
|
||||
{
|
||||
prop_array_t reqby;
|
||||
const char *pkgname = arg;
|
||||
|
||||
(void)xhp;
|
||||
(void)loop_done;
|
||||
|
||||
reqby = prop_dictionary_get(obj, "requiredby");
|
||||
@ -115,10 +121,10 @@ remove_pkg_from_reqby(prop_object_t obj, void *arg, bool *loop_done)
|
||||
}
|
||||
|
||||
int HIDDEN
|
||||
xbps_requiredby_pkg_remove(const char *pkgname)
|
||||
xbps_requiredby_pkg_remove(struct xbps_handle *xhp, const char *pkgname)
|
||||
{
|
||||
assert(pkgname != NULL);
|
||||
return xbps_pkgdb_foreach_cb(remove_pkg_from_reqby, __UNCONST(pkgname));
|
||||
return xbps_pkgdb_foreach_cb(xhp, remove_pkg_from_reqby, __UNCONST(pkgname));
|
||||
}
|
||||
|
||||
int HIDDEN
|
||||
@ -147,10 +153,11 @@ xbps_requiredby_pkg_add(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
rv = EINVAL;
|
||||
break;
|
||||
}
|
||||
xbps_dbg_printf("%s: adding reqby entry for %s\n", __func__, str);
|
||||
xbps_dbg_printf(xhp, "%s: adding reqby entry for %s\n",
|
||||
__func__, str);
|
||||
|
||||
pkgd_pkgdb = xbps_find_virtualpkg_conf_in_array_by_pattern(
|
||||
xhp->pkgdb, str);
|
||||
xhp, xhp->pkgdb, str);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
pkgd_pkgdb =
|
||||
xbps_find_virtualpkg_in_array_by_pattern(
|
||||
@ -160,13 +167,14 @@ xbps_requiredby_pkg_add(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
xhp->pkgdb, str, NULL);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
rv = ENOENT;
|
||||
xbps_dbg_printf("%s: couldnt find `%s' "
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s: couldnt find `%s' "
|
||||
"entry in pkgdb\n", __func__, str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
rv = add_pkg_into_reqby(pkgd_pkgdb, pkgver);
|
||||
rv = add_pkg_into_reqby(xhp, pkgd_pkgdb, pkgver);
|
||||
if (rv != 0)
|
||||
break;
|
||||
}
|
||||
|
@ -93,14 +93,16 @@ get_state(prop_dictionary_t dict)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_pkg_state_installed(const char *pkgname, pkg_state_t *state)
|
||||
xbps_pkg_state_installed(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
pkg_state_t *state)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(state != NULL);
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
if (pkgd == NULL)
|
||||
return ENOENT;
|
||||
|
||||
@ -156,17 +158,16 @@ set_pkg_objs(prop_dictionary_t pkgd, const char *name, const char *version)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_set_pkg_state_installed(const char *pkgname,
|
||||
xbps_set_pkg_state_installed(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *version,
|
||||
pkg_state_t state)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd;
|
||||
bool newpkg = false;
|
||||
int rv;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
if (xhp->pkgdb == NULL) {
|
||||
xhp->pkgdb = prop_array_create();
|
||||
@ -198,7 +199,7 @@ xbps_set_pkg_state_installed(const char *pkgname,
|
||||
return EINVAL;
|
||||
}
|
||||
} else {
|
||||
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
if (pkgd == NULL) {
|
||||
newpkg = true;
|
||||
pkgd = prop_dictionary_create();
|
||||
|
@ -49,7 +49,8 @@ set_extract_flags(void)
|
||||
}
|
||||
|
||||
static int
|
||||
extract_metafile(struct archive *ar,
|
||||
extract_metafile(struct xbps_handle *xhp,
|
||||
struct archive *ar,
|
||||
struct archive_entry *entry,
|
||||
const char *file,
|
||||
const char *pkgver,
|
||||
@ -85,7 +86,7 @@ extract_metafile(struct archive *ar,
|
||||
dname = dirname(dirc);
|
||||
if (access(dname, X_OK) == -1) {
|
||||
if (xbps_mkpath(dname, 0755) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] failed to create metadir `%s': %s",
|
||||
pkgver, dname, strerror(errno));
|
||||
@ -100,7 +101,7 @@ extract_metafile(struct archive *ar,
|
||||
|
||||
if (archive_read_extract(ar, entry, flags) != 0) {
|
||||
rv = archive_errno(ar);
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to extract metafile `%s': %s",
|
||||
pkgver, file, strerror(rv));
|
||||
@ -115,7 +116,9 @@ extract_metafile(struct archive *ar,
|
||||
}
|
||||
|
||||
static int
|
||||
remove_metafile(const char *file, const char *pkgver)
|
||||
remove_metafile(struct xbps_handle *xhp,
|
||||
const char *file,
|
||||
const char *pkgver)
|
||||
{
|
||||
const char *version;
|
||||
char *buf, *pkgname;
|
||||
@ -136,7 +139,7 @@ remove_metafile(const char *file, const char *pkgver)
|
||||
}
|
||||
if (unlink(buf) == -1) {
|
||||
if (errno && errno != ENOENT) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] failed to remove metafile `%s': %s",
|
||||
pkgver, file, strerror(errno));
|
||||
@ -152,11 +155,12 @@ remove_metafile(const char *file, const char *pkgver)
|
||||
}
|
||||
|
||||
static int
|
||||
unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
unpack_archive(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkg_repod,
|
||||
struct archive *ar)
|
||||
{
|
||||
prop_dictionary_t propsd = NULL, filesd = NULL, old_filesd = NULL;
|
||||
prop_array_t array;
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
const struct stat *entry_statp;
|
||||
struct stat st;
|
||||
struct xbps_unpack_cb_data *xucd = NULL;
|
||||
@ -205,7 +209,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
}
|
||||
}
|
||||
if (chdir(xhp->rootdir) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] failed to chdir to rootdir `%s': %s",
|
||||
pkgver, xhp->rootdir, strerror(errno));
|
||||
@ -218,9 +222,9 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
* Always remove current INSTALL/REMOVE scripts in pkg's metadir,
|
||||
* as security measures.
|
||||
*/
|
||||
if ((rv = remove_metafile("INSTALL", pkgver)) != 0)
|
||||
if ((rv = remove_metafile(xhp, "INSTALL", pkgver)) != 0)
|
||||
goto out;
|
||||
if ((rv = remove_metafile("REMOVE", pkgver)) != 0)
|
||||
if ((rv = remove_metafile(xhp, "REMOVE", pkgver)) != 0)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
@ -263,18 +267,19 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
rv = extract_metafile(ar, entry, "INSTALL",
|
||||
pkgver, true, flags);
|
||||
rv = extract_metafile(xhp, ar, entry,
|
||||
"INSTALL", pkgver, true, flags);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
|
||||
rv = xbps_file_exec(buf, "pre",
|
||||
rv = xbps_file_exec(xhp, buf, "pre",
|
||||
pkgname, version, update ? "yes" : "no",
|
||||
xhp->conffile, NULL);
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] INSTALL script failed "
|
||||
"to execute pre ACTION: %s",
|
||||
@ -285,8 +290,8 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
continue;
|
||||
|
||||
} else if (strcmp("./REMOVE", entry_pname) == 0) {
|
||||
rv = extract_metafile(ar, entry, "REMOVE",
|
||||
pkgver, true, flags);
|
||||
rv = extract_metafile(xhp, ar, entry,
|
||||
"REMOVE", pkgver, true, flags);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
|
||||
@ -308,12 +313,12 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
continue;
|
||||
|
||||
} else if (strcmp("./props.plist", entry_pname) == 0) {
|
||||
rv = extract_metafile(ar, entry, XBPS_PKGPROPS,
|
||||
rv = extract_metafile(xhp, ar, entry, XBPS_PKGPROPS,
|
||||
pkgver, false, flags);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
|
||||
propsd = xbps_dictionary_from_metadata_plist(
|
||||
propsd = xbps_dictionary_from_metadata_plist(xhp,
|
||||
pkgname, XBPS_PKGPROPS);
|
||||
if (propsd == NULL) {
|
||||
rv = errno;
|
||||
@ -334,7 +339,8 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
* This is not an XBPS binary package.
|
||||
*/
|
||||
if (entry_idx >= 3) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_UNPACK_FAIL,
|
||||
ENODEV, pkgname, version,
|
||||
"%s: [unpack] invalid binary package `%s'.",
|
||||
pkgver, fname);
|
||||
@ -379,13 +385,14 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
buf[x] = entry_pname[i];
|
||||
buf[x] = '\0';
|
||||
file_exists = true;
|
||||
rv = xbps_file_hash_check_dictionary(filesd,
|
||||
rv = xbps_file_hash_check_dictionary(xhp, filesd,
|
||||
conf_file ? "conf_files" : "files", buf);
|
||||
free(buf);
|
||||
|
||||
if (rv == -1) {
|
||||
/* error */
|
||||
xbps_dbg_printf("%s-%s: failed to check"
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s-%s: failed to check"
|
||||
" hash for `%s': %s\n", pkgname,
|
||||
version, entry_pname,
|
||||
strerror(errno));
|
||||
@ -397,7 +404,8 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
*/
|
||||
if (chmod(entry_pname,
|
||||
entry_statp->st_mode) != 0) {
|
||||
xbps_dbg_printf("%s-%s: failed "
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s-%s: failed "
|
||||
"to set perms %s to %s: %s\n",
|
||||
pkgname, version,
|
||||
archive_entry_strmode(entry),
|
||||
@ -406,14 +414,16 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
xbps_dbg_printf("%s-%s: entry %s perms "
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s-%s: entry %s perms "
|
||||
"to %s.\n", pkgname, version,
|
||||
entry_pname,
|
||||
archive_entry_strmode(entry));
|
||||
/*
|
||||
* hash match, skip extraction.
|
||||
*/
|
||||
xbps_dbg_printf("%s-%s: entry %s "
|
||||
xbps_dbg_printf(xhp,
|
||||
"%s-%s: entry %s "
|
||||
"matches current SHA256, "
|
||||
"skipping...\n", pkgname,
|
||||
version, entry_pname);
|
||||
@ -435,7 +445,8 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
(void)rename(entry_pname, buf);
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
xbps_set_cb_state(XBPS_STATE_CONFIG_FILE, 0,
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_CONFIG_FILE, 0,
|
||||
pkgname, version,
|
||||
"Renamed old configuration file "
|
||||
"`%s' to `%s.old'.", entry_pname, entry_pname);
|
||||
@ -449,7 +460,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
if (xucd != NULL)
|
||||
xucd->entry_is_conf = true;
|
||||
|
||||
rv = xbps_entry_install_conf_file(filesd,
|
||||
rv = xbps_entry_install_conf_file(xhp, filesd,
|
||||
entry, entry_pname, pkgname, version);
|
||||
if (rv == -1) {
|
||||
/* error */
|
||||
@ -468,21 +479,21 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
*/
|
||||
if (archive_read_extract(ar, entry, flags) != 0) {
|
||||
rv = archive_errno(ar);
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to extract file `%s': %s",
|
||||
pkgver, entry_pname, strerror(rv));
|
||||
}
|
||||
if (xucd != NULL) {
|
||||
xucd->entry_extract_count++;
|
||||
(*xhp->unpack_cb)(xucd, xhp->unpack_cb_data);
|
||||
(*xhp->unpack_cb)(xhp, xucd, xhp->unpack_cb_data);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If there was any error extracting files from archive, error out.
|
||||
*/
|
||||
if ((rv = archive_errno(ar)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to extract files: %s",
|
||||
pkgver, fname, archive_error_string(ar));
|
||||
@ -509,7 +520,7 @@ unpack_archive(prop_dictionary_t pkg_repod, struct archive *ar)
|
||||
*/
|
||||
old_filesd = prop_dictionary_internalize_from_zfile(pkgfilesd);
|
||||
if (prop_object_type(old_filesd) == PROP_TYPE_DICTIONARY) {
|
||||
rv = xbps_remove_obsoletes(pkgname, version,
|
||||
rv = xbps_remove_obsoletes(xhp, pkgname, version,
|
||||
pkgver, old_filesd, filesd);
|
||||
prop_object_release(old_filesd);
|
||||
if (rv != 0) {
|
||||
@ -530,7 +541,7 @@ out1:
|
||||
goto out;
|
||||
}
|
||||
if (xbps_mkpath(buf, 0755) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] failed to create pkg metadir `%s': %s",
|
||||
buf, pkgver, strerror(errno));
|
||||
@ -542,7 +553,7 @@ out1:
|
||||
*/
|
||||
if (!prop_dictionary_externalize_to_zfile(filesd, pkgfilesd)) {
|
||||
rv = errno;
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] failed to extract metadata file `%s': %s",
|
||||
pkgver, XBPS_PKGFILES, strerror(errno));
|
||||
@ -564,7 +575,7 @@ out:
|
||||
}
|
||||
|
||||
int HIDDEN
|
||||
xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
{
|
||||
struct archive *ar = NULL;
|
||||
const char *pkgname, *version, *repoloc, *pkgver, *fname;
|
||||
@ -579,11 +590,11 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "filename", &fname);
|
||||
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK, 0, pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK, 0, pkgname, version, NULL);
|
||||
|
||||
bpkg = xbps_path_from_repository_uri(pkg_repod, repoloc);
|
||||
bpkg = xbps_path_from_repository_uri(xhp, pkg_repod, repoloc);
|
||||
if (bpkg == NULL) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [unpack] cannot determine binary package "
|
||||
"file for `%s': %s", pkgver, fname, strerror(errno));
|
||||
@ -604,7 +615,7 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
|
||||
if (archive_read_open_filename(ar, bpkg, ARCHIVE_READ_BLOCKSIZE) != 0) {
|
||||
rv = archive_errno(ar);
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to open binary package `%s': %s",
|
||||
pkgver, fname, strerror(rv));
|
||||
@ -617,9 +628,9 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Set package state to half-unpacked.
|
||||
*/
|
||||
if ((rv = xbps_set_pkg_state_installed(pkgname, version,
|
||||
if ((rv = xbps_set_pkg_state_installed(xhp, pkgname, version,
|
||||
XBPS_PKG_STATE_HALF_UNPACKED)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to set state to half-unpacked: %s",
|
||||
pkgver, strerror(rv));
|
||||
@ -628,8 +639,8 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Extract archive files.
|
||||
*/
|
||||
if ((rv = unpack_archive(pkg_repod, ar)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
if ((rv = unpack_archive(xhp, pkg_repod, ar)) != 0) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to unpack files from archive: %s",
|
||||
pkgver, strerror(rv));
|
||||
@ -638,9 +649,9 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Set package state to unpacked.
|
||||
*/
|
||||
if ((rv = xbps_set_pkg_state_installed(pkgname, version,
|
||||
if ((rv = xbps_set_pkg_state_installed(xhp, pkgname, version,
|
||||
XBPS_PKG_STATE_UNPACKED)) != 0) {
|
||||
xbps_set_cb_state(XBPS_STATE_UNPACK_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [unpack] failed to set state to unpacked: %s",
|
||||
pkgver, strerror(rv));
|
||||
|
52
lib/pkgdb.c
52
lib/pkgdb.c
@ -64,22 +64,21 @@ xbps_pkgdb_init(struct xbps_handle *xhp)
|
||||
if (xhp->pkgdb != NULL)
|
||||
return 0;
|
||||
|
||||
if ((rv = xbps_pkgdb_update(false)) != 0) {
|
||||
if ((rv = xbps_pkgdb_update(xhp, false)) != 0) {
|
||||
if (rv != ENOENT)
|
||||
xbps_dbg_printf("[pkgdb] cannot internalize "
|
||||
xbps_dbg_printf(xhp, "[pkgdb] cannot internalize "
|
||||
"pkgdb array: %s\n", strerror(rv));
|
||||
|
||||
return rv;
|
||||
}
|
||||
xbps_dbg_printf("[pkgdb] initialized ok.\n");
|
||||
xbps_dbg_printf(xhp, "[pkgdb] initialized ok.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xbps_pkgdb_update(bool flush)
|
||||
xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
char *plist;
|
||||
int rv = 0;
|
||||
|
||||
@ -92,7 +91,8 @@ xbps_pkgdb_update(bool flush)
|
||||
if (access(xhp->metadir, X_OK) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
if (xbps_mkpath(xhp->metadir, 0755) != 0) {
|
||||
xbps_dbg_printf("[pkgdb] failed to "
|
||||
xbps_dbg_printf(xhp,
|
||||
"[pkgdb] failed to "
|
||||
"create metadir %s: %s\n",
|
||||
xhp->metadir,
|
||||
strerror(errno));
|
||||
@ -133,46 +133,47 @@ xbps_pkgdb_release(struct xbps_handle *xhp)
|
||||
|
||||
prop_object_release(xhp->pkgdb);
|
||||
xhp->pkgdb = NULL;
|
||||
xbps_dbg_printf("[pkgdb] released ok.\n");
|
||||
xbps_dbg_printf(xhp, "[pkgdb] released ok.\n");
|
||||
}
|
||||
|
||||
static int
|
||||
foreach_pkg_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
foreach_pkg_cb(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg,
|
||||
bool reverse)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
int rv;
|
||||
|
||||
if ((rv = xbps_pkgdb_init(xhp)) != 0)
|
||||
return rv;
|
||||
|
||||
if (reverse)
|
||||
rv = xbps_callback_array_iter_reverse(xhp->pkgdb, fn, arg);
|
||||
rv = xbps_callback_array_iter_reverse(xhp, xhp->pkgdb, fn, arg);
|
||||
else
|
||||
rv = xbps_callback_array_iter(xhp->pkgdb, fn, arg);
|
||||
rv = xbps_callback_array_iter(xhp, xhp->pkgdb, fn, arg);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
xbps_pkgdb_foreach_reverse_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
xbps_pkgdb_foreach_reverse_cb(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
return foreach_pkg_cb(fn, arg, true);
|
||||
return foreach_pkg_cb(xhp, fn, arg, true);
|
||||
}
|
||||
|
||||
int
|
||||
xbps_pkgdb_foreach_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
xbps_pkgdb_foreach_cb(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
return foreach_pkg_cb(fn, arg, false);
|
||||
return foreach_pkg_cb(xhp, fn, arg, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_pkgdb_get_pkgd(const char *pkg, bool bypattern)
|
||||
xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, const char *pkg, bool bypattern)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
@ -190,9 +191,8 @@ xbps_pkgdb_get_pkgd(const char *pkg, bool bypattern)
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_pkgdb_get_pkgd_by_pkgver(const char *pkgver)
|
||||
xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
@ -206,9 +206,11 @@ xbps_pkgdb_get_pkgd_by_pkgver(const char *pkgver)
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_pkgdb_remove_pkgd(const char *pkg, bool bypattern, bool flush)
|
||||
xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
bool rv = false;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
@ -222,19 +224,19 @@ xbps_pkgdb_remove_pkgd(const char *pkg, bool bypattern, bool flush)
|
||||
if (!flush || !rv)
|
||||
return rv;
|
||||
|
||||
if ((xbps_pkgdb_update(true)) != 0)
|
||||
if ((xbps_pkgdb_update(xhp, true)) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_pkgdb_replace_pkgd(prop_dictionary_t pkgd,
|
||||
xbps_pkgdb_replace_pkgd(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkgd,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool flush)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
int rv;
|
||||
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
@ -248,7 +250,7 @@ xbps_pkgdb_replace_pkgd(prop_dictionary_t pkgd,
|
||||
if (!flush)
|
||||
return rv != 0 ? false : true;
|
||||
|
||||
if ((xbps_pkgdb_update(true)) != 0)
|
||||
if ((xbps_pkgdb_update(xhp, true)) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
56
lib/plist.c
56
lib/plist.c
@ -74,9 +74,10 @@ xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_callback_array_iter(prop_array_t array,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
xbps_callback_array_iter(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
@ -91,7 +92,7 @@ xbps_callback_array_iter(prop_array_t array,
|
||||
return ENOMEM;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
rv = (*fn)(obj, arg, &loop_done);
|
||||
rv = (*fn)(xhp, obj, arg, &loop_done);
|
||||
if (rv != 0 || loop_done)
|
||||
break;
|
||||
}
|
||||
@ -101,10 +102,11 @@ xbps_callback_array_iter(prop_array_t array,
|
||||
}
|
||||
|
||||
int
|
||||
xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
xbps_callback_array_iter_in_dict(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
prop_object_t obj;
|
||||
prop_array_t array;
|
||||
@ -113,6 +115,7 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
bool cbloop_done = false;
|
||||
|
||||
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
||||
assert(xhp != NULL);
|
||||
assert(key != NULL);
|
||||
assert(fn != NULL);
|
||||
|
||||
@ -124,7 +127,7 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
obj = prop_array_get(array, i);
|
||||
if (obj == NULL)
|
||||
continue;
|
||||
rv = (*fn)(obj, arg, &cbloop_done);
|
||||
rv = (*fn)(xhp, obj, arg, &cbloop_done);
|
||||
if (rv != 0 || cbloop_done)
|
||||
break;
|
||||
}
|
||||
@ -133,9 +136,10 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
}
|
||||
|
||||
int
|
||||
xbps_callback_array_iter_reverse(prop_array_t array,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
xbps_callback_array_iter_reverse(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
prop_object_t obj;
|
||||
unsigned int cnt;
|
||||
@ -144,6 +148,7 @@ xbps_callback_array_iter_reverse(prop_array_t array,
|
||||
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
assert(fn != NULL);
|
||||
assert(xhp != NULL);
|
||||
|
||||
if ((cnt = prop_array_count(array)) == 0)
|
||||
return 0;
|
||||
@ -152,7 +157,7 @@ xbps_callback_array_iter_reverse(prop_array_t array,
|
||||
obj = prop_array_get(array, cnt);
|
||||
if (obj == NULL)
|
||||
continue;
|
||||
rv = (*fn)(obj, arg, &loop_done);
|
||||
rv = (*fn)(xhp, obj, arg, &loop_done);
|
||||
if (rv != 0 || loop_done)
|
||||
break;
|
||||
}
|
||||
@ -161,24 +166,26 @@ xbps_callback_array_iter_reverse(prop_array_t array,
|
||||
}
|
||||
|
||||
int
|
||||
xbps_callback_array_iter_reverse_in_dict(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
xbps_callback_array_iter_reverse_in_dict(struct xbps_handle *xhp,
|
||||
prop_dictionary_t dict,
|
||||
const char *key,
|
||||
int (*fn)(struct xbps_handle *, prop_object_t, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
prop_array_t array;
|
||||
|
||||
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
||||
assert(key != NULL);
|
||||
assert(fn != NULL);
|
||||
assert(xhp != NULL);
|
||||
|
||||
array = prop_dictionary_get(dict, key);
|
||||
if (prop_object_type(array) != PROP_TYPE_ARRAY) {
|
||||
xbps_dbg_printf("invalid key '%s' for dictionary", key);
|
||||
xbps_dbg_printf(xhp, "invalid key '%s' for dictionary", key);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return xbps_callback_array_iter_reverse(array, fn, arg);
|
||||
return xbps_callback_array_iter_reverse(xhp, array, fn, arg);
|
||||
}
|
||||
|
||||
prop_object_iterator_t
|
||||
@ -259,17 +266,16 @@ xbps_array_replace_dict_by_pattern(prop_array_t array,
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *plist)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd, plistd = NULL;
|
||||
const char *savedpkgname;
|
||||
char *plistf;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(plist != NULL);
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
savedpkgname = pkgname;
|
||||
plistf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir,
|
||||
@ -278,9 +284,9 @@ xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
return NULL;
|
||||
|
||||
if (access(plistf, R_OK) == -1) {
|
||||
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) {
|
||||
free(plistf);
|
||||
@ -297,7 +303,7 @@ xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
plistd = prop_dictionary_internalize_from_zfile(plistf);
|
||||
free(plistf);
|
||||
if (plistd == NULL) {
|
||||
xbps_dbg_printf("cannot read from metadata %s for %s: %s\n",
|
||||
xbps_dbg_printf(xhp, "cannot read from metadata %s for %s: %s\n",
|
||||
plist, savedpkgname, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -52,8 +52,6 @@ fetch_archive_open(struct archive *a, void *client_data)
|
||||
|
||||
(void)a;
|
||||
|
||||
xbps_dbg_printf("%s: establishing connection to `%s'...\n",
|
||||
__func__, f->url->host);
|
||||
f->fetch = fetchGet(f->url, NULL);
|
||||
if (f->fetch == NULL)
|
||||
return ENOENT;
|
||||
@ -69,9 +67,6 @@ fetch_archive_read(struct archive *a, void *client_data, const void **buf)
|
||||
(void)a;
|
||||
*buf = f->buffer;
|
||||
|
||||
xbps_dbg_printf("%s: fetching data from `%s'...\n",
|
||||
__func__, f->url->doc);
|
||||
|
||||
return fetchIO_read(f->fetch, f->buffer, sizeof(f->buffer));
|
||||
}
|
||||
|
||||
@ -82,11 +77,8 @@ fetch_archive_close(struct archive *a, void *client_data)
|
||||
|
||||
(void)a;
|
||||
|
||||
if (f->fetch != NULL) {
|
||||
xbps_dbg_printf("%s: closing connection to `%s'...\n",
|
||||
__func__, f->url->host);
|
||||
if (f->fetch != NULL)
|
||||
fetchIO_close(f->fetch);
|
||||
}
|
||||
free(f);
|
||||
|
||||
return 0;
|
||||
|
@ -161,14 +161,14 @@ xbps_find_virtualpkg_in_array_by_pattern(prop_array_t array, const char *pattern
|
||||
}
|
||||
|
||||
static const char *
|
||||
find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
|
||||
find_virtualpkg_user_in_conf(struct xbps_handle *xhp,
|
||||
const char *vpkg,
|
||||
bool bypattern)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
const char *vpkgver, *pkg = NULL;
|
||||
char *vpkgname = NULL, *tmp;
|
||||
size_t i, j, cnt;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
if (xhp->cfg == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -205,7 +205,8 @@ find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
|
||||
}
|
||||
/* virtual package matched in conffile */
|
||||
pkg = cfg_title(sec);
|
||||
xbps_dbg_printf("matched vpkg in conf `%s' for %s\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"matched vpkg in conf `%s' for %s\n",
|
||||
pkg, vpkg);
|
||||
free(vpkgname);
|
||||
break;
|
||||
@ -215,7 +216,8 @@ find_virtualpkg_user_in_conf(const char *vpkg, bool bypattern)
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
find_virtualpkg_user_in_array(prop_array_t array,
|
||||
find_virtualpkg_user_in_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str,
|
||||
bool bypattern)
|
||||
{
|
||||
@ -224,7 +226,7 @@ find_virtualpkg_user_in_array(prop_array_t array,
|
||||
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
|
||||
assert(str != NULL);
|
||||
|
||||
vpkgname = find_virtualpkg_user_in_conf(str, bypattern);
|
||||
vpkgname = find_virtualpkg_user_in_conf(xhp, str, bypattern);
|
||||
if (vpkgname == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -232,15 +234,19 @@ find_virtualpkg_user_in_array(prop_array_t array,
|
||||
}
|
||||
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(prop_array_t array, const char *name)
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name)
|
||||
{
|
||||
return find_virtualpkg_user_in_array(array, name, false);
|
||||
return find_virtualpkg_user_in_array(xhp, array, name, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t array, const char *p)
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *p)
|
||||
{
|
||||
return find_virtualpkg_user_in_array(array, p, true);
|
||||
return find_virtualpkg_user_in_array(xhp, array, p, true);
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
@ -314,19 +320,20 @@ xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t d,
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
find_pkgd_installed(const char *str, bool bypattern, bool virtual)
|
||||
find_pkgd_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern,
|
||||
bool virtual)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd, rpkgd = NULL;
|
||||
pkg_state_t state = 0;
|
||||
int rv;
|
||||
|
||||
assert(str != NULL);
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
if ((rv = xbps_pkgdb_init(xhp)) != 0) {
|
||||
if (rv != ENOENT) {
|
||||
xbps_dbg_printf("%s: couldn't initialize "
|
||||
xbps_dbg_printf(xhp, "%s: couldn't initialize "
|
||||
"pkgdb: %s\n", strerror(rv));
|
||||
return NULL;
|
||||
} else if (rv == ENOENT)
|
||||
@ -339,7 +346,7 @@ find_pkgd_installed(const char *str, bool bypattern, bool virtual)
|
||||
find_pkg_in_array(xhp->pkgdb, str, bypattern, false, NULL);
|
||||
} else {
|
||||
/* virtual pkg set by user in conf */
|
||||
pkgd = find_virtualpkg_user_in_array(xhp->pkgdb,
|
||||
pkgd = find_virtualpkg_user_in_array(xhp, xhp->pkgdb,
|
||||
str, bypattern);
|
||||
if (pkgd == NULL) {
|
||||
/* any virtual pkg in array matching pattern */
|
||||
@ -369,13 +376,17 @@ find_pkgd_installed(const char *str, bool bypattern, bool virtual)
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_dict_installed(const char *str, bool bypattern)
|
||||
xbps_find_pkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern)
|
||||
{
|
||||
return find_pkgd_installed(str, bypattern, false);
|
||||
return find_pkgd_installed(xhp, str, bypattern, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_dict_installed(const char *str, bool bypattern)
|
||||
xbps_find_virtualpkg_dict_installed(struct xbps_handle *xhp,
|
||||
const char *str,
|
||||
bool bypattern)
|
||||
{
|
||||
return find_pkgd_installed(str, bypattern, true);
|
||||
return find_pkgd_installed(xhp, str, bypattern, true);
|
||||
}
|
||||
|
@ -31,12 +31,12 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
static int
|
||||
store_dependency(prop_array_t transd_unsorted,
|
||||
store_dependency(struct xbps_handle *xhp,
|
||||
prop_dictionary_t repo_pkgd,
|
||||
pkg_state_t repo_pkg_state,
|
||||
size_t *depth)
|
||||
{
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_array_t unsorted;
|
||||
int rv;
|
||||
/*
|
||||
* Overwrite package state in dictionary with same state than the
|
||||
@ -52,7 +52,8 @@ store_dependency(prop_array_t transd_unsorted,
|
||||
/*
|
||||
* Add the dictionary into the array.
|
||||
*/
|
||||
if (!prop_array_add(transd_unsorted, repo_pkgd))
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
if (!prop_array_add(unsorted, repo_pkgd))
|
||||
return EINVAL;
|
||||
|
||||
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
||||
@ -63,19 +64,20 @@ store_dependency(prop_array_t transd_unsorted,
|
||||
"repository", &repo);
|
||||
prop_dictionary_get_cstring_nocopy(repo_pkgd,
|
||||
"pkgver", &pkgver);
|
||||
xbps_dbg_printf(" ");
|
||||
xbps_dbg_printf(xhp, " ");
|
||||
for (x = 0; x < *depth; x++)
|
||||
xbps_dbg_printf_append(" ");
|
||||
xbps_dbg_printf_append(xhp, " ");
|
||||
|
||||
xbps_dbg_printf_append("%s: added into "
|
||||
xbps_dbg_printf_append(xhp, "%s: added into "
|
||||
"the transaction (%s).\n", pkgver, repo);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
add_missing_reqdep(prop_array_t missing_rdeps, const char *reqpkg)
|
||||
add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
|
||||
{
|
||||
prop_array_t mdeps;
|
||||
prop_string_t reqpkg_str;
|
||||
prop_object_iterator_t iter = NULL;
|
||||
prop_object_t obj;
|
||||
@ -83,16 +85,16 @@ add_missing_reqdep(prop_array_t missing_rdeps, const char *reqpkg)
|
||||
bool add_pkgdep, pkgfound, update_pkgdep;
|
||||
int rv = 0;
|
||||
|
||||
assert(prop_object_type(missing_rdeps) == PROP_TYPE_ARRAY);
|
||||
assert(reqpkg != NULL);
|
||||
|
||||
add_pkgdep = update_pkgdep = pkgfound = false;
|
||||
mdeps = prop_dictionary_get(xhp->transd, "missing_deps");
|
||||
|
||||
reqpkg_str = prop_string_create_cstring_nocopy(reqpkg);
|
||||
if (reqpkg_str == NULL)
|
||||
return errno;
|
||||
|
||||
iter = prop_array_iterator(missing_rdeps);
|
||||
iter = prop_array_iterator(mdeps);
|
||||
if (iter == NULL)
|
||||
goto out;
|
||||
|
||||
@ -126,7 +128,7 @@ add_missing_reqdep(prop_array_t missing_rdeps, const char *reqpkg)
|
||||
* if new dependency version is greater than current
|
||||
* one, store it.
|
||||
*/
|
||||
xbps_dbg_printf("Missing pkgdep name matched, "
|
||||
xbps_dbg_printf(xhp, "Missing pkgdep name matched, "
|
||||
"curver: %s newver: %s\n", curver, pkgver);
|
||||
if (xbps_cmpver(curver, pkgver) <= 0) {
|
||||
add_pkgdep = false;
|
||||
@ -149,8 +151,8 @@ out:
|
||||
if (iter)
|
||||
prop_object_iterator_release(iter);
|
||||
if (update_pkgdep)
|
||||
prop_array_remove(missing_rdeps, idx);
|
||||
if (add_pkgdep && !xbps_add_obj_to_array(missing_rdeps, reqpkg_str)) {
|
||||
prop_array_remove(mdeps, idx);
|
||||
if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) {
|
||||
prop_object_release(reqpkg_str);
|
||||
return errno;
|
||||
}
|
||||
@ -161,13 +163,11 @@ out:
|
||||
#define MAX_DEPTH 512
|
||||
|
||||
static int
|
||||
find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
prop_array_t trans_mdeps, /* transaction missing deps array */
|
||||
find_repo_deps(struct xbps_handle *xhp,
|
||||
prop_array_t pkg_rdeps_array, /* current pkg rundeps array */
|
||||
const char *curpkg, /* current pkgver */
|
||||
size_t *depth) /* max recursion depth */
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_dictionary_t curpkgd, tmpd;
|
||||
prop_array_t curpkgrdeps, unsorted;
|
||||
pkg_state_t state;
|
||||
@ -186,11 +186,11 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
for (i = 0; i < prop_array_count(pkg_rdeps_array); i++) {
|
||||
prop_array_get_cstring_nocopy(pkg_rdeps_array, i, &reqpkg);
|
||||
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
||||
xbps_dbg_printf("");
|
||||
xbps_dbg_printf(xhp, "");
|
||||
for (x = 0; x < *depth; x++)
|
||||
xbps_dbg_printf_append(" ");
|
||||
xbps_dbg_printf_append("%s: requires dependency '%s': ",
|
||||
curpkg ? curpkg : " ", reqpkg);
|
||||
xbps_dbg_printf_append(xhp, " ");
|
||||
xbps_dbg_printf_append(xhp, "%s: requires dependency '%s': ",
|
||||
curpkg != NULL ? curpkg : " ", reqpkg);
|
||||
}
|
||||
/*
|
||||
* Pass 1: check if required dependency is already installed
|
||||
@ -198,19 +198,19 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
*/
|
||||
if ((pkgname = xbps_pkgpattern_name(reqpkg)) == NULL) {
|
||||
rv = EINVAL;
|
||||
xbps_dbg_printf("failed to get "
|
||||
xbps_dbg_printf(xhp, "failed to get "
|
||||
"pkgname from `%s'!", reqpkg);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Look for a real package installed...
|
||||
*/
|
||||
tmpd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||
tmpd = xbps_find_pkg_dict_installed(xhp, pkgname, false);
|
||||
if (tmpd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
/* error */
|
||||
rv = errno;
|
||||
xbps_dbg_printf("failed to find "
|
||||
xbps_dbg_printf(xhp, "failed to find "
|
||||
"installed pkg for `%s': %s\n",
|
||||
reqpkg, strerror(errno));
|
||||
break;
|
||||
@ -219,20 +219,21 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* real package not installed, try looking for
|
||||
* a virtual package instead.
|
||||
*/
|
||||
tmpd = xbps_find_virtualpkg_dict_installed(pkgname, false);
|
||||
tmpd = xbps_find_virtualpkg_dict_installed(xhp,
|
||||
pkgname, false);
|
||||
}
|
||||
free(pkgname);
|
||||
if (tmpd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
/* error */
|
||||
rv = errno;
|
||||
xbps_dbg_printf("failed to find "
|
||||
xbps_dbg_printf(xhp, "failed to find "
|
||||
"installed virtual pkg for `%s': %s\n",
|
||||
reqpkg, strerror(errno));
|
||||
break;
|
||||
}
|
||||
/* Required pkgdep not installed */
|
||||
xbps_dbg_printf_append("not installed. ");
|
||||
xbps_dbg_printf_append(xhp, "not installed. ");
|
||||
reason = "install";
|
||||
state = XBPS_PKG_STATE_NOT_INSTALLED;
|
||||
} else {
|
||||
@ -255,7 +256,8 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* package and is satisfied by an
|
||||
* installed package.
|
||||
*/
|
||||
xbps_dbg_printf_append("[virtual] satisfied by "
|
||||
xbps_dbg_printf_append(xhp,
|
||||
"[virtual] satisfied by "
|
||||
"`%s'.\n", pkgver_q);
|
||||
prop_object_release(tmpd);
|
||||
continue;
|
||||
@ -266,7 +268,8 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* Package is installed but does not match
|
||||
* the dependency pattern, update pkg.
|
||||
*/
|
||||
xbps_dbg_printf_append("installed `%s', "
|
||||
xbps_dbg_printf_append(xhp,
|
||||
"installed `%s', "
|
||||
"must be updated.\n", pkgver_q);
|
||||
reason = "update";
|
||||
} else if (rv == 1) {
|
||||
@ -277,7 +280,8 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* pattern but was only unpacked,
|
||||
* configure pkg.
|
||||
*/
|
||||
xbps_dbg_printf_append("installed `%s'"
|
||||
xbps_dbg_printf_append(xhp,
|
||||
"installed `%s'"
|
||||
", must be configured.\n",
|
||||
pkgver_q);
|
||||
reason = "configure";
|
||||
@ -287,7 +291,8 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* pattern and is fully installed,
|
||||
* skip to next one.
|
||||
*/
|
||||
xbps_dbg_printf_append("installed "
|
||||
xbps_dbg_printf_append(xhp,
|
||||
"installed "
|
||||
"`%s'.\n", pkgver_q);
|
||||
prop_object_release(tmpd);
|
||||
continue;
|
||||
@ -295,7 +300,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
} else {
|
||||
/* error matching pkgpattern */
|
||||
prop_object_release(tmpd);
|
||||
xbps_dbg_printf("failed to match "
|
||||
xbps_dbg_printf(xhp, "failed to match "
|
||||
"pattern %s with %s\n", reqpkg, pkgver_q);
|
||||
break;
|
||||
}
|
||||
@ -304,9 +309,9 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* Pass 2: check if required dependency has been already
|
||||
* added in the transaction dictionary.
|
||||
*/
|
||||
unsorted = prop_dictionary_get(transd, "unsorted_deps");
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
if (((curpkgd = xbps_find_pkg_in_array_by_pattern(unsorted, reqpkg, NULL)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(unsorted, reqpkg)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(xhp, unsorted, reqpkg)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(unsorted, reqpkg)) == NULL)) {
|
||||
/* error matching required pkgdep */
|
||||
if (errno && errno != ENOENT) {
|
||||
@ -316,7 +321,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
} else {
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"pkgver", &pkgver_q);
|
||||
xbps_dbg_printf_append(" (%s queued "
|
||||
xbps_dbg_printf_append(xhp, " (%s queued "
|
||||
"in transaction).\n", pkgver_q);
|
||||
continue;
|
||||
}
|
||||
@ -325,35 +330,37 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* If dependency does not match add pkg into the missing
|
||||
* deps array and pass to next one.
|
||||
*/
|
||||
if (((curpkgd = xbps_rpool_find_virtualpkg_conf(reqpkg, true)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_find_pkg(reqpkg, true, true)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_find_virtualpkg(reqpkg, true)) == NULL)) {
|
||||
if (((curpkgd = xbps_rpool_find_virtualpkg_conf(xhp, reqpkg, true)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_find_pkg(xhp, reqpkg, true, true)) == NULL) &&
|
||||
((curpkgd = xbps_rpool_find_virtualpkg(xhp, reqpkg, true)) == NULL)) {
|
||||
/* pkg not found, there was some error */
|
||||
if (errno && errno != ENOENT) {
|
||||
xbps_dbg_printf("failed to find pkg "
|
||||
xbps_dbg_printf(xhp, "failed to find pkg "
|
||||
"for `%s' in rpool: %s\n",
|
||||
reqpkg, strerror(errno));
|
||||
rv = errno;
|
||||
break;
|
||||
}
|
||||
rv = add_missing_reqdep(trans_mdeps, reqpkg);
|
||||
rv = add_missing_reqdep(xhp, reqpkg);
|
||||
if (rv != 0 && rv != EEXIST) {
|
||||
xbps_dbg_printf_append("`%s': "
|
||||
xbps_dbg_printf_append(xhp, "`%s': "
|
||||
"add_missing_reqdep failed %s\n",
|
||||
reqpkg);
|
||||
break;
|
||||
} else if (rv == EEXIST) {
|
||||
xbps_dbg_printf_append("`%s' missing "
|
||||
xbps_dbg_printf_append(xhp, "`%s' missing "
|
||||
"dep already added.\n", reqpkg);
|
||||
rv = 0;
|
||||
continue;
|
||||
} else {
|
||||
xbps_dbg_printf_append("`%s' added "
|
||||
xbps_dbg_printf_append(xhp, "`%s' added "
|
||||
"into the missing deps array.\n",
|
||||
reqpkg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"pkgver", &pkgver_q);
|
||||
/*
|
||||
* Check if package has matched conflicts.
|
||||
*/
|
||||
@ -362,9 +369,9 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
* Package is on repo, add it into the transaction dictionary.
|
||||
*/
|
||||
prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
|
||||
rv = store_dependency(unsorted, curpkgd, state, depth);
|
||||
rv = store_dependency(xhp, curpkgd, state, depth);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf("store_dependency failed for "
|
||||
xbps_dbg_printf(xhp, "store_dependency failed for "
|
||||
"`%s': %s\n", reqpkg, strerror(rv));
|
||||
prop_object_release(curpkgd);
|
||||
break;
|
||||
@ -379,21 +386,20 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
}
|
||||
prop_object_release(curpkgd);
|
||||
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
||||
xbps_dbg_printf("");
|
||||
xbps_dbg_printf(xhp, "");
|
||||
for (x = 0; x < *depth; x++)
|
||||
xbps_dbg_printf_append(" ");
|
||||
xbps_dbg_printf_append(xhp, " ");
|
||||
|
||||
xbps_dbg_printf_append(" %s: finding dependencies:\n",
|
||||
pkgver_q);
|
||||
xbps_dbg_printf_append(xhp,
|
||||
"%s: finding dependencies:\n", pkgver_q);
|
||||
}
|
||||
/*
|
||||
* Recursively find rundeps for current pkg dictionary.
|
||||
*/
|
||||
(*depth)++;
|
||||
rv = find_repo_deps(transd, trans_mdeps, curpkgrdeps,
|
||||
pkgver_q, depth);
|
||||
rv = find_repo_deps(xhp, curpkgrdeps, pkgver_q, depth);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf("Error checking %s for rundeps: %s\n",
|
||||
xbps_dbg_printf(xhp, "Error checking %s for rundeps: %s\n",
|
||||
reqpkg, strerror(rv));
|
||||
break;
|
||||
}
|
||||
@ -407,7 +413,7 @@ int HIDDEN
|
||||
xbps_repository_find_pkg_deps(struct xbps_handle *xhp,
|
||||
prop_dictionary_t repo_pkgd)
|
||||
{
|
||||
prop_array_t mdeps, pkg_rdeps;
|
||||
prop_array_t pkg_rdeps;
|
||||
const char *pkgver;
|
||||
size_t depth = 0;
|
||||
|
||||
@ -416,11 +422,10 @@ xbps_repository_find_pkg_deps(struct xbps_handle *xhp,
|
||||
return 0;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
|
||||
xbps_dbg_printf("Finding required dependencies for '%s':\n", pkgver);
|
||||
mdeps = prop_dictionary_get(xhp->transd, "missing_deps");
|
||||
xbps_dbg_printf(xhp, "Finding required dependencies for '%s':\n", pkgver);
|
||||
/*
|
||||
* This will find direct and indirect deps, if any of them is not
|
||||
* there it will be added into the missing_deps array.
|
||||
*/
|
||||
return find_repo_deps(xhp->transd, mdeps, pkg_rdeps, pkgver, &depth);
|
||||
return find_repo_deps(xhp, pkg_rdeps, pkgver, &depth);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ xbps_rpool_init(struct xbps_handle *xhp)
|
||||
/*
|
||||
* If index file is not there, skip.
|
||||
*/
|
||||
plist = xbps_pkg_index_plist(repouri);
|
||||
plist = xbps_pkg_index_plist(xhp, repouri);
|
||||
if (plist == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
@ -72,7 +72,8 @@ xbps_rpool_init(struct xbps_handle *xhp)
|
||||
array = prop_array_internalize_from_zfile(plist);
|
||||
free(plist);
|
||||
if (array == NULL) {
|
||||
xbps_dbg_printf("[rpool] `%s' cannot be internalized:"
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] `%s' cannot be internalized:"
|
||||
" %s\n", repouri, strerror(errno));
|
||||
nmissing++;
|
||||
continue;
|
||||
@ -102,7 +103,7 @@ xbps_rpool_init(struct xbps_handle *xhp)
|
||||
prop_object_release(d);
|
||||
goto out;
|
||||
}
|
||||
xbps_dbg_printf("[rpool] `%s' registered.\n", repouri);
|
||||
xbps_dbg_printf(xhp, "[rpool] `%s' registered.\n", repouri);
|
||||
}
|
||||
if (ntotal - nmissing == 0) {
|
||||
/* no repositories available, error out */
|
||||
@ -111,7 +112,7 @@ xbps_rpool_init(struct xbps_handle *xhp)
|
||||
}
|
||||
|
||||
prop_array_make_immutable(xhp->repo_pool);
|
||||
xbps_dbg_printf("[rpool] initialized ok.\n");
|
||||
xbps_dbg_printf(xhp, "[rpool] initialized ok.\n");
|
||||
out:
|
||||
if (rv != 0)
|
||||
xbps_rpool_release(xhp);
|
||||
@ -135,18 +136,18 @@ xbps_rpool_release(struct xbps_handle *xhp)
|
||||
d = prop_array_get(xhp->repo_pool, i);
|
||||
idx = prop_dictionary_get(d, "index");
|
||||
prop_dictionary_get_cstring_nocopy(d, "uri", &uri);
|
||||
xbps_dbg_printf("[rpool] unregistered repository '%s'\n", uri);
|
||||
xbps_dbg_printf(xhp, "[rpool] unregistered repository '%s'\n",
|
||||
uri);
|
||||
prop_object_release(idx);
|
||||
prop_object_release(d);
|
||||
}
|
||||
xhp->repo_pool = NULL;
|
||||
xbps_dbg_printf("[rpool] released ok.\n");
|
||||
xbps_dbg_printf(xhp, "[rpool] released ok.\n");
|
||||
}
|
||||
|
||||
int
|
||||
xbps_rpool_sync(const char *uri)
|
||||
xbps_rpool_sync(struct xbps_handle *xhp, const char *uri)
|
||||
{
|
||||
const struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *repouri;
|
||||
size_t i;
|
||||
|
||||
@ -161,8 +162,9 @@ xbps_rpool_sync(const char *uri)
|
||||
/*
|
||||
* Fetch repository index.
|
||||
*/
|
||||
if (xbps_repository_sync_pkg_index(repouri, XBPS_PKGINDEX) == -1) {
|
||||
xbps_dbg_printf("[rpool] `%s' failed to fetch: %s\n",
|
||||
if (xbps_repository_sync_pkg_index(xhp, repouri, XBPS_PKGINDEX) == -1) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] `%s' failed to fetch: %s\n",
|
||||
repouri, fetchLastErrCode == 0 ? strerror(errno) :
|
||||
xbps_fetch_error_string());
|
||||
continue;
|
||||
@ -170,9 +172,10 @@ xbps_rpool_sync(const char *uri)
|
||||
/*
|
||||
* Fetch repository files index.
|
||||
*/
|
||||
if (xbps_repository_sync_pkg_index(repouri,
|
||||
if (xbps_repository_sync_pkg_index(xhp, repouri,
|
||||
XBPS_PKGINDEX_FILES) == -1) {
|
||||
xbps_dbg_printf("[rpool] `%s' failed to fetch: %s\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] `%s' failed to fetch: %s\n",
|
||||
repouri, fetchLastErrCode == 0 ? strerror(errno) :
|
||||
xbps_fetch_error_string());
|
||||
continue;
|
||||
@ -182,10 +185,11 @@ xbps_rpool_sync(const char *uri)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *arg)
|
||||
xbps_rpool_foreach(struct xbps_handle *xhp,
|
||||
int (*fn)(struct xbps_handle *, struct xbps_rpool_index *, void *, bool *),
|
||||
void *arg)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
struct xbps_rpool_index rpi;
|
||||
size_t i;
|
||||
int rv = 0;
|
||||
@ -195,9 +199,11 @@ xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *a
|
||||
/* Initialize repository pool */
|
||||
if ((rv = xbps_rpool_init(xhp)) != 0) {
|
||||
if (rv == ENOTSUP) {
|
||||
xbps_dbg_printf("[rpool] empty repository list.\n");
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] empty repository list.\n");
|
||||
} else if (rv != ENOENT && rv != ENOTSUP) {
|
||||
xbps_dbg_printf("[rpool] couldn't initialize: %s\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] couldn't initialize: %s\n",
|
||||
strerror(rv));
|
||||
}
|
||||
return rv;
|
||||
@ -207,7 +213,7 @@ xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *a
|
||||
d = prop_array_get(xhp->repo_pool, i);
|
||||
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.uri);
|
||||
rpi.repo = prop_dictionary_get(d, "index");
|
||||
rv = (*fn)(&rpi, arg, &done);
|
||||
rv = (*fn)(xhp, &rpi, arg, &done);
|
||||
if (rv != 0 || done)
|
||||
break;
|
||||
}
|
||||
|
@ -45,10 +45,15 @@ struct repo_pool_fpkg {
|
||||
};
|
||||
|
||||
static int
|
||||
repo_find_virtualpkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_find_virtualpkg_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_in_array_by_pattern(rpi->repo,
|
||||
@ -68,18 +73,21 @@ repo_find_virtualpkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
}
|
||||
|
||||
static int
|
||||
repo_find_virtualpkg_conf_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_find_virtualpkg_conf_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(rpi->repo,
|
||||
rpf->pattern);
|
||||
xbps_find_virtualpkg_conf_in_array_by_pattern(xhp,
|
||||
rpi->repo, rpf->pattern);
|
||||
} else {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(rpi->repo,
|
||||
rpf->pattern);
|
||||
xbps_find_virtualpkg_conf_in_array_by_name(xhp,
|
||||
rpi->repo, rpf->pattern);
|
||||
}
|
||||
if (rpf->pkgd) {
|
||||
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
|
||||
@ -91,10 +99,15 @@ repo_find_virtualpkg_conf_cb(struct xbps_rpool_index *rpi, void *arg, bool *done
|
||||
}
|
||||
|
||||
static int
|
||||
repo_find_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_find_pkg_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->exact) {
|
||||
/* exact match by pkgver */
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->repo,
|
||||
@ -122,13 +135,17 @@ repo_find_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
}
|
||||
|
||||
static int
|
||||
repo_find_best_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
repo_find_best_pkg_cb(struct xbps_handle *xhp,
|
||||
struct xbps_rpool_index *rpi,
|
||||
void *arg,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
const char *repopkgver;
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
(void)done;
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(rpi->repo,
|
||||
@ -141,14 +158,16 @@ repo_find_best_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
if (errno && errno != ENOENT)
|
||||
return errno;
|
||||
|
||||
xbps_dbg_printf("[rpool] Package '%s' not found in repository "
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] Package '%s' not found in repository "
|
||||
"'%s'.\n", rpf->pattern, rpi->uri);
|
||||
return 0;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &repopkgver);
|
||||
if (rpf->bestpkgver == NULL) {
|
||||
xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->uri);
|
||||
rpf->pkgd = pkgd;
|
||||
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
|
||||
@ -160,7 +179,8 @@ repo_find_best_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
* version from current package in repository.
|
||||
*/
|
||||
if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) {
|
||||
xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n",
|
||||
xbps_dbg_printf(xhp,
|
||||
"[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->uri);
|
||||
rpf->pkgd = pkgd;
|
||||
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
|
||||
@ -178,7 +198,10 @@ typedef enum {
|
||||
} pkg_repo_type_t;
|
||||
|
||||
static prop_dictionary_t
|
||||
repo_find_pkg(const char *pkg, bool bypattern, pkg_repo_type_t type)
|
||||
repo_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
pkg_repo_type_t type)
|
||||
{
|
||||
struct repo_pool_fpkg rpf;
|
||||
int rv = 0;
|
||||
@ -195,31 +218,31 @@ repo_find_pkg(const char *pkg, bool bypattern, pkg_repo_type_t type)
|
||||
* Find exact pkg version.
|
||||
*/
|
||||
rpf.exact = true;
|
||||
rv = xbps_rpool_foreach(repo_find_pkg_cb, &rpf);
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_pkg_cb, &rpf);
|
||||
break;
|
||||
case BEST_PKG:
|
||||
/*
|
||||
* Find best pkg version.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(repo_find_best_pkg_cb, &rpf);
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_best_pkg_cb, &rpf);
|
||||
break;
|
||||
case VIRTUAL_PKG:
|
||||
/*
|
||||
* Find virtual pkg.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(repo_find_virtualpkg_cb, &rpf);
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_virtualpkg_cb, &rpf);
|
||||
break;
|
||||
case VIRTUAL_CONF_PKG:
|
||||
/*
|
||||
* Find virtual pkg as specified in configuration file.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(repo_find_virtualpkg_conf_cb, &rpf);
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_virtualpkg_conf_cb, &rpf);
|
||||
break;
|
||||
case REAL_PKG:
|
||||
/*
|
||||
* Find real pkg.
|
||||
*/
|
||||
rv = xbps_rpool_foreach(repo_find_pkg_cb, &rpf);
|
||||
rv = xbps_rpool_foreach(xhp, repo_find_pkg_cb, &rpf);
|
||||
break;
|
||||
}
|
||||
if (rv != 0) {
|
||||
@ -231,42 +254,51 @@ repo_find_pkg(const char *pkg, bool bypattern, pkg_repo_type_t type)
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_virtualpkg(const char *pkg, bool bypattern)
|
||||
xbps_rpool_find_virtualpkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern)
|
||||
{
|
||||
assert(pkg != NULL);
|
||||
|
||||
return repo_find_pkg(pkg, bypattern, VIRTUAL_PKG);
|
||||
return repo_find_pkg(xhp, pkg, bypattern, VIRTUAL_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_virtualpkg_conf(const char *pkg, bool bypattern)
|
||||
xbps_rpool_find_virtualpkg_conf(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern)
|
||||
{
|
||||
assert(pkg != NULL);
|
||||
|
||||
return repo_find_pkg(pkg, bypattern, VIRTUAL_CONF_PKG);
|
||||
return repo_find_pkg(xhp, pkg, bypattern, VIRTUAL_CONF_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_pkg(const char *pkg, bool bypattern, bool best)
|
||||
xbps_rpool_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool best)
|
||||
{
|
||||
assert(pkg != NULL);
|
||||
|
||||
if (best)
|
||||
return repo_find_pkg(pkg, bypattern, BEST_PKG);
|
||||
return repo_find_pkg(xhp, pkg, bypattern, BEST_PKG);
|
||||
|
||||
return repo_find_pkg(pkg, bypattern, REAL_PKG);
|
||||
return repo_find_pkg(xhp, pkg, bypattern, REAL_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_find_pkg_exact(const char *pkgver)
|
||||
xbps_rpool_find_pkg_exact(struct xbps_handle *xhp, const char *pkgver)
|
||||
{
|
||||
assert(pkgver != NULL);
|
||||
|
||||
return repo_find_pkg(pkgver, false, EXACT_PKG);
|
||||
return repo_find_pkg(xhp, pkgver, false, EXACT_PKG);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_rpool_dictionary_metadata_plist(const char *pattern, const char *plistf)
|
||||
xbps_rpool_dictionary_metadata_plist(struct xbps_handle *xhp,
|
||||
const char *pattern,
|
||||
const char *plistf)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL, plistd = NULL;
|
||||
const char *repoloc;
|
||||
@ -284,15 +316,15 @@ xbps_rpool_dictionary_metadata_plist(const char *pattern, const char *plistf)
|
||||
* libfetch!
|
||||
*/
|
||||
if (xbps_pkgpattern_version(pattern))
|
||||
pkgd = xbps_rpool_find_pkg(pattern, true, false);
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, true, false);
|
||||
else
|
||||
pkgd = xbps_rpool_find_pkg(pattern, false, true);
|
||||
pkgd = xbps_rpool_find_pkg(xhp, pattern, false, true);
|
||||
|
||||
if (pkgd == NULL)
|
||||
goto out;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
|
||||
url = xbps_path_from_repository_uri(pkgd, repoloc);
|
||||
url = xbps_path_from_repository_uri(xhp, pkgd, repoloc);
|
||||
if (url == NULL) {
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
|
@ -86,10 +86,11 @@ xbps_get_remote_repo_string(const char *uri)
|
||||
* size and/or mtime match) and 1 if downloaded successfully.
|
||||
*/
|
||||
int
|
||||
xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *plistf)
|
||||
{
|
||||
prop_array_t array;
|
||||
struct xbps_handle *xhp;
|
||||
struct url *url = NULL;
|
||||
struct stat st;
|
||||
const char *fetch_outputdir, *fetchstr = NULL;
|
||||
@ -100,7 +101,6 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
|
||||
assert(uri != NULL);
|
||||
tmp_metafile = rpidx = lrepodir = lrepofile = NULL;
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
/* ignore non remote repositories */
|
||||
if (!xbps_check_is_repository_uri_remote(uri))
|
||||
@ -118,7 +118,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
* Create metadir if necessary.
|
||||
*/
|
||||
if ((rv = xbps_mkpath(xhp->metadir, 0755)) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
|
||||
errno, NULL, NULL,
|
||||
"[reposync] failed to create metadir `%s': %s",
|
||||
xhp->metadir, strerror(errno));
|
||||
@ -162,15 +162,15 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
fetch_outputdir = xhp->metadir;
|
||||
|
||||
/* reposync start cb */
|
||||
xbps_set_cb_state(XBPS_STATE_REPOSYNC, 0, NULL, NULL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC, 0, NULL, NULL,
|
||||
"Synchronizing %s for `%s'...", plistf, uri);
|
||||
/*
|
||||
* Download plist index file from repository.
|
||||
*/
|
||||
if (xbps_fetch_file(rpidx, fetch_outputdir, true, NULL) == -1) {
|
||||
if (xbps_fetch_file(xhp, rpidx, fetch_outputdir, true, NULL) == -1) {
|
||||
/* reposync error cb */
|
||||
fetchstr = xbps_fetch_error_string();
|
||||
xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL,
|
||||
fetchLastErrCode != 0 ? fetchLastErrCode : errno,
|
||||
NULL, NULL,
|
||||
"[reposync] failed to fetch file `%s': %s",
|
||||
@ -183,11 +183,11 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
/*
|
||||
* Make sure that downloaded plist file can be internalized, i.e
|
||||
* some HTTP servers don't return proper errors and sometimes
|
||||
* you get an HTML ASCII file :-)
|
||||
you get an HTML ASCII file :-)
|
||||
*/
|
||||
array = prop_array_internalize_from_zfile(tmp_metafile);
|
||||
if (array == NULL) {
|
||||
xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL, 0, NULL, NULL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, 0, NULL, NULL,
|
||||
"[reposync] downloaded file `%s' is not valid.", rpidx);
|
||||
(void)unlink(tmp_metafile);
|
||||
rv = -1;
|
||||
@ -204,7 +204,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
* Create local repodir to store plist index file.
|
||||
*/
|
||||
if ((rv = xbps_mkpath(lrepodir, 0755)) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL, errno, NULL, NULL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, errno, NULL, NULL,
|
||||
"[reposync] failed to create repodir for `%s': %s",
|
||||
lrepodir, strerror(rv));
|
||||
goto out;
|
||||
@ -214,7 +214,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
|
||||
* Rename to destination file now it has been fetched successfully.
|
||||
*/
|
||||
if ((rv = rename(tmp_metafile, lrepofile)) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL, errno, NULL, NULL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, errno, NULL, NULL,
|
||||
"[reposync] failed to rename index file `%s' to `%s': %s",
|
||||
tmp_metafile, lrepofile, strerror(errno));
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@
|
||||
*/
|
||||
|
||||
static int
|
||||
check_binpkgs_hash(prop_object_iterator_t iter)
|
||||
check_binpkgs_hash(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
{
|
||||
prop_object_t obj;
|
||||
const char *pkgver, *repoloc, *filen, *sha256, *trans;
|
||||
@ -83,17 +83,17 @@ check_binpkgs_hash(prop_object_iterator_t iter)
|
||||
"filename-sha256", &sha256);
|
||||
assert(sha256 != NULL);
|
||||
|
||||
binfile = xbps_path_from_repository_uri(obj, repoloc);
|
||||
binfile = xbps_path_from_repository_uri(xhp, obj, repoloc);
|
||||
if (binfile == NULL) {
|
||||
rv = EINVAL;
|
||||
break;
|
||||
}
|
||||
xbps_set_cb_state(XBPS_STATE_VERIFY, 0, pkgname, version,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_VERIFY, 0, pkgname, version,
|
||||
"Verifying `%s' package integrity...", filen, repoloc);
|
||||
rv = xbps_file_hash_check(binfile, sha256);
|
||||
if (rv != 0) {
|
||||
free(binfile);
|
||||
xbps_set_cb_state(XBPS_STATE_VERIFY_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_VERIFY_FAIL,
|
||||
rv, pkgname, version,
|
||||
"Failed to verify `%s' package integrity: %s",
|
||||
filen, strerror(rv));
|
||||
@ -130,7 +130,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &filen);
|
||||
assert(filen != NULL);
|
||||
|
||||
binfile = xbps_path_from_repository_uri(obj, repoloc);
|
||||
binfile = xbps_path_from_repository_uri(xhp, obj, repoloc);
|
||||
if (binfile == NULL) {
|
||||
rv = EINVAL;
|
||||
break;
|
||||
@ -146,7 +146,7 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
* Create cachedir.
|
||||
*/
|
||||
if (xbps_mkpath(xhp->cachedir, 0755) == -1) {
|
||||
xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_DOWNLOAD_FAIL,
|
||||
errno, pkgname, version,
|
||||
"%s: [trans] cannot create cachedir `%s': %s",
|
||||
pkgver, xhp->cachedir, strerror(errno));
|
||||
@ -154,17 +154,17 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
rv = errno;
|
||||
break;
|
||||
}
|
||||
xbps_set_cb_state(XBPS_STATE_DOWNLOAD,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_DOWNLOAD,
|
||||
0, pkgname, version,
|
||||
"Downloading binary package `%s' (from `%s')...",
|
||||
filen, repoloc);
|
||||
/*
|
||||
* Fetch binary package.
|
||||
*/
|
||||
rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL);
|
||||
rv = xbps_fetch_file(xhp, binfile, xhp->cachedir, false, NULL);
|
||||
if (rv == -1) {
|
||||
fetchstr = xbps_fetch_error_string();
|
||||
xbps_set_cb_state(XBPS_STATE_DOWNLOAD_FAIL,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_DOWNLOAD_FAIL,
|
||||
fetchLastErrCode != 0 ? fetchLastErrCode : errno,
|
||||
pkgname, version,
|
||||
"%s: [trans] failed to download binary package "
|
||||
@ -182,9 +182,8 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_commit(void)
|
||||
xbps_transaction_commit(struct xbps_handle *xhp)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
size_t i;
|
||||
@ -201,26 +200,26 @@ xbps_transaction_commit(void)
|
||||
/*
|
||||
* Download binary packages (if they come from a remote repository).
|
||||
*/
|
||||
xbps_set_cb_state(XBPS_STATE_TRANS_DOWNLOAD, 0, NULL, NULL, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_DOWNLOAD, 0, NULL, NULL, NULL);
|
||||
if ((rv = download_binpkgs(xhp, iter)) != 0)
|
||||
goto out;
|
||||
/*
|
||||
* Check SHA256 hashes for binary packages in transaction.
|
||||
*/
|
||||
xbps_set_cb_state(XBPS_STATE_TRANS_VERIFY, 0, NULL, NULL, NULL);
|
||||
if ((rv = check_binpkgs_hash(iter)) != 0)
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_VERIFY, 0, NULL, NULL, NULL);
|
||||
if ((rv = check_binpkgs_hash(xhp, iter)) != 0)
|
||||
goto out;
|
||||
/*
|
||||
* Install, update, configure or remove packages as specified
|
||||
* in the transaction dictionary.
|
||||
*/
|
||||
xbps_set_cb_state(XBPS_STATE_TRANS_RUN, 0, NULL, NULL, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_RUN, 0, NULL, NULL, NULL);
|
||||
|
||||
i = 0;
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
if ((xhp->transaction_frequency_flush > 0) &&
|
||||
(++i >= xhp->transaction_frequency_flush)) {
|
||||
rv = xbps_pkgdb_update(true);
|
||||
rv = xbps_pkgdb_update(xhp, true);
|
||||
if (rv != 0 && rv != ENOENT)
|
||||
goto out;
|
||||
|
||||
@ -241,14 +240,14 @@ xbps_transaction_commit(void)
|
||||
prop_dictionary_get_bool(obj, "remove-and-update",
|
||||
&update);
|
||||
prop_dictionary_get_bool(obj, "softreplace", &sr);
|
||||
rv = xbps_remove_pkg(pkgname, version, update, sr);
|
||||
rv = xbps_remove_pkg(xhp, pkgname, version, update, sr);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
} else if (strcmp(tract, "configure") == 0) {
|
||||
/*
|
||||
* Reconfigure pending package.
|
||||
*/
|
||||
rv = xbps_configure_pkg(pkgname, false, false, false);
|
||||
rv = xbps_configure_pkg(xhp, pkgname, false, false, false);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
} else {
|
||||
@ -265,12 +264,12 @@ xbps_transaction_commit(void)
|
||||
* Update a package: execute pre-remove
|
||||
* action if found before unpacking.
|
||||
*/
|
||||
xbps_set_cb_state(XBPS_STATE_UPDATE, 0,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UPDATE, 0,
|
||||
pkgname, version, NULL);
|
||||
rv = xbps_remove_pkg(pkgname, version,
|
||||
rv = xbps_remove_pkg(xhp, pkgname, version,
|
||||
true, false);
|
||||
if (rv != 0) {
|
||||
xbps_set_cb_state(
|
||||
xbps_set_cb_state(xhp,
|
||||
XBPS_STATE_UPDATE_FAIL,
|
||||
rv, pkgname, version,
|
||||
"%s: [trans] failed to update "
|
||||
@ -280,25 +279,25 @@ xbps_transaction_commit(void)
|
||||
}
|
||||
} else {
|
||||
/* Install a package */
|
||||
xbps_set_cb_state(XBPS_STATE_INSTALL, 0,
|
||||
pkgname, version, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_INSTALL,
|
||||
0, pkgname, version, NULL);
|
||||
}
|
||||
/*
|
||||
* Unpack binary package.
|
||||
*/
|
||||
if ((rv = xbps_unpack_binary_pkg(obj)) != 0)
|
||||
if ((rv = xbps_unpack_binary_pkg(xhp, obj)) != 0)
|
||||
goto out;
|
||||
/*
|
||||
* Register package.
|
||||
*/
|
||||
if ((rv = xbps_register_pkg(obj, false)) != 0)
|
||||
if ((rv = xbps_register_pkg(xhp, obj, false)) != 0)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(iter);
|
||||
|
||||
/* force a flush now packages were removed/unpacked */
|
||||
if ((rv = xbps_pkgdb_update(true)) != 0)
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
|
||||
goto out;
|
||||
|
||||
/* if there are no packages to install or update we are done */
|
||||
@ -307,13 +306,13 @@ xbps_transaction_commit(void)
|
||||
/*
|
||||
* Configure all unpacked packages.
|
||||
*/
|
||||
xbps_set_cb_state(XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL, NULL);
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_CONFIGURE, 0, NULL, NULL, NULL);
|
||||
|
||||
i = 0;
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
if (xhp->transaction_frequency_flush > 0 &&
|
||||
++i >= xhp->transaction_frequency_flush) {
|
||||
if ((rv = xbps_pkgdb_update(true)) != 0)
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
@ -330,7 +329,7 @@ xbps_transaction_commit(void)
|
||||
if (strcmp(tract, "update") == 0)
|
||||
update = true;
|
||||
|
||||
rv = xbps_configure_pkg(pkgname, false, update, false);
|
||||
rv = xbps_configure_pkg(xhp, pkgname, false, update, false);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
/*
|
||||
@ -338,16 +337,16 @@ xbps_transaction_commit(void)
|
||||
* installed or updated.
|
||||
*/
|
||||
if (update) {
|
||||
xbps_set_cb_state(XBPS_STATE_UPDATE_DONE, 0,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UPDATE_DONE, 0,
|
||||
pkgname, version, NULL);
|
||||
} else {
|
||||
xbps_set_cb_state(XBPS_STATE_INSTALL_DONE, 0,
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_INSTALL_DONE, 0,
|
||||
pkgname, version, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Force a flush now that packages are configured */
|
||||
rv = xbps_pkgdb_update(true);
|
||||
rv = xbps_pkgdb_update(xhp, true);
|
||||
out:
|
||||
prop_object_iterator_release(iter);
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
*/
|
||||
|
||||
static int
|
||||
compute_transaction_stats(prop_dictionary_t transd)
|
||||
compute_transaction_stats(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_dictionary_t pkg_metad;
|
||||
prop_object_iterator_t iter;
|
||||
@ -66,7 +66,7 @@ compute_transaction_stats(prop_dictionary_t transd)
|
||||
inst_pkgcnt = up_pkgcnt = cf_pkgcnt = rm_pkgcnt = 0;
|
||||
tsize = dlsize = instsize = rmsize = 0;
|
||||
|
||||
iter = xbps_array_iter_from_dict(transd, "packages");
|
||||
iter = xbps_array_iter_from_dict(xhp->transd, "packages");
|
||||
if (iter == NULL)
|
||||
return EINVAL;
|
||||
|
||||
@ -98,8 +98,8 @@ compute_transaction_stats(prop_dictionary_t transd)
|
||||
if ((strcmp(tract, "remove") == 0) ||
|
||||
(strcmp(tract, "update") == 0)) {
|
||||
pkg_metad =
|
||||
xbps_dictionary_from_metadata_plist(pkgname,
|
||||
XBPS_PKGPROPS);
|
||||
xbps_dictionary_from_metadata_plist(xhp,
|
||||
pkgname, XBPS_PKGPROPS);
|
||||
if (pkg_metad == NULL)
|
||||
continue;
|
||||
prop_dictionary_get_uint64(pkg_metad,
|
||||
@ -121,25 +121,25 @@ compute_transaction_stats(prop_dictionary_t transd)
|
||||
}
|
||||
|
||||
if (inst_pkgcnt &&
|
||||
!prop_dictionary_set_uint32(transd, "total-install-pkgs",
|
||||
!prop_dictionary_set_uint32(xhp->transd, "total-install-pkgs",
|
||||
inst_pkgcnt)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (up_pkgcnt &&
|
||||
!prop_dictionary_set_uint32(transd, "total-update-pkgs",
|
||||
!prop_dictionary_set_uint32(xhp->transd, "total-update-pkgs",
|
||||
up_pkgcnt)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (cf_pkgcnt &&
|
||||
!prop_dictionary_set_uint32(transd, "total-configure-pkgs",
|
||||
!prop_dictionary_set_uint32(xhp->transd, "total-configure-pkgs",
|
||||
cf_pkgcnt)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
if (rm_pkgcnt &&
|
||||
!prop_dictionary_set_uint32(transd, "total-remove-pkgs",
|
||||
!prop_dictionary_set_uint32(xhp->transd, "total-remove-pkgs",
|
||||
rm_pkgcnt)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
@ -158,7 +158,7 @@ compute_transaction_stats(prop_dictionary_t transd)
|
||||
* Add object in transaction dictionary with total installed
|
||||
* size that it will take.
|
||||
*/
|
||||
if (!prop_dictionary_set_uint64(transd,
|
||||
if (!prop_dictionary_set_uint64(xhp->transd,
|
||||
"total-installed-size", instsize)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
@ -167,7 +167,7 @@ compute_transaction_stats(prop_dictionary_t transd)
|
||||
* Add object in transaction dictionary with total download
|
||||
* size that needs to be sucked in.
|
||||
*/
|
||||
if (!prop_dictionary_set_uint64(transd,
|
||||
if (!prop_dictionary_set_uint64(xhp->transd,
|
||||
"total-download-size", dlsize)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
@ -176,7 +176,7 @@ compute_transaction_stats(prop_dictionary_t transd)
|
||||
* Add object in transaction dictionary with total size to be
|
||||
* freed from packages to be removed.
|
||||
*/
|
||||
if (!prop_dictionary_set_uint64(transd,
|
||||
if (!prop_dictionary_set_uint64(xhp->transd,
|
||||
"total-removed-size", rmsize)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
@ -233,10 +233,9 @@ xbps_transaction_init(struct xbps_handle *xhp)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_prepare(void)
|
||||
xbps_transaction_prepare(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_array_t mdeps, conflicts;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
int rv = 0;
|
||||
|
||||
if (xhp->transd == NULL)
|
||||
@ -259,7 +258,7 @@ xbps_transaction_prepare(void)
|
||||
/*
|
||||
* Check for packages to be replaced.
|
||||
*/
|
||||
if ((rv = xbps_transaction_package_replace(xhp->transd)) != 0) {
|
||||
if ((rv = xbps_transaction_package_replace(xhp)) != 0) {
|
||||
prop_object_release(xhp->transd);
|
||||
xhp->transd = NULL;
|
||||
return rv;
|
||||
@ -277,7 +276,7 @@ xbps_transaction_prepare(void)
|
||||
* number of packages to be installed, updated, configured
|
||||
* and removed to the transaction dictionary.
|
||||
*/
|
||||
if ((rv = compute_transaction_stats(xhp->transd)) != 0) {
|
||||
if ((rv = compute_transaction_stats(xhp)) != 0) {
|
||||
prop_object_release(xhp->transd);
|
||||
xhp->transd = NULL;
|
||||
return rv;
|
||||
|
@ -57,12 +57,15 @@ enum {
|
||||
};
|
||||
|
||||
static int
|
||||
transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
transaction_find_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool bypattern,
|
||||
bool best,
|
||||
bool exact,
|
||||
int action)
|
||||
{
|
||||
prop_dictionary_t pkg_pkgdb, pkg_repod;
|
||||
prop_array_t unsorted;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *pkgname, *repoloc, *repover, *instver, *reason;
|
||||
int rv = 0;
|
||||
pkg_state_t state = 0;
|
||||
@ -74,7 +77,7 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
reason = "install";
|
||||
} else {
|
||||
/* update */
|
||||
if ((pkg_pkgdb = xbps_pkgdb_get_pkgd(pkg, false)) == NULL)
|
||||
if ((pkg_pkgdb = xbps_pkgdb_get_pkgd(xhp, pkg, false)) == NULL)
|
||||
return ENODEV;
|
||||
|
||||
reason = "update";
|
||||
@ -85,22 +88,24 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
*/
|
||||
if (action == TRANS_INSTALL) {
|
||||
if (exact) {
|
||||
if ((pkg_repod = xbps_rpool_find_pkg_exact(pkg)) == NULL) {
|
||||
pkg_repod = xbps_rpool_find_pkg_exact(xhp, pkg);
|
||||
if (pkg_repod == NULL) {
|
||||
/* not found */
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (((pkg_repod = xbps_rpool_find_pkg(pkg, bypattern, best)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_find_virtualpkg_conf(pkg, bypattern)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_find_virtualpkg(pkg, bypattern)) == NULL)) {
|
||||
if (((pkg_repod = xbps_rpool_find_pkg(xhp, pkg, bypattern, best)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_find_virtualpkg_conf(xhp, pkg, bypattern)) == NULL) &&
|
||||
((pkg_repod = xbps_rpool_find_virtualpkg(xhp, pkg, bypattern)) == NULL)) {
|
||||
/* not found */
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((pkg_repod = xbps_rpool_find_pkg(pkg, false, true)) == NULL) {
|
||||
pkg_repod = xbps_rpool_find_pkg(xhp, pkg, false, true);
|
||||
if (pkg_repod == NULL) {
|
||||
/* not found */
|
||||
rv = errno;
|
||||
goto out;
|
||||
@ -118,7 +123,7 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
"version", &instver);
|
||||
prop_object_release(pkg_pkgdb);
|
||||
if (xbps_cmpver(repover, instver) <= 0) {
|
||||
xbps_dbg_printf("[rpool] Skipping `%s-%s' "
|
||||
xbps_dbg_printf(xhp, "[rpool] Skipping `%s-%s' "
|
||||
"(installed: %s-%s) from repository `%s'\n",
|
||||
pkgname, repover, pkgname, instver, repoloc);
|
||||
rv = EEXIST;
|
||||
@ -146,7 +151,7 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
* Set package state in dictionary with same state than the
|
||||
* package currently uses, otherwise not-installed.
|
||||
*/
|
||||
if ((rv = xbps_pkg_state_installed(pkgname, &state)) != 0) {
|
||||
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0) {
|
||||
if (rv != ENOENT)
|
||||
goto out;
|
||||
/* Package not installed, don't error out */
|
||||
@ -186,7 +191,7 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
xbps_dbg_printf("%s-%s: added into the transaction (%s).\n",
|
||||
xbps_dbg_printf(xhp, "%s-%s: added into the transaction (%s).\n",
|
||||
pkgname, repover, repoloc);
|
||||
|
||||
out:
|
||||
@ -197,10 +202,9 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_update_packages(void)
|
||||
xbps_transaction_update_packages(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_object_t obj;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *pkgname, *holdpkgname;
|
||||
bool newpkg_found = false;
|
||||
int rv = 0;
|
||||
@ -215,12 +219,12 @@ xbps_transaction_update_packages(void)
|
||||
for (x = 0; x < cfg_size(xhp->cfg, "PackagesOnHold"); x++) {
|
||||
holdpkgname = cfg_getnstr(xhp->cfg, "PackagesOnHold", x);
|
||||
if (strcmp(pkgname, holdpkgname) == 0) {
|
||||
xbps_dbg_printf("[rpool] package %s on hold, "
|
||||
xbps_dbg_printf(xhp, "[rpool] package %s on hold, "
|
||||
"ignoring updates.\n", pkgname);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
rv = transaction_find_pkg(pkgname, false, true,
|
||||
rv = transaction_find_pkg(xhp, pkgname, false, true,
|
||||
false, TRANS_UPDATE);
|
||||
if (rv == 0)
|
||||
newpkg_found = true;
|
||||
@ -237,13 +241,16 @@ xbps_transaction_update_packages(void)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_update_pkg(const char *pkgname)
|
||||
xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname)
|
||||
{
|
||||
return transaction_find_pkg(pkgname, false, true, false, TRANS_UPDATE);
|
||||
return transaction_find_pkg(xhp, pkgname, false,
|
||||
true, false, TRANS_UPDATE);
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_install_pkg(const char *pkg, bool reinstall)
|
||||
xbps_transaction_install_pkg(struct xbps_handle *xhp,
|
||||
const char *pkg,
|
||||
bool reinstall)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
pkg_state_t state;
|
||||
@ -266,10 +273,10 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall)
|
||||
}
|
||||
|
||||
if (exact) {
|
||||
pkgd = xbps_pkgdb_get_pkgd(pkgname, false);
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false);
|
||||
free(pkgname);
|
||||
} else
|
||||
pkgd = xbps_pkgdb_get_pkgd(pkg, bypattern);
|
||||
pkgd = xbps_pkgdb_get_pkgd(xhp, pkg, bypattern);
|
||||
|
||||
if (pkgd) {
|
||||
if (xbps_pkg_state_dictionary(pkgd, &state) != 0) {
|
||||
@ -282,24 +289,25 @@ xbps_transaction_install_pkg(const char *pkg, bool reinstall)
|
||||
return EEXIST;
|
||||
}
|
||||
}
|
||||
rv = transaction_find_pkg(pkg, bypattern, best, exact, TRANS_INSTALL);
|
||||
rv = transaction_find_pkg(xhp, pkg, bypattern, best, exact, TRANS_INSTALL);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_remove_pkg(const char *pkgname, bool recursive)
|
||||
xbps_transaction_remove_pkg(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
bool recursive)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t orphans, orphans_pkg, unsorted, reqby;
|
||||
prop_object_t obj;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *pkgver;
|
||||
size_t count;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd(pkgname, false)) == NULL) {
|
||||
if ((pkgd = xbps_pkgdb_get_pkgd(xhp, pkgname, false)) == NULL) {
|
||||
/* pkg not installed */
|
||||
return ENOENT;
|
||||
}
|
||||
@ -323,7 +331,7 @@ xbps_transaction_remove_pkg(const char *pkgname, bool recursive)
|
||||
}
|
||||
|
||||
prop_array_set_cstring_nocopy(orphans_pkg, 0, pkgname);
|
||||
orphans = xbps_find_pkg_orphans(orphans_pkg);
|
||||
orphans = xbps_find_pkg_orphans(xhp, orphans_pkg);
|
||||
prop_object_release(orphans_pkg);
|
||||
if (prop_object_type(orphans) != PROP_TYPE_ARRAY) {
|
||||
rv = EINVAL;
|
||||
@ -336,7 +344,7 @@ xbps_transaction_remove_pkg(const char *pkgname, bool recursive)
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_set_cstring_nocopy(obj, "transaction", "remove");
|
||||
prop_array_add(unsorted, obj);
|
||||
xbps_dbg_printf("%s: added into transaction (remove).\n", pkgver);
|
||||
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver);
|
||||
}
|
||||
prop_object_release(orphans);
|
||||
rmpkg:
|
||||
@ -346,7 +354,7 @@ rmpkg:
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
prop_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove");
|
||||
prop_array_add(unsorted, pkgd);
|
||||
xbps_dbg_printf("%s: added into transaction (remove).\n", pkgver);
|
||||
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver);
|
||||
reqby = prop_dictionary_get(pkgd, "requiredby");
|
||||
/*
|
||||
* If target pkg is required by any installed pkg, the client must be aware
|
||||
@ -363,16 +371,15 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_autoremove_pkgs(void)
|
||||
xbps_transaction_autoremove_pkgs(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_array_t orphans, unsorted;
|
||||
prop_object_t obj;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *pkgver;
|
||||
size_t count;
|
||||
int rv = 0;
|
||||
|
||||
orphans = xbps_find_pkg_orphans(NULL);
|
||||
orphans = xbps_find_pkg_orphans(xhp, NULL);
|
||||
if (prop_object_type(orphans) != PROP_TYPE_ARRAY)
|
||||
return EINVAL;
|
||||
|
||||
@ -397,7 +404,7 @@ xbps_transaction_autoremove_pkgs(void)
|
||||
prop_dictionary_set_cstring_nocopy(obj,
|
||||
"transaction", "remove");
|
||||
prop_array_add(unsorted, obj);
|
||||
xbps_dbg_printf("%s: added into transaction (remove).\n",
|
||||
xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n",
|
||||
pkgver);
|
||||
}
|
||||
out:
|
||||
|
@ -34,9 +34,8 @@
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
int HIDDEN
|
||||
xbps_transaction_package_replace(prop_dictionary_t transd)
|
||||
xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
prop_array_t replaces, instd_reqby, transd_unsorted;
|
||||
prop_dictionary_t instd, pkg_repod, reppkgd, filesd;
|
||||
prop_object_t obj;
|
||||
@ -46,9 +45,7 @@ xbps_transaction_package_replace(prop_dictionary_t transd)
|
||||
bool instd_auto, sr;
|
||||
size_t idx;
|
||||
|
||||
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
|
||||
|
||||
transd_unsorted = prop_dictionary_get(transd, "unsorted_deps");
|
||||
transd_unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
|
||||
for (idx = 0; idx < prop_array_count(transd_unsorted); idx++) {
|
||||
pkg_repod = prop_array_get(transd_unsorted, idx);
|
||||
@ -67,14 +64,15 @@ xbps_transaction_package_replace(prop_dictionary_t transd)
|
||||
* Find the installed package that matches the pattern
|
||||
* to be replaced.
|
||||
*/
|
||||
instd = xbps_find_pkg_dict_installed(pattern, true);
|
||||
instd =
|
||||
xbps_find_pkg_dict_installed(xhp, pattern, true);
|
||||
if (instd == NULL) {
|
||||
/*
|
||||
* No package installed has been matched,
|
||||
* try looking for a virtual package.
|
||||
*/
|
||||
instd = xbps_find_virtualpkg_dict_installed(
|
||||
pattern, true);
|
||||
xhp, pattern, true);
|
||||
if (instd == NULL)
|
||||
continue;
|
||||
}
|
||||
@ -86,14 +84,16 @@ xbps_transaction_package_replace(prop_dictionary_t transd)
|
||||
"pkgname", &curpkgname);
|
||||
prop_dictionary_get_cstring_nocopy(instd,
|
||||
"pkgver", &curpkgver);
|
||||
xbps_dbg_printf("Package `%s' will be replaced by `%s', "
|
||||
xbps_dbg_printf(xhp,
|
||||
"Package `%s' will be replaced by `%s', "
|
||||
"matched with `%s'\n", curpkgver, pkgver, pattern);
|
||||
/*
|
||||
* Check that we are not replacing the same package,
|
||||
* due to virtual packages.
|
||||
*/
|
||||
if (strcmp(pkgname, curpkgname) == 0) {
|
||||
xbps_dbg_printf("replaced and new package "
|
||||
xbps_dbg_printf(xhp,
|
||||
"replaced and new package "
|
||||
"are equal (%s)\n", pkgname);
|
||||
prop_object_release(instd);
|
||||
continue;
|
||||
@ -110,7 +110,8 @@ xbps_transaction_package_replace(prop_dictionary_t transd)
|
||||
reppkgd = xbps_find_pkg_in_array_by_name(
|
||||
transd_unsorted, curpkgname, NULL);
|
||||
if (reppkgd) {
|
||||
xbps_dbg_printf("found replaced pkg "
|
||||
xbps_dbg_printf(xhp,
|
||||
"found replaced pkg "
|
||||
"in transaction\n");
|
||||
prop_dictionary_set_bool(instd,
|
||||
"remove-and-update", true);
|
||||
|
@ -147,44 +147,19 @@ pkgdep_alloc(prop_dictionary_t d, const char *name, const char *trans)
|
||||
static void
|
||||
pkgdep_end(prop_array_t sorted)
|
||||
{
|
||||
prop_dictionary_t sorted_pkgd;
|
||||
struct pkgdep *pd;
|
||||
const char *trans;
|
||||
|
||||
while ((pd = TAILQ_FIRST(&pkgdep_list)) != NULL) {
|
||||
TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries);
|
||||
if (sorted != NULL && pd->d != NULL) {
|
||||
/*
|
||||
* Do not add duplicate pkg dictionaries with the
|
||||
* same transaction reason into the sorted array.
|
||||
*/
|
||||
sorted_pkgd =
|
||||
xbps_find_pkg_in_array_by_name(sorted, pd->name, NULL);
|
||||
if (sorted_pkgd == NULL) {
|
||||
/* find virtualpkg if no match */
|
||||
sorted_pkgd =
|
||||
xbps_find_virtualpkg_in_array_by_name(
|
||||
sorted, pd->name);
|
||||
}
|
||||
if (sorted_pkgd == NULL) {
|
||||
prop_array_add(sorted, pd->d);
|
||||
pkgdep_release(pd);
|
||||
continue;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(sorted_pkgd,
|
||||
"transaction", &trans);
|
||||
if (strcmp(trans, pd->trans) == 0) {
|
||||
pkgdep_release(pd);
|
||||
continue;
|
||||
}
|
||||
if (sorted != NULL && pd->d != NULL)
|
||||
prop_array_add(sorted, pd->d);
|
||||
}
|
||||
|
||||
pkgdep_release(pd);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
sort_pkg_rundeps(prop_dictionary_t transd,
|
||||
sort_pkg_rundeps(struct xbps_handle *xhp,
|
||||
struct pkgdep *pd,
|
||||
prop_array_t pkg_rundeps)
|
||||
{
|
||||
@ -196,7 +171,7 @@ sort_pkg_rundeps(prop_dictionary_t transd,
|
||||
size_t i, idx = 0;
|
||||
int rv = 0;
|
||||
|
||||
xbps_dbg_printf_append("\n");
|
||||
xbps_dbg_printf_append(xhp, "\n");
|
||||
curpkgidx = pkgdep_find_idx(pd->name, pd->trans);
|
||||
|
||||
again:
|
||||
@ -207,17 +182,17 @@ again:
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
}
|
||||
xbps_dbg_printf(" Required dependency '%s': ", str);
|
||||
xbps_dbg_printf(xhp, " Required dependency '%s': ", str);
|
||||
pdn = pkgdep_find(pkgnamedep, NULL);
|
||||
if ((pdn == NULL) &&
|
||||
xbps_check_is_installed_pkg_by_pattern(str)) {
|
||||
xbps_check_is_installed_pkg_by_name(xhp, pkgnamedep)) {
|
||||
/*
|
||||
* Package dependency is installed, just add to
|
||||
* the list but just mark it as "installed", to avoid
|
||||
* calling xbps_check_is_installed_pkg_by_name(),
|
||||
* which is expensive.
|
||||
*/
|
||||
xbps_dbg_printf_append("installed.\n");
|
||||
xbps_dbg_printf_append(xhp, "installed.\n");
|
||||
lpd = pkgdep_alloc(NULL, pkgnamedep, "installed");
|
||||
if (lpd == NULL) {
|
||||
rv = ENOMEM;
|
||||
@ -231,17 +206,17 @@ again:
|
||||
* Package was added previously into the list
|
||||
* and is installed, skip.
|
||||
*/
|
||||
xbps_dbg_printf_append("installed.\n");
|
||||
xbps_dbg_printf_append(xhp, "installed.\n");
|
||||
free(pkgnamedep);
|
||||
continue;
|
||||
}
|
||||
/* Find pkg by name */
|
||||
curpkgd = xbps_find_pkg_in_dict_by_name(transd,
|
||||
curpkgd = xbps_find_pkg_in_dict_by_name(xhp->transd,
|
||||
"unsorted_deps", pkgnamedep);
|
||||
if (curpkgd == NULL) {
|
||||
/* find virtualpkg by name if no match */
|
||||
curpkgd =
|
||||
xbps_find_virtualpkg_in_dict_by_name(transd,
|
||||
xbps_find_virtualpkg_in_dict_by_name(xhp->transd,
|
||||
"unsorted_deps", pkgnamedep);
|
||||
}
|
||||
if (curpkgd == NULL) {
|
||||
@ -264,7 +239,7 @@ again:
|
||||
*/
|
||||
TAILQ_INSERT_TAIL(&pkgdep_list, lpd, pkgdep_entries);
|
||||
idx = i;
|
||||
xbps_dbg_printf_append("added into the tail, "
|
||||
xbps_dbg_printf_append(xhp, "added into the tail, "
|
||||
"checking again...\n");
|
||||
free(pkgnamedep);
|
||||
goto again;
|
||||
@ -279,7 +254,7 @@ again:
|
||||
*/
|
||||
free(pkgnamedep);
|
||||
if (pkgdepidx < curpkgidx) {
|
||||
xbps_dbg_printf_append("already sorted.\n");
|
||||
xbps_dbg_printf_append(xhp, "already sorted.\n");
|
||||
pkgdep_release(lpd);
|
||||
} else {
|
||||
/*
|
||||
@ -289,7 +264,8 @@ again:
|
||||
TAILQ_REMOVE(&pkgdep_list, pdn, pkgdep_entries);
|
||||
pkgdep_release(pdn);
|
||||
TAILQ_INSERT_BEFORE(pd, lpd, pkgdep_entries);
|
||||
xbps_dbg_printf_append("added before `%s'.\n", pd->name);
|
||||
xbps_dbg_printf_append(xhp,
|
||||
"added before `%s'.\n", pd->name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,14 +277,12 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
{
|
||||
prop_array_t sorted, unsorted, rundeps;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
struct pkgdep *pd;
|
||||
size_t ndeps = 0, cnt = 0;
|
||||
size_t i, ndeps = 0, cnt = 0;
|
||||
const char *pkgname, *pkgver, *tract;
|
||||
int rv = 0;
|
||||
|
||||
sorted = prop_array_create();
|
||||
if (sorted == NULL)
|
||||
if ((sorted = prop_array_create()) == NULL)
|
||||
return ENOMEM;
|
||||
/*
|
||||
* Add sorted packages array into transaction dictionary (empty).
|
||||
@ -330,25 +304,16 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
* all objects in the unsorted array.
|
||||
*/
|
||||
ndeps = prop_array_count(unsorted);
|
||||
if (!prop_array_ensure_capacity(sorted, ndeps)) {
|
||||
xbps_dbg_printf("failed to set capacity to the sorted "
|
||||
"pkgdeps array\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
iter = prop_array_iterator(unsorted);
|
||||
if (iter == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Iterate over the unsorted package dictionaries and sort all
|
||||
* its package dependencies.
|
||||
*/
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
for (i = 0; i < ndeps; i++) {
|
||||
obj = prop_array_get(unsorted, i);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||
xbps_dbg_printf("Sorting package '%s' (%s): ", pkgver, tract);
|
||||
xbps_dbg_printf(xhp, "Sorting package '%s' (%s): ", pkgver, tract);
|
||||
|
||||
pd = pkgdep_find(pkgname, tract);
|
||||
if (pd == NULL) {
|
||||
@ -358,16 +323,15 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
pd = pkgdep_alloc(obj, pkgname, tract);
|
||||
if (pd == NULL) {
|
||||
pkgdep_end(NULL);
|
||||
prop_object_iterator_release(iter);
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if (strcmp(pd->trans, "remove") == 0) {
|
||||
xbps_dbg_printf_append("added into head.");
|
||||
xbps_dbg_printf_append(xhp, "added into head.");
|
||||
TAILQ_INSERT_HEAD(&pkgdep_list, pd,
|
||||
pkgdep_entries);
|
||||
} else {
|
||||
xbps_dbg_printf_append("added into tail.");
|
||||
xbps_dbg_printf_append(xhp, "added into tail.");
|
||||
TAILQ_INSERT_TAIL(&pkgdep_list, pd,
|
||||
pkgdep_entries);
|
||||
}
|
||||
@ -378,21 +342,19 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
*/
|
||||
rundeps = prop_dictionary_get(obj, "run_depends");
|
||||
if (rundeps == NULL || prop_array_count(rundeps) == 0) {
|
||||
xbps_dbg_printf_append("\n");
|
||||
xbps_dbg_printf_append(xhp, "\n");
|
||||
cnt++;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Sort package run-time dependencies for this package.
|
||||
*/
|
||||
if ((rv = sort_pkg_rundeps(xhp->transd, pd, rundeps)) != 0) {
|
||||
if ((rv = sort_pkg_rundeps(xhp, pd, rundeps)) != 0) {
|
||||
pkgdep_end(NULL);
|
||||
prop_object_iterator_release(iter);
|
||||
goto out;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
/*
|
||||
* We are done, now we have to copy all pkg dictionaries
|
||||
* from the sorted list into the "packages" array, and at
|
||||
|
34
lib/util.c
34
lib/util.c
@ -60,16 +60,17 @@ xbps_check_is_repository_uri_remote(const char *uri)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_check_is_installed_pkg_by_pattern(const char *pattern)
|
||||
xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
|
||||
const char *pattern)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
pkg_state_t state;
|
||||
|
||||
assert(pattern != NULL);
|
||||
|
||||
dict = xbps_find_virtualpkg_dict_installed(pattern, true);
|
||||
dict = xbps_find_virtualpkg_dict_installed(xhp, pattern, true);
|
||||
if (dict == NULL) {
|
||||
dict = xbps_find_pkg_dict_installed(pattern, true);
|
||||
dict = xbps_find_pkg_dict_installed(xhp, pattern, true);
|
||||
if (dict == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
errno = 0;
|
||||
@ -96,14 +97,15 @@ xbps_check_is_installed_pkg_by_pattern(const char *pattern)
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_check_is_installed_pkg_by_name(const char *pkgname)
|
||||
xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp,
|
||||
const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
|
||||
if (((pkgd = xbps_find_pkg_dict_installed(pkgname, false)) == NULL) &&
|
||||
((pkgd = xbps_find_virtualpkg_dict_installed(pkgname, false)) == NULL))
|
||||
if (((pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false)) == NULL) &&
|
||||
((pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false)) == NULL))
|
||||
return false;
|
||||
|
||||
prop_object_release(pkgd);
|
||||
@ -190,14 +192,14 @@ xbps_pkgpattern_version(const char *pkg)
|
||||
}
|
||||
|
||||
static char *
|
||||
get_pkg_index_remote_plist(const char *uri, const char *plistf)
|
||||
get_pkg_index_remote_plist(struct xbps_handle *xhp,
|
||||
const char *uri,
|
||||
const char *plistf)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
char *uri_fixed, *repodir;
|
||||
|
||||
assert(uri != NULL);
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
uri_fixed = xbps_get_remote_repo_string(uri);
|
||||
if (uri_fixed == NULL)
|
||||
return NULL;
|
||||
@ -208,30 +210,31 @@ get_pkg_index_remote_plist(const char *uri, const char *plistf)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_pkg_index_plist(const char *uri)
|
||||
xbps_pkg_index_plist(struct xbps_handle *xhp, const char *uri)
|
||||
{
|
||||
assert(uri != NULL);
|
||||
|
||||
if (xbps_check_is_repository_uri_remote(uri))
|
||||
return get_pkg_index_remote_plist(uri, XBPS_PKGINDEX);
|
||||
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX);
|
||||
|
||||
return xbps_xasprintf("%s/%s", uri, XBPS_PKGINDEX);
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_pkg_index_files_plist(const char *uri)
|
||||
xbps_pkg_index_files_plist(struct xbps_handle *xhp, const char *uri)
|
||||
{
|
||||
assert(uri != NULL);
|
||||
if (xbps_check_is_repository_uri_remote(uri))
|
||||
return get_pkg_index_remote_plist(uri, XBPS_PKGINDEX_FILES);
|
||||
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX_FILES);
|
||||
|
||||
return xbps_xasprintf("%s/%s", uri, XBPS_PKGINDEX_FILES);
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
|
||||
xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
||||
prop_dictionary_t pkg_repod,
|
||||
const char *repoloc)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
const char *filen, *arch;
|
||||
char *lbinpkg = NULL;
|
||||
|
||||
@ -242,7 +245,6 @@ xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
|
||||
"filename", &filen))
|
||||
return NULL;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
/*
|
||||
* First check if binpkg is available in cachedir.
|
||||
*/
|
||||
|
@ -174,11 +174,11 @@ xbps_file_hash_dictionary(prop_dictionary_t d,
|
||||
}
|
||||
|
||||
int
|
||||
xbps_file_hash_check_dictionary(prop_dictionary_t d,
|
||||
xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
const char *sha256d = NULL;
|
||||
char *buf;
|
||||
int rv;
|
||||
|
Loading…
Reference in New Issue
Block a user