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

Build stacker on Ubuntu 24.04 LTS (noble) #644

Merged
merged 1 commit into from
Sep 11, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ on:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
mikemccracken marked this conversation as resolved.
Show resolved Hide resolved
services:
registry:
image: ghcr.io/project-stacker/registry:2
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL=/bin/bash
TOP_LEVEL := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
BUILD_D = $(TOP_LEVEL)/.build
export GOPATH ?= $(BUILD_D)/gopath
Expand Down Expand Up @@ -77,6 +78,16 @@ stacker-cov: $(STAGE1_STACKER) $(STACKER_DEPS) cmd/stacker/lxc-wrapper/lxc-wrapp
--substitute VERSION_FULL=$(VERSION_FULL) \
--substitute WITH_COV=yes

# On Ubuntu 24.04 the lxc package does not link against libsystemd so the pkg-config
# below does list -lsystemd; we must add it to the list but only for stacker-dynamic
ifeq ($(shell awk -F= '/VERSION_ID/ {print $$2}' /etc/os-release),"24.04")
ifeq (stacker-dynamic,$(firstword $(MAKECMDGOALS)))
LXC_WRAPPER_LIBS=-lsystemd
else
LXC_WRAPPER_LIBS=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it probably doesn't matter as I don't think it'll fail on undefined variables, but I think you meant for LXC_WRAPPER_LIBS= to also happen if it's not 24.04?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't. On 24.04, the lxc-wrapper binary requires a static link to systemd;

$ make stacker-dynamic
make -C cmd/stacker/lxc-wrapper LDFLAGS=-static LDLIBS="-llxc -lutil -lpthread -ldl -lpam -lseccomp -lselinux -lsepol -lpcre2-8 -L/usr/lib64 -lcap   -lpthread -ldl" lxc-wrapper
make[1]: Entering directory '/home/ubuntu/stacker/cmd/stacker/lxc-wrapper'
cc   -static  lxc-wrapper.c  -llxc -lutil -lpthread -ldl -lpam -lseccomp -lselinux -lsepol -lpcre2-8 -L/usr/lib64 -lcap   -lpthread -ldl -o lxc-wrapper
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(conf.c.o): in function `suggest_default_idmap':
(.text+0x18eb0): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(attach.c.o): in function `lxc_attach_run_shell':
(.text+0x6486): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(cgroups_cgfsng.c.o): in function `systemd_jobremoved_callback':
(.text+0x2eeb): undefined reference to `sd_bus_message_read'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(cgroups_cgfsng.c.o): in function `cgroup_attach_move_into_leaf.isra.0':
(.text+0x6813): undefined reference to `sd_bus_open_user'
/usr/bin/ld: (.text+0x6851): undefined reference to `sd_bus_message_new_method_call'
/usr/bin/ld: (.text+0x688c): undefined reference to `sd_bus_message_append'
/usr/bin/ld: (.text+0x68b5): undefined reference to `sd_bus_call'
/usr/bin/ld: (.text+0x68d5): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text+0x68e6): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text+0x68ee): undefined reference to `sd_bus_error_free'
/usr/bin/ld: (.text+0x68ff): undefined reference to `sd_bus_unref'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(cgroups_cgfsng.c.o): in function `initialize_cgroups':
(.text+0xc7bc): undefined reference to `sd_bus_open_user'
/usr/bin/ld: (.text+0xc7fa): undefined reference to `sd_bus_call_method_async'
/usr/bin/ld: (.text+0xc852): undefined reference to `sd_bus_match_signal'
/usr/bin/ld: (.text+0xc86a): undefined reference to `sd_event_new'
/usr/bin/ld: (.text+0xc887): undefined reference to `sd_bus_attach_event'
/usr/bin/ld: (.text+0xc8a2): undefined reference to `sd_event_unref'
/usr/bin/ld: (.text+0xc90d): undefined reference to `sd_bus_unref'
/usr/bin/ld: (.text+0xe127): undefined reference to `sd_bus_message_new_method_call'
/usr/bin/ld: (.text+0xe159): undefined reference to `sd_bus_message_append'
/usr/bin/ld: (.text+0xe180): undefined reference to `sd_bus_message_open_container'
/usr/bin/ld: (.text+0xe1ea): undefined reference to `sd_bus_message_append'
/usr/bin/ld: (.text+0xe209): undefined reference to `sd_bus_message_close_container'
/usr/bin/ld: (.text+0xe22f): undefined reference to `sd_bus_message_append'
/usr/bin/ld: (.text+0xe258): undefined reference to `sd_bus_call'
/usr/bin/ld: (.text+0xe27c): undefined reference to `sd_bus_message_read'
/usr/bin/ld: (.text+0xe2a0): undefined reference to `sd_event_run'
/usr/bin/ld: (.text+0xe2d8): undefined reference to `sd_event_run'
/usr/bin/ld: (.text+0xe327): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text+0xe338): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text+0xe340): undefined reference to `sd_bus_error_free'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(cgroups_cgfsng.c.o): in function `cgroup_attach_move_into_leaf.isra.0.cold':
(.text.unlikely+0x22a): undefined reference to `sd_bus_error_free'
/usr/bin/ld: (.text.unlikely+0x292): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text.unlikely+0x2aa): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text.unlikely+0x2e1): undefined reference to `sd_bus_unref'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/liblxc.a(cgroups_cgfsng.c.o): in function `initialize_cgroups.cold':
(.text.unlikely+0x6a1): undefined reference to `sd_bus_unref'
/usr/bin/ld: (.text.unlikely+0x707): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text.unlikely+0x718): undefined reference to `sd_bus_message_unref'
/usr/bin/ld: (.text.unlikely+0x720): undefined reference to `sd_bus_error_free'
collect2: error: ld returned 1 exit status
make[1]: *** [<builtin>: lxc-wrapper] Error 1
make[1]: Leaving directory '/home/ubuntu/stacker/cmd/stacker/lxc-wrapper'
make: *** [Makefile:104: cmd/stacker/lxc-wrapper/lxc-wrapper] Error 2

and pkg-config --static --libs lxc does not emit an -lsystemd.

However on 22.04; it doesn't seem to require the -lsystemd ; I'm not exactly sure why; I assume it's related to how the liblxc.a is built in the lxc-dev package in 24.04 vs what's in 22.04?

The intention then is to append the -lsystemd when making stacker-dynamic but to omit the link when we create stacker-static which is compiled inside a stacker root we constructed, and there, we don't use/need systemd since we compile our own lxc lib.

endif
endif

stacker-static: $(STACKER_DEPS) cmd/stacker/lxc-wrapper/lxc-wrapper
$(call build_stacker,,static_build,-extldflags '-static',stacker)

Expand All @@ -91,7 +102,7 @@ stacker-dynamic: $(STACKER_DEPS) cmd/stacker/lxc-wrapper/lxc-wrapper
$(call build_stacker,,,,stacker-dynamic)

cmd/stacker/lxc-wrapper/lxc-wrapper: cmd/stacker/lxc-wrapper/lxc-wrapper.c
make -C cmd/stacker/lxc-wrapper LDFLAGS=-static LDLIBS="$(shell pkg-config --static --libs lxc) -lpthread -ldl" lxc-wrapper
make -C cmd/stacker/lxc-wrapper LDFLAGS=-static LDLIBS="$(shell pkg-config --static --libs lxc) $(LXC_WRAPPER_LIBS) -lpthread -ldl" lxc-wrapper


.PHONY: go-download
Expand Down
101 changes: 78 additions & 23 deletions install-build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,58 @@ installdeps_fedora() {
}

installdeps_ubuntu() {
sudo add-apt-repository -y ppa:project-machine/squashfuse
sudo apt -yy install \
build-essential \
cryptsetup-bin \
jq \
libacl1-dev \
libcap-dev \
libcryptsetup-dev \
libdevmapper-dev \
libpam0g-dev \
libseccomp-dev \
libselinux1-dev \
libssl-dev \
libzstd-dev \
lxc-dev \
lxc-utils \
parallel \
pkg-config \
squashfs-tools \
squashfuse \
libarchive-tools
PKGS=(
build-essential
cryptsetup-bin
jq
libacl1-dev
libcap-dev
libcryptsetup-dev
libdevmapper-dev
liblxc-dev
libpam0g-dev
libseccomp-dev
libselinux1-dev
libssl-dev
libzstd-dev
lxc-dev
lxc-utils
parallel
pkg-config
squashfs-tools
squashfuse
libarchive-tools
)

case "$VERSION_ID" in
22.04)
sudo add-apt-repository -y ppa:project-machine/squashfuse
;;
24.04)
# lp:2080069
# temporarily add puzzleos/dev to pickup lxc-dev package which
# provides static liblxc.a
sudo add-apt-repository -y ppa:puzzleos/dev

# allow array to expand again
#shellcheck disable=2206
PKGS=( ${PKGS[*]} libsystemd-dev )

# 24.04 has additional apparmor restrictions, probably doesn't apply
# for root in github VM but developers will run into this
enable_userns
;;
esac

# allow array to expand
#shellcheck disable=2206
sudo apt -yy install ${PKGS[*]}

# Work around an Ubuntu packaging bug. Fixed in 23.04 onward.
if [ "$VERSION_ID" != "24.04" ]; then
sudo sed -i 's/#define LXC_DEVEL 1/#define LXC_DEVEL 0/' /usr/include/lxc/version.h
fi

# skopeo deps
sudo apt -yy install \
libgpgme-dev \
Expand All @@ -54,8 +85,24 @@ installdeps_ubuntu() {
sudo apt -yy install golang-go
go version
fi
# Work around an Ubuntu packaging bug. Fixed in 23.04 onward.
sudo sed -i 's/#define LXC_DEVEL 1/#define LXC_DEVEL 0/' /usr/include/lxc/version.h
}

enable_userns() {
SYSCTL_USERNS="/etc/sysctl.d/00-enable-userns.conf"
if ! [ -s "${SYSCTL_USERNS}" ]; then
echo "Add kernel tunables to enable user namespaces in $SYSCTL_USERNS "
cat <<EOF | sudo tee "${SYSCTL_USERNS}"
kernel.apparmor_restrict_unprivileged_io_uring = 0
kernel.apparmor_restrict_unprivileged_unconfined = 0
kernel.apparmor_restrict_unprivileged_userns = 0
kernel.apparmor_restrict_unprivileged_userns_complain = 0
kernel.apparmor_restrict_unprivileged_userns_force = 0
kernel.unprivileged_bpf_disabled = 2
kernel.unprivileged_userns_apparmor_policy = 0
kernel.unprivileged_userns_clone = 1
EOF
sudo sysctl -p /etc/sysctl.d/00-enable-userns.conf
fi
}

installdeps_golang() {
Expand All @@ -78,5 +125,13 @@ case $ID_LIKE in
;;
esac

# add container policy (if not already present
POLICY="/etc/containers/policy.json"
if ! [ -s "${POLICY}" ]; then
sudo mkdir -p "$(dirname $POLICY)"
echo "adding default containers policy (insecure):${POLICY}"
echo '{"default":[{"type":"insecureAcceptAnything"}]}' | sudo tee "${POLICY}"
fi

# install golang deps
installdeps_golang || exit 1
5 changes: 3 additions & 2 deletions test/whiteout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ EOF
continue
}
bsdtar -tvf oci/blobs/sha256/$f
run "bsdtar -tvf oci/blobs/sha256/$f | grep '.wh.sensors.d'"
if [ "$status" -eq 0 ]; then
# we expect the grep to fail, if it returns success we fail the test since
# it means we have .wh files in the tar which we should NOT.
if run bsdtar -tvf oci/blobs/sha256/$f | grep '.wh.sensors.d'; then
echo "should not have a sensors.d whiteout!";
exit 1;
fi
Expand Down
Loading