File tree Expand file tree Collapse file tree 7 files changed +60
-30
lines changed
Expand file tree Collapse file tree 7 files changed +60
-30
lines changed Original file line number Diff line number Diff line change 1717permissions :
1818 contents : read
1919
20+ env :
21+ # Enable debug logging in systemd, but keep udev's log level to info,
22+ # since it's _very_ verbose in the QEMU task
23+ KERNEL_CMDLINE : " systemd.unit=mkosi-check-and-shutdown.service !quiet systemd.log_level=debug systemd.log_target=console udev.log_level=info systemd.default_standard_output=journal+console"
24+
2025jobs :
2126 ci :
2227 runs-on : ubuntu-20.04
@@ -57,13 +62,20 @@ jobs:
5762 systemd-nspawn --version
5863
5964 - name : Build ${{ matrix.distro }}
60- run : sudo python3 -m mkosi build
65+ run : |
66+ sudo python3 -m mkosi --build-environment=CI_BUILD=1 --kernel-command-line "${{ env.KERNEL_CMDLINE }}" build
6167
6268 - name : Show ${{ matrix.distro }} image summary
6369 run : sudo python3 -m mkosi summary
6470
6571 - name : Boot ${{ matrix.distro }} systemd-nspawn
66- run : sudo ./.github/workflows/test_mkosi_boot.py python3 -m mkosi boot
72+ run : sudo python3 -m mkosi boot ${{ env.KERNEL_CMDLINE }}
73+
74+ - name : Check ${{ matrix.distro }} systemd-nspawn
75+ run : sudo python3 -m mkosi shell bash -c "[[ -e /testok ]] || { cat /failed-services; exit 1; }"
6776
6877 - name : Boot ${{ matrix.distro }} QEMU
69- run : sudo ./.github/workflows/test_mkosi_boot.py python3 -m mkosi qemu
78+ run : sudo python3 -m mkosi qemu
79+
80+ - name : Check ${{ matrix.distro }} QEMU
81+ run : sudo python3 -m mkosi shell bash -c "[[ -e /testok ]] || { cat /failed-services; exit 1; }"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -110,3 +110,12 @@ if [ -n "$IMAGE_VERSION" ] ; then
110110 cat /tmp/os-release.tmp > " $DESTDIR " /usr/lib/os-release
111111 rm /tmp/os-release.tmp
112112fi
113+
114+ # If $CI_BUILD is set, copy over the CI service which executes a service check
115+ # after boot and then shuts down the machine
116+ if [ -n " $CI_BUILD " ]; then
117+ mkdir -p " $DESTDIR /usr/lib/systemd/system"
118+ cp -v " $SRCDIR /test/mkosi-check-and-shutdown.service" " $DESTDIR /usr/lib/systemd/system/mkosi-check-and-shutdown.service"
119+ cp -v " $SRCDIR /test/mkosi-check-and-shutdown.sh" " $DESTDIR /usr/lib/systemd/mkosi-check-and-shutdown.sh"
120+ chmod +x " $DESTDIR /usr/lib/systemd/mkosi-check-and-shutdown.sh"
121+ fi
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ BuildPackages=
2323 libcryptsetup-devel
2424 libcurl-devel
2525 libgcrypt-devel
26+ libgnutls-devel
2627 libkmod-devel
2728 liblz4-devel
2829 libmicrohttpd-devel
@@ -35,8 +36,8 @@ BuildPackages=
3536 pciutils-devel
3637 pcre-devel
3738 python3
38- python3-lxml
3939 python3-Jinja2
40+ python3-lxml
4041 qrencode-devel
4142 system-user-nobody
4243 systemd-sysvinit
@@ -61,6 +62,7 @@ Packages=
6162 libcrypt1
6263 libcryptsetup12
6364 libgcrypt20
65+ libgnutls30
6466 libkmod2
6567 liblz4-1
6668 libmount1
Original file line number Diff line number Diff line change 44if [ " $1 " = " final" ] && command -v bootctl > /dev/null; then
55 bootctl install
66fi
7+
8+ # Temporary workaround until https://github.com/openSUSE/suse-module-tools/commit/158643414ddb8d8208016a5f03a4484d58944d7a
9+ # gets into OpenSUSE repos
10+ if [ " $1 " = " final" ] && grep -q openSUSE /etc/os-release; then
11+ if [ -e " /usr/lib/systemd/system/boot-sysctl.service" ] && \
12+ ! grep -F -q ' ConditionPathExists=/boot/sysctl.conf' " /usr/lib/systemd/system/boot-sysctl.service" ; then
13+ mkdir -p " /etc/systemd/system/boot-sysctl.service.d/"
14+ printf ' [Unit]\nConditionPathExists=/boot/sysctl.conf-%%v' > " /etc/systemd/system/boot-sysctl.service.d/99-temporary-workaround.conf"
15+ fi
16+ fi
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: LGPL-2.1-or-later
2+ [Unit]
3+ Description =Check if any service failed and then shutdown the machine
4+ After =multi-user.target network-online.target
5+ Requires =multi-user.target
6+ Wants =systemd-resolved.service systemd-networkd.service network-online.target
7+ OnFailure =poweroff.target
8+ OnFailureJobMode =replace-irreversibly
9+
10+ [Service]
11+ Type =oneshot
12+ ExecStartPre =-rm -f /failed-services
13+ ExecStart =/usr/lib/systemd/mkosi-check-and-shutdown.sh
14+ ExecStartPost =systemctl poweroff --no-block
Original file line number Diff line number Diff line change 1+ #! /bin/bash -eux
2+ # SPDX-License-Identifier: LGPL-2.1-or-later
3+
4+ systemctl --failed --no-legend | tee /failed-services
5+
6+ # Exit with non-zero EC if the /failed-services file is not empty (we have -e set)
7+ [[ ! -s /failed-services ]]
8+
9+ : > /testok
You can’t perform that action at this time.
0 commit comments