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

Conversation

raharper
Copy link
Contributor

Fix build on Ubuntu 24.04

  • install libsystem-dev for static libsystemd library
  • Use ppa:puzzleos/dev to pull in patched lxc 5.0.3 which includes liblxc.a in the lxc-dev package
  • Handle modifying kernel tunables for user-namespace and apparmor restrictions
  • Adjust Makefile to add -lsystemd to the libs when making stacker-dynamic, but omit the library when stacker-static is building built
  • Add default container policy to rfs if not already present

What type of PR is this?

feature

Which issue does this PR fix:

#632 Feat: build on Ubuntu 24.04

What does this PR do / Why do we need it:

Allows stacker to be build on Ubuntu 24.04

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

none

Automation added to e2e:

none

Will this break upgrades or downgrades?

no

Does this PR introduce any user-facing change?:

no


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.72%. Comparing base (7b4a6e2) to head (1fb1d2e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   62.83%   63.72%   +0.89%     
==========================================
  Files          57       57              
  Lines        5015     5015              
==========================================
+ Hits         3151     3196      +45     
+ Misses       1241     1176      -65     
- Partials      623      643      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@raharper raharper force-pushed the feat/build-on-noble branch 2 times, most recently from 81abcb6 to 776a5b0 Compare September 11, 2024 19:03
Fix build on Ubuntu 24.04

- install libsystem-dev for static libsystemd library
- Use ppa:puzzleos/dev to pull in patched lxc 5.0.3 which includes
  liblxc.a in the lxc-dev package
- Handle modifying kernel tunables for user-namespace and apparmor
  restrictions
- Adjust Makefile to add -lsystemd to the libs when making
  stacker-dynamic, but omit the library when stacker-static is building
  built
- Add default container policy to rfs if not already present
- Fix whiteouts.bats test, don't quote the bsdtar | grep or we get
  command not found, further, check the grep return code, if it's
  0, then we found the whiteout file in the tar and the test should
  fail.

Fixes: project-stacker#632

Signed-off-by: Ryan Harper <rharper@woxford.com>
Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

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

lgtm

@rchincha rchincha merged commit dbfe650 into project-stacker:main Sep 11, 2024
11 checks passed
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants