diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-03-11 12:06:49 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-03-11 12:06:49 +0200 |
commit | d370816ba508a33cc39252cbb9ba85dcd99504d5 (patch) | |
tree | 1eb5a3af5091ba2bb24a26709f5440f9b4f6b7a8 /build/pack.c | |
parent | d0a959a571d7b34ea2263619b8cfba623a425c44 (diff) | |
download | rpm-d370816ba508a33cc39252cbb9ba85dcd99504d5.tar.gz rpm-d370816ba508a33cc39252cbb9ba85dcd99504d5.tar.bz2 rpm-d370816ba508a33cc39252cbb9ba85dcd99504d5.zip |
Support run-time macro and queryformat expansion on scriptlets
- Add per-scriptlet type flag tags to control special behavior.
- Add rpmlib dependency on scriptlet expansion - if a package relies
on scriptlet expansion it cannot be correctly installed with
a version of rpm that doesn't support it.
- Expansion is always an opt-in behavior, enabled with -q and/or -e argument
in spec. We can't just blindly expand even macros as there's no telling
%{} constructs might mean in whatever language is used for the script.
- Queryformat expansion requires great care with strange and ugly escapes
when writing scriptlets, but OTOH it permits access arbitrary header
data at runtime, which has previously been completely impossible.
- The handling of these expansions needs unifying for all scriptlet types,
the trigger scriptlet handling is uuugly. Macro expansion could be
transparently done from rpmScriptRun(), but because of their similar
syntax, macro expansion needs to happen before query format expansion,
and we dont have the header available in rpmScriptrun()
Diffstat (limited to 'build/pack.c')
-rw-r--r-- | build/pack.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/build/pack.c b/build/pack.c index 1857257e4..fa947bff5 100644 --- a/build/pack.c +++ b/build/pack.c @@ -185,6 +185,7 @@ static int addFileToArrayTag(rpmSpec spec, const char *file, Header h, rpmTag ta static rpmRC processScriptFiles(rpmSpec spec, Package pkg) { struct TriggerFileEntry *p; + int addflags = 0; if (pkg->preInFile) { if (addFileToTag(spec, pkg->preInFile, pkg->header, RPMTAG_PREIN)) { @@ -237,8 +238,20 @@ static rpmRC processScriptFiles(rpmSpec spec, Package pkg) } } + /* if any trigger has flags, we need to add flags entry for all of them */ + for (p = pkg->triggerFiles; p != NULL; p = p->next) { + if (p->flags) { + addflags = 1; + break; + } + } + for (p = pkg->triggerFiles; p != NULL; p = p->next) { headerPutString(pkg->header, RPMTAG_TRIGGERSCRIPTPROG, p->prog); + if (addflags) { + headerPutUint32(pkg->header, RPMTAG_TRIGGERSCRIPTFLAGS, + &p->flags, 1); + } if (p->script) { headerPutString(pkg->header, RPMTAG_TRIGGERSCRIPTS, p->script); |