scripts: Honor the -e flag for scripts
This is required for glibc-all-langpacks at least: https://bugzilla.redhat.com/show_bug.cgi?id=1367585 Otherwise, its usage is...extraordinarily rare. In fact looking at a snapshot of `rpm-specs-20170518.tar.xz` from Fedora, the only other use is in `postfix.spec`, and it appears bogus (the value is already expanded at build time). But the glibc case is special, as the value of `install_langs` is indeed potentially dynamic per system. Closes: #873 Approved by: jlebon
This commit is contained in:
parent
4222407657
commit
1f3ebba982
@ -28,6 +28,13 @@
|
||||
|
||||
#include "rpmostree-scripts.h"
|
||||
|
||||
/* This bit is currently private in librpm */
|
||||
enum rpmscriptFlags_e {
|
||||
RPMSCRIPT_FLAG_NONE = 0,
|
||||
RPMSCRIPT_FLAG_EXPAND = (1 << 0), /* macro expansion */
|
||||
RPMSCRIPT_FLAG_QFORMAT = (1 << 1), /* header queryformat expansion */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const char *desc;
|
||||
rpmsenseFlags sense;
|
||||
@ -224,8 +231,12 @@ impl_run_rpm_script (const KnownRpmScriptKind *rpmscript,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
g_autofree char *script_owned = NULL;
|
||||
const char *script = headerGetString (hdr, rpmscript->tag);
|
||||
g_assert (script);
|
||||
const rpmFlags flags = headerGetNumber (hdr, rpmscript->flagtag);
|
||||
if (flags & RPMSCRIPT_FLAG_EXPAND)
|
||||
script = script_owned = rpmExpand (script, NULL);
|
||||
|
||||
struct rpmtd_s td;
|
||||
g_autofree char **args = NULL;
|
||||
|
@ -377,7 +377,7 @@ Summary: %{name}
|
||||
License: GPLv2+
|
||||
EOF
|
||||
|
||||
local build= install= files= pretrans= pre= post= posttrans= post_interp=
|
||||
local build= install= files= pretrans= pre= post= posttrans= post_args=
|
||||
while [ $# -ne 0 ]; do
|
||||
local section=$1; shift
|
||||
local arg=$1; shift
|
||||
@ -388,8 +388,8 @@ EOF
|
||||
echo "Provides: $arg" >> $spec;;
|
||||
conflicts)
|
||||
echo "Conflicts: $arg" >> $spec;;
|
||||
post_interp)
|
||||
post_interp="$arg"; post="$1"; shift;;
|
||||
post_args)
|
||||
post_args="$arg";;
|
||||
version|release|arch|build|install|files|pretrans|pre|post|posttrans)
|
||||
declare $section="$arg";;
|
||||
*)
|
||||
@ -417,7 +417,7 @@ $pretrans
|
||||
${pre:+%pre}
|
||||
$pre
|
||||
|
||||
${post:+%post} ${post_interp:+-p ${post_interp}}
|
||||
${post:+%post} ${post_args}
|
||||
$post
|
||||
|
||||
${posttrans:+%posttrans}
|
||||
|
@ -32,7 +32,8 @@ vm_build_rpm scriptpkg1 \
|
||||
pre "groupadd -r scriptpkg1" \
|
||||
pretrans "# http://lists.rpm.org/pipermail/rpm-ecosystem/2016-August/000391.html
|
||||
echo i should've been ignored && exit 1" \
|
||||
post_interp /usr/bin/python 'open("/usr/lib/rpmostreetestinterp", "w")' \
|
||||
post_args "-p /usr/bin/python" \
|
||||
post 'open("/usr/lib/rpmostreetestinterp", "w")' \
|
||||
posttrans "# Firewalld; https://github.com/projectatomic/rpm-ostree/issues/638
|
||||
. /etc/os-release || :
|
||||
# See https://github.com/projectatomic/rpm-ostree/pull/647
|
||||
@ -63,6 +64,19 @@ echo "ok group scriptpkg1 active"
|
||||
vm_has_files "/usr/lib/rpmostreetestinterp"
|
||||
echo "ok interp"
|
||||
|
||||
vm_build_rpm scriptpkg2 \
|
||||
post_args "-e" \
|
||||
post 'echo %%{_prefix} > /usr/lib/prefixtest.txt'
|
||||
vm_build_rpm scriptpkg3 \
|
||||
post 'echo %%{_prefix} > /usr/lib/noprefixtest.txt'
|
||||
vm_rpmostree pkg-add scriptpkg{2,3}
|
||||
vm_rpmostree ex livefs
|
||||
vm_cmd cat /usr/lib/noprefixtest.txt > noprefixtest.txt
|
||||
assert_file_has_content noprefixtest.txt '%{_prefix}'
|
||||
vm_cmd cat /usr/lib/prefixtest.txt > prefixtest.txt
|
||||
assert_file_has_content prefixtest.txt "/usr"
|
||||
echo "ok script expansion"
|
||||
|
||||
# And now, things that should fail
|
||||
vm_build_rpm rofiles-violation \
|
||||
post "echo should fail >> /usr/share/licenses/glibc/COPYING"
|
||||
|
Loading…
Reference in New Issue
Block a user