Share transaction callbacks for xbps-{bin,repo}, reposync cb support.

This commit is contained in:
Juan RP
2011-07-28 09:25:30 +02:00
parent d7d077a377
commit 6f783389dd
15 changed files with 199 additions and 153 deletions

View File

@@ -3,7 +3,8 @@ TOPDIR = ../..
BIN = xbps-repo
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
include $(TOPDIR)/prog.mk

View File

@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2009-2010 Juan Romero Pardines.
* Copyright (c) 2009-2011 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,12 +30,16 @@
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
#endif
#include <xbps_api.h>
/* From index.c */
int repo_genindex(const char *);
/* From repository.c */
int show_pkg_info_from_repolist(const char *);
int show_pkg_deps_from_repolist(const char *);
int repository_sync(void);
/* From find-files.c */
int repo_find_files_in_packages(const char *);

View File

@@ -135,6 +135,8 @@ main(int argc, char **argv)
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;
xhp->xfcd->cookie = &xfer;
xhp->rootdir = rootdir;

View File

@@ -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))
return 0;
printf("Synchronizing package index for `%s' ...\n", rpi->rpi_uri);
rv = xbps_repository_sync_pkg_index(rpi->rpi_uri);
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;
} else if (rv == 0) {
printf("Package index file is already up to date.\n");