From 2c8207cdba71b53ba8705fa6115bbaa262fa21a3 Mon Sep 17 00:00:00 2001 From: Erik Rantapaa Date: Tue, 9 Jun 2015 13:35:35 -0400 Subject: [PATCH] Add Posix installer script --- .../installer/install-haskell-platform.sh | 32 +++++++++++++++++++ hptool/src/OS/Posix.hs | 24 +++++++++----- 2 files changed, 48 insertions(+), 8 deletions(-) create mode 100755 hptool/os-extras/posix/installer/install-haskell-platform.sh diff --git a/hptool/os-extras/posix/installer/install-haskell-platform.sh b/hptool/os-extras/posix/installer/install-haskell-platform.sh new file mode 100755 index 0000000..0d7c49d --- /dev/null +++ b/hptool/os-extras/posix/installer/install-haskell-platform.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# +# This is the Haskell Platform installer script for Posix systems. +# +# It expects a tar archive named "hp-usr-local.tar.gz" to be present +# in the current working directory. +# +# It will unpack the archive at / and run the activate-hs script. +# +# This script needs be run as root. + +usr_local_tar="./hp-usr-local.tar.gz" + +if ! test -f ""$usr_local_tar""; then + echo Archive $usr_local_tar not found. + exit 1 +fi + +if ! test -w /; then + echo "The directory / is not writable. Please run this script as root." + exit 1 +fi + +echo "Unpacking $usr_local_tar to /..." +if ! tar -C / -xf "$usr_local_tar"; then + echo "Unpack failed - aborting installation." + exit 1 +fi + +echo "Running /usr/local/bin/activate-hs ..." +/usr/local/bin/activate-hs + diff --git a/hptool/src/OS/Posix.hs b/hptool/src/OS/Posix.hs index 0b17e42..d2d3a2a 100644 --- a/hptool/src/OS/Posix.hs +++ b/hptool/src/OS/Posix.hs @@ -67,6 +67,9 @@ posixOS BuildConfig{..} = OS{..} osDocAction = return () osProduct = productDir productName ++ ".tar.gz" + usrLocalTar = productDir "hp-usr-local" ++ ".tar.gz" + installScript = extrasDir "installer" "install-haskell-platform.sh" + productName = "haskell-platform-" ++ showVersion hpVersion ++ "-unknown-posix-" ++ bcArch @@ -78,19 +81,24 @@ posixOS BuildConfig{..} = OS{..} copyExpandedDir ctx genericExtrasSrc dst osProduct %> \out -> do - need [targetDir, vdir ghcVirtualTarget] - command_ [Cwd targetDir] - "tar" ["czf", out ® targetDir, hpTargetDir ® targetDir] + let installFile = takeFileName installScript + need [ usrLocalTar, dir extrasDir] + command_ [] "cp" [ installScript, productDir ] + command_ [Cwd productDir] + "tar" ["czf", out ® targetDir, installFile, usrLocalTar ® productDir ] mapM_ putNormal [ replicate 72 '-' , "To install this build:" - , "1) copy " ++ out ++ " (found in " ++ targetDir - ++ ") to the target machine" - , "2) untar it at / (files in the archive have the prefix " - ++ relPrefix ++ ")" - , "3) run the script " ++ absVersionDir ++ "/bin/activate-hs" + , "1) copy " ++ out ++ " to the target machine" + , "2) untar it (creates files in the working directory)" + , "3) as root, run the script ./" ++ installFile ] + usrLocalTar %> \out -> do + need [targetDir, vdir ghcVirtualTarget] + command_ [Cwd targetDir] + "tar" ["czf", out ® targetDir, hpTargetDir ® targetDir] + versionFile %> \out -> do writeFileChanged out $ unlines [ "platform " ++ showVersion hpVersion