It's documented at www.rpm.org, Red Hat and SuSE.

https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/
https://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets
https://rpm-packaging-guide.github.io/

It's available since RPM 4.4. RPM 4.16.1.3 is in Hardknott.

A short Google search showed that *maybe* dpkg also supports it,
or at least there are(were?) plans to implement it:
https://wiki.debian.org/i18n/TranslationDebsProposals

With postinst, the time when the scriptlet runs may depend
on the order of the packages in the upgrade transaction and
may run with the older binaries in place.

The posttrans scriptlet runs at the very end of the
install/upgrade transaction, just like the OPKG "intercept"
scripts.

I successfully tested it long ago with a kernel upgrade
that was running dracut on the new version, plus a dracut
upgrade in the same session. Dissecting the initramfs proved
that with postinst, the old dracut version generated it,
while with posttrans, the new one did.

Who would want to use it? Anyone who needs some finalizer
script to be run at the end of an RPM/DNF transaction.

I started on Angstrom and I know opkg doesn't implement this
and Yocto inherited it. This patch is basically a heads up
that there's another way to do the same thing. Maybe opkg
implements this some day, maybe not. Anyway, Yocto in general
will need more changes before the main package.bbclass can
start to use it for all package formats.

Zoltán

2021. 08. 23. 14:34 keltezéssel, Alexander Kanavin írta:
This needs to be better documented and tested.

What does this posttrans thing really do?
Who would want to use it?
Can there be examples?
Can the Postinst test in meta/lib/oeqa/selftest/cases/runtime_test.py be extended to regression-check that it works?

Alex

On Mon, 23 Aug 2021 at 14:23, Zoltan Boszormenyi via lists.openembedded.org <http://lists.openembedded.org> <[email protected] <mailto:[email protected]>> wrote:

    From: Zoltán Böszörményi <[email protected] <mailto:[email protected]>>

    The "posttrans" scriptlet is the RPM equivalent of the
    OPKG "intercept script" concept and probably a cleaner one.

    "pretrans" also exists in RPM but there's no equivalent
    for it in OPKG.

    Signed-off-by: Zoltán Böszörményi <[email protected] 
<mailto:[email protected]>>
    ---
      meta/classes/package_rpm.bbclass | 30 +++++++++++++++++++++---------
      1 file changed, 21 insertions(+), 9 deletions(-)

    diff --git a/meta/classes/package_rpm.bbclass 
b/meta/classes/package_rpm.bbclass
    index 88d861c0e7..5992d3fd06 100644
    --- a/meta/classes/package_rpm.bbclass
    +++ b/meta/classes/package_rpm.bbclass
    @@ -308,10 +308,11 @@ python write_specfile () {
          srcrconflicts  = ""
          srcrobsoletes  = ""

    -    srcrpreinst  = []
    -    srcrpostinst = []
    -    srcrprerm    = []
    -    srcrpostrm   = []
    +    srcrpreinst   = []
    +    srcrpostinst  = []
    +    srcrprerm     = []
    +    srcrpostrm    = []
    +    srcrposttrans = []

          spec_preamble_top = []
          spec_preamble_bottom = []
    @@ -373,11 +374,11 @@ python write_specfile () {
              splitrconflicts  = localdata.getVar('RCONFLICTS') or ""
              splitrobsoletes  = ""

    -        splitrpreinst  = localdata.getVar('pkg_preinst')
    -        splitrpostinst = localdata.getVar('pkg_postinst')
    -        splitrprerm    = localdata.getVar('pkg_prerm')
    -        splitrpostrm   = localdata.getVar('pkg_postrm')
    -
    +        splitrpreinst   = localdata.getVar('pkg_preinst')
    +        splitrpostinst  = localdata.getVar('pkg_postinst')
    +        splitrprerm     = localdata.getVar('pkg_prerm')
    +        splitrpostrm    = localdata.getVar('pkg_postrm')
    +        splitrposttrans = localdata.getVar('pkg_posttrans')

              if not perfiledeps:
                  # Add in summary of per file dependencies
    @@ -405,6 +406,7 @@ python write_specfile () {
                  srcrpostinst   = splitrpostinst
                  srcrprerm      = splitrprerm
                  srcrpostrm     = splitrpostrm
    +            srcrposttrans  = splitrposttrans

                  file_list = []
                  walk_files(root, file_list, conffiles, dirfiles)
    @@ -496,6 +498,11 @@ python write_specfile () {
                  scriptvar = wrap_uninstall(splitrpostrm)
                  spec_scriptlets_bottom.append(scriptvar)
                  spec_scriptlets_bottom.append('')
    +        if splitrposttrans:
    +            spec_scriptlets_bottom.append('%%posttrans -n %s' % splitname)
    +            spec_scriptlets_bottom.append('# %s - posttrans' % splitname)
    +            spec_scriptlets_bottom.append(splitrposttrans)
    +            spec_scriptlets_bottom.append('')

              # Now process files
              file_list = []
    @@ -590,6 +597,11 @@ python write_specfile () {
              scriptvar = wrap_uninstall(srcrpostrm)
              spec_scriptlets_top.append(scriptvar)
              spec_scriptlets_top.append('')
    +    if srcrposttrans:
    +        spec_scriptlets_top.append('%posttrans')
    +        spec_scriptlets_top.append('# %s - posttrans' % srcname)
    +        spec_scriptlets_top.append(srcrposttrans)
    +        spec_scriptlets_top.append('')

          # Write the SPEC file
          specfile = open(outspecfile, 'w')
-- 2.31.1









-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#155155): 
https://lists.openembedded.org/g/openembedded-core/message/155155
Mute This Topic: https://lists.openembedded.org/mt/85083966/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to