summaryrefslogtreecommitdiff
path: root/src/pacman/sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r--src/pacman/sync.c112
1 files changed, 53 insertions, 59 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index c56934b6..5fb8c346 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -47,7 +47,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) {
dir = opendir(dbpath);
if(dir == NULL) {
pm_fprintf(stderr, PM_LOG_ERROR, _("could not access database directory\n"));
- return(1);
+ return 1;
}
syncdbs = alpm_option_get_syncdbs();
@@ -84,7 +84,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) {
pm_fprintf(stderr, PM_LOG_ERROR,
_("could not remove %s\n"), path);
closedir(dir);
- return(1);
+ return 1;
}
continue;
}
@@ -110,12 +110,12 @@ static int sync_cleandb(const char *dbpath, int keep_used) {
pm_fprintf(stderr, PM_LOG_ERROR,
_("could not remove %s\n"), path);
closedir(dir);
- return(1);
+ return 1;
}
}
}
closedir(dir);
- return(0);
+ return 0;
}
static int sync_cleandb_all(void) {
@@ -126,7 +126,7 @@ static int sync_cleandb_all(void) {
dbpath = alpm_option_get_dbpath();
printf(_("Database directory: %s\n"), dbpath);
if(!yesno(_("Do you want to remove unused repositories?"))) {
- return(0);
+ return 0;
}
/* The sync dbs were previously put in dbpath/ but are now in dbpath/sync/.
* We will clean everything in dbpath/ except local/, sync/ and db.lck, and
@@ -137,7 +137,7 @@ static int sync_cleandb_all(void) {
ret += sync_cleandb(newdbpath, 1);
printf(_("Database directory cleaned up\n"));
- return(ret);
+ return ret;
}
static int sync_cleancache(int level)
@@ -148,7 +148,7 @@ static int sync_cleancache(int level)
int ret = 0;
for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
- printf(_("Cache directory: %s\n"), (char*)alpm_list_getdata(i));
+ printf(_("Cache directory: %s\n"), (char *)alpm_list_getdata(i));
}
if(!config->cleanmethod) {
@@ -165,12 +165,12 @@ static int sync_cleancache(int level)
printf(_(" All current sync database packages\n"));
}
if(!yesno(_("Do you want to remove all other packages from cache?"))) {
- return(0);
+ return 0;
}
printf(_("removing old packages from cache...\n"));
} else {
if(!noyes(_("Do you want to remove ALL files from cache?"))) {
- return(0);
+ return 0;
}
printf(_("removing all files from cache...\n"));
}
@@ -211,7 +211,8 @@ static int sync_cleancache(int level)
/* attempt to load the package, prompt removal on failures as we may have
* files here that aren't valid packages. we also don't need a full
* load of the package, just the metadata. */
- if(alpm_pkg_load(path, 0, &localpkg) != 0 || localpkg == NULL) {
+ if(alpm_pkg_load(path, 0, PM_PGP_VERIFY_NEVER, &localpkg) != 0
+ || localpkg == NULL) {
if(yesno(_("File %s does not seem to be a valid package, remove it?"), path)) {
if(localpkg) {
alpm_pkg_free(localpkg);
@@ -258,7 +259,7 @@ static int sync_cleancache(int level)
closedir(dir);
}
- return(ret);
+ return ret;
}
static int sync_synctree(int level, alpm_list_t *syncs)
@@ -267,7 +268,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
int success = 0, ret;
if(trans_init(0) == -1) {
- return(0);
+ return 0;
}
for(i = syncs; i; i = alpm_list_next(i)) {
@@ -286,7 +287,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
}
if(trans_release() == -1) {
- return(0);
+ return 0;
}
/* 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
@@ -295,7 +296,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
if(!success) {
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to synchronize any databases\n"));
}
- return(success > 0);
+ return (success > 0);
}
static void print_installed(pmdb_t *db_local, pmpkg_t *pkg)
@@ -340,22 +341,14 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(j);
- if (!config->quiet) {
+ if(!config->quiet) {
printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg));
} else {
printf("%s", alpm_pkg_get_name(pkg));
}
- /* print the package size with the output if ShowSize option set */
- if(!config->quiet && config->showsize) {
- /* Convert byte size to MB */
- double mbsize = (double)alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
-
- printf(" [%.2f MB]", mbsize);
- }
-
- if (!config->quiet) {
+ if(!config->quiet) {
if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
alpm_list_t *k;
printf(" (");
@@ -384,7 +377,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
}
}
- return(!found);
+ return !found;
}
static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
@@ -432,7 +425,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
}
}
- return(0);
+ return 0;
}
static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
@@ -466,14 +459,14 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
if(!db) {
pm_fprintf(stderr, PM_LOG_ERROR,
_("repository '%s' does not exist\n"), repo);
- return(1);
+ return 1;
}
for(k = alpm_db_get_pkgcache(db); k; k = alpm_list_next(k)) {
pmpkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
- dump_pkg_sync(pkg, alpm_db_get_name(db), config->op_s_info);
+ dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1);
foundpkg = 1;
break;
}
@@ -494,7 +487,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
pmpkg_t *pkg = alpm_list_getdata(k);
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
- dump_pkg_sync(pkg, alpm_db_get_name(db), config->op_s_info);
+ dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1);
foundpkg = 1;
break;
}
@@ -512,12 +505,13 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
pmdb_t *db = alpm_list_getdata(i);
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
- dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db), config->op_s_info);
+ pmpkg_t *pkg = alpm_list_getdata(j);
+ dump_pkg_full(pkg, PKG_FROM_SYNCDB, config->op_s_info > 1);
}
}
}
- return(ret);
+ return ret;
}
static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
@@ -543,7 +537,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
pm_fprintf(stderr, PM_LOG_ERROR,
_("repository \"%s\" was not found.\n"),repo);
alpm_list_free(ls);
- return(1);
+ return 1;
}
ls = alpm_list_add(ls, db);
@@ -558,7 +552,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
pmpkg_t *pkg = alpm_list_getdata(j);
- if (!config->quiet) {
+ if(!config->quiet) {
printf("%s %s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg));
print_installed(db_local, pkg);
@@ -573,7 +567,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
alpm_list_free(ls);
}
- return(0);
+ return 0;
}
static alpm_list_t *syncfirst(void) {
@@ -592,7 +586,7 @@ static alpm_list_t *syncfirst(void) {
}
}
- return(res);
+ return res;
}
static pmdb_t *get_db(const char *dbname)
@@ -601,10 +595,10 @@ static pmdb_t *get_db(const char *dbname)
for(i = alpm_option_get_syncdbs(); i; i = i->next) {
pmdb_t *db = i->data;
if(strcmp(alpm_db_get_name(db), dbname) == 0) {
- return(db);
+ return db;
}
}
- return(NULL);
+ return NULL;
}
static int process_pkg(pmpkg_t *pkg)
@@ -616,14 +610,14 @@ static int process_pkg(pmpkg_t *pkg)
|| pm_errno == PM_ERR_PKG_IGNORED) {
/* just skip duplicate or ignored targets */
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));
- return(0);
+ return 0;
} else {
pm_fprintf(stderr, PM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),
alpm_strerrorlast());
- return(1);
+ return 1;
}
}
- return(0);
+ return 0;
}
static int process_group(alpm_list_t *dbs, char *group)
@@ -635,7 +629,7 @@ static int process_group(alpm_list_t *dbs, char *group)
if(!count) {
pm_fprintf(stderr, PM_LOG_ERROR, _("target not found: %s\n"), group);
- return(1);
+ return 1;
}
@@ -669,7 +663,7 @@ static int process_group(alpm_list_t *dbs, char *group)
}
cleanup:
alpm_list_free(pkgs);
- return(ret);
+ return ret;
}
static int process_targname(alpm_list_t *dblist, char *targname)
@@ -680,14 +674,14 @@ static int process_targname(alpm_list_t *dblist, char *targname)
if(pm_errno == PM_ERR_PKG_IGNORED) {
pm_printf(PM_LOG_WARNING, _("skipping target: %s\n"), targname);
pm_errno = 0;
- return(0);
+ return 0;
}
if(pkg) {
- return(process_pkg(pkg));
+ return process_pkg(pkg);
}
/* fallback on group */
- return(process_group(dblist, targname));
+ return process_group(dblist, targname);
}
static int process_target(char *target)
@@ -722,7 +716,7 @@ static int process_target(char *target)
}
cleanup:
free(targstring);
- return(ret);
+ return ret;
}
static int sync_trans(alpm_list_t *targets)
@@ -734,7 +728,7 @@ static int sync_trans(alpm_list_t *targets)
/* Step 1: create a new transaction... */
if(trans_init(config->flags) == -1) {
- return(1);
+ return 1;
}
/* process targets */
@@ -874,7 +868,7 @@ cleanup:
retval = 1;
}
- return(retval);
+ return retval;
}
int pacman_sync(alpm_list_t *targets)
@@ -886,7 +880,7 @@ int pacman_sync(alpm_list_t *targets)
int ret = 0;
if(trans_init(0) == -1) {
- return(1);
+ return 1;
}
ret += sync_cleancache(config->op_s_clean);
@@ -897,14 +891,14 @@ int pacman_sync(alpm_list_t *targets)
ret++;
}
- return(ret);
+ return ret;
}
/* ensure we have at least one valid sync db set up */
sync_dbs = alpm_option_get_syncdbs();
if(sync_dbs == NULL || alpm_list_count(sync_dbs) == 0) {
pm_printf(PM_LOG_ERROR, _("no usable package repositories configured.\n"));
- return(1);
+ return 1;
}
if(config->op_s_sync) {
@@ -912,40 +906,40 @@ int pacman_sync(alpm_list_t *targets)
printf(_(":: Synchronizing package databases...\n"));
alpm_logaction("synchronizing package lists\n");
if(!sync_synctree(config->op_s_sync, sync_dbs)) {
- return(1);
+ return 1;
}
}
/* search for a package */
if(config->op_s_search) {
- return(sync_search(sync_dbs, targets));
+ return sync_search(sync_dbs, targets);
}
/* look for groups */
if(config->group) {
- return(sync_group(config->group, sync_dbs, targets));
+ return sync_group(config->group, sync_dbs, targets);
}
/* get package info */
if(config->op_s_info) {
- return(sync_info(sync_dbs, targets));
+ return sync_info(sync_dbs, targets);
}
/* get a listing of files in sync DBs */
if(config->op_q_list) {
- return(sync_list(sync_dbs, targets));
+ return sync_list(sync_dbs, targets);
}
if(targets == NULL) {
if(config->op_s_upgrade) {
/* proceed */
} else if(config->op_s_sync) {
- return(0);
+ return 0;
} else {
/* don't proceed here unless we have an operation that doesn't require a
* target list */
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
- return(1);
+ return 1;
}
}
@@ -980,7 +974,7 @@ int pacman_sync(alpm_list_t *targets)
int ret = sync_trans(targs);
FREELIST(targs);
- return(ret);
+ return ret;
}
/* vim: set ts=2 sw=2 noet: */