2017-10-24 21:03:49 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2018-07-31 18:18:17 +00:00
|
|
|
alpine_install=${INSTALL:-'alpine-chroot-install'}
|
|
|
|
alpine_directory=${DIR:-'/alpine'}
|
2017-10-24 21:03:49 +00:00
|
|
|
|
2018-08-02 14:59:18 +00:00
|
|
|
# Tests
|
|
|
|
DIR="${alpine_directory}"
|
|
|
|
if ! [[ $DIR == /* ]]; then
|
|
|
|
echo "DIR is not an absolute URL. It should start with a '/'" && exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-24 21:03:49 +00:00
|
|
|
# DL alpine install script
|
|
|
|
if ! test -f "$alpine_install"; then
|
2018-07-31 18:18:17 +00:00
|
|
|
wget https://raw.githubusercontent.com/alpinelinux/alpine-chroot-install/v0.9.0/alpine-chroot-install -O "$alpine_install" \
|
|
|
|
&& echo 'e5dfbbdc0c4b3363b99334510976c86bfa6cb251 alpine-chroot-install' | sha1sum -c \
|
2017-10-24 21:03:49 +00:00
|
|
|
|| exit 1
|
|
|
|
chmod +x "$alpine_install"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install Alpine
|
2018-08-02 14:59:18 +00:00
|
|
|
if ! test -d "$DIR"; then
|
|
|
|
sudo sh ./$alpine_install -d $DIR -p build-base -p git -p zsh -p lua-filesystem -p luarocks5.1 -p lua-toml -p moonscript -p abuild -p lua-argparse || exit 1
|
2017-10-24 21:03:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set rc_sys="prefix" to not disturb systemd on current system
|
2018-08-02 14:59:18 +00:00
|
|
|
sudo sed -e 's/#rc_sys=""/rc_sys="prefix"/g' -i "$DIR/etc/rc.conf"
|
2017-10-24 21:03:49 +00:00
|
|
|
|
|
|
|
# Launch chroot
|
2018-08-02 14:59:18 +00:00
|
|
|
sh $DIR/enter-chroot ./build
|
|
|
|
|
|
|
|
exit 0
|