mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #20436 from fbuihuu/add-no-build-support-on-opensuse
Add no build support on opensuse
This commit is contained in:
commit
468d9bc901
@ -11,7 +11,10 @@ TEST_NO_NSPAWN=1
|
||||
test_append_files() {
|
||||
(
|
||||
local workspace="${1:?}"
|
||||
dracut_install busybox
|
||||
|
||||
# On openSUSE the static linked version of busybox is named "busybox-static".
|
||||
busybox="$(type -P busybox-static || type -P busybox)"
|
||||
inst_simple "$busybox" "$(dirname $busybox)/busybox"
|
||||
|
||||
if selinuxenabled >/dev/null; then
|
||||
dracut_install selinuxenabled
|
||||
|
@ -7,18 +7,10 @@ set -o pipefail
|
||||
root="${1:?Usage $0 container-root}"
|
||||
mkdir -p "$root"
|
||||
mkdir "$root/bin"
|
||||
cp $(type -P busybox) "$root/bin"
|
||||
|
||||
os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release)
|
||||
ID_LIKE=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' $os_release)
|
||||
if [[ "$ID_LIKE" = *"suse"* ]]; then
|
||||
mkdir -p "$root/lib"
|
||||
mkdir -p "$root/lib64"
|
||||
for lib in $(find /lib*/ld*); do
|
||||
[[ -d $root/$(dirname $lib) ]] || mkdir -p $root/$(dirname $lib)
|
||||
cp $lib $root/$lib
|
||||
done
|
||||
fi
|
||||
# On openSUSE the static linked version of busybox is named "busybox-static".
|
||||
busybox="$(type -P busybox-static || type -P busybox)"
|
||||
cp "$busybox" "$root/bin/busybox"
|
||||
|
||||
mkdir -p "$root/usr/lib"
|
||||
touch "$root/usr/lib/os-release"
|
||||
@ -30,6 +22,7 @@ ln -s busybox "$root/bin/ps"
|
||||
ln -s busybox "$root/bin/ip"
|
||||
ln -s busybox "$root/bin/seq"
|
||||
ln -s busybox "$root/bin/sleep"
|
||||
ln -s busybox "$root/bin/usleep"
|
||||
ln -s busybox "$root/bin/test"
|
||||
|
||||
mkdir -p "$root/sbin"
|
||||
|
@ -83,13 +83,11 @@ TOOLS_DIR="$SOURCE_DIR/tools"
|
||||
export TEST_BASE_DIR TEST_UNITS_DIR SOURCE_DIR TOOLS_DIR
|
||||
|
||||
# note that find-build-dir.sh will return $BUILD_DIR if provided, else it will try to find it
|
||||
if ! BUILD_DIR="$("$TOOLS_DIR"/find-build-dir.sh)"; then
|
||||
if get_bool "${NO_BUILD:=}"; then
|
||||
BUILD_DIR="$SOURCE_DIR"
|
||||
else
|
||||
echo "ERROR: no build found, please set BUILD_DIR or use NO_BUILD" >&2
|
||||
exit 1
|
||||
fi
|
||||
if get_bool "${NO_BUILD:=}"; then
|
||||
BUILD_DIR="$SOURCE_DIR"
|
||||
elif ! BUILD_DIR="$("$TOOLS_DIR"/find-build-dir.sh)"; then
|
||||
echo "ERROR: no build found, please set BUILD_DIR or use NO_BUILD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PATH_TO_INIT="$ROOTLIBDIR/systemd"
|
||||
@ -667,6 +665,7 @@ setup_basic_environment() {
|
||||
install_fs_tools
|
||||
install_modules
|
||||
install_plymouth
|
||||
install_haveged
|
||||
install_debug_tools
|
||||
install_ld_so_conf
|
||||
install_testuser
|
||||
@ -936,11 +935,52 @@ install_debian_systemd() {
|
||||
done < <(grep -E '^Package:' "${SOURCE_DIR}/debian/control" | cut -d ':' -f 2)
|
||||
}
|
||||
|
||||
install_suse_systemd() {
|
||||
local testsdir=/usr/lib/systemd/tests
|
||||
local pkgs
|
||||
|
||||
dinfo "Install SUSE systemd"
|
||||
|
||||
pkgs=(
|
||||
systemd
|
||||
systemd-container
|
||||
systemd-coredump
|
||||
systemd-experimental
|
||||
systemd-journal-remote
|
||||
systemd-portable
|
||||
udev
|
||||
)
|
||||
|
||||
for p in "${pkgs[@]}"; do
|
||||
rpm -q "$p" &>/dev/null || continue
|
||||
|
||||
ddebug "Install files from package $p"
|
||||
while read -r f; do
|
||||
[ -e "$f" ] || continue
|
||||
[ -d "$f" ] && continue
|
||||
inst "$f"
|
||||
done < <(rpm -ql "$p")
|
||||
done
|
||||
|
||||
# we only need testsdata dir as well as the unit tests (for
|
||||
# TEST-02-UNITTESTS) in the image.
|
||||
dinfo "Install unit tests and testdata directory"
|
||||
|
||||
mkdir -p "$initdir/$testsdir"
|
||||
cp "$testsdir"/test-* "$initdir/$testsdir/"
|
||||
cp -a "$testsdir/testdata" "$initdir/$testsdir/"
|
||||
|
||||
# On openSUSE, these dirs are not created at package install for now on.
|
||||
mkdir -p "$initdir/var/log/journal/remote"
|
||||
}
|
||||
|
||||
install_distro_systemd() {
|
||||
dinfo "Install distro systemd"
|
||||
|
||||
if get_bool "$LOOKS_LIKE_DEBIAN"; then
|
||||
install_debian_systemd
|
||||
elif get_bool "$LOOKS_LIKE_SUSE"; then
|
||||
install_suse_systemd
|
||||
else
|
||||
dfatal "NO_BUILD not supported for this distro"
|
||||
exit 1
|
||||
@ -958,8 +998,6 @@ install_systemd() {
|
||||
# remove unneeded documentation
|
||||
rm -fr "$initdir"/usr/share/{man,doc}
|
||||
|
||||
get_bool "$LOOKS_LIKE_SUSE" && setup_suse
|
||||
|
||||
# enable debug logging in PID1
|
||||
echo LogLevel=debug >>"$initdir/etc/systemd/system.conf"
|
||||
# store coredumps in journal
|
||||
@ -1390,6 +1428,16 @@ install_plymouth() {
|
||||
# fi
|
||||
}
|
||||
|
||||
install_haveged() {
|
||||
# If haveged is installed and probably included in initrd, it needs to be
|
||||
# installed in the image too.
|
||||
if [ -x /usr/sbin/haveged ]; then
|
||||
dinfo "Install haveged files"
|
||||
inst /usr/sbin/haveged
|
||||
inst /usr/lib/systemd/system/haveged.service
|
||||
fi
|
||||
}
|
||||
|
||||
install_ld_so_conf() {
|
||||
dinfo "Install /etc/ld.so.conf*"
|
||||
cp -a /etc/ld.so.conf* "${initdir:?}/etc"
|
||||
@ -1551,7 +1599,7 @@ install_pam() {
|
||||
paths+=(/lib*/security)
|
||||
fi
|
||||
|
||||
for d in /etc/pam.d /etc/security /usr/lib/pam.d; do
|
||||
for d in /etc/pam.d /etc/security /usr/{etc,lib}/pam.d; do
|
||||
[ -d "$d" ] && paths+=("$d")
|
||||
done
|
||||
|
||||
@ -1565,6 +1613,13 @@ install_pam() {
|
||||
|
||||
# set empty root password for easy debugging
|
||||
sed -i 's/^root:x:/root::/' "${initdir:?}/etc/passwd"
|
||||
|
||||
# And make sure pam_unix will accept it by making sure that
|
||||
# the PAM module has the nullok option.
|
||||
for d in /etc/pam.d /usr/{etc,lib}/pam.d; do
|
||||
[ -d "$initdir/$d" ] || continue
|
||||
sed -i '/^auth.*pam_unix.so/s/$/ nullok/' "$initdir/$d"/*
|
||||
done
|
||||
}
|
||||
|
||||
install_keymaps() {
|
||||
@ -2406,12 +2461,6 @@ instmods() {
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_suse() {
|
||||
ln -fs ../usr/bin/systemctl "${initdir:?}/bin/"
|
||||
ln -fs ../usr/lib/systemd "$initdir/lib/"
|
||||
inst_simple "/usr/lib/systemd/system/haveged.service"
|
||||
}
|
||||
|
||||
_umount_dir() {
|
||||
local mountpoint="${1:?}"
|
||||
if mountpoint -q "$mountpoint"; then
|
||||
|
@ -30,19 +30,13 @@ if unshare -U sh -c :; then
|
||||
is_user_ns_supported=yes
|
||||
fi
|
||||
|
||||
SUSE_OPTS=()
|
||||
ID_LIKE=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' /etc/os-release)
|
||||
if [[ "$ID_LIKE" = *"suse"* ]]; then
|
||||
SUSE_OPTS+=(--bind /lib64 --bind /usr/lib64)
|
||||
fi
|
||||
|
||||
function check_bind_tmp_path {
|
||||
# https://github.com/systemd/systemd/issues/4789
|
||||
local _root="/var/lib/machines/testsuite-13.bind-tmp-path"
|
||||
rm -rf "$_root"
|
||||
/usr/lib/systemd/tests/testdata/create-busybox-container "$_root"
|
||||
: >/tmp/bind
|
||||
systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" --bind=/tmp/bind /bin/sh -c 'test -e /tmp/bind'
|
||||
systemd-nspawn --register=no -D "$_root" --bind=/tmp/bind /bin/sh -c 'test -e /tmp/bind'
|
||||
}
|
||||
|
||||
function check_norbind {
|
||||
@ -54,15 +48,15 @@ function check_norbind {
|
||||
mount -t tmpfs tmpfs /tmp/binddir/subdir
|
||||
echo -n "inner" >/tmp/binddir/subdir/file
|
||||
/usr/lib/systemd/tests/testdata/create-busybox-container "$_root"
|
||||
systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" --bind=/tmp/binddir:/mnt:norbind /bin/sh -c 'CONTENT=$(cat /mnt/subdir/file); if [[ $CONTENT != "outer" ]]; then echo "*** unexpected content: $CONTENT"; return 1; fi'
|
||||
systemd-nspawn --register=no -D "$_root" --bind=/tmp/binddir:/mnt:norbind /bin/sh -c 'CONTENT=$(cat /mnt/subdir/file); if [[ $CONTENT != "outer" ]]; then echo "*** unexpected content: $CONTENT"; return 1; fi'
|
||||
}
|
||||
|
||||
function check_notification_socket {
|
||||
# https://github.com/systemd/systemd/issues/4944
|
||||
local _cmd='echo a | $(busybox which nc) -U -u -w 1 /run/host/notify'
|
||||
# /testsuite-13.nc-container is prepared by test.sh
|
||||
systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D /testsuite-13.nc-container /bin/sh -x -c "$_cmd"
|
||||
systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D /testsuite-13.nc-container -U /bin/sh -x -c "$_cmd"
|
||||
systemd-nspawn --register=no -D /testsuite-13.nc-container /bin/sh -x -c "$_cmd"
|
||||
systemd-nspawn --register=no -D /testsuite-13.nc-container -U /bin/sh -x -c "$_cmd"
|
||||
}
|
||||
|
||||
function check_os_release {
|
||||
@ -84,7 +78,7 @@ if echo test >>/run/host/os-release; then exit 1; fi
|
||||
echo MARKER=1 >>/etc/os-release
|
||||
fi
|
||||
|
||||
systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D /testsuite-13.nc-container --bind="${_os_release_source}":/tmp/os-release /bin/sh -x -e -c "$_cmd"
|
||||
systemd-nspawn --register=no -D /testsuite-13.nc-container --bind="${_os_release_source}":/tmp/os-release /bin/sh -x -e -c "$_cmd"
|
||||
|
||||
if grep -q MARKER /etc/os-release; then
|
||||
rm /etc/os-release
|
||||
@ -93,7 +87,7 @@ if echo test >>/run/host/os-release; then exit 1; fi
|
||||
}
|
||||
|
||||
function check_machinectl_bind {
|
||||
local _cmd='for i in $(seq 1 20); do if test -f /tmp/marker; then exit 0; fi; sleep 0.5; done; exit 1;'
|
||||
local _cmd='for i in $(seq 1 20); do if test -f /tmp/marker; then exit 0; fi; usleep 500000; done; exit 1;'
|
||||
|
||||
cat >/run/systemd/system/nspawn_machinectl_bind.service <<EOF
|
||||
[Service]
|
||||
@ -138,16 +132,16 @@ function run {
|
||||
local _root="/var/lib/machines/testsuite-13.unified-$1-cgns-$2-api-vfs-writable-$3"
|
||||
rm -rf "$_root"
|
||||
/usr/lib/systemd/tests/testdata/create-busybox-container "$_root"
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" -b
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" --private-network -b
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -b
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" --private-network -b
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" -U -b; then
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -U -b; then
|
||||
[[ "$is_user_ns_supported" = "yes" && "$3" = "network" ]] && return 1
|
||||
else
|
||||
[[ "$is_user_ns_supported" = "no" && "$3" = "network" ]] && return 1
|
||||
fi
|
||||
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" --private-network -U -b; then
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" --private-network -U -b; then
|
||||
[[ "$is_user_ns_supported" = "yes" && "$3" = "yes" ]] && return 1
|
||||
else
|
||||
[[ "$is_user_ns_supported" = "no" && "$3" = "yes" ]] && return 1
|
||||
@ -167,21 +161,21 @@ function run {
|
||||
# --network-namespace-path and network-related options cannot be used together
|
||||
for netopt in "${_net_opts[@]}"; do
|
||||
echo "$_netns_opt in combination with $netopt should fail"
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" -b "$_netns_opt" "$netopt"; then
|
||||
if SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -b "$_netns_opt" "$netopt"; then
|
||||
echo >&2 "unexpected pass"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
# allow combination of --network-namespace-path and --private-network
|
||||
if ! SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" -b "$_netns_opt" --private-network; then
|
||||
if ! SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" -b "$_netns_opt" --private-network; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# test --network-namespace-path works with a network namespace created by "ip netns"
|
||||
ip netns add nspawn_test
|
||||
_netns_opt="--network-namespace-path=/run/netns/nspawn_test"
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn "${SUSE_OPTS[@]}" --register=no -D "$_root" "$_netns_opt" /bin/ip a | grep -v -E '^1: lo.*UP'
|
||||
SYSTEMD_NSPAWN_UNIFIED_HIERARCHY="$1" SYSTEMD_NSPAWN_USE_CGNS="$2" SYSTEMD_NSPAWN_API_VFS_WRITABLE="$3" systemd-nspawn --register=no -D "$_root" "$_netns_opt" /bin/ip a | grep -v -E '^1: lo.*UP'
|
||||
local r=$?
|
||||
ip netns del nspawn_test
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user