Compare commits

..

14 Commits

Author SHA1 Message Date
Allan McRae
f1c7341a81 WIP: First pass at adding a pkgdiff script
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-05-22 20:05:03 +10:00
Allan McRae
2c45e854ab Disable brittle valgrind test in CI
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-05-22 19:32:47 +10:00
Allan McRae
a81ec016d7 Update pactest README
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-05-22 19:25:23 +10:00
Allan McRae
55da1a01b6 makepkg.conf.in: strip leading slash from LIB_DIRS
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-05-22 18:55:23 +10:00
Allan McRae
5e94752434 makepkg.conf.5: correction option name
Also fix typo "librarys"

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-05-22 18:54:01 +10:00
Allan McRae
262aa6c24e Fix comment
Signed-off-by: Allan McRae <allan@archlinux.org>
2023-02-13 12:09:11 +00:00
Allan McRae
3323662ee0 makepkg: do not recurse into LIB_DIRS when looking for library provides
We should only find library provides in the configured directories, and
not their subdirectories.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-02-13 12:09:11 +00:00
Allan McRae
6c913af95d Add the -pedantic' compiler flag back to our debug builds
This was lost in the transition from autotools to meson. No additional
warnings are given with current gcc and clang.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-02-13 22:07:32 +10:00
Allan McRae
71764b6d4c makepkg.conf: allow configuration additions via a subdirectory
Move rust related buildflags to their own configuration file to
provide an example of how other languages could be supported.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-17 10:26:07 +10:00
Allan McRae
e0bbfb5682 libmakepkg: ensure clearing of buildflags happens first
When 'options=('!buildflags') is used, we want to ensure our
buildflags are cleared first. Currently this happens due to luck
of alphabetical ordering, but this could change with libmakepkg
drop-ins.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-13 11:35:42 +10:00
Allan McRae
09e82f01ea libmakepkg: move rust buildenv handling to separate file
This serves as a demonstration for how other languages could drop
in support into libmakepkg.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-13 11:35:35 +10:00
Stefan Weil
d35728f924 pacman-key: Fix shell syntax
Fixes: 3f8029af92 ("pacman-key: Use ngettext for plurals")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2023-01-01 15:54:48 +01:00
Allan McRae
3f8029af92 pacman-key: Use ngettext for plurals
There are two strings that may be singular or plural in pacman-key.
Use ngettext to handle these strings correctly, and provide a fallback
function if it is not available.

Fixes FS#70556.

Signed-off-by: Allan McRae <allan@archlinux.org>
2023-01-01 13:41:52 +10:00
Allan McRae
6344aab3bd zsh: make names unique to avoid clashes
The function _keys is a bit generic and can result in clashes.  Change
other functions starting with _key_ to be _pacman_key_ as well.

Fixes FS#74507.

Signed-off-by: Allan McRae <allan@archlinux.org>
2022-12-24 00:55:30 +10:00
26 changed files with 423 additions and 552 deletions

View File

@@ -46,14 +46,14 @@ arch-clang:
- ninja -C build
- fakechroot meson test -C build
arch-valgrind:
extends: .arch-test
script:
- pacman -Syu --needed --noconfirm valgrind
- pacman -U --noconfirm https://geo.mirror.pkgbuild.com/core-debug/os/x86_64/glibc-debug-$(pacman -S --print-format %v glibc)-x86_64.pkg.tar.zst
- meson setup build
- ninja -C build
- PACTEST_VALGRIND=1 fakechroot meson test -C build
#arch-valgrind:
# extends: .arch-test
# script:
# - pacman -Syu --needed --noconfirm valgrind
# - pacman -U --noconfirm https://geo.mirror.pkgbuild.com/core-debug/os/x86_64/glibc-debug-$(pacman -S --print-format %v glibc)-x86_64.pkg.tar.zst
# - meson setup build
# - ninja -C build
# - PACTEST_VALGRIND=1 fakechroot meson test -C build
arch-nettle:
extends: .arch-test

View File

@@ -199,7 +199,7 @@ Options
flags specified in LTOFLAGS to CFLAGS, CXXFLAGS and LDFLAGS (or
``-flto'' if LTOFLAGS is empty).
*autodep*;;
*autodeps*;;
Enable the automatic addition of libraries to the depends and
provides arrays. Search library directories are controlled by
the LIB_DIRS variable defined below.
@@ -236,7 +236,7 @@ Options
**LIB_DIRS=(**lib:usr/lib ...**)**::
If `autodeps` is specified in the `OPTIONS` array, this variable will
instruct makepkg where to look to find librarys to add to the `provides`
instruct makepkg where to look to find libraries to add to the `provides`
array. The format is "prefix:path", where provides will be added for
libraries found in "path" with the specified prefix added.

View File

@@ -0,0 +1,11 @@
#!/hint/bash
#
# @sysconfdir@/makepkg.conf.d/rust.conf
#
#########################################################################
# RUST LANGUAGE SUPPORT
#########################################################################
#
#RUSTFLAGS="-C opt-level=2"
#DEBUG_RUSTFLAGS="-C debuginfo=2"

View File

@@ -42,13 +42,11 @@ CHOST="@CHOST@"
#CXXFLAGS="-O2 -pipe"
#LDFLAGS=""
#LTOFLAGS="-flto"
#RUSTFLAGS="-C opt-level=2"
#-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2"
#-- Debugging flags
#DEBUG_CFLAGS="-g"
#DEBUG_CXXFLAGS="-g"
#DEBUG_RUSTFLAGS="-C debuginfo=2"
#########################################################################
# BUILD ENVIRONMENT
@@ -111,7 +109,7 @@ PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"
#-- Prefix and directories for library autodeps
LIB_DIRS=('lib:/usr/lib' 'lib32:/usr/lib32')
LIB_DIRS=('lib:usr/lib' 'lib32:usr/lib32')
#########################################################################
# PACKAGE OUTPUT

View File

@@ -2913,9 +2913,6 @@ int alpm_capabilities(void);
/* End of libalpm_api */
/** @} */
size_t alpm_info_print_pkg(const char *format, alpm_pkg_t *pkg);
size_t alpm_info_print_pkgs(const char *format, alpm_list_t *pkgs);
#ifdef __cplusplus
}
#endif

View File

@@ -1,226 +0,0 @@
#include <errno.h>
#include <string.h>
#include "alpm.h"
#include "util.h"
#include "mfmt.h"
typedef enum field_t {
FILENAME,
NAME,
BASE,
DESCRIPTION,
VERSION,
ORIGIN,
REASON,
LICENSE,
GROUP,
DEPENDS,
OPTDEPENDS,
CONFLICTS,
PROVIDES,
REPLACES,
REQUIREDBY,
DELTAS,
FILES,
BACKUP,
DB,
VALIDATION,
URL,
BUILDDATE,
INSTALLDATE,
PACKAGER,
MD5SUM,
SHA256SUM,
ARCH,
SIZE,
ISIZE,
BASE64SIG,
UNKNOWN,
} field_t;
static struct field_map_t {
const char *input;
field_t field;
} field_map[] = {
{"filename", FILENAME},
{"name", NAME},
{"base", BASE},
{"description", DESCRIPTION},
{"version", VERSION},
{"license", LICENSE},
{"group", GROUP},
{"groups", GROUP},
{"depends", DEPENDS},
{"optdepends", OPTDEPENDS},
{"conflicts", CONFLICTS},
{"provides", PROVIDES},
{"replaces", REPLACES},
{"requiredby", REQUIREDBY},
{"url", URL},
{"builddate", BUILDDATE},
{"installdate", INSTALLDATE},
{"packager", PACKAGER},
{"md5sum", MD5SUM},
{"sha256sum", SHA256SUM},
{"arch", ARCH},
{"size", SIZE},
{"isize", ISIZE},
{"base64sig", BASE64SIG},
{NULL, 0}
};
static char *_alpm_hr_size(off_t bytes, char *dest)
{
static const char *suff[] = {"B", "K", "M", "G", "T", "P", "E", NULL};
float hrsize;
int s = 0;
while((bytes >= 1000000 || bytes <= -1000000) && suff[s + 1]) {
bytes /= 1024;
++s;
}
hrsize = bytes;
if((hrsize >= 1000 || hrsize <= -1000) && suff[s + 1]) {
hrsize /= 1024;
++s;
}
sprintf(dest, "%.2f %s", hrsize, suff[s]);
return dest;
}
static field_t _alpm_info_lookup_field(const char *name) {
struct field_map_t *m;
for(m = field_map; m->input; m++) {
if(strcmp(name, m->input) == 0) { return m->field; }
}
return UNKNOWN;
}
static size_t _alpm_info_print_str(mfmt_token_callback_t *t, const char *str, FILE *f) {
return mfmt_render_str(t, str ? str : "NULL", f);
}
static size_t _alpm_info_print_size(mfmt_token_callback_t *t, const off_t s, FILE *f) {
if(s) {
char hrsize[50];
if(t->conversion == 'd') {
snprintf(hrsize, 50, "%lld", (long long)s);
} else {
_alpm_hr_size(s, hrsize);
}
return mfmt_render_str(t, hrsize, f);
} else {
return mfmt_render_str(t, "NULL", f);
}
}
static size_t _alpm_info_print_strlist(mfmt_token_callback_t *t, alpm_list_t *l, FILE *f) {
if(l) {
size_t len = 0;
while(l) {
len += mfmt_render_str(t, l->data, f) + 1;
fputc('\n', f);
l = l->next;
}
return len;
} else {
return mfmt_render_str(t, "NULL", f);
}
}
static size_t _alpm_info_print_deplist(mfmt_token_callback_t *t, alpm_list_t *l, FILE *f) {
if(l) {
size_t len = 0;
while(l) {
char *s = alpm_dep_compute_string(l->data);
len += mfmt_render_str(t, s, f) + 1;
fputc('\n', f);
l = l->next;
free(s);
}
return len;
} else {
return mfmt_render_str(t, "NULL", f);
}
}
static size_t _alpm_info_print_timestamp(mfmt_token_callback_t *t, const alpm_time_t s, FILE *f) {
if(s) {
char datestr[50] = "";
if(strftime(datestr, 50, " %c", localtime(&s)) == 0) { return 0; }
return mfmt_render_str(t, datestr + 1, f);
} else {
return mfmt_render_str(t, "NULL", f);
}
}
static size_t _alpm_info_process_token(FILE *f, mfmt_token_callback_t *t, void *ctx, void *arg) {
alpm_pkg_t *p = arg;
(void)ctx;
switch(_alpm_info_lookup_field(t->name)) {
case NAME: return _alpm_info_print_str(t, alpm_pkg_get_name(p), f);
case DESCRIPTION: return _alpm_info_print_str(t, alpm_pkg_get_desc(p), f);
case PACKAGER: return _alpm_info_print_str(t, alpm_pkg_get_packager(p), f);
case MD5SUM: return _alpm_info_print_str(t, alpm_pkg_get_md5sum(p), f);
case FILENAME: return _alpm_info_print_str(t, alpm_pkg_get_filename(p), f);
case BASE: return _alpm_info_print_str(t, alpm_pkg_get_base(p), f);
case VERSION: return _alpm_info_print_str(t, alpm_pkg_get_version(p), f);
case URL: return _alpm_info_print_str(t, alpm_pkg_get_url(p), f);
case SHA256SUM: return _alpm_info_print_str(t, alpm_pkg_get_sha256sum(p), f);
case ARCH: return _alpm_info_print_str(t, alpm_pkg_get_arch(p), f);
case BASE64SIG: return _alpm_info_print_str(t, alpm_pkg_get_base64_sig(p), f);
case SIZE: return _alpm_info_print_size(t, alpm_pkg_get_size(p), f);
case ISIZE: return _alpm_info_print_size(t, alpm_pkg_get_isize(p), f);
case BUILDDATE: return _alpm_info_print_timestamp(t, alpm_pkg_get_builddate(p), f);
case INSTALLDATE: return _alpm_info_print_timestamp(t, alpm_pkg_get_installdate(p), f);
case DEPENDS: return _alpm_info_print_deplist(t, alpm_pkg_get_depends(p), f);
case OPTDEPENDS: return _alpm_info_print_deplist(t, alpm_pkg_get_optdepends(p), f);
case CONFLICTS: return _alpm_info_print_deplist(t, alpm_pkg_get_conflicts(p), f);
case PROVIDES: return _alpm_info_print_deplist(t, alpm_pkg_get_provides(p), f);
case REPLACES: return _alpm_info_print_deplist(t, alpm_pkg_get_replaces(p), f);
case REQUIREDBY: {
alpm_list_t *rb = alpm_pkg_compute_requiredby(p);
size_t len = _alpm_info_print_strlist(t, rb, f);
FREELIST(rb);
return len;
}
default: errno = EINVAL; return 0;
}
}
size_t SYMEXPORT alpm_info_print_pkg(const char *format, alpm_pkg_t *pkg) {
alpm_list_t l = {
.data = pkg,
.next = NULL,
};
l.prev = &l;
return alpm_info_print_pkgs(format, &l);
}
size_t SYMEXPORT alpm_info_print_pkgs(const char *format, alpm_list_t *pkgs) {
mfmt_t *mfmt = mfmt_parse(format, _alpm_info_process_token, NULL);
size_t len = 0;
if(mfmt == NULL) {
return 0;
}
for(alpm_list_t *i = pkgs; i; i = i->next) {
size_t plen = mfmt_printf(mfmt, i->data, stdout);
if(plen == 0) { return 0; }
len += plen;
}
return len;
}
/* vim: set ts=2 sw=2 et: */

View File

@@ -28,7 +28,5 @@ libalpm_sources = files('''
sync.h sync.c
trans.h trans.c
util.h util.c
info.c
mfmt.c mfmt.h
version.c
'''.split())

View File

@@ -1,193 +0,0 @@
#define _GNU_SOURCE
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include "mfmt.h"
char *_mfmt_find_unescaped_char(char *haystack, char needle) {
while(1) {
haystack = strchrnul(haystack, needle);
if(*haystack && *(haystack + 1) == needle) { haystack += 2; continue; }
else { break; }
}
return haystack;
}
void _mfmt_brace_dedup(char *str) {
char *c = str, *end = str + strlen(str);
while((c = strchr(c, '{'))) {
memmove(c, c + 1, end - c);
c++;
}
c = str;
while((c = strchr(c, '}'))) {
memmove(c, c + 1, end - c);
c++;
}
}
mfmt_t *mfmt_parse(const char *tmpl, mfmt_callback_t *cb, void *ctx) {
mfmt_t *mfmt;
char *c;
mfmt = calloc(sizeof(mfmt_t), 1);
if(mfmt == NULL) { return NULL; }
mfmt->cb = cb;
mfmt->ctx = ctx;
for(c = (char*) tmpl; c && *c; ) {
mfmt->token_count++;
if(*c == '{' && *(c + 1) != '{') {
/* replacement */
if(!*(c = _mfmt_find_unescaped_char(c + 1, '}'))) {
errno = EINVAL;
free(mfmt);
return NULL;
} else {
c++;
}
} else {
/* literal */
c = _mfmt_find_unescaped_char(c, '{');
}
}
if((mfmt->tokens = calloc(sizeof(mfmt_token_t), mfmt->token_count)) == NULL) {
free(mfmt);
return NULL;
}
size_t i;
for(c = (char*) tmpl, i = 0; c && *c; i++) {
if(*c == '{' && *(c + 1) != '{') {
/* replacement */
mfmt_token_callback_t *t = &mfmt->tokens[i].callback;
char *end = _mfmt_find_unescaped_char(c + 1, '}');
t->type = MFMT_TOKEN_CALLBACK;
t->name = strndup(c + 1, end - c - 1);
c = end + 1;
} else {
/* literal */
char *end = _mfmt_find_unescaped_char(c, '{');
mfmt_token_literal_t *t = &mfmt->tokens[i].literal;
t->type = MFMT_TOKEN_LITERAL;
t->string = strndup(c, end - c);
_mfmt_brace_dedup(t->string);
c = end;
}
}
return mfmt;
}
size_t mfmt_printf(mfmt_t *mfmt, void *args, FILE *f) {
size_t len = 0;
size_t i;
for(i = 0; i < mfmt->token_count; i++) {
mfmt_token_t *t = &mfmt->tokens[i];
switch(t->base.type) {
case MFMT_TOKEN_LITERAL:
len += fputs(t->literal.string, f);
break;
case MFMT_TOKEN_CALLBACK:
len += mfmt->cb(f, &t->callback, mfmt->ctx, args);
break;
default:
errno = EINVAL;
return 0;
}
}
return len;
}
static size_t _mfmt_printf_close(mfmt_t *mfmt, void *args, FILE *f) {
if(f) {
size_t len = mfmt_printf(mfmt, args, f);
fclose(f);
return len;
}
return -1;
}
size_t mfmt_printd(mfmt_t *mfmt, void *args, int fd) {
return _mfmt_printf_close(mfmt, args, fdopen(fd, "w"));
}
size_t mfmt_printb(mfmt_t *mfmt, void *args, char *buf, size_t buflen) {
return _mfmt_printf_close(mfmt, args, fmemopen(buf, buflen, "w"));
}
size_t mfmt_prints(mfmt_t *mfmt, void *args, char **buf, size_t *buflen) {
return _mfmt_printf_close(mfmt, args, open_memstream(buf, buflen));
}
size_t mfmt_fmt(const char *tmpl, mfmt_val_t *args, FILE *f) {
mfmt_t *mfmt = mfmt_parse(tmpl, NULL, NULL);
size_t len;
for(size_t i = 0; i < mfmt->token_count; i++) {
mfmt_token_t *t = &mfmt->tokens[i];
switch(t->base.type) {
case MFMT_TOKEN_LITERAL:
len += fputs(t->literal.string, f);
break;
case MFMT_TOKEN_CALLBACK:
/* fprintf(stderr, "token: %s\n", t->callback.name); */
if(t->callback.name[0]) {
for(mfmt_val_t *v = args; v; v++) {
/* fprintf(stderr, "val: %s\n", v->name); */
if(strcmp(v->name, t->callback.name) == 0) {
len += fputs(v->string, f);
break;
}
}
} else {
len += fputs(args->string, f);
args++;
}
break;
}
}
return len;
}
size_t mfmt_mfmt(mfmt_t *mfmt, mfmt_val_t *args, FILE *f) {
size_t len;
for(size_t i = 0; i < mfmt->token_count; i++) {
mfmt_token_t *t = &mfmt->tokens[i];
switch(t->base.type) {
case MFMT_TOKEN_LITERAL:
len += fputs(t->literal.string, f);
break;
case MFMT_TOKEN_CALLBACK:
/* fprintf(stderr, "token: %s\n", t->callback.name); */
if(t->callback.name[0]) {
for(mfmt_val_t *v = args; v; v++) {
/* fprintf(stderr, "val: %s\n", v->name); */
if(strcmp(v->name, t->callback.name) == 0) {
len += fputs(v->string, f);
break;
}
}
} else {
len += fputs(args->string, f);
args++;
}
break;
}
}
return len;
}
size_t mfmt_render_int(mfmt_token_callback_t *t, const intmax_t i, FILE *f) {
(void)t;
return fprintf(f, "%jd", i);
}
size_t mfmt_render_str(mfmt_token_callback_t *t, const char *str, FILE *f) {
(void)t;
return fputs(str, f);
}

View File

@@ -1,66 +0,0 @@
#include <stdio.h>
#include <stddef.h>
#include <inttypes.h>
typedef enum mfmt_token_type_t {
MFMT_TOKEN_LITERAL,
MFMT_TOKEN_CALLBACK,
} mfmt_token_type_t;
typedef struct mfmt_token_literal_t {
mfmt_token_type_t type;
char *string;
} mfmt_token_literal_t;
typedef struct mfmt_token_base_t {
mfmt_token_type_t type;
} mfmt_token_base_t;
typedef struct mfmt_token_callback_t {
mfmt_token_type_t type;
size_t position;
char *name;
size_t width;
size_t precision;
char align;
char fill;
char conversion;
int sign;
} mfmt_token_callback_t;
typedef union mfmt_token_t {
mfmt_token_base_t base;
mfmt_token_literal_t literal;
mfmt_token_callback_t callback;
} mfmt_token_t;
typedef size_t (mfmt_callback_t)(FILE *f, mfmt_token_callback_t *token, void *ctx, void *args);
typedef struct mfmt_t {
mfmt_callback_t *cb;
void *ctx;
size_t token_count;
mfmt_token_t *tokens;
} mfmt_t;
typedef struct mfmt_val_t {
const char *name;
const char *string;
} mfmt_val_t;
mfmt_t *mfmt_parse(const char *tmpl, mfmt_callback_t *cb, void *ctx);
size_t mfmt_printf(mfmt_t *mfmt, void *args, FILE *f);
size_t mfmt_printd(mfmt_t *mfmt, void *args, int fd);
size_t mfmt_printb(mfmt_t *mfmt, void *args, char *buf, size_t buflen);
size_t mfmt_prints(mfmt_t *mfmt, void *args, char **buf, size_t *buflen);
void mfmt_free(mfmt_t *mfmt);
size_t mfmt_render_int(mfmt_token_callback_t *token, intmax_t i, FILE *f);
size_t mfmt_render_uint(mfmt_token_callback_t *token, uintmax_t i, FILE *f);
size_t mfmt_render_str(mfmt_token_callback_t *token, const char *str, FILE *f);
size_t mfmt_formatf(const char *tmpl, mfmt_callback_t *cb, void *ctx, FILE *f);
size_t mfmt_formatd(const char *tmpl, mfmt_callback_t *cb, void *ctx, int fd);
size_t mfmt_formatb(const char *tmpl, mfmt_callback_t *cb, void *ctx, char *buf, size_t buflen);
size_t mfmt_formats(const char *tmpl, mfmt_callback_t *cb, void *ctx, char **buf);

View File

@@ -190,6 +190,7 @@ endif
if get_option('debug')
extra_cflags = [
'-pedantic',
'-Wcast-align',
'-Wclobbered',
'-Wempty-body',
@@ -401,6 +402,12 @@ configure_file(
configuration : substs,
install_dir : SYSCONFDIR)
configure_file(
input : 'etc/makepkg.conf.d/rust.conf.in',
output : 'rust.conf',
configuration : substs,
install_dir : join_paths(SYSCONFDIR, 'makepkg.conf.d/'))
configure_file(
input : 'etc/pacman.conf.in',
output : 'pacman.conf',

View File

@@ -586,38 +586,38 @@ _pacman_conf() {
esac
}
_key_shortopts=(
_pacman_key_shortopts=(
'-h[show help]'
'-a[Add the specified keys (empty for stdin)]: :_files'
'-d[Remove the Specified keyids]:*: :_keys'
'-e[Export the specified or all keyids]:*: :_keys'
'-f[List fingerprint for specified or all keyids]:*: :_keys'
'-l[List the specified or all keys]:*: :_keys'
'-r[Fetch the specified keyids]:*: :_keys'
'-d[Remove the Specified keyids]:*: :_pacman_key_list'
'-e[Export the specified or all keyids]:*: :_pacman_key_list'
'-f[List fingerprint for specified or all keyids]:*: :_pacman_key_list'
'-l[List the specified or all keys]:*: :_pacman_key_list'
'-r[Fetch the specified keyids]:*: :_pacman_key_list'
'-u[Update the trustdb of pacman]'
'-v[Verify the file specified by the signature]: :_files -g "*.sig"'
'-V[Show program version]'
)
_key_longopts=(
_pacman_key_longopts=(
'--help[show help]'
'--add[Add the specified keys (empty for stdin)]: :_files'
'--delete[Remove the Specified keyids]:*: :_keys'
'--export[Export the specified or all keyids]:*: :_keys'
'--finger[List fingerprint for specified or all keyids]:*: :_keys'
'--list-keys[List the specified or all keys]:*: :_keys'
'--recv-keys[Fetch the specified keyids]:*: :_keys'
'--delete[Remove the Specified keyids]:*: :_pacman_key_list'
'--export[Export the specified or all keyids]:*: :_pacman_key_list'
'--finger[List fingerprint for specified or all keyids]:*: :_pacman_key_list'
'--list-keys[List the specified or all keys]:*: :_pacman_key_list'
'--recv-keys[Fetch the specified keyids]:*: :_pacman_key_list'
'--updatedb[Update the trustdb of pacman]'
'--verify[Verify the file specified by the signature]: :_files -g "*.sig"'
'--version[Show program version]'
'--edit-key[Present a menu for key management task on keyids]:*: :_keys'
'--edit-key[Present a menu for key management task on keyids]:*: :_pacman_key_list'
'--import[Imports pubring.gpg from dir(s)]: :_files -g "*.gpg"'
'--import-tb[Imports ownertrust values from trustdb.gpg in dir(s)]: :_files -g "*.gpg"'
'--init[Ensure the keyring is properly initialized]'
'--list-sigs[List keys and their signatures]:*: :_keys'
'--lsign-key[Locally sign the specified keyid]:*: :_keys'
'--list-sigs[List keys and their signatures]:*: :_pacman_key_list'
'--lsign-key[Locally sign the specified keyid]:*: :_pacman_key_list'
'--populate[Reload the default keys from the (given) keyrings in '@keyringdir@']: :_path_files -W @keyringdir@'
'--refresh-keys[Update specified or all keys from a keyserver]:*: :_keys'
'--refresh-keys[Update specified or all keys from a keyserver]:*: :_pacman_key_list'
)
_pacman_key_options=(
@@ -631,13 +631,13 @@ _pacman_key() {
--*)
_arguments -s : \
"$_pacman_key_options[@]" \
"$_key_longopts[@]"
"$_pacman_key_longopts[@]"
;;
-*)
_arguments -s : \
"$_pacman_key_options[@]" \
"$_key_shortopts[@]" \
"$_key_longopts[@]"
"$_pacman_key_shortopts[@]" \
"$_pacman_key_longopts[@]"
;;
*)
i=$#
@@ -648,13 +648,13 @@ _pacman_key() {
--*)
_arguments -s : \
"$_pacman_key_options[@]" \
"$_key_longopts[@]"
"$_pacman_key_longopts[@]"
;;
-*)
_arguments -s : \
"$_pacman_key_options[@]" \
"$_key_shortopts[@]" \
"$_key_longopts[@]"
"$_pacman_key_shortopts[@]" \
"$_pacman_key_longopts[@]"
;;
*)
return 1
@@ -664,7 +664,7 @@ _pacman_key() {
esac
}
_keys() {
_pacman_key_list() {
local keylist keys
keylist=$(pacman-key --list-keys 2>/dev/null | awk '
$1 == "pub" {
@@ -733,7 +733,7 @@ _makepkg_longopts=(
'--check[Run check() function in the PKGBUILD]'
'--config[Use an alternate config file instead of '@sysconfdir@/makepkg.conf']: :_files'
'--holdver[Do not update VCS sources]'
'--key[Specify key to use for gpg signing instead of the default]: :_keys'
'--key[Specify key to use for gpg signing instead of the default]: :_pacman_key_list'
'--noarchive[Do not create package archive]'
'--nocheck[Do not run the check() function in the PKGBUILD]'
'--noprepare[Do not run the prepare() function in the PKGBUILD]'

View File

@@ -35,7 +35,7 @@ library_provides() {
continue;
fi
mapfile -t filenames < <(find "$pkgdir/$dir" -type f | LC_ALL=C sort)
mapfile -t filenames < <(find "$pkgdir/$dir" -maxdepth 1 -type f | LC_ALL=C sort)
for fn in "${filenames[@]}"; do
# check we have a shared library
@@ -44,7 +44,7 @@ library_provides() {
local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
if [[ -z "$sofile" ]]; then
# the library is not versioned
# the library has no soname
continue
fi

View File

@@ -25,18 +25,22 @@ LIBMAKEPKG_BUILDENV_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
declare -a buildenv_functions build_options
buildenv_vars=('CPPFLAGS' 'CFLAGS' 'CXXFLAGS' 'LDFLAGS' 'MAKEFLAGS' 'CHOST')
for lib in "$LIBRARY/buildenv/"*.sh; do
source "$lib"
done
readonly -a buildenv_functions build_options
readonly -a buildenv_functions buildenv_vars build_options
prepare_buildenv() {
# ensure this function runs first
buildenv_buildflags
for func in ${buildenv_functions[@]}; do
$func
done
# ensure all necessary build variables are exported
export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS RUSTFLAGS MAKEFLAGS CHOST
export ${buildenv_vars[@]}
}

View File

@@ -26,10 +26,9 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/option.sh"
build_options+=('buildflags')
buildenv_functions+=('buildenv_buildflags')
buildenv_buildflags() {
if check_option "buildflags" "n"; then
unset CPPFLAGS CFLAGS DEBUG_CFLAGS CXXFLAGS DEBUG_CXXFLAGS LDFLAGS LTOFLAGS RUSTFLAGS DEBUG_RUSTFLAGS
unset ${buildenv_vars[@]}
fi
}

View File

@@ -32,9 +32,7 @@ buildenv_debugflags() {
if check_option "debug" "y" && ! check_option "buildflags" "n"; then
DEBUG_CFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
DEBUG_CXXFLAGS+=" -ffile-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
CFLAGS+=" $DEBUG_CFLAGS"
CXXFLAGS+=" $DEBUG_CXXFLAGS"
RUSTFLAGS+=" $DEBUG_RUSTFLAGS"
fi
}

View File

@@ -6,6 +6,7 @@ sources = [
'debugflags.sh.in',
'lto.sh.in',
'makeflags.sh.in',
'rust.sh.in',
]
foreach src : sources

View File

@@ -0,0 +1,36 @@
#!/usr/bin/bash
#
# rust.sh - Specify flags for building a package with rust
#
# Copyright (c) 2022 Pacman Development Team <pacman-dev@lists.archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -n "$LIBMAKEPKG_BUILDENV_RUST_SH" ]] && return
LIBMAKEPKG_BUILDENV_RUST_SH=1
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/option.sh"
buildenv_var+=('RUSTFLAGS' 'DEBUG_RUSTFLAGS')
buildenv_functions+=('buildenv_rust')
buildenv_rust() {
if check_option "debug" "y" && ! check_option "buildflags" "n"; then
DEBUG_RUSTFLAGS+=" --remap-path-prefix=$srcdir=${DBGSRCDIR:-/usr/src/debug}/${pkgbase}"
RUSTFLAGS+=" $DEBUG_RUSTFLAGS"
fi
}

View File

@@ -32,10 +32,10 @@ lint_config_variables() {
local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS
DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ
COMPRESSLRZ COMPRESSLZO COMPRESSZ)
local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS RUSTFLAGS LDFLAGS LTOFLAGS
DEBUG_CFLAGS DEBUG_CXXFLAGS DEBUG_RUSTFLAGS DISTCC_HOSTS BUILDDIR
STRIP_BINARIES STRIP_SHARED STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST
LOGDEST PACKAGER GPGKEY PKGEXT SRCEXT)
local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS LTOFLAGS DEBUG_CFLAGS
DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED
STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY
PKGEXT SRCEXT)
local i keys ret=0

View File

@@ -37,6 +37,11 @@ source_makepkg_config() {
# Source the config file; fail if it is not found
if [[ -r $MAKEPKG_CONF ]]; then
source_safe "$MAKEPKG_CONF"
if [[ -d "$MAKEPKG_CONF.d" ]]; then
for c in "$MAKEPKG_CONF.d"/*.conf; do
source_safe $c
done
fi
else
error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
plainerr "$(gettext "Aborting...")"

View File

@@ -2,6 +2,7 @@ wrapped_scripts = [
'makepkg.sh.in',
'pacman-db-upgrade.sh.in',
'pacman-key.sh.in',
'pkgdiff.sh.in',
'repo-add.sh.in'
]

View File

@@ -378,7 +378,7 @@ populate_keyring() {
key_count=$((key_count+1))
done
if (( key_count )); then
msg2 "$(gettext "Disabled %s keys.")" "${key_count}"
msg2 "$(ngettext "Disabled %s key." "Disabled %s keys." "${key_count}")" "${key_count}"
fi
fi
}
@@ -506,7 +506,7 @@ lsign_keys() {
exit 1
fi
if (( key_count )); then
msg2 "$(gettext "Locally signed %s keys.")" "${key_count}"
msg2 "$(ngettext "Locally signed %s key." "Locally signed %s keys." "${key_count}")" "${key_count}"
fi
}
@@ -612,6 +612,16 @@ if ! type gettext &>/dev/null; then
}
fi
if ! type ngettext &>/dev/null; then
ngettext() {
if (( $3 == 1 )); then
echo "$1"
else
echo "$2"
fi
}
fi
OPT_SHORT="adefhlruvV"
OPT_LONG=('add' 'config:' 'delete' 'edit-key' 'export' 'finger' 'gpgdir:'
'help' 'import' 'import-trustdb' 'init' 'keyserver:' 'list-keys' 'list-sigs'

301
scripts/pkgdiff.sh.in Executable file
View File

@@ -0,0 +1,301 @@
#!/bin/bash
#
# pkgdiff - package differencing utility
#
# Copyright (c) 2022 Pacman Development Team <pacman-dev@lists.archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# gettext initialization
export TEXTDOMAIN='pacman-scripts'
export TEXTDOMAINDIR='@localedir@'
declare -r myver='@PACKAGE_VERSION@'
declare -r confdir='@sysconfdir@'
LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
QUIET=0
USE_COLOR='y'
source "$LIBRARY"/util/compress.sh
source "$LIBRARY"/util/message.sh
source "$LIBRARY"/util/parseopts.sh
# minimal of package before a pkgdiff is generated (bytes)
min_pkg_size=$((1024*1024))
# percent of new package above which the pkgdiff will be discarded
max_diff_size=70
# ensure we have a sane umask set
umask 0022
# print usage instructions
usage() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
echo
printf -- $(gettext "Usage: pkgdiff <old> <new>\n")
echo
printf -- "$(gettext "\
pkgdiff will create a file providing the differences between two packages.\n
This file can then be added to a database using repo-add.\n")"
echo
printf -- "$(gettext "Example: pkgdiff pacman-6.0.0-1-x86_64.pkg.tar.gz pacman-6.0.1-1-x86_64.pkg.tar.gz")\n"
echo
printf -- "$(gettext "Options:\n")"
printf -- "$(gettext " -q, --quiet minimize output\n")"
printf -- "$(gettext " --nocolor remove color from output\n")"
printf -- "$(gettext " --min-pkg-size minimum package size before pkgdiffs are generated\n")"
printf -- "$(gettext " --max-diff-size percent of new package above which the pkgdiff will be discarded\n")"
}
version() {
cmd=${0##*/}
printf "%s (pacman) %s\n\n" "$cmd" "$myver"
printf -- "Copyright (c) 2022 Pacman Development Team <pacman-dev@lists.archlinux.org>.\n"
echo
printf -- "$(gettext "\
This is free software; see the source for copying conditions.\n\
There is NO WARRANTY, to the extent permitted by law.\n")"
}
trap_exit() {
# unhook all traps to avoid race conditions
trap '' EXIT TERM HUP QUIT INT ERR
echo
error "$@"
clean_up 1
}
clean_up() {
local exit_code=${1:-$?}
# unhook all traps to avoid race conditions
trap '' EXIT TERM HUP QUIT INT ERR
[[ -d $tmpdir ]] && rm -rf "$tmpdir"
exit $exit_code
}
read_pkginfo() {
unset pkgver pkgname arch
while IFS='=' read -r field value; do
# skip comments and invalid lines
[[ $field = '#'* || -z $value ]] && continue
# skip lines which aren't fields we care about
[[ $field != @(pkgver|pkgname|arch) ]] || continue
declare -g "${field% }=${value# }"
[[ $pkgname && $pkgver && $arch ]] && return 0
done < <(bsdtar -xOqf "$1" .PKGINFO 2>/dev/null)
error "$(gettext "Invalid package file '%s'.")" "$1"
return 1
}
create_pkgdiff() {
local oldfile=$1
local newfile=$2
local \
oldname oldver oldarch \
newname newver newarch \
diff_file
read_pkginfo "$oldfile" || return 1
oldname="$pkgname"
oldver="$pkgver"
oldarch="$arch"
read_pkginfo "$newfile" || return 1
newname="$pkgname"
newver="$pkgver"
newarch="$arch"
pkgsize=$(wc -c < "$newfile")
if ((pkgsize < min_pkg_size)); then
msg "$(gettext "Skipping pkgdiff creation for small package: %s - size %s")" "$newname" "$pkgsize"
return 0
fi
if [[ $oldname != "$newname" ]]; then
error "$(gettext "The package names don't match : '%s' and '%s'")" "$oldname" "$newname"
return 1
fi
if [[ $oldarch != "$newarch" ]]; then
error "$(gettext "The package architectures don't match : '%s' and '%s'")" "$oldarch" "$newarch"
return 1
fi
if [[ $oldver == "$newver" ]]; then
error "$(gettext "Both packages have the same version : '%s'")" "$newver"
return 1
fi
### TODO: check oldver < newver with vercmp ###
declare -r startdir="$(pwd -P)"
if [[ ${oldfile::1} != "/" ]]; then
oldfile=${startdir}/${oldfile}
fi
if [[ ${newfile::1} != "/" ]]; then
newfile=${startdir}/${newfile}
fi
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/pkgdiff.XXXXXXXXXX")
pushd $tmpdir &>/dev/null
### TODO: almost everything below here is a quick hack... ###
bsdtar -xOf $oldfile .MTREE | zcat | awk '{for (i=1;i<=NF;i++){if ($i ~/^sha256/) {print $1 " " $i}}}' > ${oldver}.files
bsdtar -xOf $newfile .MTREE | zcat | awk '{for (i=1;i<=NF;i++){if ($i ~/^sha256/) {print $1 " " $i}}}' > ${newver}.files
files=($(diff -Naur ${oldver}.files ${newver}.files |
grep "^+\./" |
grep -v -e "\.BUILDINFO" -e "\.PKGINFO" |
cut -f1 -d' ' |
sed 's|+./||'))
mkdir $newname
tar -xf $newfile -C $newname
diffdir="${oldname}-${oldver}-to-${newname}-${newver}-${newarch}.pkgdiff"
mkdir $diffdir
for f in ${files[@]}; do
mkdir -p ${diffdir}/${f%/*}
cp ${newname}/$f ${diffdir}/$f
done
cp ${newname}/.{BUILD,PKG}INFO ${diffdir}
### TODO: this should use libmakepkg/compress - need PKGEXT from makepkg.conf ###
### TODO: collect files in same order as makepkg ###
tar -cf ${diffdir}.tar ${diffdir}
zstd -T0 --ultra -20 ${diffdir}.tar &> /dev/null
diff_file=${diffdir}.tar.zst
diffsize=$(wc -c < "$diff_file")
if ((max_diff_size * pkgsize / 100 < diffsize)); then
msg "$(gettext "pkgdiff larger than maximum size. Removing.")"
rm -f "$diff_file"
return 0
fi
popd &>/dev/null
mv ${tmpdir}/${diff_file} .
msg "$(gettext "Generated pkgdiff : '%s'")" "$diff_file"
(( QUIET )) && echo "$diff_file"
return 0
}
# PROGRAM START
# determine whether we have gettext; make it a no-op if we do not
if ! type gettext &>/dev/null; then
gettext() {
echo "$@"
}
fi
case $1 in
-h|--help) usage; exit 0;;
-V|--version) version; exit 0;;
esac
trap 'clean_up' EXIT
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 "An unknown error has occurred. Exiting...")"' ERR
OPT_SHORT='hqV'
OPT_LONG=('help' 'quiet' 'max-diff-size:' 'min-pkg-size:' 'nocolor' 'version')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1
fi
set -- "${OPTRET[@]}"
unset OPT_SHORT OPT_LONG OPTRET
# parse options
while :; do
case $1 in
-h|--help)
usage
exit 0 ;;
-V|--version)
version
exit 0 ;;
-q|--quiet)
QUIET=1;;
--nocolor)
USE_COLOR='n';;
--min-pkg-size)
### TODO ###
shift ;;
--max-delta-size)
### TODO ###
shift ;;
--)
shift
break ;;
esac
shift
done
# check if messages are to be printed using color
if [[ -t 2 && $USE_COLOR != "n" ]]; then
colorize
else
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
fi
if (( $# != 2 )); then
usage
exit 1
fi
for i in "$@"; do
if [[ ! -f $i ]]; then
error "$(gettext "File '%s' does not exist")" "$i"
exit 1
fi
done
### TODO: the creation of the pkgdiff should be done in fakeroot ###
create_pkgdiff "$@"

View File

@@ -58,7 +58,6 @@ typedef struct __config_t {
unsigned short color;
unsigned short disable_dl_timeout;
char *print_format;
char *pformat;
/* unfortunately, we have to keep track of paths both here and in the library
* because they can come from both the command line or config file, and we
* need to ensure we get the order of preference right. */
@@ -173,7 +172,6 @@ enum {
OP_ASEXPLICIT,
OP_ARCH,
OP_PRINTFORMAT,
OP_PFORMAT,
OP_GPGDIR,
OP_DBONLY,
OP_FORCE,

View File

@@ -651,9 +651,6 @@ static int parsearg_trans(int opt)
free(config->print_format);
config->print_format = strdup(optarg);
break;
case OP_PFORMAT:
config->pformat = strdup(optarg);
break;
case OP_ASSUMEINSTALLED:
parsearg_util_addlist(&(config->assumeinstalled));
break;
@@ -947,7 +944,6 @@ static int parseargs(int argc, char *argv[])
{"asexplicit", no_argument, 0, OP_ASEXPLICIT},
{"arch", required_argument, 0, OP_ARCH},
{"print-format", required_argument, 0, OP_PRINTFORMAT},
{"pformat" , required_argument, 0, OP_PFORMAT},
{"gpgdir", required_argument, 0, OP_GPGDIR},
{"dbonly", no_argument, 0, OP_DBONLY},
{"color", required_argument, 0, OP_COLOR},

View File

@@ -1168,10 +1168,6 @@ double humanize_size(off_t bytes, const char target_unit, int precision,
void print_packages(const alpm_list_t *packages)
{
const alpm_list_t *i;
if(config->pformat) {
alpm_info_print_pkgs(config->pformat, (alpm_list_t*) packages);
return;
}
if(!config->print_format) {
config->print_format = strdup("%l");
}

View File

@@ -65,7 +65,7 @@ Use the "help" option to get the full list of parameters:
When run with the `--valgrind' option, an additional rule will be added to all
tests to check for memory leaks. To use `--valgrind' when running the full
test suite, run:
make PY_LOG_FLAGS=--valgrind check
PACTEST_VALGRIND=1 ninja test
The following pieces of software are required to run the pactest suite: