mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 10:51:20 +03:00
ae6c598791
We have four legal cases: 1. /usr/lib/os-release exists and /etc/os-release is a symlink to it 2. both exist but /etc/os-release is not a symlink to /usr/lib/os-release 3. only /usr/lib/os-release exists 4. only /etc/os-release exists The generic setup code in test-functions and create-busybox-image didn't handle case 3. The test-specific code in TEST-50 didn't handle 2 (because the general setup code would only install /etc/os-release in the image and grep -f /usr/lib/os-release would not work) and 4 (same reason) and would fail in case 3 in generic setup.
65 lines
1.4 KiB
Bash
Executable File
65 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
set -u
|
|
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
|
|
|
|
mkdir -p "$root/usr/lib"
|
|
touch "$root/usr/lib/os-release"
|
|
|
|
ln -s busybox "$root/bin/sh"
|
|
ln -s busybox "$root/bin/cat"
|
|
ln -s busybox "$root/bin/tr"
|
|
ln -s busybox "$root/bin/ps"
|
|
ln -s busybox "$root/bin/ip"
|
|
|
|
mkdir -p "$root/sbin"
|
|
cat <<'EOF' >"$root/sbin/init"
|
|
#!/bin/sh
|
|
|
|
printf "ps aufx:\n"
|
|
ps aufx
|
|
|
|
printf "/proc/1/cmdline:\n"
|
|
printf "%s\n\n" "$(tr '\0' ' ' </proc/1/cmdline)"
|
|
|
|
printf "/proc/1/environ:\n"
|
|
printf "%s\n\n" "$(tr '\0' '\n' </proc/1/environ)"
|
|
|
|
printf "/proc/1/mountinfo:\n"
|
|
cat /proc/self/mountinfo
|
|
printf "\n"
|
|
|
|
printf "/proc/1/cgroup:\n"
|
|
printf "%s\n\n" "$(cat /proc/1/cgroup)"
|
|
|
|
printf "/proc/1/uid_map:\n"
|
|
printf "%s\n\n" "$(cat /proc/1/uid_map)"
|
|
|
|
printf "/proc/1/setgroups:\n"
|
|
printf "%s\n\n" "$(cat /proc/1/setgroups)"
|
|
|
|
printf "/proc/1/gid_map:\n"
|
|
printf "%s\n\n" "$(cat /proc/1/gid_map)"
|
|
|
|
printf "ip link:\n"
|
|
ip link
|
|
EOF
|
|
chmod +x "$root/sbin/init"
|