Skip to content

Commit

Permalink
Add Posix installer script
Browse files Browse the repository at this point in the history
  • Loading branch information
erantapaa committed Jun 9, 2015
1 parent 6950d8c commit 2c8207c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
32 changes: 32 additions & 0 deletions 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

24 changes: 16 additions & 8 deletions hptool/src/OS/Posix.hs
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 2c8207c

Please sign in to comment.