Skip to content

Commit

Permalink
Support different interpreters in prein/postin scriptlets
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed May 5, 2020
1 parent a25c882 commit 3692d82
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions build-pkg-rpm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ pkg_preinstall_rpm() {
fi
if test -e ".init_b_cache/scripts/$PKG.run" ; then
rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.pre"
rpm -qp --nodigest --nosignature --qf "%{PREINPROG}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.preprog"
rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post"
rpm -qp --nodigest --nosignature --qf "%{POSTINPROG}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.postprog"
echo -n '(none)' > .init_b_cache/scripts/.none
cmp -s ".init_b_cache/scripts/$PKG.pre" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.pre"
cmp -s ".init_b_cache/scripts/$PKG.post" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.post"
Expand All @@ -198,12 +200,16 @@ pkg_preinstall_rpm() {
pkg_runscripts_rpm() {
if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
echo "running $PKG preinstall script"
(cd $BUILD_ROOT && chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0)
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
local prog
read prog < "$BUILD_ROOT/.init_b_cache/scripts/$PKG.preprog"
(cd $BUILD_ROOT && chroot $BUILD_ROOT "${prog:-sh}" ".init_b_cache/scripts/$PKG.pre" 0)
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" "$BUILD_ROOT/.init_b_cache/scripts/$PKG.preprog"
fi
if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
echo "running $PKG postinstall script"
(cd $BUILD_ROOT && chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1)
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
local prog
read prog < "$BUILD_ROOT/.init_b_cache/scripts/$PKG.postprog"
(cd $BUILD_ROOT && chroot $BUILD_ROOT "${prog:-sh}" ".init_b_cache/scripts/$PKG.post" 1)
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" "$BUILD_ROOT/.init_b_cache/scripts/$PKG.postprog"
fi
}

0 comments on commit 3692d82

Please sign in to comment.