create deb package deployment infrastructure

This commit is contained in:
tali 2024-02-02 13:22:58 -05:00
parent 7d8669867c
commit 59b79167a4
7 changed files with 64 additions and 48 deletions

View File

@ -1,13 +1,32 @@
#!/usr/bin/env bash #!/usr/bin/env bash
export OPAMROOTISOK=1
opam init --disable-sandboxing --no-setup opam init --disable-sandboxing --no-setup
eval $(opam env) eval $(opam env)
root=dist/root
rm -rf $root
mkdir -p $root/DEBIAN $root/etc $root/usr/lib/systemd/system
opam pin add ./talircd --kind=path --no-action --yes opam pin add ./talircd --kind=path --no-action --yes
opam install talircd --destdir=dist opam install talircd --destdir=$root/usr --yes
pkg=$(opam info talircd -fname)
ver="$(opam info talircd -fversion)"
rev=0
dsc="$(opam info talircd -fdescription)"
mtr="iitalics"
control=$root/DEBIAN/control
#opam install talircd --destdir=dist --yes set -x
echo "Package: ${pkg}" > $control
echo "Version: ${ver}" >> $control
echo "Description: ${dsc}" >> $control
echo "Maintainer: ${mtr}" >> $control
echo "Architecture: all" >> $control
install -m 644 talircd/deploy/talircd.service $root/usr/lib/systemd/system
install -m 644 talircd/deploy/talircd.conf $root/etc
dpkg-deb --root-owner-group -b $root "dist/${pkg}_${ver}-${rev}_all.deb"

View File

@ -1,16 +0,0 @@
#!/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

View File

@ -8,13 +8,9 @@ DIST_DIR=${DIST_DIR:-${PROJECT_ROOT}/_dist}
CODENAME=bullseye CODENAME=bullseye
MIRROR=${MIRROR:-http://debian.csail.mit.edu/debian/} MIRROR=${MIRROR:-http://debian.csail.mit.edu/debian/}
COMMAND=${1:-build}
set -x
function init() { function init() {
# TODO: fakeroot ? # TODO: fakeroot ?
set -x
sudo debootstrap \ sudo debootstrap \
--include=ocaml-base,ocaml,opam,ca-certificates,git,rsync \ --include=ocaml-base,ocaml,opam,ca-certificates,git,rsync \
--components=main,contrib \ --components=main,contrib \
@ -22,31 +18,43 @@ function init() {
} }
function cleanall() { function cleanall() {
set -x
sudo rm -rf ${MACHINE_PATH} sudo rm -rf ${MACHINE_PATH}
} }
function clean() { function in_container() {
sudo systemd-nspawn -q \ set -x
--machine ${MACHINE} \ mkdir -p ${DIST_DIR}
rm -rf /root/.opam
}
function build() {
sudo systemd-nspawn -q \ sudo systemd-nspawn -q \
--machine ${MACHINE} \ --machine ${MACHINE} \
--bind-ro ${PROJECT_ROOT}:/root/talircd \ --bind-ro ${PROJECT_ROOT}:/root/talircd \
--bind ${DIST_DIR}:/root/dist \ --bind ${DIST_DIR}:/root/dist:rootidmap \
--chdir /root \ -E OPAMROOTISOK=1 \
/root/talircd/deploy/_build.sh "$@"
} }
case $1 in function clean() {
rm -rf ${DIST_DIR}/root
in_container rm -rf /root/.opam
}
function build() {
in_container --chdir /root /root/talircd/deploy/_build.sh
}
function shell() {
in_container
}
case ${1:-build} in
init) init ;; init) init ;;
build) build ;; build) build ;;
clean) clean ;; clean) clean ;;
cleanall) cleanall ;; cleanall) cleanall ;;
shell) shell ;;
*) *)
echo "$1" echo "invalid command $1"
esac esac
# mkdir -p "${DIST_DIR}" # mkdir -p "${DIST_DIR}"

4
deploy/talircd.conf Normal file
View File

@ -0,0 +1,4 @@
IRC_MOTD=/usr/share/talircd/motd
IRC_HOSTNAME=irc.tali.software
IRC_PORT=6667
LOG_LEVEL=debug

9
deploy/talircd.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=tali IRCd
ConditionPathExists=/etc/talircd.conf
[Service]
Type=notify
ExecStart=/usr/bin/talircd
KillSignal=SIGTERM
EnvironmentFile=/etc/talircd.conf

4
dune Normal file
View File

@ -0,0 +1,4 @@
(install
(package talircd)
(files (motd.txt as motd))
(section share))

View File

@ -1,12 +0,0 @@
[Unit]
Description=tali IRCd
[Service]
Environment=IRC_HOSTNAME=irc.tali.software
Environment=IRC_MOTD=/usr/local/share/talircd/motd
#Environment=IRC_PORT=6667
#Environment=LOG_LEVEL=DEBUG
Type=notify
KillSignal=SIGTERM
ExecStart=/usr/local/bin/talircd