mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Merge branch 'maint'
Conflicts: src/pacman/util.c
This commit is contained in:
commit
ff87046354
4
NEWS
4
NEWS
@ -1,5 +1,8 @@
|
|||||||
VERSION DESCRIPTION
|
VERSION DESCRIPTION
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
4.0.1 - ensure VerbosePkgList table display supports multibyte chars
|
||||||
|
- add guidance message for users when public keyring not found
|
||||||
|
- repo-add: fix race condition around lock file removal
|
||||||
4.0.0 - well-integrated and powerful signed packages and databases
|
4.0.0 - well-integrated and powerful signed packages and databases
|
||||||
support in pacman, the library, and scripts (FS#5331)
|
support in pacman, the library, and scripts (FS#5331)
|
||||||
- over 800 commits to pacman.git since 3.5.4 release
|
- over 800 commits to pacman.git since 3.5.4 release
|
||||||
@ -44,6 +47,7 @@ VERSION DESCRIPTION
|
|||||||
- makepkg:
|
- makepkg:
|
||||||
- allow signing packages after creation
|
- allow signing packages after creation
|
||||||
- allow verifying source file signatures (FS#20448)
|
- allow verifying source file signatures (FS#20448)
|
||||||
|
- add auto-versioned libdepends/libprovides support
|
||||||
- support UPX compression of executables (FS#17213)
|
- support UPX compression of executables (FS#17213)
|
||||||
- allow usage of an alternate build directory (FS#22308)
|
- allow usage of an alternate build directory (FS#22308)
|
||||||
- cleancache option has been removed; use shell instead
|
- cleancache option has been removed; use shell instead
|
||||||
|
@ -140,6 +140,9 @@ static int init_gpgme(alpm_handle_t *handle)
|
|||||||
|| _alpm_access(handle, sigdir, "trustdb.gpg", R_OK)) {
|
|| _alpm_access(handle, sigdir, "trustdb.gpg", R_OK)) {
|
||||||
handle->pm_errno = ALPM_ERR_NOT_A_FILE;
|
handle->pm_errno = ALPM_ERR_NOT_A_FILE;
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "Signature verification will fail!\n");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "Signature verification will fail!\n");
|
||||||
|
_alpm_log(handle, ALPM_LOG_WARNING,
|
||||||
|
_("Public keyring not found; have you run '%s'?\n"),
|
||||||
|
"pacman-key --init");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calling gpgme_check_version() returns the current version and runs
|
/* calling gpgme_check_version() returns the current version and runs
|
||||||
@ -370,7 +373,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
const char *base64_sig, alpm_siglist_t *siglist)
|
const char *base64_sig, alpm_siglist_t *siglist)
|
||||||
{
|
{
|
||||||
int ret = -1, sigcount;
|
int ret = -1, sigcount;
|
||||||
gpgme_error_t err;
|
gpgme_error_t err = 0;
|
||||||
gpgme_ctx_t ctx;
|
gpgme_ctx_t ctx;
|
||||||
gpgme_data_t filedata, sigdata;
|
gpgme_data_t filedata, sigdata;
|
||||||
gpgme_verify_result_t verify_result;
|
gpgme_verify_result_t verify_result;
|
||||||
@ -394,9 +397,27 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
_alpm_access(handle, NULL, sigpath, R_OK);
|
_alpm_access(handle, NULL, sigpath, R_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* does the file we are verifying exist? */
|
||||||
|
file = fopen(path, "rb");
|
||||||
|
if(file == NULL) {
|
||||||
|
handle->pm_errno = ALPM_ERR_NOT_A_FILE;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* does the sig file exist (if we didn't get the data directly)? */
|
||||||
|
if(!base64_sig) {
|
||||||
|
sigfile = fopen(sigpath, "rb");
|
||||||
|
if(sigfile == NULL) {
|
||||||
|
_alpm_log(handle, ALPM_LOG_DEBUG, "sig path %s could not be opened\n",
|
||||||
|
sigpath);
|
||||||
|
handle->pm_errno = ALPM_ERR_SIG_MISSING;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(init_gpgme(handle)) {
|
if(init_gpgme(handle)) {
|
||||||
/* pm_errno was set in gpgme_init() */
|
/* pm_errno was set in gpgme_init() */
|
||||||
return -1;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "checking signature for %s\n", path);
|
_alpm_log(handle, ALPM_LOG_DEBUG, "checking signature for %s\n", path);
|
||||||
@ -409,11 +430,6 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
CHECK_ERR();
|
CHECK_ERR();
|
||||||
|
|
||||||
/* create our necessary data objects to verify the signature */
|
/* create our necessary data objects to verify the signature */
|
||||||
file = fopen(path, "rb");
|
|
||||||
if(file == NULL) {
|
|
||||||
handle->pm_errno = ALPM_ERR_NOT_A_FILE;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
err = gpgme_data_new_from_stream(&filedata, file);
|
err = gpgme_data_new_from_stream(&filedata, file);
|
||||||
CHECK_ERR();
|
CHECK_ERR();
|
||||||
|
|
||||||
@ -425,19 +441,12 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
&decoded_sigdata, &data_len);
|
&decoded_sigdata, &data_len);
|
||||||
if(decode_ret) {
|
if(decode_ret) {
|
||||||
handle->pm_errno = ALPM_ERR_SIG_INVALID;
|
handle->pm_errno = ALPM_ERR_SIG_INVALID;
|
||||||
goto error;
|
goto gpg_error;
|
||||||
}
|
}
|
||||||
err = gpgme_data_new_from_mem(&sigdata,
|
err = gpgme_data_new_from_mem(&sigdata,
|
||||||
(char *)decoded_sigdata, data_len, 0);
|
(char *)decoded_sigdata, data_len, 0);
|
||||||
} else {
|
} else {
|
||||||
/* file-based, it is on disk */
|
/* file-based, it is on disk */
|
||||||
sigfile = fopen(sigpath, "rb");
|
|
||||||
if(sigfile == NULL) {
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "sig path %s could not be opened\n",
|
|
||||||
sigpath);
|
|
||||||
handle->pm_errno = ALPM_ERR_SIG_MISSING;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
err = gpgme_data_new_from_stream(&sigdata, sigfile);
|
err = gpgme_data_new_from_stream(&sigdata, sigfile);
|
||||||
}
|
}
|
||||||
CHECK_ERR();
|
CHECK_ERR();
|
||||||
@ -450,14 +459,14 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
if(!verify_result || !verify_result->signatures) {
|
if(!verify_result || !verify_result->signatures) {
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "no signatures returned\n");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "no signatures returned\n");
|
||||||
handle->pm_errno = ALPM_ERR_SIG_MISSING;
|
handle->pm_errno = ALPM_ERR_SIG_MISSING;
|
||||||
goto error;
|
goto gpg_error;
|
||||||
}
|
}
|
||||||
for(gpgsig = verify_result->signatures, sigcount = 0;
|
for(gpgsig = verify_result->signatures, sigcount = 0;
|
||||||
gpgsig; gpgsig = gpgsig->next, sigcount++);
|
gpgsig; gpgsig = gpgsig->next, sigcount++);
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "%d signatures returned\n", sigcount);
|
_alpm_log(handle, ALPM_LOG_DEBUG, "%d signatures returned\n", sigcount);
|
||||||
|
|
||||||
CALLOC(siglist->results, sigcount, sizeof(alpm_sigresult_t),
|
CALLOC(siglist->results, sigcount, sizeof(alpm_sigresult_t),
|
||||||
handle->pm_errno = ALPM_ERR_MEMORY; goto error);
|
handle->pm_errno = ALPM_ERR_MEMORY; goto gpg_error);
|
||||||
siglist->count = sigcount;
|
siglist->count = sigcount;
|
||||||
|
|
||||||
for(gpgsig = verify_result->signatures, sigcount = 0; gpgsig;
|
for(gpgsig = verify_result->signatures, sigcount = 0; gpgsig;
|
||||||
@ -488,7 +497,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
err = GPG_ERR_NO_ERROR;
|
err = GPG_ERR_NO_ERROR;
|
||||||
/* we dupe the fpr in this case since we have no key to point at */
|
/* we dupe the fpr in this case since we have no key to point at */
|
||||||
STRDUP(result->key.fingerprint, gpgsig->fpr,
|
STRDUP(result->key.fingerprint, gpgsig->fpr,
|
||||||
handle->pm_errno = ALPM_ERR_MEMORY; goto error);
|
handle->pm_errno = ALPM_ERR_MEMORY; goto gpg_error);
|
||||||
} else {
|
} else {
|
||||||
CHECK_ERR();
|
CHECK_ERR();
|
||||||
if(key->uids) {
|
if(key->uids) {
|
||||||
@ -555,10 +564,12 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
error:
|
gpg_error:
|
||||||
gpgme_data_release(sigdata);
|
gpgme_data_release(sigdata);
|
||||||
gpgme_data_release(filedata);
|
gpgme_data_release(filedata);
|
||||||
gpgme_release(ctx);
|
gpgme_release(ctx);
|
||||||
|
|
||||||
|
error:
|
||||||
if(sigfile) {
|
if(sigfile) {
|
||||||
fclose(sigfile);
|
fclose(sigfile);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,9 @@ clean_up() {
|
|||||||
##
|
##
|
||||||
set -E
|
set -E
|
||||||
trap 'clean_up' 0
|
trap 'clean_up' 0
|
||||||
trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
|
for signal in TERM HUP QUIT; do
|
||||||
|
trap "trap_exit \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
|
||||||
|
done
|
||||||
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
||||||
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
||||||
|
|
||||||
|
@ -520,13 +520,19 @@ remove() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trap_exit() {
|
trap_exit() {
|
||||||
|
# unhook all traps to avoid race conditions
|
||||||
|
trap '' EXIT TERM HUP QUIT INT ERR
|
||||||
|
|
||||||
echo
|
echo
|
||||||
error "$@"
|
error "$@"
|
||||||
exit 1
|
clean_up 1
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_up() {
|
clean_up() {
|
||||||
local exit_code=$?
|
local exit_code=${1:-$?}
|
||||||
|
|
||||||
|
# unhook all traps to avoid race conditions
|
||||||
|
trap '' EXIT TERM HUP QUIT INT ERR
|
||||||
|
|
||||||
[[ -d $tmpdir ]] && rm -rf "$tmpdir"
|
[[ -d $tmpdir ]] && rm -rf "$tmpdir"
|
||||||
(( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE"
|
(( CLEAN_LOCK )) && [[ -f $LOCKFILE ]] && rm -f "$LOCKFILE"
|
||||||
@ -566,9 +572,11 @@ tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/repo-tools.XXXXXXXXXX") || (\
|
|||||||
mkdir $tmpdir/tree
|
mkdir $tmpdir/tree
|
||||||
|
|
||||||
trap 'clean_up' EXIT
|
trap 'clean_up' EXIT
|
||||||
trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
|
for signal in TERM HUP QUIT; do
|
||||||
|
trap "trap_exit \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
|
||||||
|
done
|
||||||
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
||||||
trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR
|
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
||||||
|
|
||||||
declare -a args
|
declare -a args
|
||||||
success=0
|
success=0
|
||||||
|
@ -488,34 +488,47 @@ void string_display(const char *title, const char *string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void table_print_line(const alpm_list_t *line,
|
static void table_print_line(const alpm_list_t *line,
|
||||||
const alpm_list_t *formats)
|
size_t colcount, size_t *widths)
|
||||||
{
|
{
|
||||||
const alpm_list_t *curformat = formats;
|
size_t i;
|
||||||
const alpm_list_t *curcell = line;
|
const alpm_list_t *curcell;
|
||||||
|
|
||||||
while(curcell && curformat) {
|
for(i = 0, curcell = line; curcell && i < colcount;
|
||||||
printf(curformat->data, curcell->data);
|
i++, curcell = alpm_list_next(curcell)) {
|
||||||
curcell = alpm_list_next(curcell);
|
const char *value = curcell->data;
|
||||||
curformat = alpm_list_next(curformat);
|
size_t len = string_length(value);
|
||||||
|
/* silly printf requires padding size to be an int */
|
||||||
|
int padding = (int)widths[i] - (int)len;
|
||||||
|
if(padding < 0) {
|
||||||
|
padding = 0;
|
||||||
|
}
|
||||||
|
/* left-align all but the last column */
|
||||||
|
if(i + 1 < colcount) {
|
||||||
|
printf("%s%*s", value, padding, "");
|
||||||
|
} else {
|
||||||
|
printf("%*s%s", padding, "", value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* creates format strings by checking max cell lengths in cols */
|
/* find the max string width of each column */
|
||||||
static alpm_list_t *table_create_format(const alpm_list_t *header,
|
static size_t table_calc_widths(const alpm_list_t *header,
|
||||||
const alpm_list_t *rows)
|
const alpm_list_t *rows, size_t totalcols, size_t **widths)
|
||||||
{
|
{
|
||||||
alpm_list_t *formats = NULL;
|
|
||||||
const alpm_list_t *i;
|
const alpm_list_t *i;
|
||||||
const unsigned short padding = 2;
|
const unsigned short padding = 2;
|
||||||
size_t curcol, totalcols, totalwidth = 0;
|
size_t curcol, totalwidth = 0;
|
||||||
size_t *colwidths;
|
size_t *colwidths;
|
||||||
|
|
||||||
totalcols = alpm_list_count(header);
|
if(totalcols <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
colwidths = malloc(totalcols * sizeof(size_t));
|
colwidths = malloc(totalcols * sizeof(size_t));
|
||||||
if(!colwidths) {
|
if(!colwidths) {
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
/* header determines column count and initial values of longest_strs */
|
/* header determines column count and initial values of longest_strs */
|
||||||
for(i = header, curcol = 0; i; i = alpm_list_next(i), curcol++) {
|
for(i = header, curcol = 0; i; i = alpm_list_next(i), curcol++) {
|
||||||
@ -536,30 +549,16 @@ static alpm_list_t *table_create_format(const alpm_list_t *header,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now use the column width info to generate format strings */
|
for(i = header, curcol = 0; i; i = alpm_list_next(i), curcol++) {
|
||||||
for(curcol = 0; curcol < totalcols; curcol++) {
|
/* pad everything but the last column */
|
||||||
const char *display;
|
if(curcol + 1 < totalcols) {
|
||||||
char *formatstr;
|
colwidths[curcol] += padding;
|
||||||
size_t colwidth = colwidths[curcol] + padding;
|
}
|
||||||
totalwidth += colwidth;
|
totalwidth += colwidths[curcol];
|
||||||
|
|
||||||
/* right align the last column for a cleaner table display */
|
|
||||||
display = (curcol + 1 < totalcols) ? "%%-%ds" : "%%%ds";
|
|
||||||
pm_asprintf(&formatstr, display, colwidth);
|
|
||||||
|
|
||||||
formats = alpm_list_add(formats, formatstr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(colwidths);
|
*widths = colwidths;
|
||||||
|
return totalwidth;
|
||||||
/* return NULL if terminal is not wide enough */
|
|
||||||
if(totalwidth > getcols()) {
|
|
||||||
fprintf(stderr, _("insufficient columns available for table display\n"));
|
|
||||||
FREELIST(formats);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return formats;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Displays the list in table format
|
/** Displays the list in table format
|
||||||
@ -576,14 +575,20 @@ int table_display(const char *title, const alpm_list_t *header,
|
|||||||
const alpm_list_t *rows)
|
const alpm_list_t *rows)
|
||||||
{
|
{
|
||||||
const alpm_list_t *i;
|
const alpm_list_t *i;
|
||||||
alpm_list_t *formats;
|
size_t *widths = NULL, totalcols, totalwidth;
|
||||||
|
|
||||||
if(rows == NULL || header == NULL) {
|
if(rows == NULL || header == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
formats = table_create_format(header, rows);
|
totalcols = alpm_list_count(header);
|
||||||
if(formats == NULL) {
|
totalwidth = table_calc_widths(header, rows, totalcols, &widths);
|
||||||
|
/* return -1 if terminal is not wide enough */
|
||||||
|
if(totalwidth > getcols()) {
|
||||||
|
fprintf(stderr, _("insufficient columns available for table display\n"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if(!totalwidth || !widths) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,14 +596,14 @@ int table_display(const char *title, const alpm_list_t *header,
|
|||||||
printf("%s\n\n", title);
|
printf("%s\n\n", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
table_print_line(header, formats);
|
table_print_line(header, totalcols, widths);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
for(i = rows; i; i = alpm_list_next(i)) {
|
for(i = rows; i; i = alpm_list_next(i)) {
|
||||||
table_print_line(i->data, formats);
|
table_print_line(i->data, totalcols, widths);
|
||||||
}
|
}
|
||||||
|
|
||||||
FREELIST(formats);
|
free(widths);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user