Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install tarball packages with custom extraction #21

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ FROM debian:${DEBIAN_VERSION}-slim AS base
ARG RUNDIR
ARG ENTRYPOINT=/bin/bash
ARG RUNTIME_PACKAGES
ARG RUNTIME_TAR_PACKAGES

RUN apt update -y && \
apt install -y --no-install-recommends \
libreadline8 \
busybox \
netcat-openbsd \
procserv \
wget \
$RUNTIME_PACKAGES && \
apt clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=build-image /usr/local/bin/lnls-get-n-unpack /usr/local/bin/lnls-get-n-unpack
RUN lnls-get-n-unpack -r $RUNTIME_TAR_PACKAGES && \
ldconfig

henriquesimoes marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR ${RUNDIR}

RUN ln -s ${ENTRYPOINT} ./entrypoint
Expand All @@ -34,8 +40,10 @@ FROM build-image AS build-stage

ARG REPONAME
ARG BUILD_PACKAGES
ARG BUILD_TAR_PACKAGES

RUN if [ -n "$BUILD_PACKAGES" ]; then apt update && apt install $BUILD_PACKAGES; fi
RUN lnls-get-n-unpack -r $BUILD_TAR_PACKAGES

WORKDIR /opt/${REPONAME}

Expand Down
2 changes: 2 additions & 0 deletions base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ RUN apt update -y && \
wget \
ca-certificates

COPY lnls-get-n-unpack.sh /usr/local/bin/lnls-get-n-unpack

ARG EPICS_BASE_VERSION
ENV EPICS_BASE_PATH /opt/epics/base
ENV EPICS_MODULES_PATH /opt/epics/modules
Expand Down
4 changes: 1 addition & 3 deletions base/install_epics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

set -ex

wget https://epics-controls.org/download/base/base-${EPICS_BASE_VERSION}.tar.gz
tar -xf base-${EPICS_BASE_VERSION}.tar.gz
rm base-${EPICS_BASE_VERSION}.tar.gz
lnls-get-n-unpack -l https://epics-controls.org/download/base/base-${EPICS_BASE_VERSION}.tar.gz

mv base-${EPICS_BASE_VERSION} ${EPICS_BASE_PATH}
make -j ${JOBS} -C ${EPICS_BASE_PATH} install
Expand Down
8 changes: 2 additions & 6 deletions base/install_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ download_github_module() {
module_name=$2
tag=$3

wget https://github.com/$github_org/$module_name/archive/refs/tags/$tag.tar.gz
tar -xf $tag.tar.gz
rm $tag.tar.gz
lnls-get-n-unpack -l https://github.com/$github_org/$module_name/archive/refs/tags/$tag.tar.gz

mv $module_name-$tag $module_name
}
Expand Down Expand Up @@ -45,9 +43,7 @@ install_github_module() {
echo EPICS_BASE=${EPICS_BASE_PATH} > ${EPICS_MODULES_PATH}/../RELEASE

# Build seq first since it doesn't depend on anything
wget "https://static.erico.dev/seq-$SEQUENCER_VERSION.tar.gz"
tar -xf seq-$SEQUENCER_VERSION.tar.gz
rm seq-$SEQUENCER_VERSION.tar.gz
lnls-get-n-unpack -l "https://static.erico.dev/seq-$SEQUENCER_VERSION.tar.gz"
mv seq-$SEQUENCER_VERSION seq
install_module seq SNCSEQ "
EPICS_BASE = ${EPICS_BASE_PATH}
Expand Down
24 changes: 24 additions & 0 deletions base/lnls-get-n-unpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Download and extract tarball archive from the network.

set -eu

case "$1" in
-r) dest=/ ;;
-l) dest=. ;;
*) >&2 echo "Invalid extraction mode: must be either root (-r) or local (-l)."
exit 1;
;;
esac

shift

for url; do
download_dir=$(mktemp -d)

echo Downloading "$url"...
wget -P $download_dir -o /tmp/wget.log "$url" || (cat /tmp/wget.log && false)
tar --no-same-owner -xf $download_dir/* -C $dest
rm -rf $download_dir /tmp/wget.log
done