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

Add support for Ubuntu Noble #1085

Closed
wants to merge 3 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
116 changes: 116 additions & 0 deletions balena-base-images/aarch64/ubuntu/noble/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
FROM arm64v8/ubuntu:noble
LABEL io.balena.architecture="aarch64"

LABEL io.balena.qemu.version="7.0.0+balena1-aarch64"
COPY qemu-aarch64-static /usr/bin

RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
ca-certificates \
findutils \
gnupg \
dirmngr \
inetutils-ping \
netbase \
curl \
udev \
$( \
if apt-cache show 'iproute' 2>/dev/null | grep -q '^Version:'; then \
echo 'iproute'; \
else \
echo 'iproute2'; \
fi \
) \
&& rm -rf /var/lib/apt/lists/* \
&& c_rehash \
&& echo '#!/bin/sh\n\
set -e\n\
set -u\n\
export DEBIAN_FRONTEND=noninteractive\n\
n=0\n\
max=2\n\
until [ $n -gt $max ]; do\n\
set +e\n\
(\n\
apt-get update -qq &&\n\
apt-get install -y --no-install-recommends "$@"\n\
)\n\
CODE=$?\n\
set -e\n\
if [ $CODE -eq 0 ]; then\n\
break\n\
fi\n\
if [ $n -eq $max ]; then\n\
exit $CODE\n\
fi\n\
echo "apt failed, retrying"\n\
n=$(($n + 1))\n\
done\n\
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*' > /usr/sbin/install_packages \
&& chmod 0755 "/usr/sbin/install_packages"

# Install packages for build variant
RUN install_packages \
ca-certificates \
curl \
wget \
bzr \
git \
mercurial \
openssh-client \
subversion \
autoconf \
build-essential \
imagemagick \
libbz2-dev \
libcurl4-openssl-dev \
libevent-dev \
libffi-dev \
libglib2.0-dev \
libjpeg-dev \
libmagickcore-dev \
libmagickwand-dev \
libncurses-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxslt-dev \
libyaml-dev \
zlib1g-dev \
$( \
if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
echo 'default-libmysqlclient-dev'; \
else \
echo 'libmysqlclient-dev'; \
fi \
) \
&& rm -rf /var/lib/apt/lists/*

RUN curl -SLO "http://resin-packages.s3.amazonaws.com/resin-xbuild/v1.0.0/resin-xbuild1.0.0.tar.gz" \
&& echo "1eb099bc3176ed078aa93bd5852dbab9219738d16434c87fc9af499368423437 resin-xbuild1.0.0.tar.gz" | sha256sum -c - \
&& tar -xzf "resin-xbuild1.0.0.tar.gz" \
&& rm "resin-xbuild1.0.0.tar.gz" \
&& chmod +x resin-xbuild \
&& mv resin-xbuild /usr/bin \
&& ln -sf resin-xbuild /usr/bin/cross-build-start \
&& ln -sf resin-xbuild /usr/bin/cross-build-end

ENV LC_ALL C.UTF-8
ENV UDEV off

RUN mkdir -p /usr/share/man/man1

COPY entry.sh /usr/bin/entry.sh
COPY balena-info /usr/bin/balena-info
COPY balena-idle /usr/bin/balena-idle
ENTRYPOINT ["/usr/bin/entry.sh"]

RUN curl -SLO "https://raw.githubusercontent.com/balena-io-library/base-images/a95300eda2320833e537ca20d728a870bf02177d/scripts/assets/tests/test-os.sh" \
&& echo "Running test-os" \
&& chmod +x test-os.sh \
&& bash test-os.sh ubuntu noble \
&& rm -rf test-os.sh

RUN [ ! -d /.balena/messages ] && mkdir -p /.balena/messages; echo 'Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): \nArchitecture: ARM v8 \nOS: Ubuntu noble \nVariant: build variant \nDefault variable(s): UDEV=off \nExtra features: \n- Easy way to install packages with `install_packages <package-name>` command \n- Run anywhere with cross-build feature (for ARM only) \n- Keep the container idling with `balena-idle` command \n- Show base image details with `balena-info` command' > /.balena/messages/image-info
47 changes: 47 additions & 0 deletions balena-base-images/aarch64/ubuntu/noble/build/balena-idle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

set -e

usage() {
cat <<EOUSAGE
A small script that runs an idle process to keep the container running, while periodically printing the log: "Idling..."

Options:
--message Message to print when ilding (Default to "Idling...").
--interval Printing interval in second (Default to 600 seconds).
--silent No idle message.

EOUSAGE
}

message="Idling..."
interval=600
is_silent=

# Args handling
opts="$(getopt -o 'h?' --long 'message:,interval:,silent' -- "$@" || { usage >&2 && exit 1; })"
eval set -- "$opts"

while true; do
flag=$1
shift
case "$flag" in
--message) message="$1" && shift ;;
--interval) interval="$1" && shift ;;
--silent) is_silent=true ;;
--) break ;;
*)
{
echo "error: unknown flag: $flag"
usage
} >&2
exit 1
;;
esac
done

if [ "$is_silent" == true ] ; then
sleep infinity
else
while : ; do echo "$message"; sleep $interval; done
fi
13 changes: 13 additions & 0 deletions balena-base-images/aarch64/ubuntu/noble/build/balena-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Print all files in /.balena/messages directory

set -e

if [ -d /.balena/messages ]; then
for i in /.balena/messages/*; do
if [ -r $i ]; then
cat $i
fi
done
unset i
fi
85 changes: 85 additions & 0 deletions balena-base-images/aarch64/ubuntu/noble/build/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# This command only works in privileged container
tmp_mount='/tmp/_balena'
mkdir -p "$tmp_mount"
if mount -t devtmpfs none "$tmp_mount" &> /dev/null; then
PRIVILEGED=true
umount "$tmp_mount"
else
PRIVILEGED=false
fi
rm -rf "$tmp_mount"

function mount_dev()
{
tmp_dir='/tmp/tmpmount'
mkdir -p "$tmp_dir"
mount -t devtmpfs none "$tmp_dir"
mkdir -p "$tmp_dir/shm"
mount --move /dev/shm "$tmp_dir/shm"
mkdir -p "$tmp_dir/mqueue"
mount --move /dev/mqueue "$tmp_dir/mqueue"
mkdir -p "$tmp_dir/pts"
mount --move /dev/pts "$tmp_dir/pts"
touch "$tmp_dir/console"
mount --move /dev/console "$tmp_dir/console"
umount /dev || true
mount --move "$tmp_dir" /dev

# Since the devpts is mounted with -o newinstance by Docker, we need to make
# /dev/ptmx point to its ptmx.
# ref: https://www.kernel.org/doc/Documentation/filesystems/devpts.txt
ln -sf /dev/pts/ptmx /dev/ptmx

# When using io.balena.features.sysfs the mount point will already exist
# we need to check the mountpoint first.
sysfs_dir='/sys/kernel/debug'

if ! mountpoint -q "$sysfs_dir"; then
mount -t debugfs nodev "$sysfs_dir"
fi

}

function start_udev()
{
if [ "$UDEV" == "on" ]; then
if $PRIVILEGED; then
mount_dev
if command -v udevd &>/dev/null; then
unshare --net udevd --daemon &> /dev/null
else
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
fi
udevadm trigger &> /dev/null
else
echo "Unable to start udev, container must be run in privileged mode to start udev!"
fi
fi
}

function init()
{
# echo error message, when executable file is passed but doesn't exist.
if [ -n "$1" ]; then
if CMD=$(command -v "$1" 2>/dev/null); then
shift
exec "$CMD" "$@"
else
echo "Command not found: $1"
exit 1
fi
fi
}

UDEV=$(echo "$UDEV" | awk '{print tolower($0)}')

case "$UDEV" in
'1' | 'true')
UDEV='on'
;;
esac

start_udev
init "$@"
Binary file not shown.
77 changes: 77 additions & 0 deletions balena-base-images/aarch64/ubuntu/noble/run/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
FROM arm64v8/ubuntu:noble
LABEL io.balena.architecture="aarch64"

LABEL io.balena.qemu.version="7.0.0+balena1-aarch64"
COPY qemu-aarch64-static /usr/bin

RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
ca-certificates \
findutils \
gnupg \
dirmngr \
inetutils-ping \
netbase \
curl \
udev \
$( \
if apt-cache show 'iproute' 2>/dev/null | grep -q '^Version:'; then \
echo 'iproute'; \
else \
echo 'iproute2'; \
fi \
) \
&& rm -rf /var/lib/apt/lists/* \
&& c_rehash \
&& echo '#!/bin/sh\n\
set -e\n\
set -u\n\
export DEBIAN_FRONTEND=noninteractive\n\
n=0\n\
max=2\n\
until [ $n -gt $max ]; do\n\
set +e\n\
(\n\
apt-get update -qq &&\n\
apt-get install -y --no-install-recommends "$@"\n\
)\n\
CODE=$?\n\
set -e\n\
if [ $CODE -eq 0 ]; then\n\
break\n\
fi\n\
if [ $n -eq $max ]; then\n\
exit $CODE\n\
fi\n\
echo "apt failed, retrying"\n\
n=$(($n + 1))\n\
done\n\
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*' > /usr/sbin/install_packages \
&& chmod 0755 "/usr/sbin/install_packages"

RUN curl -SLO "http://resin-packages.s3.amazonaws.com/resin-xbuild/v1.0.0/resin-xbuild1.0.0.tar.gz" \
&& echo "1eb099bc3176ed078aa93bd5852dbab9219738d16434c87fc9af499368423437 resin-xbuild1.0.0.tar.gz" | sha256sum -c - \
&& tar -xzf "resin-xbuild1.0.0.tar.gz" \
&& rm "resin-xbuild1.0.0.tar.gz" \
&& chmod +x resin-xbuild \
&& mv resin-xbuild /usr/bin \
&& ln -sf resin-xbuild /usr/bin/cross-build-start \
&& ln -sf resin-xbuild /usr/bin/cross-build-end

ENV LC_ALL C.UTF-8
ENV UDEV off

RUN mkdir -p /usr/share/man/man1

COPY entry.sh /usr/bin/entry.sh
COPY balena-info /usr/bin/balena-info
COPY balena-idle /usr/bin/balena-idle
ENTRYPOINT ["/usr/bin/entry.sh"]

RUN curl -SLO "https://raw.githubusercontent.com/balena-io-library/base-images/a95300eda2320833e537ca20d728a870bf02177d/scripts/assets/tests/test-os.sh" \
&& echo "Running test-os" \
&& chmod +x test-os.sh \
&& bash test-os.sh ubuntu noble \
&& rm -rf test-os.sh

RUN [ ! -d /.balena/messages ] && mkdir -p /.balena/messages; echo 'Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): \nArchitecture: ARM v8 \nOS: Ubuntu noble \nVariant: run variant \nDefault variable(s): UDEV=off \nExtra features: \n- Easy way to install packages with `install_packages <package-name>` command \n- Run anywhere with cross-build feature (for ARM only) \n- Keep the container idling with `balena-idle` command \n- Show base image details with `balena-info` command' > /.balena/messages/image-info
47 changes: 47 additions & 0 deletions balena-base-images/aarch64/ubuntu/noble/run/balena-idle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

set -e

usage() {
cat <<EOUSAGE
A small script that runs an idle process to keep the container running, while periodically printing the log: "Idling..."

Options:
--message Message to print when ilding (Default to "Idling...").
--interval Printing interval in second (Default to 600 seconds).
--silent No idle message.

EOUSAGE
}

message="Idling..."
interval=600
is_silent=

# Args handling
opts="$(getopt -o 'h?' --long 'message:,interval:,silent' -- "$@" || { usage >&2 && exit 1; })"
eval set -- "$opts"

while true; do
flag=$1
shift
case "$flag" in
--message) message="$1" && shift ;;
--interval) interval="$1" && shift ;;
--silent) is_silent=true ;;
--) break ;;
*)
{
echo "error: unknown flag: $flag"
usage
} >&2
exit 1
;;
esac
done

if [ "$is_silent" == true ] ; then
sleep infinity
else
while : ; do echo "$message"; sleep $interval; done
fi
Loading
Loading