Moved install transaction code to libxbps, see NEWS file.
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
*/
|
||||
|
||||
int
|
||||
xbps_check_pkg_integrity_all(void)
|
||||
check_pkg_integrity_all(void)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_object_t obj;
|
||||
@@ -71,7 +71,7 @@ xbps_check_pkg_integrity_all(void)
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
printf("Checking %s-%s ...\n", pkgname, version);
|
||||
if ((rv = xbps_check_pkg_integrity(pkgname)) != 0)
|
||||
if ((rv = check_pkg_integrity(pkgname)) != 0)
|
||||
nbrokenpkgs++;
|
||||
npkgs++;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_check_pkg_integrity(const char *pkgname)
|
||||
check_pkg_integrity(const char *pkgname)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd, propsd = NULL, filesd = NULL;
|
||||
prop_array_t array;
|
||||
prop_object_t obj;
|
||||
|
@@ -32,26 +32,38 @@
|
||||
|
||||
#include <xbps_api.h>
|
||||
|
||||
int xbps_install_new_pkg(const char *);
|
||||
int xbps_update_pkg(const char *);
|
||||
int xbps_autoupdate_pkgs(bool, bool);
|
||||
int xbps_autoremove_pkgs(bool, bool);
|
||||
int xbps_exec_transaction(bool, bool);
|
||||
int xbps_remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
||||
int xbps_check_pkg_integrity(const char *);
|
||||
int xbps_check_pkg_integrity_all(void);
|
||||
int xbps_show_pkg_deps(const char *);
|
||||
int xbps_show_pkg_reverse_deps(const char *);
|
||||
/* from install.c */
|
||||
int install_new_pkg(const char *);
|
||||
int update_pkg(const char *);
|
||||
int autoupdate_pkgs(bool, bool);
|
||||
int autoremove_pkgs(bool, bool);
|
||||
int exec_transaction(bool, bool);
|
||||
void transaction_cb(struct xbps_transaction_cb_data *);
|
||||
void transaction_err_cb(struct xbps_transaction_cb_data *);
|
||||
|
||||
int remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
||||
|
||||
/* from check.c */
|
||||
int check_pkg_integrity(const char *);
|
||||
int check_pkg_integrity_all(void);
|
||||
|
||||
/* from show-deps.c */
|
||||
int show_pkg_deps(const char *);
|
||||
int show_pkg_reverse_deps(const char *);
|
||||
|
||||
/* from show-info-files.c */
|
||||
int show_pkg_info_from_metadir(const char *);
|
||||
int show_pkg_files_from_metadir(const char *);
|
||||
|
||||
/* from find-files.c */
|
||||
int find_files_in_packages(const char *);
|
||||
|
||||
/* from question.c */
|
||||
bool xbps_yesno(const char *, ...);
|
||||
bool xbps_noyes(const char *, ...);
|
||||
bool yesno(const char *, ...);
|
||||
bool noyes(const char *, ...);
|
||||
|
||||
/* from fetch.c */
|
||||
void fetch_file_progress_cb(void *);
|
||||
void fetch_file_progress_cb(struct xbps_fetch_cb_data *);
|
||||
|
||||
/* From util.c */
|
||||
int show_pkg_files(prop_dictionary_t);
|
||||
|
@@ -52,7 +52,7 @@ struct xferstat {
|
||||
* Compute and display ETA
|
||||
*/
|
||||
static const char *
|
||||
stat_eta(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
stat_eta(struct xbps_fetch_cb_data *xfpd, struct xferstat *xsp)
|
||||
{
|
||||
static char str[16];
|
||||
long elapsed, eta;
|
||||
@@ -92,7 +92,7 @@ compare_double(const double a, const double b)
|
||||
* Compute and display transfer rate
|
||||
*/
|
||||
static const char *
|
||||
stat_bps(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
stat_bps(struct xbps_fetch_cb_data *xfpd, struct xferstat *xsp)
|
||||
{
|
||||
static char str[16];
|
||||
char size[8];
|
||||
@@ -115,7 +115,7 @@ stat_bps(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
* Update the stats display
|
||||
*/
|
||||
static void
|
||||
stat_display(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
stat_display(struct xbps_fetch_cb_data *xfpd, struct xferstat *xsp)
|
||||
{
|
||||
struct timeval now;
|
||||
char totsize[8], recvsize[8];
|
||||
@@ -152,7 +152,7 @@ stat_start(struct xferstat *xsp)
|
||||
* Update the transfer statistics
|
||||
*/
|
||||
static void
|
||||
stat_update(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
stat_update(struct xbps_fetch_cb_data *xfpd, struct xferstat *xsp)
|
||||
{
|
||||
xfpd->file_dloaded += xfpd->file_offset;
|
||||
stat_display(xfpd, xsp);
|
||||
@@ -162,7 +162,7 @@ stat_update(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
* Finalize the transfer statistics
|
||||
*/
|
||||
static void
|
||||
stat_end(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
stat_end(struct xbps_fetch_cb_data *xfpd, struct xferstat *xsp)
|
||||
{
|
||||
char size[8];
|
||||
|
||||
@@ -173,9 +173,8 @@ stat_end(struct xbps_fetch_progress_data *xfpd, struct xferstat *xsp)
|
||||
}
|
||||
|
||||
void
|
||||
fetch_file_progress_cb(void *data)
|
||||
fetch_file_progress_cb(struct xbps_fetch_cb_data *xfpd)
|
||||
{
|
||||
struct xbps_fetch_progress_data *xfpd = data;
|
||||
static struct xferstat xs;
|
||||
|
||||
if (xfpd->cb_start)
|
||||
|
@@ -71,7 +71,7 @@ match_files_by_pattern(prop_dictionary_t pkg_filesd, prop_dictionary_keysym_t ke
|
||||
int
|
||||
find_files_in_packages(const char *pattern)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkg_filesd;
|
||||
prop_array_t files_keys;
|
||||
DIR *dirp;
|
||||
|
@@ -39,10 +39,8 @@
|
||||
#include "../xbps-repo/defs.h"
|
||||
|
||||
struct transaction {
|
||||
prop_dictionary_t dict;
|
||||
prop_dictionary_t d;
|
||||
prop_object_iterator_t iter;
|
||||
bool yes;
|
||||
bool only_show;
|
||||
uint32_t inst_pkgcnt;
|
||||
uint32_t up_pkgcnt;
|
||||
uint32_t cf_pkgcnt;
|
||||
@@ -66,118 +64,40 @@ show_missing_deps(prop_array_t a)
|
||||
}
|
||||
|
||||
static int
|
||||
check_binpkg_hash(const char *path,
|
||||
const char *filename,
|
||||
const char *sha256)
|
||||
show_binpkgs_url(prop_object_iterator_t iter)
|
||||
{
|
||||
int rv;
|
||||
|
||||
printf("Checking %s integrity... ", filename);
|
||||
rv = xbps_file_hash_check(path, sha256);
|
||||
if (rv != 0 && rv != ERANGE) {
|
||||
xbps_error_printf("\nxbps-bin: unexpected error: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
} else if (rv == ERANGE) {
|
||||
printf("hash mismatch!\n");
|
||||
xbps_warn_printf("Package '%s' has wrong checksum, removing "
|
||||
"and refetching it again...\n", filename);
|
||||
(void)remove(path);
|
||||
return rv;
|
||||
}
|
||||
printf("OK.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
download_package_list(prop_object_iterator_t iter, bool only_show)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_object_t obj;
|
||||
const char *pkgver, *repoloc, *filename, *sha256, *trans;
|
||||
const char *repoloc, *trans;
|
||||
char *binfile;
|
||||
int rv = 0;
|
||||
bool cksum;
|
||||
|
||||
xhp = xbps_handle_get();
|
||||
again:
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &trans);
|
||||
if ((strcmp(trans, "remove") == 0) ||
|
||||
(strcmp(trans, "configure") == 0))
|
||||
continue;
|
||||
|
||||
cksum = false;
|
||||
prop_dictionary_get_bool(obj, "checksum_ok", &cksum);
|
||||
if (cksum == true)
|
||||
continue;
|
||||
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"repository", &repoloc))
|
||||
continue;
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &filename);
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"filename-sha256", &sha256);
|
||||
|
||||
/* ignore pkgs from local repositories */
|
||||
if (!xbps_check_is_repository_uri_remote(repoloc))
|
||||
continue;
|
||||
|
||||
binfile = xbps_path_from_repository_uri(obj, repoloc);
|
||||
if (binfile == NULL)
|
||||
return errno;
|
||||
/*
|
||||
* If downloaded package is in cachedir, check its hash
|
||||
* and refetch the binpkg again if didn't match.
|
||||
* If downloaded package is in cachedir, ignore it.
|
||||
*/
|
||||
if (access(binfile, R_OK) == 0) {
|
||||
rv = check_binpkg_hash(binfile, filename, sha256);
|
||||
free(binfile);
|
||||
if (rv != 0 && rv != ERANGE) {
|
||||
return rv;
|
||||
} else if (rv == ERANGE) {
|
||||
break;
|
||||
}
|
||||
prop_dictionary_set_bool(obj, "checksum_ok", true);
|
||||
continue;
|
||||
}
|
||||
if (only_show) {
|
||||
printf("%s\n", binfile);
|
||||
free(binfile);
|
||||
continue;
|
||||
}
|
||||
if (xbps_mkpath(xhp->cachedir, 0755) == -1) {
|
||||
xbps_error_printf("xbps-bin: cannot mkdir cachedir "
|
||||
"`%s': %s.\n", xhp->cachedir, strerror(errno));
|
||||
free(binfile);
|
||||
return errno;
|
||||
}
|
||||
printf("Downloading %s binary package ...\n", pkgver);
|
||||
rv = xbps_fetch_file(binfile, xhp->cachedir, false, NULL);
|
||||
if (rv == -1) {
|
||||
xbps_error_printf("xbps-bin: couldn't download `%s'\n",
|
||||
filename);
|
||||
xbps_error_printf("xbps-bin: %s returned: `%s'\n",
|
||||
repoloc, xbps_fetch_error_string());
|
||||
free(binfile);
|
||||
return -1;
|
||||
}
|
||||
printf("%s\n", binfile);
|
||||
free(binfile);
|
||||
binfile = xbps_path_from_repository_uri(obj, repoloc);
|
||||
if (binfile == NULL)
|
||||
return errno;
|
||||
|
||||
rv = check_binpkg_hash(binfile, filename, sha256);
|
||||
free(binfile);
|
||||
if (rv != 0 && rv != ERANGE) {
|
||||
return rv;
|
||||
} else if (rv == ERANGE) {
|
||||
break;
|
||||
}
|
||||
prop_dictionary_set_bool(obj, "checksum_ok", true);
|
||||
}
|
||||
prop_object_iterator_reset(iter);
|
||||
if (rv == ERANGE)
|
||||
goto again;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -207,28 +127,28 @@ show_transaction_sizes(struct transaction *trans)
|
||||
/*
|
||||
* Show the list of packages that will be installed.
|
||||
*/
|
||||
if (prop_dictionary_get_uint32(trans->dict, "total-install-pkgs",
|
||||
if (prop_dictionary_get_uint32(trans->d, "total-install-pkgs",
|
||||
&trans->inst_pkgcnt)) {
|
||||
printf("%u package%s will be installed:\n\n",
|
||||
trans->inst_pkgcnt, trans->inst_pkgcnt == 1 ? "" : "s");
|
||||
show_package_list(trans->iter, "install");
|
||||
printf("\n\n");
|
||||
}
|
||||
if (prop_dictionary_get_uint32(trans->dict, "total-update-pkgs",
|
||||
if (prop_dictionary_get_uint32(trans->d, "total-update-pkgs",
|
||||
&trans->up_pkgcnt)) {
|
||||
printf("%u package%s will be updated:\n\n",
|
||||
trans->up_pkgcnt, trans->up_pkgcnt == 1 ? "" : "s");
|
||||
show_package_list(trans->iter, "update");
|
||||
printf("\n\n");
|
||||
}
|
||||
if (prop_dictionary_get_uint32(trans->dict, "total-configure-pkgs",
|
||||
if (prop_dictionary_get_uint32(trans->d, "total-configure-pkgs",
|
||||
&trans->cf_pkgcnt)) {
|
||||
printf("%u package%s will be configured:\n\n",
|
||||
trans->cf_pkgcnt, trans->cf_pkgcnt == 1 ? "" : "s");
|
||||
show_package_list(trans->iter, "configure");
|
||||
printf("\n\n");
|
||||
}
|
||||
if (prop_dictionary_get_uint32(trans->dict, "total-remove-pkgs",
|
||||
if (prop_dictionary_get_uint32(trans->d, "total-remove-pkgs",
|
||||
&trans->rm_pkgcnt)) {
|
||||
printf("%u package%s will be removed:\n\n",
|
||||
trans->rm_pkgcnt, trans->rm_pkgcnt == 1 ? "" : "s");
|
||||
@@ -239,8 +159,8 @@ show_transaction_sizes(struct transaction *trans)
|
||||
/*
|
||||
* Show total download/installed size for all required packages.
|
||||
*/
|
||||
prop_dictionary_get_uint64(trans->dict, "total-download-size", &dlsize);
|
||||
prop_dictionary_get_uint64(trans->dict, "total-installed-size",
|
||||
prop_dictionary_get_uint64(trans->d, "total-download-size", &dlsize);
|
||||
prop_dictionary_get_uint64(trans->d, "total-installed-size",
|
||||
&instsize);
|
||||
if (xbps_humanize_number(size, (int64_t)dlsize) == -1) {
|
||||
xbps_error_printf("xbps-bin: error: humanize_number returns "
|
||||
@@ -259,7 +179,7 @@ show_transaction_sizes(struct transaction *trans)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_autoupdate_pkgs(bool yes, bool show_download_pkglist_url)
|
||||
autoupdate_pkgs(bool yes, bool show_download_pkglist_url)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -282,11 +202,11 @@ xbps_autoupdate_pkgs(bool yes, bool show_download_pkglist_url)
|
||||
}
|
||||
}
|
||||
|
||||
return xbps_exec_transaction(yes, show_download_pkglist_url);
|
||||
return exec_transaction(yes, show_download_pkglist_url);
|
||||
}
|
||||
|
||||
int
|
||||
xbps_install_new_pkg(const char *pkg)
|
||||
install_new_pkg(const char *pkg)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
char *pkgname = NULL, *pkgpatt = NULL;
|
||||
@@ -343,7 +263,7 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_update_pkg(const char *pkgname)
|
||||
update_pkg(const char *pkgname)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
@@ -363,219 +283,99 @@ xbps_update_pkg(const char *pkgname)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
exec_transaction(struct transaction *trans)
|
||||
void
|
||||
transaction_cb(struct xbps_transaction_cb_data *xtcd)
|
||||
{
|
||||
prop_dictionary_t instpkgd;
|
||||
prop_object_t obj;
|
||||
const char *pkgname, *version, *pkgver, *instver, *filen, *tract;
|
||||
int rv = 0;
|
||||
bool update, preserve;
|
||||
pkg_state_t state;
|
||||
|
||||
/*
|
||||
* Only show the URLs to download the binary packages.
|
||||
*/
|
||||
if (trans->only_show)
|
||||
return download_package_list(trans->iter, true);
|
||||
/*
|
||||
* Show download/installed size for the transaction.
|
||||
*/
|
||||
if ((rv = show_transaction_sizes(trans)) != 0)
|
||||
return rv;
|
||||
/*
|
||||
* Ask interactively (if -y not set).
|
||||
*/
|
||||
if (trans->yes == false) {
|
||||
if (xbps_noyes("Do you want to continue?") == false) {
|
||||
printf("Aborting!\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Download binary packages (if they come from a remote repository)
|
||||
* and check its SHA256 hash.
|
||||
*/
|
||||
printf("[*] Downloading/integrity check ...\n");
|
||||
if ((rv = download_package_list(trans->iter, false)) != 0)
|
||||
return rv;
|
||||
/*
|
||||
* Remove packages to be replaced.
|
||||
*/
|
||||
if (trans->rm_pkgcnt) {
|
||||
printf("\n[*] Removing packages to be replaced ...\n");
|
||||
while ((obj = prop_object_iterator_next(trans->iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction",
|
||||
&tract);
|
||||
if (strcmp(tract, "remove"))
|
||||
continue;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname",
|
||||
&pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version",
|
||||
&version);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver",
|
||||
&pkgver);
|
||||
update = false;
|
||||
prop_dictionary_get_bool(obj, "remove-and-update",
|
||||
&update);
|
||||
|
||||
/* Remove and purge packages that shall be replaced */
|
||||
printf("Removing `%s' package ...\n", pkgver);
|
||||
rv = xbps_remove_pkg(pkgname, version, update);
|
||||
if (rv != 0) {
|
||||
xbps_error_printf("xbps-bin: failed to "
|
||||
"remove `%s': %s\n", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
if (!update)
|
||||
continue;
|
||||
printf("Purging `%s' package...\n", pkgver);
|
||||
if ((rv = xbps_purge_pkg(pkgname, false)) != 0) {
|
||||
xbps_error_printf("xbps-bin: failed to "
|
||||
"purge `%s': %s\n", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(trans->iter);
|
||||
}
|
||||
/*
|
||||
* Configure pending packages.
|
||||
*/
|
||||
if (trans->cf_pkgcnt) {
|
||||
printf("\n[*] Reconfigure unpacked packages ...\n");
|
||||
while ((obj = prop_object_iterator_next(trans->iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction",
|
||||
&tract);
|
||||
if (strcmp(tract, "configure"))
|
||||
continue;
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname",
|
||||
&pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version",
|
||||
&version);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver",
|
||||
&pkgver);
|
||||
rv = xbps_configure_pkg(pkgname, version, false, false);
|
||||
if (rv != 0) {
|
||||
xbps_error_printf("xbps-bin: failed to "
|
||||
"configure `%s': %s\n", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(trans->iter);
|
||||
}
|
||||
/*
|
||||
* Install or update packages in transaction.
|
||||
*/
|
||||
printf("\n[*] Unpacking packages to be installed/updated ...\n");
|
||||
while ((obj = prop_object_iterator_next(trans->iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||
/* Match only packages to be installed or updated */
|
||||
if ((strcmp(tract, "remove") == 0) ||
|
||||
(strcmp(tract, "configure") == 0))
|
||||
continue;
|
||||
preserve = false;
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &filen);
|
||||
prop_dictionary_get_bool(obj, "preserve", &preserve);
|
||||
/*
|
||||
* If dependency is already unpacked skip this phase.
|
||||
*/
|
||||
state = 0;
|
||||
if (xbps_pkg_state_dictionary(obj, &state) != 0)
|
||||
return EINVAL;
|
||||
if (state == XBPS_PKG_STATE_UNPACKED)
|
||||
continue;
|
||||
|
||||
if (strcmp(tract, "update") == 0) {
|
||||
/* Update a package */
|
||||
instpkgd = xbps_find_pkg_dict_installed(pkgname, false);
|
||||
if (instpkgd == NULL) {
|
||||
xbps_error_printf("xbps-bin: error: unable to "
|
||||
"find %s installed dict!\n", pkgname);
|
||||
return EINVAL;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(instpkgd,
|
||||
"version", &instver);
|
||||
prop_object_release(instpkgd);
|
||||
if (preserve)
|
||||
printf("Conserving %s-%s files, installing new "
|
||||
"version ...\n", pkgname, instver);
|
||||
else
|
||||
printf("Replacing %s files (%s -> %s) ...\n",
|
||||
pkgname, instver, version);
|
||||
|
||||
if ((rv = xbps_remove_pkg(pkgname, version, true)) != 0) {
|
||||
xbps_error_printf("xbps-bin: error "
|
||||
"replacing %s-%s (%s)\n", pkgname,
|
||||
instver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Unpack binary package.
|
||||
*/
|
||||
printf("Unpacking `%s' (from ../%s) ...\n", pkgver, filen);
|
||||
if ((rv = xbps_unpack_binary_pkg(obj)) != 0) {
|
||||
xbps_error_printf("xbps-bin: error unpacking %s "
|
||||
"(%s)\n", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
/*
|
||||
* Register binary package.
|
||||
*/
|
||||
if ((rv = xbps_register_pkg(obj)) != 0) {
|
||||
xbps_error_printf("xbps-bin: error registering %s "
|
||||
"(%s)\n", pkgver, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(trans->iter);
|
||||
/*
|
||||
* Configure all unpacked packages.
|
||||
*/
|
||||
printf("\n[*] Configuring packages installed/updated ...\n");
|
||||
while ((obj = prop_object_iterator_next(trans->iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
|
||||
if ((strcmp(tract, "remove") == 0) ||
|
||||
(strcmp(tract, "configure") == 0))
|
||||
continue;
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
update = false;
|
||||
if (strcmp(tract, "update") == 0)
|
||||
update = true;
|
||||
rv = xbps_configure_pkg(pkgname, version, false, update);
|
||||
if (rv != 0) {
|
||||
xbps_error_printf("xbps-bin: error configuring "
|
||||
"package %s (%s)\n", pkgname, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
trans->cf_pkgcnt++;
|
||||
if (xtcd->desc != NULL && xtcd->pkgver == NULL) {
|
||||
printf("\n%s ...\n", xtcd->desc);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\nxbps-bin: %u installed, %u updated, "
|
||||
"%u configured, %u removed.\n", trans->inst_pkgcnt,
|
||||
trans->up_pkgcnt, trans->cf_pkgcnt, trans->rm_pkgcnt);
|
||||
switch (xtcd->state) {
|
||||
case XBPS_TRANS_STATE_DOWNLOAD:
|
||||
printf("Downloading `%s' (from %s) ...\n",
|
||||
xtcd->pkgver, xtcd->binpkg_repourl);
|
||||
break;
|
||||
case XBPS_TRANS_STATE_VERIFY:
|
||||
printf("Checking `%s' integrity ...\n", xtcd->binpkg_fname);
|
||||
break;
|
||||
case XBPS_TRANS_STATE_REMOVE:
|
||||
printf("Removing `%s' ...\n", xtcd->pkgver);
|
||||
break;
|
||||
case XBPS_TRANS_STATE_PURGE:
|
||||
printf("Purging `%s' ...\n", xtcd->pkgver);
|
||||
break;
|
||||
case XBPS_TRANS_STATE_CONFIGURE:
|
||||
printf("Configuring `%s' ...\n", xtcd->pkgver);
|
||||
break;
|
||||
case XBPS_TRANS_STATE_REGISTER:
|
||||
case XBPS_TRANS_STATE_INSTALL:
|
||||
break;
|
||||
case XBPS_TRANS_STATE_UPDATE:
|
||||
printf("Updating `%s' ...\n", xtcd->pkgver);
|
||||
break;
|
||||
case XBPS_TRANS_STATE_UNPACK:
|
||||
printf("Unpacking `%s' (from ../%s) ...\n",
|
||||
xtcd->pkgver, xtcd->binpkg_fname);
|
||||
break;
|
||||
default:
|
||||
xbps_dbg_printf("%s: unknown transaction state %d %s\n",
|
||||
xtcd->pkgver, xtcd->state, xtcd->desc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
void
|
||||
transaction_err_cb(struct xbps_transaction_cb_data *xtcd)
|
||||
{
|
||||
const char *state_descr = NULL;
|
||||
|
||||
switch (xtcd->state) {
|
||||
case XBPS_TRANS_STATE_DOWNLOAD:
|
||||
state_descr = "failed to download binary package";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_VERIFY:
|
||||
state_descr = "failed to verify binary package SHA256";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_REMOVE:
|
||||
state_descr = "failed to remove package";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_PURGE:
|
||||
state_descr = "failed to purge package";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_CONFIGURE:
|
||||
state_descr = "failed to configure package";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_UPDATE:
|
||||
state_descr = "failed to update package";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_UNPACK:
|
||||
state_descr = "failed to unpack binary package";
|
||||
break;
|
||||
case XBPS_TRANS_STATE_REGISTER:
|
||||
state_descr = "failed to register package";
|
||||
break;
|
||||
default:
|
||||
state_descr = "unknown transaction state";
|
||||
break;
|
||||
}
|
||||
|
||||
xbps_error_printf("%s: %s: %s\n",
|
||||
xtcd->pkgver, state_descr, strerror(xtcd->err));
|
||||
}
|
||||
|
||||
int
|
||||
xbps_exec_transaction(bool yes, bool show_download_pkglist_url)
|
||||
exec_transaction(bool yes, bool show_download_urls)
|
||||
{
|
||||
struct transaction *trans;
|
||||
prop_array_t array;
|
||||
int rv = 0;
|
||||
|
||||
trans = calloc(1, sizeof(struct transaction));
|
||||
trans = calloc(1, sizeof(*trans));
|
||||
if (trans == NULL)
|
||||
return errno;
|
||||
return ENOMEM;
|
||||
|
||||
trans->dict = xbps_transaction_prepare();
|
||||
if (trans->dict == NULL) {
|
||||
if ((trans->d = xbps_transaction_prepare()) == NULL) {
|
||||
if (errno == ENODEV) {
|
||||
/* missing packages */
|
||||
array = xbps_transaction_missingdeps_get();
|
||||
@@ -583,33 +383,54 @@ xbps_exec_transaction(bool yes, bool show_download_pkglist_url)
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
rv = errno;
|
||||
xbps_dbg_printf("Empty transaction dictionary: %s\n",
|
||||
strerror(errno));
|
||||
goto out;
|
||||
return errno;
|
||||
}
|
||||
xbps_dbg_printf("Dictionary before transaction happens:\n");
|
||||
xbps_dbg_printf_append("%s", prop_dictionary_externalize(trans->dict));
|
||||
xbps_dbg_printf_append("%s", prop_dictionary_externalize(trans->d));
|
||||
|
||||
/*
|
||||
* It's time to run the transaction!
|
||||
*/
|
||||
trans->iter = xbps_array_iter_from_dict(trans->dict, "packages");
|
||||
trans->iter = xbps_array_iter_from_dict(trans->d, "packages");
|
||||
if (trans->iter == NULL) {
|
||||
rv = errno;
|
||||
xbps_error_printf("xbps-bin: error allocating array mem! (%s)\n",
|
||||
strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
|
||||
trans->yes = yes;
|
||||
trans->only_show = show_download_pkglist_url;
|
||||
rv = exec_transaction(trans);
|
||||
/*
|
||||
* Only show URLs to download binary packages.
|
||||
*/
|
||||
if (show_download_urls) {
|
||||
rv = show_binpkgs_url(trans->iter);
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Show download/installed size for the transaction.
|
||||
*/
|
||||
if ((rv = show_transaction_sizes(trans)) != 0)
|
||||
goto out;
|
||||
/*
|
||||
* Ask interactively (if -y not set).
|
||||
*/
|
||||
if (!yes && !noyes("Do you want to continue?")) {
|
||||
printf("Aborting!\n");
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* It's time to run the transaction!
|
||||
*/
|
||||
rv = xbps_transaction_commit(trans->d);
|
||||
if (rv == 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,
|
||||
trans->rm_pkgcnt);
|
||||
}
|
||||
out:
|
||||
if (trans->iter)
|
||||
prop_object_iterator_release(trans->iter);
|
||||
if (trans->dict)
|
||||
prop_object_release(trans->dict);
|
||||
if (trans->d)
|
||||
prop_object_release(trans->d);
|
||||
if (trans)
|
||||
free(trans);
|
||||
|
||||
|
@@ -46,7 +46,7 @@ struct list_pkgver_cb {
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
{
|
||||
xbps_end();
|
||||
xbps_end(xbps_handle_get());
|
||||
fprintf(stderr,
|
||||
"Usage: xbps-bin [options] [target] [arguments]\n"
|
||||
"See xbps-bin(8) for more information.\n");
|
||||
@@ -145,15 +145,15 @@ show_orphans(void)
|
||||
static void __attribute__((noreturn))
|
||||
cleanup(int signum)
|
||||
{
|
||||
xbps_end();
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
|
||||
xbps_end(xhp);
|
||||
exit(signum);
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_progress_cb_verbose(void *data)
|
||||
unpack_progress_cb_verbose(struct xbps_unpack_cb_data *xpd)
|
||||
{
|
||||
struct xbps_unpack_progress_data *xpd = data;
|
||||
|
||||
if (xpd->entry == NULL || xpd->entry_is_metadata)
|
||||
return;
|
||||
else if (xpd->entry_size <= 0)
|
||||
@@ -165,10 +165,8 @@ unpack_progress_cb_verbose(void *data)
|
||||
}
|
||||
|
||||
static void
|
||||
unpack_progress_cb(void *data)
|
||||
unpack_progress_cb(struct xbps_unpack_cb_data *xpd)
|
||||
{
|
||||
struct xbps_unpack_progress_data *xpd = data;
|
||||
|
||||
if (xpd->entry == NULL || xpd->entry_is_metadata)
|
||||
return;
|
||||
else if (xpd->entry_size <= 0)
|
||||
@@ -181,20 +179,17 @@ unpack_progress_cb(void *data)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
struct xbps_handle xh;
|
||||
struct xbps_unpack_progress_data xupd;
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
struct xbps_handle *xhp;
|
||||
struct list_pkgver_cb lpc;
|
||||
struct sigaction sa;
|
||||
const char *rootdir, *cachedir, *conffile;
|
||||
int i , c, flags, rv;
|
||||
bool yes, purge, with_debug, force_rm_with_deps, recursive_rm;
|
||||
bool yes, purge, debug, force_rm_with_deps, recursive_rm;
|
||||
bool install_auto, install_manual, show_download_pkglist_url;
|
||||
|
||||
rootdir = cachedir = conffile = NULL;
|
||||
flags = rv = 0;
|
||||
yes = purge = force_rm_with_deps = recursive_rm = with_debug = false;
|
||||
yes = purge = force_rm_with_deps = recursive_rm = debug = false;
|
||||
install_auto = install_manual = show_download_pkglist_url = false;
|
||||
|
||||
while ((c = getopt(argc, argv, "AC:c:dDFfMpRr:Vvy")) != -1) {
|
||||
@@ -209,7 +204,7 @@ main(int argc, char **argv)
|
||||
cachedir = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
with_debug = true;
|
||||
debug = true;
|
||||
break;
|
||||
case 'D':
|
||||
show_download_pkglist_url = true;
|
||||
@@ -273,28 +268,31 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize stuff for libxbps.
|
||||
*/
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.with_debug = with_debug;
|
||||
xh.xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xh.xfpd = &xfpd;
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL) {
|
||||
xbps_error_printf("xbps-bin: failed to allocate resources.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp->debug = debug;
|
||||
xhp->xbps_transaction_cb = transaction_cb;
|
||||
xhp->xbps_transaction_err_cb = transaction_err_cb;
|
||||
xhp->xbps_fetch_cb = fetch_file_progress_cb;
|
||||
if (flags & XBPS_FLAG_VERBOSE)
|
||||
xh.xbps_unpack_cb = unpack_progress_cb_verbose;
|
||||
xhp->xbps_unpack_cb = unpack_progress_cb_verbose;
|
||||
else
|
||||
xh.xbps_unpack_cb = unpack_progress_cb;
|
||||
xh.xupd = &xupd;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xh.flags = flags;
|
||||
xh.conffile = conffile;
|
||||
xh.install_reason_manual = install_manual;
|
||||
xh.install_reason_auto = install_auto;
|
||||
xhp->xbps_unpack_cb = unpack_progress_cb;
|
||||
xhp->rootdir = rootdir;
|
||||
xhp->cachedir = cachedir;
|
||||
xhp->flags = flags;
|
||||
xhp->conffile = conffile;
|
||||
xhp->install_reason_manual = install_manual;
|
||||
xhp->install_reason_auto = install_auto;
|
||||
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
if ((rv = xbps_init(xhp)) != 0) {
|
||||
xbps_error_printf("xbps-bin: couldn't initialize library: %s\n",
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists packages currently registered in database. */
|
||||
@@ -337,10 +335,10 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = xbps_install_new_pkg(argv[i])) != 0)
|
||||
if ((rv = install_new_pkg(argv[i])) != 0)
|
||||
goto out;
|
||||
|
||||
rv = xbps_exec_transaction(yes, show_download_pkglist_url);
|
||||
rv = exec_transaction(yes, show_download_pkglist_url);
|
||||
|
||||
} else if (strcasecmp(argv[0], "update") == 0) {
|
||||
/* Update an installed package. */
|
||||
@@ -348,17 +346,17 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = xbps_update_pkg(argv[i])) != 0)
|
||||
if ((rv = update_pkg(argv[i])) != 0)
|
||||
goto out;
|
||||
|
||||
rv = xbps_exec_transaction(yes, show_download_pkglist_url);
|
||||
rv = exec_transaction(yes, show_download_pkglist_url);
|
||||
|
||||
} else if (strcasecmp(argv[0], "remove") == 0) {
|
||||
/* Removes a binary package. */
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
rv = xbps_remove_installed_pkgs(argc, argv, yes, purge,
|
||||
rv = remove_installed_pkgs(argc, argv, yes, purge,
|
||||
force_rm_with_deps, recursive_rm);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
@@ -389,9 +387,9 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = xbps_check_pkg_integrity_all();
|
||||
rv = check_pkg_integrity_all();
|
||||
else
|
||||
rv = xbps_check_pkg_integrity(argv[1]);
|
||||
rv = check_pkg_integrity(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "autoupdate") == 0) {
|
||||
/*
|
||||
@@ -400,7 +398,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
rv = xbps_autoupdate_pkgs(yes, show_download_pkglist_url);
|
||||
rv = autoupdate_pkgs(yes, show_download_pkglist_url);
|
||||
|
||||
} else if (strcasecmp(argv[0], "show-orphans") == 0) {
|
||||
/*
|
||||
@@ -421,7 +419,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
rv = xbps_autoremove_pkgs(yes, purge);
|
||||
rv = autoremove_pkgs(yes, purge);
|
||||
|
||||
} else if (strcasecmp(argv[0], "purge") == 0) {
|
||||
/*
|
||||
@@ -454,7 +452,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
rv = xbps_show_pkg_deps(argv[1]);
|
||||
rv = show_pkg_deps(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "list-manual") == 0) {
|
||||
/*
|
||||
@@ -474,7 +472,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
rv = xbps_show_pkg_reverse_deps(argv[1]);
|
||||
rv = show_pkg_reverse_deps(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "find-files") == 0) {
|
||||
/*
|
||||
@@ -491,6 +489,6 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end();
|
||||
xbps_end(xhp);
|
||||
exit(rv);
|
||||
}
|
||||
|
@@ -84,7 +84,7 @@ question(bool preset, const char *fmt, va_list ap)
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_yesno(const char *fmt, ...)
|
||||
yesno(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
bool res;
|
||||
@@ -97,7 +97,7 @@ xbps_yesno(const char *fmt, ...)
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_noyes(const char *fmt, ...)
|
||||
noyes(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
bool res;
|
||||
|
@@ -61,7 +61,7 @@ pkg_remove_and_purge(const char *pkgname, const char *version, bool purge)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_autoremove_pkgs(bool yes, bool purge)
|
||||
autoremove_pkgs(bool yes, bool purge)
|
||||
{
|
||||
prop_array_t orphans = NULL;
|
||||
prop_object_t obj = NULL;
|
||||
@@ -98,7 +98,7 @@ xbps_autoremove_pkgs(bool yes, bool purge)
|
||||
prop_object_iterator_reset(iter);
|
||||
printf("\n\n");
|
||||
|
||||
if (!yes && !xbps_noyes("Do you want to continue?")) {
|
||||
if (!yes && !noyes("Do you want to continue?")) {
|
||||
printf("Cancelled!\n");
|
||||
goto out;
|
||||
}
|
||||
@@ -120,12 +120,8 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_remove_installed_pkgs(int argc,
|
||||
char **argv,
|
||||
bool yes,
|
||||
bool purge,
|
||||
bool force_rm_with_deps,
|
||||
bool recursive_rm)
|
||||
remove_installed_pkgs(int argc, char **argv, bool yes, bool purge,
|
||||
bool force_rm_with_deps, bool recursive_rm)
|
||||
{
|
||||
prop_array_t sorted_pkgs, orphans, reqby, orphans_user = NULL;
|
||||
prop_dictionary_t dict;
|
||||
@@ -219,7 +215,7 @@ xbps_remove_installed_pkgs(int argc,
|
||||
prop_array_count(sorted_pkgs) == 1 ? "" : "s",
|
||||
purge ? " and purged" : "");
|
||||
|
||||
if (!yes && !xbps_noyes("Do you want to continue?")) {
|
||||
if (!yes && !noyes("Do you want to continue?")) {
|
||||
printf("Cancelling!\n");
|
||||
prop_object_release(sorted_pkgs);
|
||||
return 0;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "../xbps-repo/defs.h"
|
||||
|
||||
int
|
||||
xbps_show_pkg_deps(const char *pkgname)
|
||||
show_pkg_deps(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t propsd;
|
||||
int rv = 0;
|
||||
@@ -60,7 +60,7 @@ xbps_show_pkg_deps(const char *pkgname)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_show_pkg_reverse_deps(const char *pkgname)
|
||||
show_pkg_reverse_deps(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
int rv = 0;
|
||||
|
@@ -31,7 +31,7 @@
|
||||
#endif
|
||||
|
||||
/* From index.c */
|
||||
int xbps_repo_genindex(const char *);
|
||||
int repo_genindex(const char *);
|
||||
/* From repository.c */
|
||||
int show_pkg_info_from_repolist(const char *);
|
||||
int show_pkg_deps_from_repolist(const char *);
|
||||
|
@@ -316,7 +316,7 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_repo_genindex(const char *pkgdir)
|
||||
repo_genindex(const char *pkgdir)
|
||||
{
|
||||
prop_dictionary_t idxdict = NULL;
|
||||
struct dirent *dp;
|
||||
|
@@ -41,7 +41,9 @@
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
{
|
||||
xbps_end();
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
|
||||
xbps_end(xhp);
|
||||
fprintf(stderr,
|
||||
"Usage: xbps-repo [options] [action] [arguments]\n"
|
||||
"See xbps-repo(8) for more information.\n");
|
||||
@@ -85,8 +87,7 @@ repo_search_pkgs_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *rootdir, *cachedir, *conffile;
|
||||
int c, rv = 0;
|
||||
@@ -127,15 +128,18 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize XBPS subsystems.
|
||||
*/
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.with_debug = debug;
|
||||
xh.xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xh.xfpd = &xfpd;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xh.conffile = conffile;
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL) {
|
||||
xbps_error_printf("xbps-repo: failed to allocate resources.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp->debug = debug;
|
||||
xhp->xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xhp->rootdir = rootdir;
|
||||
xhp->cachedir = cachedir;
|
||||
xhp->conffile = conffile;
|
||||
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
if ((rv = xbps_init(xhp)) != 0) {
|
||||
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -224,7 +228,7 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
rv = xbps_repo_genindex(argv[1]);
|
||||
rv = repo_genindex(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "sync") == 0) {
|
||||
/* Syncs the pkg index for all registered remote repos */
|
||||
@@ -238,6 +242,6 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end();
|
||||
xbps_end(xhp);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ write_plist_file(prop_dictionary_t dict, const char *file)
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
{
|
||||
xbps_end();
|
||||
xbps_end(xbps_handle_get());
|
||||
|
||||
fprintf(stderr,
|
||||
"usage: xbps-uhelper [options] [action] [args]\n"
|
||||
@@ -109,8 +109,7 @@ usage(void)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct xbps_handle xh;
|
||||
struct xbps_fetch_progress_data xfpd;
|
||||
struct xbps_handle *xhp;
|
||||
prop_dictionary_t dict;
|
||||
const char *version, *rootdir = NULL, *conffile = NULL;
|
||||
char *plist, *pkgname, *pkgver, *in_chroot_env, *hash;
|
||||
@@ -147,14 +146,17 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize the callbacks and debug in libxbps.
|
||||
*/
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.with_debug = debug;
|
||||
xh.xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xh.xfpd = &xfpd;
|
||||
xh.rootdir = rootdir;
|
||||
xh.conffile = conffile;
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL) {
|
||||
xbps_error_printf("xbps-uhelper: failed to allocate resources\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp->debug = debug;
|
||||
xhp->xbps_fetch_cb = fetch_file_progress_cb;
|
||||
xhp->rootdir = rootdir;
|
||||
xhp->conffile = conffile;
|
||||
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
if ((rv = xbps_init(xhp)) != 0) {
|
||||
xbps_error_printf("xbps-uhelper: failed to "
|
||||
"initialize libxbps.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
@@ -163,7 +165,7 @@ main(int argc, char **argv)
|
||||
plist = xbps_xasprintf("%s/%s/%s", rootdir,
|
||||
XBPS_META_PATH, XBPS_REGPKGDB);
|
||||
if (plist == NULL) {
|
||||
xbps_end();
|
||||
xbps_end(xhp);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -372,7 +374,7 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
}
|
||||
|
||||
xbps_end();
|
||||
xbps_end(xhp);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
Reference in New Issue
Block a user