Merge branch 'maint'

Conflicts:
	src/pacman/package.c

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-10-21 19:29:47 -05:00
commit 90ddcbe71d
11 changed files with 56 additions and 66 deletions

View File

@ -93,7 +93,7 @@ pkg_dest="${PKGDEST:-$PWD}"
pkg_pkger=${PACKAGER:-'Unknown Packager'} pkg_pkger=${PACKAGER:-'Unknown Packager'}
pkg_name="$1" pkg_name="$1"
pkg_dir=("$pac_db/$pkg_name"-+([^-])-+([0-9])) pkg_dir=("$pac_db/$pkg_name"-+([^-])-+([^-]))
pkg_namver=("${pkg_dir[@]##*/}") pkg_namver=("${pkg_dir[@]##*/}")
# #

View File

@ -797,8 +797,8 @@ int _alpm_process_siglist(alpm_handle_t *handle, const char *identifier,
fetch_key.fingerprint, fetch_key.uid); fetch_key.fingerprint, fetch_key.uid);
} }
} else { } else {
_alpm_log(handle, ALPM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_ERROR,
"key could not be looked up remotely\n"); _("key \"%s\" could not be looked up remotely\n"), name);
} }
gpgme_key_unref(fetch_key.data); gpgme_key_unref(fetch_key.data);
} }

View File

@ -166,6 +166,7 @@ initialize() {
add_gpg_conf_option "$conffile" 'lock-never' add_gpg_conf_option "$conffile" 'lock-never'
keyserv=${KEYSERVER:-$DEFAULT_KEYSERVER} keyserv=${KEYSERVER:-$DEFAULT_KEYSERVER}
add_gpg_conf_option "$conffile" 'keyserver' "$keyserv" add_gpg_conf_option "$conffile" 'keyserver' "$keyserv"
add_gpg_conf_option "$conffile" 'keyserver-options' 'timeout=10'
# set up a private signing key (if none available) # set up a private signing key (if none available)
if [[ $(secret_keys_available) -lt 1 ]]; then if [[ $(secret_keys_available) -lt 1 ]]; then

View File

@ -45,7 +45,7 @@ config_t *config_new(void)
{ {
config_t *newconfig = calloc(1, sizeof(config_t)); config_t *newconfig = calloc(1, sizeof(config_t));
if(!newconfig) { if(!newconfig) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("malloc failure: could not allocate %zd bytes\n"), _("malloc failure: could not allocate %zd bytes\n"),
sizeof(config_t)); sizeof(config_t));
return NULL; return NULL;

View File

@ -187,7 +187,7 @@ static const char *get_backup_file_status(const char *root,
char *md5sum = alpm_compute_md5sum(path); char *md5sum = alpm_compute_md5sum(path);
if(md5sum == NULL) { if(md5sum == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("could not calculate checksums for %s\n"), path); _("could not calculate checksums for %s\n"), path);
return NULL; return NULL;
} }
@ -274,7 +274,7 @@ void dump_pkg_changelog(alpm_pkg_t *pkg)
void *fp = NULL; void *fp = NULL;
if((fp = alpm_pkg_changelog_open(pkg)) == NULL) { if((fp = alpm_pkg_changelog_open(pkg)) == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("no changelog available for '%s'.\n"), pm_printf(ALPM_LOG_ERROR, _("no changelog available for '%s'.\n"),
alpm_pkg_get_name(pkg)); alpm_pkg_get_name(pkg));
return; return;
} else { } else {

View File

@ -118,7 +118,7 @@ static int query_fileowner(alpm_list_t *targets)
/* This code is here for safety only */ /* This code is here for safety only */
if(targets == NULL) { if(targets == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("no file was specified for --owns\n")); pm_printf(ALPM_LOG_ERROR, _("no file was specified for --owns\n"));
return 1; return 1;
} }
@ -129,7 +129,7 @@ static int query_fileowner(alpm_list_t *targets)
rootlen = strlen(root); rootlen = strlen(root);
if(rootlen + 1 > PATH_MAX) { if(rootlen + 1 > PATH_MAX) {
/* we are in trouble here */ /* we are in trouble here */
pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, ""); pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, "");
return 1; return 1;
} }
strcpy(path, root); strcpy(path, root);
@ -149,14 +149,14 @@ static int query_fileowner(alpm_list_t *targets)
/* if it is not a path but a program name, then check in PATH */ /* if it is not a path but a program name, then check in PATH */
if(strchr(filename, '/') == NULL) { if(strchr(filename, '/') == NULL) {
if(search_path(&filename, &buf) == -1) { if(search_path(&filename, &buf) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"), pm_printf(ALPM_LOG_ERROR, _("failed to find '%s' in PATH: %s\n"),
filename, strerror(errno)); filename, strerror(errno));
ret++; ret++;
free(filename); free(filename);
continue; continue;
} }
} else { } else {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to read file '%s': %s\n"), pm_printf(ALPM_LOG_ERROR, _("failed to read file '%s': %s\n"),
filename, strerror(errno)); filename, strerror(errno));
ret++; ret++;
free(filename); free(filename);
@ -165,7 +165,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
if(S_ISDIR(buf.st_mode)) { if(S_ISDIR(buf.st_mode)) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("cannot determine ownership of directory '%s'\n"), filename); _("cannot determine ownership of directory '%s'\n"), filename);
ret++; ret++;
free(filename); free(filename);
@ -181,7 +181,7 @@ static int query_fileowner(alpm_list_t *targets)
rpath = resolve_path(dname); rpath = resolve_path(dname);
if(!rpath) { if(!rpath) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"), pm_printf(ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s\n"),
filename, strerror(errno)); filename, strerror(errno));
free(filename); free(filename);
free(dname); free(dname);
@ -215,7 +215,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
if(rootlen + 1 + strlen(pkgfile) > PATH_MAX) { if(rootlen + 1 + strlen(pkgfile) > PATH_MAX) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, pkgfile); pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, pkgfile);
} }
/* concatenate our file and the root path */ /* concatenate our file and the root path */
strcpy(path + rootlen, pkgfile); strcpy(path + rootlen, pkgfile);
@ -232,7 +232,7 @@ static int query_fileowner(alpm_list_t *targets)
} }
} }
if(!found) { if(!found) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("No package owns %s\n"), filename); pm_printf(ALPM_LOG_ERROR, _("No package owns %s\n"), filename);
ret++; ret++;
} }
free(filename); free(filename);
@ -334,7 +334,7 @@ static int query_group(alpm_list_t *targets)
} }
} }
} else { } else {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname); pm_printf(ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname);
ret++; ret++;
} }
} }
@ -416,7 +416,7 @@ static int check(alpm_pkg_t *pkg)
rootlen = strlen(root); rootlen = strlen(root);
if(rootlen + 1 > PATH_MAX) { if(rootlen + 1 > PATH_MAX) {
/* we are in trouble here */ /* we are in trouble here */
pm_fprintf(stderr, ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, ""); pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s\n"), root, "");
return 1; return 1;
} }
strcpy(f, root); strcpy(f, root);
@ -429,7 +429,7 @@ static int check(alpm_pkg_t *pkg)
const char *path = file->name; const char *path = file->name;
if(rootlen + 1 + strlen(path) > PATH_MAX) { if(rootlen + 1 + strlen(path) > PATH_MAX) {
pm_fprintf(stderr, ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path); pm_printf(ALPM_LOG_WARNING, _("path too long: %s%s\n"), root, path);
continue; continue;
} }
strcpy(f + rootlen, path); strcpy(f + rootlen, path);
@ -563,16 +563,16 @@ int pacman_query(alpm_list_t *targets)
if(pkg == NULL) { if(pkg == NULL) {
switch(alpm_errno(config->handle)) { switch(alpm_errno(config->handle)) {
case ALPM_ERR_PKG_NOT_FOUND: case ALPM_ERR_PKG_NOT_FOUND:
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("package '%s' was not found\n"), strname); _("package '%s' was not found\n"), strname);
if(!config->op_q_isfile && access(strname, R_OK) == 0) { if(!config->op_q_isfile && access(strname, R_OK) == 0) {
pm_fprintf(stderr, ALPM_LOG_WARNING, pm_printf(ALPM_LOG_WARNING,
_("'%s' is a file, you might want to use %s.\n"), _("'%s' is a file, you might want to use %s.\n"),
strname, "-p/--file"); strname, "-p/--file");
} }
break; break;
default: default:
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("could not load package '%s': %s\n"), strname, _("could not load package '%s': %s\n"), strname,
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
break; break;

View File

@ -39,7 +39,7 @@ static int remove_target(const char *target)
if((pkg = alpm_db_get_pkg(db_local, target)) != NULL) { if((pkg = alpm_db_get_pkg(db_local, target)) != NULL) {
if(alpm_remove_pkg(config->handle, pkg) == -1) { if(alpm_remove_pkg(config->handle, pkg) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target, pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target,
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
return -1; return -1;
} }
@ -50,13 +50,13 @@ static int remove_target(const char *target)
/* fallback to group */ /* fallback to group */
alpm_group_t *grp = alpm_db_readgroup(db_local, target); alpm_group_t *grp = alpm_db_readgroup(db_local, target);
if(grp == NULL) { if(grp == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': target not found\n", target); pm_printf(ALPM_LOG_ERROR, "'%s': target not found\n", target);
return -1; return -1;
} }
for(p = grp->packages; p; p = alpm_list_next(p)) { for(p = grp->packages; p; p = alpm_list_next(p)) {
pkg = p->data; pkg = p->data;
if(alpm_remove_pkg(config->handle, pkg) == -1) { if(alpm_remove_pkg(config->handle, pkg) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", target, pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", target,
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
return -1; return -1;
} }
@ -105,7 +105,7 @@ int pacman_remove(alpm_list_t *targets)
/* Step 2: prepare the transaction based on its type, targets and flags */ /* Step 2: prepare the transaction based on its type, targets and flags */
if(alpm_trans_prepare(config->handle, &data) == -1) { if(alpm_trans_prepare(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case ALPM_ERR_PKG_INVALID_ARCH: case ALPM_ERR_PKG_INVALID_ARCH:
@ -166,7 +166,7 @@ int pacman_remove(alpm_list_t *targets)
} }
if(alpm_trans_commit(config->handle, &data) == -1) { if(alpm_trans_commit(config->handle, &data) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
retval = 1; retval = 1;
} }

View File

@ -47,7 +47,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
dir = opendir(dbpath); dir = opendir(dbpath);
if(dir == NULL) { if(dir == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("could not access database directory\n")); pm_printf(ALPM_LOG_ERROR, _("could not access database directory\n"));
return 1; return 1;
} }
@ -82,7 +82,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
len = strlen(path); len = strlen(path);
if(S_ISDIR(buf.st_mode) || strcmp(path + len - 3, ".db") != 0) { if(S_ISDIR(buf.st_mode) || strcmp(path + len - 3, ".db") != 0) {
if(rmrf(path)) { if(rmrf(path)) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("could not remove %s\n"), path); _("could not remove %s\n"), path);
closedir(dir); closedir(dir);
return 1; return 1;
@ -108,7 +108,7 @@ static int sync_cleandb(const char *dbpath, int keep_used)
} }
if(rmrf(path)) { if(rmrf(path)) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("could not remove %s\n"), path); _("could not remove %s\n"), path);
closedir(dir); closedir(dir);
return 1; return 1;
@ -188,7 +188,7 @@ static int sync_cleancache(int level)
struct dirent *ent; struct dirent *ent;
if(dir == NULL) { if(dir == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("could not access cache directory %s\n"), cachedir); _("could not access cache directory %s\n"), cachedir);
ret++; ret++;
continue; continue;
@ -292,7 +292,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
ret = alpm_db_update((level < 2 ? 0 : 1), db); ret = alpm_db_update((level < 2 ? 0 : 1), db);
if(ret < 0) { if(ret < 0) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to update %s (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to update %s (%s)\n"),
alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle))); alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));
} else if(ret == 1) { } else if(ret == 1) {
printf(_(" %s is up to date\n"), alpm_db_get_name(db)); printf(_(" %s is up to date\n"), alpm_db_get_name(db));
@ -307,7 +307,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
* expected * expected
*/ */
if(!success) { if(!success) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to synchronize any databases\n")); pm_printf(ALPM_LOG_ERROR, _("failed to synchronize any databases\n"));
trans_init_error(); trans_init_error();
} }
return (success > 0); return (success > 0);
@ -482,12 +482,12 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
} }
if(!founddb) { if(!founddb) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("repository '%s' does not exist\n"), repo); _("repository '%s' does not exist\n"), repo);
ret++; ret++;
} }
if(!foundpkg) { if(!foundpkg) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("package '%s' was not found\n"), target); _("package '%s' was not found\n"), target);
ret++; ret++;
} }
@ -527,7 +527,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
} }
if(db == NULL) { if(db == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, pm_printf(ALPM_LOG_ERROR,
_("repository \"%s\" was not found.\n"),repo); _("repository \"%s\" was not found.\n"),repo);
alpm_list_free(ls); alpm_list_free(ls);
return 1; return 1;
@ -607,7 +607,7 @@ static int process_pkg(alpm_pkg_t *pkg)
pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg)); pm_printf(ALPM_LOG_WARNING, _("skipping target: %s\n"), alpm_pkg_get_name(pkg));
return 0; return 0;
} else { } else {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg), pm_printf(ALPM_LOG_ERROR, "'%s': %s\n", alpm_pkg_get_name(pkg),
alpm_strerror(err)); alpm_strerror(err));
return 1; return 1;
} }
@ -624,7 +624,7 @@ static int process_group(alpm_list_t *dbs, const char *group)
int count = alpm_list_count(pkgs); int count = alpm_list_count(pkgs);
if(!count) { if(!count) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("target not found: %s\n"), group); pm_printf(ALPM_LOG_ERROR, _("target not found: %s\n"), group);
return 1; return 1;
} }
@ -705,7 +705,7 @@ static int process_target(const char *target)
dbname = targstring; dbname = targstring;
db = get_db(dbname); db = get_db(dbname);
if(!db) { if(!db) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("database not found: %s\n"), pm_printf(ALPM_LOG_ERROR, _("database not found: %s\n"),
dbname); dbname);
ret = 1; ret = 1;
goto cleanup; goto cleanup;
@ -721,7 +721,7 @@ static int process_target(const char *target)
cleanup: cleanup:
free(targstring); free(targstring);
if(ret && access(target, R_OK) == 0) { if(ret && access(target, R_OK) == 0) {
pm_fprintf(stderr, ALPM_LOG_WARNING, pm_printf(ALPM_LOG_WARNING,
_("'%s' is a file, did you mean %s instead of %s?\n"), _("'%s' is a file, did you mean %s instead of %s?\n"),
target, "-U/--upgrade", "-S/--sync"); target, "-U/--upgrade", "-S/--sync");
} }
@ -750,7 +750,7 @@ static int sync_trans(alpm_list_t *targets)
printf(_(":: Starting full system upgrade...\n")); printf(_(":: Starting full system upgrade...\n"));
alpm_logaction(config->handle, "starting full system upgrade\n"); alpm_logaction(config->handle, "starting full system upgrade\n");
if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) { if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle))); pm_printf(ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle)));
trans_release(); trans_release();
return 1; return 1;
} }
@ -767,7 +767,7 @@ int sync_prepare_execute(void)
/* Step 2: "compute" the transaction based on targets and flags */ /* Step 2: "compute" the transaction based on targets and flags */
if(alpm_trans_prepare(config->handle, &data) == -1) { if(alpm_trans_prepare(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case ALPM_ERR_PKG_INVALID_ARCH: case ALPM_ERR_PKG_INVALID_ARCH:
@ -836,7 +836,7 @@ int sync_prepare_execute(void)
if(alpm_trans_commit(config->handle, &data) == -1) { if(alpm_trans_commit(config->handle, &data) == -1) {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
case ALPM_ERR_FILE_CONFLICTS: case ALPM_ERR_FILE_CONFLICTS:

View File

@ -55,7 +55,7 @@ int pacman_upgrade(alpm_list_t *targets)
if(strstr(i->data, "://")) { if(strstr(i->data, "://")) {
char *str = alpm_fetch_pkgurl(config->handle, i->data); char *str = alpm_fetch_pkgurl(config->handle, i->data);
if(str == NULL) { if(str == NULL) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",
(char *)i->data, alpm_strerror(alpm_errno(config->handle))); (char *)i->data, alpm_strerror(alpm_errno(config->handle)));
return 1; return 1;
} else { } else {
@ -77,13 +77,13 @@ int pacman_upgrade(alpm_list_t *targets)
alpm_pkg_t *pkg; alpm_pkg_t *pkg;
if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) { if(alpm_pkg_load(config->handle, targ, 1, level, &pkg) != 0) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle))); targ, alpm_strerror(alpm_errno(config->handle)));
trans_release(); trans_release();
return 1; return 1;
} }
if(alpm_add_pkg(config->handle, pkg) == -1) { if(alpm_add_pkg(config->handle, pkg) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, "'%s': %s\n", pm_printf(ALPM_LOG_ERROR, "'%s': %s\n",
targ, alpm_strerror(alpm_errno(config->handle))); targ, alpm_strerror(alpm_errno(config->handle)));
alpm_pkg_free(pkg); alpm_pkg_free(pkg);
trans_release(); trans_release();

View File

@ -66,7 +66,7 @@ int trans_init(alpm_transflag_t flags, int check_valid)
void trans_init_error(void) void trans_init_error(void)
{ {
enum _alpm_errno_t err = alpm_errno(config->handle); enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
if(err == ALPM_ERR_HANDLE_LOCK) { if(err == ALPM_ERR_HANDLE_LOCK) {
fprintf(stderr, _(" if you're sure a package manager is not already\n" fprintf(stderr, _(" if you're sure a package manager is not already\n"
@ -78,7 +78,7 @@ void trans_init_error(void)
int trans_release(void) int trans_release(void)
{ {
if(alpm_trans_release(config->handle) == -1) { if(alpm_trans_release(config->handle) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to release transaction (%s)\n"), pm_printf(ALPM_LOG_ERROR, _("failed to release transaction (%s)\n"),
alpm_strerror(alpm_errno(config->handle))); alpm_strerror(alpm_errno(config->handle)));
return -1; return -1;
} }
@ -631,7 +631,8 @@ int table_display(const char *title, const alpm_list_t *header,
&widths, &has_data); &widths, &has_data);
/* return -1 if terminal is not wide enough */ /* return -1 if terminal is not wide enough */
if(totalwidth > getcols()) { if(totalwidth > getcols()) {
fprintf(stderr, _("insufficient columns available for table display\n")); pm_printf(ALPM_LOG_WARNING,
_("insufficient columns available for table display\n"));
return -1; return -1;
} }
if(!totalwidth || !widths || !has_data) { if(!totalwidth || !widths || !has_data) {
@ -789,7 +790,7 @@ void signature_display(const char *title, alpm_siglist_t *siglist)
ret = pm_asprintf(&sigline, _("%s, %s from \"%s\""), ret = pm_asprintf(&sigline, _("%s, %s from \"%s\""),
status, validity, name); status, validity, name);
if(ret == -1) { if(ret == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to allocate string\n")); pm_printf(ALPM_LOG_ERROR, _("failed to allocate string\n"));
continue; continue;
} }
indentprint(sigline, len); indentprint(sigline, len);
@ -1209,14 +1210,15 @@ static int parseindex(char *s, int *val, int min, int max)
int n = strtol(s, &endptr, 10); int n = strtol(s, &endptr, 10);
if(*endptr == '\0') { if(*endptr == '\0') {
if(n < min || n > max) { if(n < min || n > max) {
fprintf(stderr, _("Invalid value: %d is not between %d and %d\n"), pm_printf(ALPM_LOG_ERROR,
_("invalid value: %d is not between %d and %d\n"),
n, min, max); n, min, max);
return -1; return -1;
} }
*val = n; *val = n;
return 0; return 0;
} else { } else {
fprintf(stderr, _("Invalid number: %s\n"), s); pm_printf(ALPM_LOG_ERROR, _("invalid number: %s\n"), s);
return -1; return -1;
} }
} }
@ -1468,20 +1470,7 @@ int pm_printf(alpm_loglevel_t level, const char *format, ...)
/* print the message using va_arg list */ /* print the message using va_arg list */
va_start(args, format); va_start(args, format);
ret = pm_vfprintf(stdout, level, format, args); ret = pm_vfprintf(stderr, level, format, args);
va_end(args);
return ret;
}
int pm_fprintf(FILE *stream, alpm_loglevel_t level, const char *format, ...)
{
int ret;
va_list args;
/* print the message using va_arg list */
va_start(args, format);
ret = pm_vfprintf(stream, level, format, args);
va_end(args); va_end(args);
return ret; return ret;
@ -1495,7 +1484,7 @@ int pm_asprintf(char **string, const char *format, ...)
/* print the message using va_arg list */ /* print the message using va_arg list */
va_start(args, format); va_start(args, format);
if(vasprintf(string, format, args) == -1) { if(vasprintf(string, format, args) == -1) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to allocate string\n")); pm_printf(ALPM_LOG_ERROR, _("failed to allocate string\n"));
ret = -1; ret = -1;
} }
va_end(args); va_end(args);

View File

@ -75,8 +75,8 @@ int select_question(int count);
int multiselect_question(char *array, int count); int multiselect_question(char *array, int count);
int yesno(char *fmt, ...); int yesno(char *fmt, ...);
int noyes(char *fmt, ...); int noyes(char *fmt, ...);
int pm_printf(alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,2,3))); int pm_printf(alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
int pm_fprintf(FILE *stream, alpm_loglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));
int pm_asprintf(char **string, const char *format, ...); int pm_asprintf(char **string, const char *format, ...);
int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0))); int pm_vfprintf(FILE *stream, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));
int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0))); int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_list args) __attribute__((format(printf,3,0)));