Skip to content

Commit

Permalink
Balenalib now supports Debian bullseye container
Browse files Browse the repository at this point in the history
* Remove temporary workarounds used to build our own balenalib-bullseye
  Docker container approximation.
  • Loading branch information
ArturKlauser committed Mar 30, 2020
1 parent f1c9b15 commit d86b8c3
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 119 deletions.
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ jobs:
# the first sign of trouble.
before_script:
- stage="$(echo ${TRAVIS_BUILD_STAGE_NAME} | tr '[A-Z]' '[a-z]')"
- |
if [[ "${debian_version}" == 'bullseye' ]]; then
if [[ "${stage}" == 'build-env' ]]; then
bash -ec "./balenalib-bullseye-build.sh build"
elif [[ "${stage}" == 'server' ]]; then
bash -ec "./balenalib-bullseye-build.sh run"
fi
fi
# For some reason executing a function with 'set -e; f' hangs Travis
# on error in the function, whereas 'bash -ec f' errors the build as
# expected.
Expand Down
26 changes: 0 additions & 26 deletions balenalib-bullseye-build.sh

This file was deleted.

6 changes: 1 addition & 5 deletions build-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# Account name prefix for docker image tags.
readonly DOCKERHUB_USER='arturklauser'
readonly GITHUB_REPO='raspberrypi-rstudio'

source ./build-functions.sh

Expand All @@ -18,11 +19,6 @@ function main() {
docker container prune --force
docker image prune --force

# Build our own bullseye starting image since there ain't any yet.
if [[ "${debian_version}" == 'bullseye' ]]; then
./balenalib-bullseye-build.sh
fi

build 'build-env'
(# handle docker in background
push 'build-env'
Expand Down
10 changes: 2 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function usage() {
Usage: $script_name <debian-version> <stage>
debian-version: stretch ..... Debian version 9
buster ...... Debian version 10
bullseye .... Debian version 11 (experimental)
bullseye .... Debian version 11
stage: build-env ......... create build environment
server-deb ........ build server Debian package
desktop-deb ....... build desktop Debian package
Expand Down Expand Up @@ -131,12 +131,6 @@ EOF
else
readonly CROSS_BUILD_FIX=''
fi
if [[ "${DEBIAN_VERSION}" == 'bullseye' ]]; then
# shellcheck disable=SC2016
readonly BULLSEYE_FIX='s#(balenalib)/(raspberrypi3)#$1-$2#'
else
readonly BULLSEYE_FIX=''
fi

# Build the docker image.
(for i in {0..100}; do
Expand All @@ -150,7 +144,6 @@ EOF
set -x
time \
perl -pe "${CROSS_BUILD_FIX}" "${DOCKERFILE}" \
| perl -pe "${BULLSEYE_FIX}" \
| docker build \
--build-arg DEBIAN_VERSION="${DEBIAN_VERSION}" \
--build-arg VERSION_TAG="${VERSION_TAG}" \
Expand All @@ -164,6 +157,7 @@ EOF
--build-arg BUILD_DATE="$(timestamp)" \
-t "${IMAGE_NAME}:${VERSION_TAG}-${DEBIAN_VERSION}" \
-

set +x
kill $pid

Expand Down
30 changes: 20 additions & 10 deletions buildx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function usage() {
Usage: $script_name <debian-version> <stage>
debian-version: stretch ..... Debian version 9
buster ...... Debian version 10
bullseye .... Debian version 11 (experimental)
bullseye .... Debian version 11
stage: build-env ......... create build environment
server-deb ........ build server Debian package
desktop-deb ....... build desktop Debian package
Expand Down Expand Up @@ -114,7 +114,13 @@ EOF

# Parallelism is no greater than number of available CPUs and max 2.
readonly NPROC=$(nproc 2> /dev/null)
readonly BUILD_PARALLELISM=$(min '2' "${NPROC}")
# Travis: There is a 50 minute job time limit. The aarch64 VM has 32 CPUs.
# Make use of them to stay within the job time limit.
if [ "$TRAVIS" = 'true' ]; then
readonly BUILD_PARALLELISM=$(min '8' "${NPROC}")
else
readonly BUILD_PARALLELISM=$(min '2' "${NPROC}")
fi

# If we're running on real or simulated ARM we comment out the cross-build
# lines.
Expand All @@ -125,20 +131,21 @@ EOF
else
readonly CROSS_BUILD_FIX=''
fi
if [[ "${DEBIAN_VERSION}" == 'bullseye' ]]; then
# shellcheck disable=SC2016
readonly BULLSEYE_FIX='s#(balenalib)/(raspberrypi3)#$1-$2#'
else
readonly BULLSEYE_FIX=''
fi

# Build the docker image.
# --load \

(for i in {0..100}; do
sleep 1
echo "Still building ... ($i min)"
sleep 59
done) &
pid=$!
# Get current commit SHA. Works also on --depth=1 shallow clones.
ref="$(git log --pretty=format:'%H' HEAD^!)"
set -x
time \
perl -pe "${CROSS_BUILD_FIX}" "${DOCKERFILE}" \
| perl -pe "${BULLSEYE_FIX}" \
| perl -pe 's#^(FROM '"${DOCKERHUB_USER}"'/\S+)#$1-buildx#' \
| docker buildx build \
--platform linux/arm/v7 \
Expand All @@ -151,11 +158,14 @@ EOF
--build-arg VERSION_PATCH="${VERSION_PATCH}" \
--build-arg PACKAGE_RELEASE="${PACKAGE_RELEASE}" \
--build-arg BUILD_PARALLELISM="${BUILD_PARALLELISM}" \
--build-arg VCS_REF="$(git log --pretty=format:'%H' HEAD~..HEAD)" \
--build-arg TRAVIS="${TRAVIS}" \
--build-arg VCS_REF="${ref}" \
--build-arg BUILD_DATE="$(timestamp)" \
-t "${IMAGE_NAME}:${VERSION_TAG}-${DEBIAN_VERSION}-buildx" \
-

set +x
kill $pid

echo "Done building at $(timestamp)"
}
Expand Down
29 changes: 0 additions & 29 deletions docker/Dockerfile.balenalib-raspberrypi3-debian-bullseye-build

This file was deleted.

29 changes: 0 additions & 29 deletions docker/Dockerfile.balenalib-raspberrypi3-debian-bullseye-run

This file was deleted.

8 changes: 6 additions & 2 deletions docker/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ RUN set -x \
texlive-latex-extra \
texlive-fonts-recommended \
lmodern \
# bullseye provisional balenalib image doesn't have this; don't fail
&& (apt-get install -y texlive-generic-extra || true) \
#--- begin not bullseye
&& if [[ "${DEBIAN_VERSION}" != 'bullseye' ]]; then \
# bullseye balenalib image doesn't have this; don't fail
apt-get install -y texlive-generic-extra; \
fi \
#--- end not bullseye
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
4 changes: 2 additions & 2 deletions tools/dry-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ function main() {

rm -f "${log}"
run ./build-all.sh
# expected: like above + 2 balenalib bullseye pre-builds
check_num_lines './build-all.sh' 'would execute: docker build ' 14
# expected: same as above
check_num_lines './build-all.sh' 'would execute: docker build ' 12
check_num_lines './build-all.sh' 'would execute: docker push ' 12

teardown
Expand Down

0 comments on commit d86b8c3

Please sign in to comment.