mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 20:05:07 -05:00
pacman: move database syncing to util.c
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
b0dac754d2
commit
e49abc9860
@ -305,37 +305,6 @@ static int sync_cleancache(int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sync_synctree(int level, alpm_list_t *syncs)
|
|
||||||
{
|
|
||||||
alpm_list_t *i;
|
|
||||||
unsigned int success = 0;
|
|
||||||
|
|
||||||
for(i = syncs; i; i = alpm_list_next(i)) {
|
|
||||||
alpm_db_t *db = i->data;
|
|
||||||
|
|
||||||
int ret = alpm_db_update((level < 2 ? 0 : 1), db);
|
|
||||||
if(ret < 0) {
|
|
||||||
pm_printf(ALPM_LOG_ERROR, _("failed to update %s (%s)\n"),
|
|
||||||
alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));
|
|
||||||
} else if(ret == 1) {
|
|
||||||
printf(_(" %s is up to date\n"), alpm_db_get_name(db));
|
|
||||||
success++;
|
|
||||||
} else {
|
|
||||||
success++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We should always succeed if at least one DB was upgraded - we may possibly
|
|
||||||
* fail later with unresolved deps, but that should be rare, and would be
|
|
||||||
* expected
|
|
||||||
*/
|
|
||||||
if(!success) {
|
|
||||||
pm_printf(ALPM_LOG_ERROR, _("failed to synchronize any databases\n"));
|
|
||||||
trans_init_error();
|
|
||||||
}
|
|
||||||
return (success > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* search the sync dbs for a matching package */
|
/* search the sync dbs for a matching package */
|
||||||
static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
|
static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
|
||||||
{
|
{
|
||||||
@ -903,7 +872,7 @@ int pacman_sync(alpm_list_t *targets)
|
|||||||
colon_printf(_("Synchronizing package databases...\n"));
|
colon_printf(_("Synchronizing package databases...\n"));
|
||||||
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
||||||
"synchronizing package lists\n");
|
"synchronizing package lists\n");
|
||||||
if(!sync_synctree(config->op_s_sync, sync_dbs)) {
|
if(!sync_syncdbs(config->op_s_sync, sync_dbs)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,37 @@ int check_syncdbs(size_t need_repos, int check_valid)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sync_syncdbs(int level, alpm_list_t *syncs)
|
||||||
|
{
|
||||||
|
alpm_list_t *i;
|
||||||
|
unsigned int success = 0;
|
||||||
|
|
||||||
|
for(i = syncs; i; i = alpm_list_next(i)) {
|
||||||
|
alpm_db_t *db = i->data;
|
||||||
|
|
||||||
|
int ret = alpm_db_update((level < 2 ? 0 : 1), db);
|
||||||
|
if(ret < 0) {
|
||||||
|
pm_printf(ALPM_LOG_ERROR, _("failed to update %s (%s)\n"),
|
||||||
|
alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));
|
||||||
|
} else if(ret == 1) {
|
||||||
|
printf(_(" %s is up to date\n"), alpm_db_get_name(db));
|
||||||
|
success++;
|
||||||
|
} else {
|
||||||
|
success++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We should always succeed if at least one DB was upgraded - we may possibly
|
||||||
|
* fail later with unresolved deps, but that should be rare, and would be
|
||||||
|
* expected
|
||||||
|
*/
|
||||||
|
if(!success) {
|
||||||
|
pm_printf(ALPM_LOG_ERROR, _("failed to synchronize any databases\n"));
|
||||||
|
trans_init_error();
|
||||||
|
}
|
||||||
|
return (success > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* discard unhandled input on the terminal's input buffer */
|
/* discard unhandled input on the terminal's input buffer */
|
||||||
static int flush_term_input(int fd)
|
static int flush_term_input(int fd)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ int trans_init(alpm_transflag_t flags, int check_valid);
|
|||||||
int trans_release(void);
|
int trans_release(void);
|
||||||
int needs_root(void);
|
int needs_root(void);
|
||||||
int check_syncdbs(size_t need_repos, int check_valid);
|
int check_syncdbs(size_t need_repos, int check_valid);
|
||||||
|
int sync_syncdbs(int level, alpm_list_t *syncs);
|
||||||
unsigned short getcols(void);
|
unsigned short getcols(void);
|
||||||
void columns_cache_reset(void);
|
void columns_cache_reset(void);
|
||||||
int rmrf(const char *path);
|
int rmrf(const char *path);
|
||||||
|
Loading…
Reference in New Issue
Block a user