-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·120 lines (113 loc) · 4.18 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
set -e
# Defaults
FORCE=false
ATTEMPT_NIX_INSTALL=false
TMP=`getopt --name=$0 -a --longoptions=checkout-version:,cv:,force,playground:,for-development,attempt-nix-install -o p: -- $@`
eval set -- $TMP
until [ $1 == -- ]; do
case $1 in
--force)
FORCE=true;;
--attempt-nix-install)
ATTEMPT_NIX_INSTALL=true;;
# The remaining options are 'to be implemented'
# --cv|--checkout-version)
# CHECKOUT_VERSION="$2"
# shift;; # Remove option value.
# We leave this one active to allow early testing.
-p|--playground)
CONVEYOR_PLAYGROUND="$2"
shift;; # Remove option value.
esac
shift # Remove just-processed option.
done
shift # Remove the '--', now $1 positioned at first argument if any.
# /**
# * </div><!-- #Default-Values.section -->
# *
# * <div id="Prerequisite-Checks" class="section">
# * <div class="section-header"><span>Prerequisites Check</span></div>
# */
PREREQUISITES_GOOD='true'
# /**
# * Unless <code>--force</code>d, the OS+distro is explicitly
# * supported.
# */
if [[ $FORCE != 'true' ]]; then
DISTRO_SUPPORT_STATEMENT="Conveyor 0.1 supports openSuSE 13.1."
if [ ! -f /etc/SuSE-release ]; then
echo $DISTRO_SUPPORT_STATEMENT >&2
PREREQUISITES_GOOD='false'
else
# Wish the SuSE-release file was bash compatible...
VERSION=`grep 'VERSION' /etc/SuSE-release | awk '{print $3}'`
case "$VERSION" in
13.1)
;; # that's fine
*) # anything else though...
echo $DISTRO_SUPPORT_STATEMENT >&2
PREREQUISITES_GOOD='false'
;;
esac
fi
fi
# /**
# * Now we check absolute, un-forceable prerequisites.
# */
# Check if 'nix' is installed / available.
if [[ ! $(type -P nix-env) ]]; then
if [[ "$ATTEMPT_NIX_INSTALL" != "true" ]]; then
read -r -p "Nix installation not found, install? (y/N) " ANSWER
fi
if [[ "$ATTEMPT_NIX_INSTALL" == "true" ]] \
|| [[ "$ANSWER" =~ ^([yY]|[yY][eE][sS])$ ]]; then
# TODO: Implement MD5 check, target specific version.
bash <(curl https://nixos.org/nix/install)
source $HOME/.nix-profile/etc/profile.d/nix.sh
fi
fi
# If nix still not installed at this point, then we're out of luck.
if [[ ! $(type -P nix-env) ]]; then
echo "Could not find or install nix. After manually install nix," >&2
echo " try the installation again." >&2
exit 2
fi
# Setup DogFoodSoftware.com distro.
for DIR in "$HOME/.conveyor" \
"$HOME/.conveyor/subscriptions"; do
# We do the check and create because the '-p' can mask problems. Since
# we build from the bottom up, the 'create parents' effect is not
# necessary.
if [ ! -d "$DIR" ]; then
mkdir "$DIR"
fi
done
# Use local playground distro if present.
if [ -d "$HOME/playground/dogfoodsoftware.com/distro" ]; then
if [ -h "$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro" ]; then
if [[ `readlink "$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro"` == "$HOME/playground/dogfoodsoftware.com/distro" ]]; then
echo "Local DogFoodSoftware.com distro checkout already linked as subscription. Continuing..."
else
echo "Local DogFoodSoftware.com distro found, but subscription links to:" >&2
echo " `readlink '$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro'`" >&2
echo "bailing out. >&2"
exit 2
fi
elif [ -d "$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro" ]; then
echo "Found local dogfoodsoftware.com/distro checkout, but also" >&2
echo "'$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro' to use checkout, execute:" >&2
echo >&2
echo " rm -rf '$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro'"
echo >&2
echo "and re-run the install script."
exit 2
else # Then we have a local checkout, but no distro link; create it.
mkdir -p "$HOME/playground/dogfoodsoftware.com"
ln -s "$HOME/playground/dogfoodsoftware.com/distro" "$HOME/.conveyor/subscriptions/dogfoodsoftware.com/distro"
fi
else # No local checkout found, checkout from github.
mkdir -p "$HOME/.conveyor/subscriptions/dogfoodsoftware.com"
cd "$HOME/.conveyor/subscriptions/dogfoodsoftware.com"
git clone --depth 1 https://github.com/DogFoodSoftware/distro
fi