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

run_qemu.sh: make ndctl compilation compatible with mkosi v15+ #80

Merged
merged 6 commits into from
Dec 13, 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
10 changes: 9 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
img_distro: ubuntu
img_rel: noble
arch: [x86_64]
run_opts: [--cxl]
run_opts: [--cxl --ndctl-build]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -79,6 +79,13 @@ jobs:
sudo apt install -y autoconf
sudo make -C argbash-${AB_VER}/resources install PREFIX=/usr/local/

- name: download ndctl
uses: actions/checkout@v4
with:
repository: pmem/ndctl
ref: v80
path: ndctl

- name: download kernel
uses: actions/checkout@v4
with:
Expand All @@ -105,6 +112,7 @@ jobs:
mkosi --version
cd kernel
distro=${{ matrix.cfg.img_distro }} rev=${{ matrix.cfg.img_rel }} \
ndctl='${{ github.workspace }}'/ndctl \
../run_qemu/run_qemu.sh -v --no-run ${{ matrix.run_opts }}

# TODO: drop --no-run thanks to "nested KVM" or something?
1 change: 1 addition & 0 deletions mkosi.ubuntu.default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Packages=
libkeyutils-dev
python3
cmake
pkgconf
openssh-server
gdb
git
Expand Down
18 changes: 18 additions & 0 deletions mkosi/extra/root/ndctl/reinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -e
set -x

MYDIR=$(dirname "$0")

main()
{
cd "$MYDIR"
rm -rf build
meson setup build
meson configure -Dtest=enabled -Ddestructive=enabled build
meson compile -C build
meson install -C build
}

main
41 changes: 25 additions & 16 deletions run_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ process_options_logic()
if [[ $_arg_kvm = "off" ]]; then
accel="tcg"
fi

check_ndctl_dir
}

make_install_kernel()
Expand Down Expand Up @@ -922,20 +924,30 @@ setup_network()
EOF
}

prepare_ndctl_build()
check_ndctl_dir()
{
cat <<- EOF > mkosi.postinst
#!/bin/bash -ex
if [ -n "$ndctl" ]; then
[ -f "$ndctl/meson.build" ] ||
fail 'ndctl="%s" is not a valid source directory\n' "$ndctl"
fi
}

if [[ ! -d /root/ndctl ]]; then
exit 0
prepare_ndctl_build()
{
cp "${script_dir}"/mkosi/extra/root/ndctl/reinstall.sh \
mkosi.extra/root/ndctl/
cat <<- 'EOF' > mkosi.postinst
# v14: 'systemd-nspawn"; v15: "mkosi"
printf 'container=%s\n' "$container"
# .postinst and others moved outside container in mkosi v15, see
# https://github.com/systemd/mkosi/commit/9b626c647037bc8a
if [ -n "$container" ]; then
/root/ndctl/reinstall.sh
else
# The magic, short-lived $SCRIPT variable is already deprecated
# and we don't need it.
mkosi-chroot /root/ndctl/reinstall.sh
fi
pushd /root/ndctl
rm -rf build
meson setup build
meson configure -Dtest=enabled -Ddestructive=enabled build
meson compile -C build
meson install -C build
EOF
chmod +x mkosi.postinst
}
Expand Down Expand Up @@ -1060,8 +1072,9 @@ make_rootfs()
rsync "${rsync_opts[@]}" ~/git/extra-scripts/bin/* mkosi.extra/root/bin/
fi
if [[ $_arg_ndctl_build == "on" ]]; then
if [ -d "$ndctl" ]; then
if [ -n "$ndctl" ]; then
rsync "${rsync_opts[@]}" "$ndctl/" mkosi.extra/root/ndctl
prepare_ndctl_build # create mkosi.postinst which compiles
fi
fi
if [ -f /etc/localtime ]; then
Expand Down Expand Up @@ -1091,10 +1104,6 @@ make_rootfs()
setup_depmod "mkosi.extra"
setup_autorun "mkosi.extra"

if [[ $_arg_ndctl_build == "on" ]]; then
prepare_ndctl_build
fi

if [[ $_arg_gcp == "off" ]]; then
mkosi_opts+=("--autologin")
fi
Expand Down