]> gitweb @ CieloNegro.org - build-hc-pkg.git/blob - build-hc-pkg
detect the name of GNU tar
[build-hc-pkg.git] / build-hc-pkg
1 #!/usr/bin/env bash
2 set -e
3 declare canon_name="canon-name/src/canon-name"
4 declare archive="work/archive"
5
6 if [[ ! -x "$canon_name" ]]; then
7     gmake -f mk/canon-name.mk
8 fi
9 readonly platform=$("$canon_name")
10
11 echo "This is build-hc-pkg, running on \"$platform\"."
12
13 if [[ "$1" = "clean" ]]; then
14     echo "Cleaning..."
15     rm -rf work
16     exit
17 fi
18
19 declare srcpath=""
20 if [[ -e "$archive" ]]; then
21     srcpath=$(cat "$archive")
22 fi
23
24 if [[ -z "$srcpath" || ! -e "$srcpath" ]]; then
25     mkdir -p work
26     read -e -p "Enter the file path to ghc-x.y.z-src.tar.bz2: " srcpath
27     if [[ -e "$srcpath" ]]; then
28         mkdir -p work
29         echo "$srcpath" > "$archive"
30     else
31         echo "$srcpath not found." >&2
32         exit 1
33     fi
34 fi
35
36 # What's the name of our GNU tar?
37 declare gnutar=""
38 if which gnutar >/dev/null 2>&1; then
39     gnutar="gnutar"
40 elif which gtar >/dev/null 2>&1; then
41     gnutar="gtar"
42 else
43     echo "We need GNU tar to be installed." >&2
44     exit 1
45 fi
46
47 gmake -f mk/main.mk \
48     SRCPATH="$srcpath" \
49     PLATFORM="$platform" \
50     GNUTAR="$gnutar" \
51     SHELL="$SHELL"
52
53 echo "If you are done, run \"$0 clean\" to cleanup the working directory."