[pacman-dev] [PATCH] meson: add configure-time option to run tests with valgrind
ninja doesn't support dynamic modification of commands via command-line defines the way Make does. Resolves a major blocker for FS#64394 Signed-off-by: Eli Schwartz --- meson_options.txt | 4 test/pacman/meson.build | 3 +++ 2 files changed, 7 insertions(+) diff --git a/meson_options.txt b/meson_options.txt index 4d8cc300..80d9422a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -54,3 +54,7 @@ option('i18n', type : 'boolean', value : true, # tools option('file-seccomp', type: 'feature', value: 'auto', description: 'determine whether file is seccomp-enabled') + +# test options +option('valgrind', type : 'boolean', value : false, + description : 'run pacman tests using valgrind') diff --git a/test/pacman/meson.build b/test/pacman/meson.build index 4e87b4f3..2e0a2f5f 100644 --- a/test/pacman/meson.build +++ b/test/pacman/meson.build @@ -346,6 +346,9 @@ foreach input : pacman_tests if not conf.get('HAVE_LIBGPGME') args += '--without-gpg' endif + if get_option('valgrind') +args += '--valgrind' + endif test( test_name, -- 2.24.0
[pacman-dev] [PATCH v2] meson: make non-symlink scripts install for real, and use a better wrapper
We now generate the scripts using their real name, install them using meson's builtin facility instead of an install_script, and generate the wrapper scripts in the root of the build directory, instead of a subdirectory. This gets us closer to resolving FS#64394. Signed-off-by: Eli Schwartz --- v2: remove EXTRA_DIST file from autotools Makefile.am | 1 - build-aux/meson-install-script.sh | 6 - meson.build | 16 - scripts/meson.build | 38 ++- 4 files changed, 32 insertions(+), 29 deletions(-) delete mode 100644 build-aux/meson-install-script.sh diff --git a/Makefile.am b/Makefile.am index 9216ef00..fbbc2559 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,6 @@ EXTRA_DIST = \ HACKING test/tap.sh \ meson.build meson_options.txt \ build-aux/edit-script.sh.in \ - build-aux/meson-install-script.sh \ build-aux/meson-make-symlink.sh \ build-aux/script-wrapper.sh.in diff --git a/build-aux/meson-install-script.sh b/build-aux/meson-install-script.sh deleted file mode 100644 index f5a42fca.. --- a/build-aux/meson-install-script.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -built_script=$1 -dest_path=$2 - -install -Dm755 "$built_script" "$DESTDIR/$dest_path" diff --git a/meson.build b/meson.build index 2c9185a6..572526b2 100644 --- a/meson.build +++ b/meson.build @@ -32,7 +32,6 @@ SED = find_program('sed') DU = find_program('du') LDCONFIG = get_option('ldconfig') MESON_MAKE_SYMLINK = join_paths(meson.source_root(), 'build-aux/meson-make-symlink.sh') -MESON_INSTALL_SCRIPT = join_paths(meson.source_root(), 'build-aux/meson-install-script.sh') BASH = find_program('bash4', 'bash') if BASH.found() @@ -366,6 +365,21 @@ executable( install : true, ) +foreach wrapper : script_wrappers + cdata = configuration_data() + cdata.set_quoted('BASH', BASH.path()) + cdata.set_quoted('BUILDDIR', wrapper[2]) + cdata.set_quoted('REAL_PROGPATH', wrapper[1].full_path()) + + # Create a wrapper script that bootstraps the real script within the build + # directory. Use configure_file instead of a custom_target to ensure that + # permissions on the input script wrapper are preserved. + configure_file( +input : join_paths(meson.source_root(), 'build-aux', 'script-wrapper.sh.in'), +output : wrapper[0], +configuration : cdata) +endforeach + configure_file( input : 'etc/makepkg.conf.in', output : 'makepkg.conf', diff --git a/scripts/meson.build b/scripts/meson.build index 696d8ddd..d2466523 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -26,42 +26,38 @@ foreach script : scripts install_dir : get_option('bindir')) endforeach +script_wrappers = [] foreach script : wrapped_scripts script_shortname = script.split('.')[0] - # Build the script, but don't install it. We want to keep it as a "private" - # artifact that we reference from a wrapper script in order to bootstrap it - # the build directory. internal_script = custom_target( script, input : script, command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@', '0755'], -output : script, -build_by_default : true) - - cdata = configuration_data() - cdata.set_quoted('BASH', BASH.path()) - cdata.set_quoted('BUILDDIR', meson.current_build_dir()) - cdata.set_quoted('REAL_PROGPATH', internal_script.full_path()) - - # Create a wrapper script that bootstraps the real script within the build - # directory. Use configure_file instead of a custom_target to ensure that - # permissions on the input script wrapper are preserved. - configure_file( -input : join_paths(meson.source_root(), 'build-aux', 'script-wrapper.sh.in'), output : script_shortname, -configuration : cdata) +install : true, +install_dir : BINDIR) + + script_wrappers += [[ script_shortname, internal_script, meson.current_build_dir() ]] - # Install the real script - meson.add_install_script(MESON_INSTALL_SCRIPT, - internal_script.full_path(), - join_paths(BINDIR, script_shortname)) + if script_shortname == 'repo-add' +repo_add = internal_script + endif endforeach foreach symlink : ['repo-remove', 'repo-elephant'] meson.add_install_script(MESON_MAKE_SYMLINK, 'repo-add', join_paths(BINDIR, symlink)) + + internal_script = custom_target( +symlink, +build_by_default : true, +command : ['ln', '-sf', 'repo-add', '@OUTPUT@'], +depends : repo_add, +output : symlink) + + script_wrappers += [[ symlink, internal_script, meson.current_build_dir() ]] endforeach subdir('libmakepkg') -- 2.24.0
[pacman-dev] [PATCH] pactest: set package tar format to GNU_FORMAT
python-3.8 changed the default tar format to PAX_FORMAT. This caused issues in our testsuite with package extraction of files with UTF-8 characters as we run the tests under the C locale. sycn600.py: error: error while reading package /tmp/pactest-xuhri4xa/var/cache/pacman/pkg/unicodechars-2.0-1.pkg.tar.gz: Pathname can't be converted from UTF-8 to current locale. Set format back to GNU_FORMAT. Signed-off-by: Allan McRae --- This patch at least gets us back to where we were with python-3.7. We probably have heaps more issues with UTF-8 usage... test/pacman/pmpkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py index 6a845222..e40868cc 100644 --- a/test/pacman/pmpkg.py +++ b/test/pacman/pmpkg.py @@ -142,7 +142,7 @@ def makepkg(self, path): util.mkdir(os.path.dirname(self.path)) # Generate package metadata -tar = tarfile.open(self.path, "w:gz") +tar = tarfile.open(self.path, "w:gz", format=tarfile.GNU_FORMAT) for name, data in archive_files: info = tarfile.TarInfo(name) info.size = len(data) -- 2.24.0
Re: [pacman-dev] [PATCH] meson: make non-symlink scripts install for real, and use a better wrapper
On 11/11/19 11:19 PM, Eli Schwartz wrote: > We now generate the scripts using their real name, install them using > meson's builtin facility instead of an install_script, and generate the > wrapper scripts in the root of the build directory, instead of a > subdirectory. > > This gets us closer to resolving FS#64394. > > Signed-off-by: Eli Schwartz > --- > > This sort of seems to work, but passing variables around between > different meson.build files feels awkward. On the plus side, fewer > build-aux/ scripts! [...] > delete mode 100644 build-aux/meson-install-script.sh Yeah... missing removal in Makefile.am's EXTRA_DIST... on the plus side I'd actually run ninja dist for this patch, and that works... -- Eli Schwartz Bug Wrangler and Trusted User signature.asc Description: OpenPGP digital signature
[pacman-dev] [PATCH] meson: make non-symlink scripts install for real, and use a better wrapper
We now generate the scripts using their real name, install them using meson's builtin facility instead of an install_script, and generate the wrapper scripts in the root of the build directory, instead of a subdirectory. This gets us closer to resolving FS#64394. Signed-off-by: Eli Schwartz --- This sort of seems to work, but passing variables around between different meson.build files feels awkward. On the plus side, fewer build-aux/ scripts! Is this a desirable experience? We now create all the wrapped scripts in the root of the build tree, which matches what we do for the pacman binaries and so on, and I guess this should be fine since unlike autotools we do not need to care about dirtying the source tree (we cannot do in-tree builds). It is more convenient accessing the scripts from there, too, and in fact we now create wrappers for repo-elephant (long may he live), pacman-key, pacman-db-upgrade, etc as well. build-aux/meson-install-script.sh | 6 - meson.build | 16 - scripts/meson.build | 38 ++- 3 files changed, 32 insertions(+), 28 deletions(-) delete mode 100644 build-aux/meson-install-script.sh diff --git a/build-aux/meson-install-script.sh b/build-aux/meson-install-script.sh deleted file mode 100644 index f5a42fca.. --- a/build-aux/meson-install-script.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -built_script=$1 -dest_path=$2 - -install -Dm755 "$built_script" "$DESTDIR/$dest_path" diff --git a/meson.build b/meson.build index 2c9185a6..572526b2 100644 --- a/meson.build +++ b/meson.build @@ -32,7 +32,6 @@ SED = find_program('sed') DU = find_program('du') LDCONFIG = get_option('ldconfig') MESON_MAKE_SYMLINK = join_paths(meson.source_root(), 'build-aux/meson-make-symlink.sh') -MESON_INSTALL_SCRIPT = join_paths(meson.source_root(), 'build-aux/meson-install-script.sh') BASH = find_program('bash4', 'bash') if BASH.found() @@ -366,6 +365,21 @@ executable( install : true, ) +foreach wrapper : script_wrappers + cdata = configuration_data() + cdata.set_quoted('BASH', BASH.path()) + cdata.set_quoted('BUILDDIR', wrapper[2]) + cdata.set_quoted('REAL_PROGPATH', wrapper[1].full_path()) + + # Create a wrapper script that bootstraps the real script within the build + # directory. Use configure_file instead of a custom_target to ensure that + # permissions on the input script wrapper are preserved. + configure_file( +input : join_paths(meson.source_root(), 'build-aux', 'script-wrapper.sh.in'), +output : wrapper[0], +configuration : cdata) +endforeach + configure_file( input : 'etc/makepkg.conf.in', output : 'makepkg.conf', diff --git a/scripts/meson.build b/scripts/meson.build index 696d8ddd..d2466523 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -26,42 +26,38 @@ foreach script : scripts install_dir : get_option('bindir')) endforeach +script_wrappers = [] foreach script : wrapped_scripts script_shortname = script.split('.')[0] - # Build the script, but don't install it. We want to keep it as a "private" - # artifact that we reference from a wrapper script in order to bootstrap it - # the build directory. internal_script = custom_target( script, input : script, command : [ SCRIPT_EDITOR, '@INPUT@', '@OUTPUT@', '0755'], -output : script, -build_by_default : true) - - cdata = configuration_data() - cdata.set_quoted('BASH', BASH.path()) - cdata.set_quoted('BUILDDIR', meson.current_build_dir()) - cdata.set_quoted('REAL_PROGPATH', internal_script.full_path()) - - # Create a wrapper script that bootstraps the real script within the build - # directory. Use configure_file instead of a custom_target to ensure that - # permissions on the input script wrapper are preserved. - configure_file( -input : join_paths(meson.source_root(), 'build-aux', 'script-wrapper.sh.in'), output : script_shortname, -configuration : cdata) +install : true, +install_dir : BINDIR) + + script_wrappers += [[ script_shortname, internal_script, meson.current_build_dir() ]] - # Install the real script - meson.add_install_script(MESON_INSTALL_SCRIPT, - internal_script.full_path(), - join_paths(BINDIR, script_shortname)) + if script_shortname == 'repo-add' +repo_add = internal_script + endif endforeach foreach symlink : ['repo-remove', 'repo-elephant'] meson.add_install_script(MESON_MAKE_SYMLINK, 'repo-add', join_paths(BINDIR, symlink)) + + internal_script = custom_target( +symlink, +build_by_default : true, +command : ['ln', '-sf', 'repo-add', '@OUTPUT@'], +depends : repo_add, +output : symlink) + + script_wrappers += [[ symlink, internal_script, meson.current_build_dir() ]] endforeach subdir('libmakepkg') -- 2.24.0
[pacman-dev] [PATCH] pacman: print error when -Fx is given invalid regex
When processing the targets for -Fx, compile all the regex ahead of time, printing an error for each that failed to compile. Then, if they all compiled successfully, continue with printing files. Signed-off-by: morganamilo diff --git a/src/pacman/files.c b/src/pacman/files.c index 3b6dc23b..91d891a6 100644 --- a/src/pacman/files.c +++ b/src/pacman/files.c @@ -94,17 +94,26 @@ static void print_match(alpm_list_t *match, alpm_db_t *repo, alpm_pkg_t *pkg, in } } +struct filetarget { + char *targ; + int exact_file; + regex_t reg; +}; + +static void filetarget_free(struct filetarget *ftarg) { + regfree(>reg); + free(ftarg); +} + static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { int ret = 0; - alpm_list_t *t; + alpm_list_t *t, *filetargs = NULL; for(t = targets; t; t = alpm_list_next(t)) { char *targ = t->data; - alpm_list_t *s; - int found = 0; - regex_t reg; size_t len = strlen(targ); int exact_file = strchr(targ, '/') != NULL; + regex_t reg; if(exact_file) { while(len > 1 && targ[0] == '/') { @@ -115,11 +124,33 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { if(regex) { if(regcomp(, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) { - /* TODO: error message */ - goto notfound; + pm_printf(ALPM_LOG_ERROR, + _("invalid regular expression '%s'\n"), targ); + ret = 1; + continue; } } + struct filetarget *ftarg = malloc(sizeof(struct filetarget)); + ftarg->targ = targ; + ftarg->exact_file = exact_file; + ftarg->reg = reg; + + filetargs = alpm_list_add(filetargs, ftarg); + } + + if(ret != 0) { + goto cleanup; + } + + for(t = filetargs; t; t = alpm_list_next(t)) { + struct filetarget *ftarg = t->data; + char *targ = ftarg->targ; + regex_t *reg = >reg; + int exact_file = ftarg->exact_file; + alpm_list_t *s; + int found = 0; + for(s = syncs; s; s = alpm_list_next(s)) { alpm_list_t *p; alpm_db_t *repo = s->data; @@ -135,7 +166,7 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { if (regex) { for(size_t f = 0; f < files->count; f++) { char *c = files->files[f].name; - if(regexec(, c, 0, 0, 0) == 0) { + if(regexec(reg, c, 0, 0, 0) == 0) { match = alpm_list_add(match, files->files[f].name); found = 1; } @@ -151,7 +182,7 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { char *c = strrchr(files->files[f].name, '/'); if(c && *(c + 1)) { if(regex) { - m = regexec(, (c + 1), 0, 0, 0); + m = regexec(reg, (c + 1), 0, 0, 0); } else { m = strcmp(c + 1, targ); } @@ -170,16 +201,15 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { } } - if(regex) { - regfree(); - } - -notfound: if(!found) { ret = 1; } } +cleanup: + alpm_list_free_inner(filetargs, (alpm_list_fn_free) filetarget_free); + alpm_list_free(filetargs); + return ret; } -- 2.23.0
[pacman-dev] [PATCH] libalpm/sync.c: Do not download missing keys multiple times
We now store key structs of our missing key info, so can not search the list for string matches. This caused missing keys to be downloaded once for every package they signed. Signed-off-by: Allan McRae --- lib/libalpm/sync.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 59108eb9..70c37890 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -873,6 +873,14 @@ finish: } #ifdef HAVE_LIBGPGME + +static int key_cmp(const void *k1, const void *k2) { + const struct keyinfo_t *key1 = k1; + const char *key2 = k2; + + return strcmp(key1->keyid, key2); +} + static int check_keyring(alpm_handle_t *handle) { size_t current = 0, numtargs; @@ -910,7 +918,7 @@ static int check_keyring(alpm_handle_t *handle) alpm_list_t *k; for(k = keys; k; k = k->next) { char *key = k->data; - if(!alpm_list_find_str(errors, key) && + if(!alpm_list_find(errors, key, key_cmp) && _alpm_key_in_keychain(handle, key) == 0) { keyinfo = malloc(sizeof(struct keyinfo_t)); if(!keyinfo) { @@ -940,7 +948,7 @@ static int check_keyring(alpm_handle_t *handle) alpm_list_t *k; for(k = errors; k; k = k->next) { keyinfo = k->data; - if(_alpm_key_import(handle, keyinfo->uid, keyinfo->keyid) == -1) { + if(_alpm_key_import(handle, keyinfo->uid, keyinfo->keyid) == -1) { fail = 1; } free(keyinfo->uid); -- 2.24.0