-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.sh
82 lines (68 loc) · 2.22 KB
/
bootstrap.sh
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
#!/usr/bin/env sh
no_prereqs() {
echo '# The toolset requires the following tools to be installed:'
echo '# - stow'
echo '# - git'
echo '# - curl'
echo '# - python3'
echo '# - realpath'
echo '# - giturlparse python module for python3'
echo '#'
exit 1
}
which stow >/dev/null 2>&1 || no_prereqs
which git >/dev/null 2>&1 || no_prereqs
which curl >/dev/null 2>&1 || no_prereqs
which python3 >/dev/null 2>&1 || no_prereqs
which realpath >/dev/null 2>&1 || no_prereqs
python3 -c 'import giturlparse' || no_prereqs
#
# Configuration
#
if [ -z $REPOS_ROOT ]; then
export REPOS_ROOT="$HOME/repos"
fi
if [ -z $STOW_DIR ]; then
export STOW_DIR="$HOME/stow"
fi
echo "# Configuration:"
echo "# Repos will be cloned into '$REPOS_ROOT'"
echo "# Packages will be stowed inside '$STOW_DIR'"
mkdir -p "$REPOS_ROOT" "$STOW_DIR"
# Get the clonerepo tool
TMPDIR=$(mktemp -d)
echo "Temporary directory will be '$TMPDIR'"
(
cd "$TMPDIR"; export PATH="$PWD:$PATH";
# Use redirection instead of -O beacuse curl installed from Ubuntu snap cannot write to arbitrary locations.
# Reference: https://github.com/woutervb/snap-curl/issues/2
# https://forum.snapcraft.io/t/classic-confinement-request-for-curl/24611
curl https://raw.githubusercontent.com/enkiusz/tools/master/bin/clonerepo > clonerepo
curl https://raw.githubusercontent.com/enkiusz/tools/master/bin/urlparse > urlparse
chmod +x clonerepo urlparse
clonerepo https://github.com/enkiusz/tools.git
)
# Create stow package
(
cd "$REPOS_ROOT/github.com/enkiusz/tools"
# This is needed only because we are bootstrapping an we don't have the tools
# stowed yet in a directory available in PATH
export PATH="$PWD/bin:$PATH"
./makepkgs
)
# Stow tools
( cd "$STOW_DIR"; stow tools )
echo ""
echo ""
echo "#"
echo "#"
echo "# Bootstrap completed"
echo "# You need to modify your PATH variable to include the $HOME/.local/bin directory"
echo "# For example, put the following in your $HOME/.profile"
echo "export PATH=\"\$PATH:\$HOME/.local/bin\""
echo ""
echo "In more recent Linux distributions this directory is added to the PATH automatically, so you can try"
echo "to logout and login again and see if the PATH variable contains the \"\$PATH:\$HOME/.local/bin\" directory"
echo ""
echo ""
rm -r "$TMPDIR"