blob: 054e5cd4a68090527fc3a35944027d5fb1cfac27 (
plain)
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
|
#!/usr/bin/env zsh
# bootstrap - populate a home with the most necessary scripts
# After running this, other packages can be installed using 'pkg'
# Note: Since pkg is written in zsh, this script also is.
# This way, I don't have to check for zsh somewhere in the script,
# and also have an excuse for using zsh here :P
typeset -i rcempty=0
typeset PKG_ROOT PKG_PATH default_path='~/packages'
if [[ -n $1 ]] {
PKG_ROOT=$1
PKG_PATH=${~${2-$default_path}}
} else {
cat <<- meow
Usage: ./bootstrap PKG_ROOT [PKG_PATH]
PKG_ROOT is an URI, either of the form proto://host/path, or just /path
PKG_PATH is the path where pkg and all further packages will be installed,
by default $default_path
meow
exit 100
}
# zsh keeps complaining about not having a configuration,
# so let's be kind and give it an empty one.
if ! [[ -e ~/.zshrc ]] {
echo 'Creating empty zshrc'
rcempty=1
touch ~/.zshrc
}
# Make basic dirctories
echo 'Creating the basic directory structure'
mkdir -p ~/bin
path=(~/bin $path)
mkdir -p $PKG_PATH/.collected/man/man{1..8}
if ! which git &> /dev/null; then
echo 'It appears that git is not available on this system.'
echo '-Installation aborted-'
exit 200
fi
echo 'Fetching the core package...'
cd $PKG_PATH
git clone $PKG_ROOT/core
cd core || exit 1
echo 'Writing pkg.conf'
echo "PKG_ROOT='$PKG_ROOT'" > ~/.pkg.conf
echo "PKG_PATH=\"${PKG_PATH/$HOME/\$HOME}\"" >> ~/.pkg.conf
echo 'Installing core package'
rehash
bin/checklinks
bin/pkg eval populate_collected core
bin/pkg eval exec_hook core post-add
bin/pkg update
if (( rcempty )) {
echo 'Removing empty zshrc'
rm ~/.zshrc
}
|