Share transaction callbacks for xbps-{bin,repo}, reposync cb support.
This commit is contained in:
@ -4,7 +4,7 @@ TOPDIR = ../..
|
|||||||
BIN = xbps-bin
|
BIN = xbps-bin
|
||||||
OBJS = check.o install.o main.o remove.o show-deps.o
|
OBJS = check.o install.o main.o remove.o show-deps.o
|
||||||
OBJS += show-info-files.o util.o find-files.o
|
OBJS += show-info-files.o util.o find-files.o
|
||||||
OBJS += question.o fetch.o
|
OBJS += question.o fetch_cb.o trans_cb.o
|
||||||
MAN = $(BIN).8
|
MAN = $(BIN).8
|
||||||
|
|
||||||
include $(TOPDIR)/prog.mk
|
include $(TOPDIR)/prog.mk
|
||||||
|
@ -44,8 +44,6 @@ int update_pkg(const char *);
|
|||||||
int autoupdate_pkgs(bool, bool);
|
int autoupdate_pkgs(bool, bool);
|
||||||
int autoremove_pkgs(bool, bool);
|
int autoremove_pkgs(bool, bool);
|
||||||
int exec_transaction(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);
|
int remove_installed_pkgs(int, char **, bool, bool, bool, bool);
|
||||||
|
|
||||||
@ -68,9 +66,13 @@ int find_files_in_packages(const char *);
|
|||||||
bool yesno(const char *, ...);
|
bool yesno(const char *, ...);
|
||||||
bool noyes(const char *, ...);
|
bool noyes(const char *, ...);
|
||||||
|
|
||||||
/* from fetch.c */
|
/* from fetch_cb.c */
|
||||||
void fetch_file_progress_cb(struct xbps_fetch_cb_data *);
|
void fetch_file_progress_cb(struct xbps_fetch_cb_data *);
|
||||||
|
|
||||||
|
/* from trans_cb.c */
|
||||||
|
void transaction_cb(struct xbps_transaction_cb_data *);
|
||||||
|
void transaction_err_cb(struct xbps_transaction_cb_data *);
|
||||||
|
|
||||||
/* From util.c */
|
/* From util.c */
|
||||||
int show_pkg_files(prop_dictionary_t);
|
int show_pkg_files(prop_dictionary_t);
|
||||||
void show_pkg_info(prop_dictionary_t);
|
void show_pkg_info(prop_dictionary_t);
|
||||||
|
@ -283,87 +283,6 @@ update_pkg(const char *pkgname)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
transaction_cb(struct xbps_transaction_cb_data *xtcd)
|
|
||||||
{
|
|
||||||
if (xtcd->desc != NULL && xtcd->pkgver == NULL) {
|
|
||||||
printf("\n%s ...\n", xtcd->desc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
int
|
||||||
exec_transaction(bool yes, bool show_download_urls)
|
exec_transaction(bool yes, bool show_download_urls)
|
||||||
{
|
{
|
||||||
|
117
bin/xbps-bin/trans_cb.c
Normal file
117
bin/xbps-bin/trans_cb.c
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2011 Juan Romero Pardines.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <xbps_api.h>
|
||||||
|
#include "defs.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
transaction_cb(struct xbps_transaction_cb_data *xtcd)
|
||||||
|
{
|
||||||
|
if (xtcd->desc != NULL && xtcd->pkgver == NULL) {
|
||||||
|
printf("\n%s ...\n", xtcd->desc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (xtcd->state) {
|
||||||
|
case XBPS_TRANS_STATE_DOWNLOAD:
|
||||||
|
printf("Downloading `%s' (from %s) ...\n",
|
||||||
|
xtcd->pkgver, xtcd->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;
|
||||||
|
case XBPS_TRANS_STATE_REPOSYNC:
|
||||||
|
printf("Syncing repository pkg-index for `%s' ...\n",
|
||||||
|
xtcd->repourl);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
xbps_dbg_printf("%s: unknown transaction state %d %s\n",
|
||||||
|
xtcd->pkgver, xtcd->state, xtcd->desc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
case XBPS_TRANS_STATE_REPOSYNC:
|
||||||
|
xbps_error_printf("Failed to sync pkg-index: %s\n",
|
||||||
|
xtcd->err);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
state_descr = "unknown transaction state";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
xbps_error_printf("%s: %s: %s\n",
|
||||||
|
xtcd->pkgver, state_descr, strerror(xtcd->err));
|
||||||
|
}
|
@ -3,7 +3,8 @@ TOPDIR = ../..
|
|||||||
|
|
||||||
BIN = xbps-repo
|
BIN = xbps-repo
|
||||||
OBJS = main.o index.o repository.o find-files.o
|
OBJS = main.o index.o repository.o find-files.o
|
||||||
OBJS += ../xbps-bin/fetch.o ../xbps-bin/util.o
|
OBJS += ../xbps-bin/fetch_cb.o ../xbps-bin/util.o
|
||||||
|
OBJS += ../xbps-bin/trans_cb.o
|
||||||
MAN = $(BIN).8
|
MAN = $(BIN).8
|
||||||
|
|
||||||
include $(TOPDIR)/prog.mk
|
include $(TOPDIR)/prog.mk
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2009-2010 Juan Romero Pardines.
|
* Copyright (c) 2009-2011 Juan Romero Pardines.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -30,12 +30,16 @@
|
|||||||
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <xbps_api.h>
|
||||||
|
|
||||||
/* From index.c */
|
/* From index.c */
|
||||||
int repo_genindex(const char *);
|
int repo_genindex(const char *);
|
||||||
|
|
||||||
/* From repository.c */
|
/* From repository.c */
|
||||||
int show_pkg_info_from_repolist(const char *);
|
int show_pkg_info_from_repolist(const char *);
|
||||||
int show_pkg_deps_from_repolist(const char *);
|
int show_pkg_deps_from_repolist(const char *);
|
||||||
int repository_sync(void);
|
int repository_sync(void);
|
||||||
|
|
||||||
/* From find-files.c */
|
/* From find-files.c */
|
||||||
int repo_find_files_in_packages(const char *);
|
int repo_find_files_in_packages(const char *);
|
||||||
|
|
||||||
|
@ -135,6 +135,8 @@ main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
xhp->debug = debug;
|
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;
|
xhp->xbps_fetch_cb = fetch_file_progress_cb;
|
||||||
xhp->xfcd->cookie = &xfer;
|
xhp->xfcd->cookie = &xfer;
|
||||||
xhp->rootdir = rootdir;
|
xhp->rootdir = rootdir;
|
||||||
|
@ -148,12 +148,8 @@ repo_sync_pkg_index_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
|||||||
if (!xbps_check_is_repository_uri_remote(rpi->rpi_uri))
|
if (!xbps_check_is_repository_uri_remote(rpi->rpi_uri))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("Synchronizing package index for `%s' ...\n", rpi->rpi_uri);
|
|
||||||
rv = xbps_repository_sync_pkg_index(rpi->rpi_uri);
|
rv = xbps_repository_sync_pkg_index(rpi->rpi_uri);
|
||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
xbps_error_printf("xbps-repo: failed to sync `%s': %s%s\n",
|
|
||||||
rpi->rpi_uri, strerror(errno), xbps_fetch_error_string() ?
|
|
||||||
xbps_fetch_error_string() : "");
|
|
||||||
return rv;
|
return rv;
|
||||||
} else if (rv == 0) {
|
} else if (rv == 0) {
|
||||||
printf("Package index file is already up to date.\n");
|
printf("Package index file is already up to date.\n");
|
||||||
|
@ -2,6 +2,6 @@ TOPDIR = ../..
|
|||||||
-include $(TOPDIR)/config.mk
|
-include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
BIN = xbps-uhelper
|
BIN = xbps-uhelper
|
||||||
OBJS = main.o ../xbps-bin/fetch.o
|
OBJS = main.o ../xbps-bin/fetch_cb.o
|
||||||
|
|
||||||
include $(TOPDIR)/prog.mk
|
include $(TOPDIR)/prog.mk
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.2"
|
#define XBPS_PKGINDEX_VERSION "1.2"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20110727"
|
#define XBPS_API_VERSION "20110728"
|
||||||
#define XBPS_VERSION "0.10.0"
|
#define XBPS_VERSION "0.10.0"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,6 +168,9 @@ void xbps_warn_printf(const char *, ...);
|
|||||||
* <b>XBPS_TRANS_STATE_CONFIGURE</b>: a package is being configured.
|
* <b>XBPS_TRANS_STATE_CONFIGURE</b>: a package is being configured.
|
||||||
*
|
*
|
||||||
* <b>XBPS_TRANS_STATE_REGISTER</b>: a package is being registered.
|
* <b>XBPS_TRANS_STATE_REGISTER</b>: a package is being registered.
|
||||||
|
*
|
||||||
|
* <b>XBPS_TRANS_STATE_REPOSYNC</b>. a remote repository's
|
||||||
|
* pkg index is being synced.
|
||||||
*/
|
*/
|
||||||
typedef enum trans_state {
|
typedef enum trans_state {
|
||||||
XBPS_TRANS_STATE_UNKNOWN = 0,
|
XBPS_TRANS_STATE_UNKNOWN = 0,
|
||||||
@ -180,7 +183,8 @@ typedef enum trans_state {
|
|||||||
XBPS_TRANS_STATE_UPDATE,
|
XBPS_TRANS_STATE_UPDATE,
|
||||||
XBPS_TRANS_STATE_UNPACK,
|
XBPS_TRANS_STATE_UNPACK,
|
||||||
XBPS_TRANS_STATE_CONFIGURE,
|
XBPS_TRANS_STATE_CONFIGURE,
|
||||||
XBPS_TRANS_STATE_REGISTER
|
XBPS_TRANS_STATE_REGISTER,
|
||||||
|
XBPS_TRANS_STATE_REPOSYNC
|
||||||
} trans_state_t;
|
} trans_state_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,9 +221,9 @@ struct xbps_transaction_cb_data {
|
|||||||
/**
|
/**
|
||||||
* @var binpkg_repourl
|
* @var binpkg_repourl
|
||||||
*
|
*
|
||||||
* Binary package's repository URL (set internally, read-only).
|
* Repository URL (set internally, read-only).
|
||||||
*/
|
*/
|
||||||
const char *binpkg_repourl;
|
const char *repourl;
|
||||||
/**
|
/**
|
||||||
* @var err
|
* @var err
|
||||||
*
|
*
|
||||||
|
@ -114,7 +114,7 @@ xbps_configure_pkg(const char *pkgname,
|
|||||||
if (xhp->xbps_transaction_cb) {
|
if (xhp->xbps_transaction_cb) {
|
||||||
xhp->xtcd->desc = NULL;
|
xhp->xtcd->desc = NULL;
|
||||||
xhp->xtcd->binpkg_fname = NULL;
|
xhp->xtcd->binpkg_fname = NULL;
|
||||||
xhp->xtcd->binpkg_repourl = NULL;
|
xhp->xtcd->repourl = NULL;
|
||||||
xhp->xtcd->state = XBPS_TRANS_STATE_CONFIGURE;
|
xhp->xtcd->state = XBPS_TRANS_STATE_CONFIGURE;
|
||||||
xhp->xtcd->pkgver = pkgver;
|
xhp->xtcd->pkgver = pkgver;
|
||||||
xhp->xbps_transaction_cb(xhp->xtcd);
|
xhp->xbps_transaction_cb(xhp->xtcd);
|
||||||
|
@ -52,6 +52,22 @@ static bool repolist_initialized;
|
|||||||
(x == FETCH_ABORT) || \
|
(x == FETCH_ABORT) || \
|
||||||
(x == FETCH_TIMEOUT) || \
|
(x == FETCH_TIMEOUT) || \
|
||||||
(x == FETCH_DOWN))
|
(x == FETCH_DOWN))
|
||||||
|
static int
|
||||||
|
sync_remote_repo(const char *plist, const char *repourl)
|
||||||
|
{
|
||||||
|
/* if file is there, continue */
|
||||||
|
if (access(plist, R_OK) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* file not found, fetch it */
|
||||||
|
if (xbps_repository_sync_pkg_index(repourl) == -1) {
|
||||||
|
if (FETCH_ERROR(fetchLastErrCode))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#undef FETCH_ERROR
|
||||||
|
|
||||||
int HIDDEN
|
int HIDDEN
|
||||||
xbps_repository_pool_init(void)
|
xbps_repository_pool_init(void)
|
||||||
@ -107,43 +123,11 @@ xbps_repository_pool_init(void)
|
|||||||
rv = errno;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/*
|
if (sync_remote_repo(plist, repouri) == -1) {
|
||||||
* For remote repositories, check that its pkg-index.plist
|
nmissing++;
|
||||||
* file is there, otherwise we have to fetch it.
|
|
||||||
*/
|
|
||||||
if (xbps_check_is_repository_uri_remote(repouri)) {
|
|
||||||
if ((access(plist, R_OK) == -1) && errno == ENOENT) {
|
|
||||||
/* file not found, fetch it */
|
|
||||||
xbps_printf("Synchronizing package index for "
|
|
||||||
"`%s'...\n", repouri);
|
|
||||||
rv = xbps_repository_sync_pkg_index(repouri);
|
|
||||||
if (rv == -1) {
|
|
||||||
const char *fetcherr =
|
|
||||||
xbps_fetch_error_string();
|
|
||||||
|
|
||||||
xbps_error_printf("failed to sync "
|
|
||||||
"repository `%s': %s%s\n",
|
|
||||||
repouri,
|
|
||||||
errno ? strerror(errno) : "",
|
|
||||||
fetchLastErrCode ? fetcherr : "");
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ignore if the file cannot be
|
|
||||||
* fetched due to network, missing
|
|
||||||
* file, moved, etc.
|
|
||||||
*/
|
|
||||||
if (FETCH_ERROR(fetchLastErrCode)) {
|
|
||||||
rv = 0;
|
|
||||||
free(plist);
|
free(plist);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rv = errno;
|
|
||||||
free(plist);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
rv = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ntotal++;
|
ntotal++;
|
||||||
/*
|
/*
|
||||||
* Iterate over the repository pool and add the dictionary
|
* Iterate over the repository pool and add the dictionary
|
||||||
|
@ -97,6 +97,10 @@ xbps_repository_sync_pkg_index(const char *uri)
|
|||||||
tmp_metafile = rpidx = lrepodir = lrepofile = NULL;
|
tmp_metafile = rpidx = lrepodir = lrepofile = NULL;
|
||||||
xhp = xbps_handle_get();
|
xhp = xbps_handle_get();
|
||||||
|
|
||||||
|
/* ignore non remote repositories */
|
||||||
|
if (!xbps_check_is_repository_uri_remote(uri))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (uname(&un) == -1)
|
if (uname(&un) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -160,15 +164,28 @@ xbps_repository_sync_pkg_index(const char *uri)
|
|||||||
} else
|
} else
|
||||||
fetch_outputdir = metadir;
|
fetch_outputdir = metadir;
|
||||||
|
|
||||||
|
if (xhp->xbps_transaction_cb) {
|
||||||
|
xhp->xtcd->state = XBPS_TRANS_STATE_REPOSYNC;
|
||||||
|
xhp->xtcd->repourl = uri;
|
||||||
|
xhp->xbps_transaction_cb(xhp->xtcd);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Download pkg-index.plist file from repository.
|
* Download pkg-index.plist file from repository.
|
||||||
*/
|
*/
|
||||||
rv = xbps_fetch_file(rpidx, fetch_outputdir, true, NULL);
|
if (xbps_fetch_file(rpidx, fetch_outputdir, true, NULL) == -1) {
|
||||||
if (rv == -1) {
|
|
||||||
sverrno = errno;
|
sverrno = errno;
|
||||||
xbps_dbg_printf("%s: failed to sync: %s %s\n",
|
if (fetchLastErrCode)
|
||||||
__func__, strerror(errno), xbps_fetch_error_string());
|
rv = fetchLastErrCode;
|
||||||
(void)remove(tmp_metafile);
|
else
|
||||||
|
rv = errno;
|
||||||
|
|
||||||
|
if (xhp->xbps_transaction_err_cb) {
|
||||||
|
xhp->xtcd->state = XBPS_TRANS_STATE_REPOSYNC;
|
||||||
|
xhp->xtcd->repourl = uri;
|
||||||
|
xhp->xtcd->err = rv;
|
||||||
|
xhp->xbps_transaction_cb(xhp->xtcd);
|
||||||
|
}
|
||||||
|
rv = -1;
|
||||||
errno = sverrno;
|
errno = sverrno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ do { \
|
|||||||
xhp->xtcd->desc = d; \
|
xhp->xtcd->desc = d; \
|
||||||
xhp->xtcd->pkgver = p; \
|
xhp->xtcd->pkgver = p; \
|
||||||
xhp->xtcd->binpkg_fname = bf; \
|
xhp->xtcd->binpkg_fname = bf; \
|
||||||
xhp->xtcd->binpkg_repourl = burl; \
|
xhp->xtcd->repourl = burl; \
|
||||||
(*xhp->xbps_transaction_cb)(xhp->xtcd); \
|
(*xhp->xbps_transaction_cb)(xhp->xtcd); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
Reference in New Issue
Block a user