From 7d8669867c0298d91b851b00176b7559e1d7c42a Mon Sep 17 00:00:00 2001 From: tali Date: Fri, 2 Feb 2024 11:15:40 -0500 Subject: [PATCH] wip deploy --- .gitignore | 1 + deploy/_build.sh | 13 ++++++++++++ deploy/build.sh | 16 +++++++++++++++ deploy/deploy.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100755 deploy/_build.sh create mode 100755 deploy/build.sh create mode 100755 deploy/deploy.sh diff --git a/.gitignore b/.gitignore index 9a93bba..2628599 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ _build/ _opam/ +_dist/ *.install diff --git a/deploy/_build.sh b/deploy/_build.sh new file mode 100755 index 0000000..badedfc --- /dev/null +++ b/deploy/_build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +export OPAMROOTISOK=1 + +opam init --disable-sandboxing --no-setup + +eval $(opam env) + +opam pin add ./talircd --kind=path --no-action --yes +opam install talircd --destdir=dist + + +#opam install talircd --destdir=dist --yes diff --git a/deploy/build.sh b/deploy/build.sh new file mode 100755 index 0000000..14474f1 --- /dev/null +++ b/deploy/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +MACHINE=${MACHINE:-talircd-build} +PROJECT_ROOT=${PROJECT_ROOT:-$(git rev-parse --show-toplevel)} +DIST_DIR=${DIST_DIR:-${PROJECT_ROOT}/_dist} + +set -x + +mkdir -p "${DIST_DIR}" + +sudo systemd-nspawn -q \ + --machine ${MACHINE} \ + --bind-ro ${PROJECT_ROOT}:/root/talircd \ + --bind ${DIST_DIR}:/root/dist \ + --chdir /root \ + /root/talircd/deploy/_run.sh diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100755 index 0000000..284f3d9 --- /dev/null +++ b/deploy/deploy.sh @@ -0,0 +1,52 @@ +#!/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}"