Skip to content

Commit

Permalink
wip: primitive automation to build for different docker-based linuxes
Browse files Browse the repository at this point in the history
  • Loading branch information
garikello3d committed Dec 25, 2023
1 parent ae4ebcf commit 6d6aa38
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
13 changes: 13 additions & 0 deletions scripts/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG OS
FROM $OS

ARG PAC

RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN $PAC update && $PAC install -y git gcc curl

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup && sh /tmp/rustup -y
ADD scripts/build-internal.sh /
RUN mkdir -p /dummy/src
COPY Cargo.toml /dummy
RUN source $HOME/.cargo/env && cd /dummy && echo "// dummy file" > src/lib.rs && cargo build --release
4 changes: 4 additions & 0 deletions scripts/PLATFORMS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# short name # docker from # pac mgr cmd
centos7 centos:7.9.2009 yum
rocky9 rockylinux:9.3 yum
debian12 debian:12.4 apt-get
13 changes: 13 additions & 0 deletions scripts/build-internal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo usage $0 \<os_ident\>
exit 1
fi

cd /
git clone /src/ bigarchiver && \
cd bigarchiver/ && \
cargo test --release && cargo build --release && \
mkdir -pv /src/scripts/build/$1/ && \
cp -v target/release/bigarchiver /src/scripts/build/$1/
44 changes: 44 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

set -e

if [ $# -eq 0 ]; then
echo usage $0 --image\|--app [ os_ident ]
exit 1
fi

cat PLATFORMS | sed '/^#/d;/^[[:space:]]*$/d' | while read LINE; do
WORDS=($LINE)
if [ ${#WORDS[@]} -ne 3 ]; then
echo Invalid PLATFORMS file
exit 1
fi

IDENT=${WORDS[0]}
IMAGE_FROM=${WORDS[1]}
PAC_MGR=${WORDS[2]}

if [ -n "$2" ]; then
if [ x"$IDENT" != x"$2" ] ; then
continue
fi
fi

cd ..
case $1 in
--image)
echo preparing build image for $IDENT
docker build -t bigarchiver-$IDENT -f scripts/Dockerfile.template --build-arg OS=$IMAGE_FROM --build-arg PAC=$PAC_MGR .
;;
--app)
echo building application for $IDENT
docker run -v=.:/src bigarchiver-$IDENT /bin/bash -l -c "/build-internal.sh $IDENT"
;;
*)
echo invalid usage
exit 3
esac
cd scripts
done

echo all done

0 comments on commit 6d6aa38

Please sign in to comment.