Skip to content

Instantly share code, notes, and snippets.

@andras-tim
Last active March 1, 2023 03:38
Show Gist options
  • Save andras-tim/aaf7716bc3fd095c5f4a1296fff1be98 to your computer and use it in GitHub Desktop.
Save andras-tim/aaf7716bc3fd095c5f4a1296fff1be98 to your computer and use it in GitHub Desktop.
Sanoid .deb builder
# https://gist.github.com/andras-tim/aaf7716bc3fd095c5f4a1296fff1be98
ARG sanoid_rev='v2.1.0'
FROM ubuntu:jammy AS requirements
ENV DEBIAN_FRONTEND='noninteractive'
ENV TZ='Europe/Budapest'
RUN set -xe \
&& apt-get update \
&& ln -fs "/usr/share/zoneinfo/${TZ}" /etc/localtime \
&& apt-get install -y \
build-essential \
debhelper \
git \
libcapture-tiny-perl \
libconfig-inifiles-perl \
lzop \
mbuffer \
pv \
zfsutils-linux \
&& apt-get clean
FROM requirements AS build
ARG sanoid_rev
RUN set -xe \
&& git clone --depth 1 -b "${sanoid_rev}" 'https://github.com/jimsalterjrs/sanoid.git' \
&& cd sanoid \
&& ln -s packages/debian . \
&& dpkg-buildpackage -uc -us \
&& cd .. \
# include revision into the deb name if it is not the same as the package version
&& deb_name="$(ls sanoid*.deb)" \
&& if [ "${deb_name}" != "sanoid_${sanoid_rev}_all.deb" ] && [ "${deb_name}" != "sanoid_${sanoid_rev##v}_all.deb" ]; then \
mv -v "${deb_name}" "sanoid-${sanoid_rev}_${deb_name##sanoid_}"; \
fi
FROM requirements AS test
COPY --from=build sanoid*.deb /
RUN set -xe \
&& dpkg -i /sanoid*.deb \
&& sanoid --version
FROM scratch AS export
ARG sanoid_rev
COPY --from=test sanoid*.deb /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment