talircd/deploy/deploy.sh

53 lines
1.1 KiB
Bash
Raw Normal View History

2024-02-02 16:15:40 +00:00
#!/usr/bin/env bash
MACHINE=${MACHINE:-talircd-build}
MACHINE_PATH=/var/lib/machines/${MACHINE}
PROJECT_ROOT=${PROJECT_ROOT:-$(git rev-parse --show-toplevel)}
DIST_DIR=${DIST_DIR:-${PROJECT_ROOT}/_dist}
CODENAME=bullseye
MIRROR=${MIRROR:-http://debian.csail.mit.edu/debian/}
COMMAND=${1:-build}
set -x
function init() {
# TODO: fakeroot ?
sudo debootstrap \
--include=ocaml-base,ocaml,opam,ca-certificates,git,rsync \
--components=main,contrib \
${CODENAME} ${MACHINE_PATH} ${MIRROR}
}
function cleanall() {
sudo rm -rf ${MACHINE_PATH}
}
function clean() {
sudo systemd-nspawn -q \
--machine ${MACHINE} \
rm -rf /root/.opam
}
function build() {
sudo systemd-nspawn -q \
--machine ${MACHINE} \
--bind-ro ${PROJECT_ROOT}:/root/talircd \
--bind ${DIST_DIR}:/root/dist \
--chdir /root \
/root/talircd/deploy/_build.sh
}
case $1 in
init) init ;;
build) build ;;
clean) clean ;;
cleanall) cleanall ;;
*)
echo "$1"
esac
# mkdir -p "${DIST_DIR}"