feat(build-package.sh): create debscripts for haskell packages

Signed-off-by: Aditya Alok <dev.aditya.alok@gmail.com>
This commit is contained in:
Aditya Alok 2022-03-12 10:51:12 +05:30 committed by Henrik Grimler
parent 0590811415
commit f58de40f2e
No known key found for this signature in database
GPG Key ID: B0076E490B71616B

View File

@ -268,14 +268,24 @@ termux_step_post_massage() {
return
}
# Create debscripts for haskell packages. This only executes for haskell lib packages.
# shellcheck source=scripts/build/haskell-build/termux_create_haskell_debscripts.sh
source "$TERMUX_SCRIPTDIR/scripts/build/haskell-build/termux_create_haskell_debscripts.sh"
# Hook function to create {pre,post}install, {pre,post}rm-scripts and similar
termux_step_create_debscripts() {
# This function is written here as it will allow overriding from build.sh.
termux_create_haskell_debscripts
# Create debscripts for haskell packages.
if ls "${TERMUX_PKG_SRCDIR}"/*.cabal &>/dev/null && [ "${TERMUX_PKG_IS_HASKELL_LIB}" = true ]; then
cat <<-EOF >./postinst
#!${TERMUX_PREFIX}/bin/sh
sh ${TERMUX_PREFIX}/share/haskell/register/${TERMUX_PKG_NAME}.sh
EOF
cat <<-EOF >./prerm
#!${TERMUX_PREFIX}/bin/sh
if [ "${TERMUX_PACKAGE_FORMAT}" = "pacman" ] || [ "\$1" = "remove" ] || [ "\$1" = "update" ]; then
sh ${TERMUX_PREFIX}/share/haskell/unregister/${TERMUX_PKG_NAME}.sh
fi
EOF
else
return 0
fi
}
# Convert Debian maintainer scripts into pacman-compatible installation hooks.