From f58de40f2e8bd8958e72731892027f0a13612d3c Mon Sep 17 00:00:00 2001 From: Aditya Alok Date: Sat, 12 Mar 2022 10:51:12 +0530 Subject: [PATCH] feat(build-package.sh): create debscripts for haskell packages Signed-off-by: Aditya Alok --- build-package.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/build-package.sh b/build-package.sh index 5ef4b188e..faf84cdb2 100755 --- a/build-package.sh +++ b/build-package.sh @@ -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.