Skip to content

Commit

Permalink
Add experimental Debian 11 (Bullseye) support
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturKlauser authored Dec 12, 2019
1 parent c831018 commit 34889ac
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 48 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Use Dockerfile.build-env to create the build environment in which the code for
RStudio Server and Desktop is going to be compiled. The build procedure has
been adapted to the Raspbian environment using the native version of the Boost
library and the native QT libraries. It has been tested on Debian 9 (Stretch)
and Debian 10 (Buster). Once the build environment is created, it is used by
and Debian 10 (Buster). An experimental Debian 11 (Bullseye) version is also
available. Once the build environment is created, it is used by
Dockerfile.server-deb and Dockerfile.desktop-deb to build the RStudio Server and
Desktop Debian packages respectively.

Expand Down Expand Up @@ -83,7 +84,7 @@ shell script `build.sh`.
To build, run:
```
for stage in build-env server-deb desktop-deb; do
./build.sh stretch "${stage}"
./build.sh buster "${stage}"
done
```

Expand All @@ -107,7 +108,7 @@ basic R programs in RStudio Server but doesn't have any extras installed. For
this you would add the `--target install-minimal` to the docker build command.
The default is to build a more fully featured runtime with:
```
./build.sh stretch server
./build.sh buster server
```
The full runtime also has the necessary system and R packages installed to
support working with .Rmd files including latex for generating PDF, as well as
Expand Down Expand Up @@ -142,9 +143,9 @@ If you have specified a different `USER` at build time, you have to adjust the
`/home` directory accordingly.

## Getting the .deb Package Files
If what you want to do is not running RStudio in a Docker container but
installing it natively on your Raspberry Pi you can do that too. You can
extract the RStudio Server Debian package from that docker build image with:
If you want to install and run RStudio natively on your Raspberry Pi you can do
that too. You can extract the RStudio Server Debian package from that docker
build image with:
```
docker image save arturklauser/raspberrypi-rstudio-server-deb | tar xO --wildcards '*/layer.tar' | tar x
```
Expand Down
16 changes: 16 additions & 0 deletions balenalib-bullseye-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# Balenalib doesn't currently distribute the built Debian SID (generic next
# release) or Bullseye (Debian 11) containers, so this tries to build a
# semblance of them based on their Dockerfile with some modifications.
# See: https://github.com/balena-io-library/base-images/blob/master/balena-base-images/device-base/raspberrypi3/debian/sid/run/Dockerfile

docker build \
-f docker/Dockerfile.balenalib-raspberrypi3-debian-bullseye-run \
-t balenalib-raspberrypi3-debian:bullseye-run \
docker

docker build \
-f docker/Dockerfile.balenalib-raspberrypi3-debian-bullseye-build \
-t balenalib-raspberrypi3-debian:bullseye-build \
docker
25 changes: 21 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function usage() {
fi
cat - >&2 << END_USAGE
Usage: build.sh <debian-version> <build-stage>
debian-version: stretch ... Debian version 9
buster .... Debian version 10
debian-version: stretch ..... Debian version 9
buster ...... Debian version 10
bullseye .... Debian version 11 (experimental)
build-stage: build-env ..... build environment
server-deb .... server Debian package
desktop-deb ... desktop Debian package
Expand Down Expand Up @@ -54,6 +55,13 @@ function main() {
readonly VERSION_PATCH=5019
readonly PACKAGE_RELEASE='1~r2r'
;;
'bullseye')
# As of 2019-10-26 v1.2.5019 is the latest version 1.2 tag.
readonly VERSION_MAJOR=1
readonly VERSION_MINOR=2
readonly VERSION_PATCH=5019
readonly PACKAGE_RELEASE='1~r2r'
;;
*)
usage "Unsupported Debian version '${DEBIAN_VERSION}'"
;;
Expand All @@ -71,19 +79,28 @@ function main() {
esac

readonly VERSION_TAG=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
readonly BUILD_PARALLELISM=2
# Parallelism is no greater than number of available CPUs and max 2.
readonly NPROC=$(nproc 2>/dev/null)
readonly BUILD_PARALLELISM=$(printf '2\n%s' ${NPROC} | sort -n | head -1)

# If we're running on ARM we comment out the cross-build lines.
if [[ $(uname -m) =~ 'arm' ]]; then
readonly ARCH=$(uname -m)
if [[ ${ARCH} =~ 'arm' || ${ARCH} =~ 'aarch64' ]]; then
readonly CROSS_BUILD_FIX='s/^(.*cross-build-.*)/# $1/'
else
readonly CROSS_BUILD_FIX=''
fi
if [[ "${DEBIAN_VERSION}" == 'bullseye' ]]; then
readonly BULLSEYE_FIX='s#(balenalib)/(raspberrypi3)#$1-$2#'
else
readonly BULLSEYE_FIX=''
fi

# Build the docker image.
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 Down
33 changes: 29 additions & 4 deletions buildx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function usage() {
fi
cat - >&2 << END_USAGE
Usage: buildx.sh <debian-version> <build-stage>
debian-version: stretch ... Debian version 9
buster .... Debian version 10
debian-version: stretch ..... Debian version 9
buster ...... Debian version 10
bullseye .... Debian version 11 (experimental)
build-stage: build-env ..... build environment
server-deb .... server Debian package
desktop-deb ... desktop Debian package
Expand All @@ -28,6 +29,14 @@ function timestamp() {
}

function main() {
cat <<EOF
==============================================================================
Note that this buildx.sh script depends on the experimental Docker support for
the _buildx_ plugin. Unless you know what you're doing, use build.sh instead.
==============================================================================
EOF

if [[ "$#" != 2 ]]; then
usage "Invalid number ($#) of command line arguments."
fi
Expand All @@ -54,6 +63,13 @@ function main() {
readonly VERSION_PATCH=5019
readonly PACKAGE_RELEASE='1~r2r'
;;
'bullseye')
# As of 2019-10-26 v1.2.5019 is the latest version 1.2 tag.
readonly VERSION_MAJOR=1
readonly VERSION_MINOR=2
readonly VERSION_PATCH=5019
readonly PACKAGE_RELEASE='1~r2r'
;;
*)
usage "Unsupported Debian version '${DEBIAN_VERSION}'"
;;
Expand All @@ -71,22 +87,31 @@ function main() {
esac

readonly VERSION_TAG=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
readonly BUILD_PARALLELISM=2
# Parallelism is no greater than number of available CPUs and max 2.
readonly NPROC=$(nproc 2>/dev/null)
readonly BUILD_PARALLELISM=$(printf '2\n%s' ${NPROC} | sort -n | head -1)

# We comment out the cross-build lines since buildx has cross-build
# integrated already.
# if [[ $(uname -m) =~ 'arm' ]]; then
# readonly ARCH=$(uname -m)
# if [[ ${ARCH} =~ 'arm' || ${ARCH} =~ 'aarch64' ]]; then
readonly CROSS_BUILD_FIX='s/^(.*cross-build-.*)/# $1/'
# else
# readonly CROSS_BUILD_FIX=''
# fi
if [[ "${DEBIAN_VERSION}" == 'bullseye' ]]; then
readonly BULLSEYE_FIX='s#(balenalib)/(raspberrypi3)#$1-$2#'
else
readonly BULLSEYE_FIX=''
fi

# Build the docker image.
# --load \

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 Down
26 changes: 26 additions & 0 deletions docker/Dockerfile.balenalib-raspberrypi3-debian-bullseye-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use this Dockerfile to build a Debian 11 (Bullseye) version of balenalib while
# there is no such version yet officially.
#
# from https://github.com/balena-io-library/base-images/blob/master/balena-base-images/device-base/raspberrypi3/debian/sid/build/Dockerfile
FROM balenalib/armv7hf-debian:sid-build
LABEL io.balena.device-type="raspberrypi3"
RUN echo "deb http://archive.raspbian.org/raspbian bullseye main contrib non-free rpi firmware" >> /etc/apt/sources.list \
&& apt-key adv --batch --keyserver ha.pool.sks-keyservers.net --recv-key 0x9165938D90FDDD2E
# No bullseye repository yet:
# && echo "deb http://archive.raspberrypi.org/debian bullseye main ui" >> /etc/apt/sources.list.d/raspi.list \
# && apt-key adv --batch --keyserver ha.pool.sks-keyservers.net --recv-key 0x82B129927FA3303E

RUN apt-get update \
&& apt-get --with-new-pkgs upgrade -y \
&& apt-get install -y --no-install-recommends \
less \
libraspberrypi-bin \
kmod \
nano \
net-tools \
ifupdown \
iputils-ping \
i2c-tools \
usbutils \
&& apt autoremove \
&& rm -rf /var/lib/apt/lists/*
26 changes: 26 additions & 0 deletions docker/Dockerfile.balenalib-raspberrypi3-debian-bullseye-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use this Dockerfile to build a Debian 11 (Bullseye) version of balenalib while
# there is no such version yet officially.
#
# from https://github.com/balena-io-library/base-images/blob/master/balena-base-images/device-base/raspberrypi3/debian/sid/run/Dockerfile
FROM balenalib/armv7hf-debian:sid-run
LABEL io.balena.device-type="raspberrypi3"
RUN echo "deb http://archive.raspbian.org/raspbian bullseye main contrib non-free rpi firmware" >> /etc/apt/sources.list \
&& apt-key adv --batch --keyserver ha.pool.sks-keyservers.net --recv-key 0x9165938D90FDDD2E
# No bullseye repository yet:
# && echo "deb http://archive.raspberrypi.org/debian bullseye main ui" >> /etc/apt/sources.list.d/raspi.list \
# && apt-key adv --batch --keyserver ha.pool.sks-keyservers.net --recv-key 0x82B129927FA3303E

RUN apt-get update \
&& apt-get --with-new-pkgs upgrade -y \
&& apt-get install -y --no-install-recommends \
less \
libraspberrypi-bin \
kmod \
nano \
net-tools \
ifupdown \
iputils-ping \
i2c-tools \
usbutils \
&& apt autoremove \
&& rm -rf /var/lib/apt/lists/*
14 changes: 10 additions & 4 deletions docker/Dockerfile.build-env
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,19 @@ RUN set -x \
&& ln -s rstudio rstudio-${VERSION_TAG}

WORKDIR /home/pi/Downloads/rstudio/dependencies/linux
# We're going to use the system version of the boost library (version
# 1.62.0) instead of installing and building the RStudio version of boost
# (version 1.63.0) which takes several hours of build time.
# We're going to use the pre-built system version of the boost library instead
# of installing and building the RStudio version of boost (version 1.63.0) which
# takes several hours of build time.
# Comment out boost source installation.
RUN perl -i -pe 's/(^.*install-boost$)/# \1/s' ../common/install-common
# Install system boost.
RUN apt-get install libboost1.62-all-dev
RUN set -x \
&& if [ "${DEBIAN_VERSION}" = 'stretch' -o "${DEBIAN_VERSION}" = 'buster' ]; then \
BOOST_VERSION=1.62; \
elif [ "${DEBIAN_VERSION}" = 'bullseye' ]; then \
BOOST_VERSION=1.67; \
fi \
&& apt-get install libboost${BOOST_VERSION}-all-dev
# We use the system QT libraries instead of RSTudio's.
# Script installs qt-sdk binaries for x86 but we need armhf, so skip it.
RUN ./install-dependencies-debian --exclude-qt-sdk
Expand Down
17 changes: 11 additions & 6 deletions docker/Dockerfile.desktop-deb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ FROM arturklauser/raspberrypi-rstudio-build-env:${VERSION_TAG}-${DEBIAN_VERSION}
RUN [ "cross-build-start" ]

# Define RStudio source code version to use and the package release tag.
ARG DEBIAN_VERSION
ARG VERSION_MAJOR
ARG VERSION_MINOR
ARG VERSION_PATCH
Expand All @@ -49,17 +50,21 @@ ENV RSTUDIO_VERSION_MAJOR=${VERSION_MAJOR} \

# Build everything.
RUN set -x \
# Set up boost dependency.
&& case $(echo ${VERSION_TAG} | cut -c1-3) in \
'1.1') BOOST='-DRSTUDIO_BOOST_VERSION' ;; \
'1.2') BOOST='-DRSTUDIO_BOOST_REQUESTED_VERSION' ;; \
esac \
&& case ${DEBIAN_VERSION} in \
'stretch' | 'buster') BOOST="${BOOST}=1.62.0" ;; \
'bullseye') BOOST="${BOOST}=1.67.0" ;; \
esac \
# Configure the build.
&& cmake .. \
-DRSTUDIO_TARGET=Desktop \
-DCMAKE_BUILD_TYPE=Release \
-DRSTUDIO_PACKAGE_BUILD=1 \
#--- begin stretch
-DRSTUDIO_BOOST_VERSION=1.62.0 \
#--- end stretch
#--- begin buster
-DRSTUDIO_BOOST_REQUESTED_VERSION=1.62.0 \
#--- end buster
${BOOST} \
-DRSTUDIO_USE_SYSTEM_BOOST=1 \
-DQT_QMAKE_EXECUTABLE=/usr/lib/arm-linux-gnueabihf/qt5/bin/qmake \
# Compile the C++ targets.
Expand Down
Loading

0 comments on commit 34889ac

Please sign in to comment.