|
| 1 | +#!/bin/bash |
| 2 | +# All local filesystem configuration for a derived test image. |
| 3 | +# No network access required; this runs after provision-fetch.sh has |
| 4 | +# installed all packages. See also: Dockerfile fetch/base stage split. |
| 5 | +set -xeu |
| 6 | + |
| 7 | +cloudinit=0 |
| 8 | +case ${1:-} in |
| 9 | + cloudinit) cloudinit=1 ;; |
| 10 | + "") ;; |
| 11 | + *) echo "Unhandled flag: ${1:-}" 1>&2; exit 1 ;; |
| 12 | +esac |
| 13 | + |
| 14 | +# Clean root's homedir (provision-fetch.sh may have left cargo/dnf state). |
| 15 | +rm -rf /var/roothome/.config |
| 16 | +mkdir -p -m 0700 /var/roothome |
| 17 | + |
| 18 | +# Nushell config for root: store the files under /usr so they are covered by |
| 19 | +# the OS image, then use tmpfiles.d 'C' to copy them into /var/roothome at |
| 20 | +# first boot. Writing directly to /var would require tmpfiles entries anyway |
| 21 | +# and would fail `bootc container lint --fatal-warnings`. |
| 22 | +mkdir -p /usr/share/bootc-test/nushell-skel |
| 23 | +echo '$env.config = { show_banner: false, }' > /usr/share/bootc-test/nushell-skel/config.nu |
| 24 | +touch /usr/share/bootc-test/nushell-skel/env.nu |
| 25 | +cat >/usr/lib/tmpfiles.d/bootc-test-nushell.conf <<'EOF' |
| 26 | +d /var/roothome/.config 0700 root root - - |
| 27 | +d /var/roothome/.config/nushell 0700 root root - - |
| 28 | +C+ /var/roothome/.config/nushell/config.nu 0600 root root - /usr/share/bootc-test/nushell-skel/config.nu |
| 29 | +C+ /var/roothome/.config/nushell/env.nu 0600 root root - /usr/share/bootc-test/nushell-skel/env.nu |
| 30 | +EOF |
| 31 | + |
| 32 | +# kargs for serial console |
| 33 | +cat <<KARGEOF >> /usr/lib/bootc/kargs.d/20-console.toml |
| 34 | +kargs = ["console=ttyS0,115200n8"] |
| 35 | +KARGEOF |
| 36 | + |
| 37 | +if test $cloudinit = 1; then |
| 38 | + ln -s ../cloud-init.target /usr/lib/systemd/system/default.target.wants |
| 39 | + # Allow root SSH login for testing with bcvk/tmt |
| 40 | + mkdir -p /etc/cloud/cloud.cfg.d |
| 41 | + cat > /etc/cloud/cloud.cfg.d/80-enable-root.cfg <<'CLOUDEOF' |
| 42 | +# Enable root login for testing |
| 43 | +disable_root: false |
| 44 | +
|
| 45 | +# In image mode, the host root filesystem is mounted at /sysroot, not / |
| 46 | +# That is the one we should attempt to resize, not what is mounted at / |
| 47 | +growpart: |
| 48 | + mode: auto |
| 49 | + devices: ["/sysroot"] |
| 50 | +resize_rootfs: false |
| 51 | +CLOUDEOF |
| 52 | +fi |
| 53 | + |
| 54 | +cat >/usr/lib/tmpfiles.d/bootc-cloud-init.conf <<'EOF' |
| 55 | +d /var/lib/cloud 0755 root root - - |
| 56 | +EOF |
| 57 | + |
| 58 | +# Fast track tmpfiles.d content from the base image, xref |
| 59 | +# https://gitlab.com/fedora/bootc/base-images/-/merge_requests/92 |
| 60 | +if test '!' -f /usr/lib/tmpfiles.d/bootc-base-rpmstate.conf; then |
| 61 | + cat >/usr/lib/tmpfiles.d/bootc-base-rpmstate.conf <<'EOF' |
| 62 | +# Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=771713 |
| 63 | +d /var/lib/rpm-state 0755 - - - |
| 64 | +EOF |
| 65 | +fi |
| 66 | +if ! grep -q -r var/roothome/buildinfo /usr/lib/tmpfiles.d; then |
| 67 | + cat > /usr/lib/tmpfiles.d/bootc-contentsets.conf <<'EOF' |
| 68 | +# Workaround for https://github.com/konflux-ci/build-tasks-dockerfiles/pull/243 |
| 69 | +d /var/roothome/buildinfo 0755 - - - |
| 70 | +d /var/roothome/buildinfo/content_manifests 0755 - - - |
| 71 | +# Note we don't actually try to recreate the content; this just makes the linter ignore it |
| 72 | +f /var/roothome/buildinfo/content_manifests/content-sets.json 0644 - - - |
| 73 | +EOF |
| 74 | +fi |
| 75 | + |
| 76 | +# And add missing sysusers.d entries |
| 77 | +if ! grep -q -r sudo /usr/lib/sysusers.d; then |
| 78 | + cat >/usr/lib/sysusers.d/bootc-sudo-workaround.conf <<'EOF' |
| 79 | +g sudo 16 |
| 80 | +EOF |
| 81 | +fi |
| 82 | + |
| 83 | +# dhcpcd |
| 84 | +if rpm -q dhcpcd &>/dev/null; then |
| 85 | +if ! grep -q -r dhcpcd /usr/lib/sysusers.d; then |
| 86 | + cat >/usr/lib/sysusers.d/bootc-dhcpcd-workaround.conf <<'EOF' |
| 87 | +u dhcpcd - 'Minimalistic DHCP client' /var/lib/dhcpcd |
| 88 | +EOF |
| 89 | +fi |
| 90 | +cat >/usr/lib/tmpfiles.d/bootc-dhcpd.conf <<'EOF' |
| 91 | +d /var/lib/dhcpcd 0755 root dhcpcd - - |
| 92 | +EOF |
| 93 | + rm -rf /var/lib/dhcpcd |
| 94 | +fi |
| 95 | +# dhclient |
| 96 | +if test -d /var/lib/dhclient; then |
| 97 | + cat >/usr/lib/tmpfiles.d/bootc-dhclient.conf <<'EOF' |
| 98 | +d /var/lib/dhclient 0755 root root - - |
| 99 | +EOF |
| 100 | + rm -rf /var/lib/dhclient |
| 101 | +fi |
| 102 | + |
| 103 | +# The following configs are skipped when SKIP_CONFIGS=1, which is used |
| 104 | +# for testing bootc install on Fedora CoreOS where these would conflict. |
| 105 | +if test -z "${SKIP_CONFIGS:-}"; then |
| 106 | + # For test-22-logically-bound-install |
| 107 | + install -D -m 0644 -t /usr/share/containers/systemd/ lbi/* |
| 108 | + for x in curl.container curl-base.image podman.image; do |
| 109 | + ln -s /usr/share/containers/systemd/$x /usr/lib/bootc/bound-images.d/$x |
| 110 | + done |
| 111 | + |
| 112 | + # Add some testing kargs into our dev builds |
| 113 | + install -D -t /usr/lib/bootc/kargs.d test-kargs/* |
| 114 | + # Also copy in some default install configs we use for testing |
| 115 | + install -D -t /usr/lib/bootc/install/ install-test-configs/* |
| 116 | + |
| 117 | + # Install os-image-map.json for tests that need to select OS-matched images |
| 118 | + install -D -m 0644 os-image-map.json /usr/share/bootc/os-image-map.json |
| 119 | +else |
| 120 | + echo "SKIP_CONFIGS is set, skipping LBIs, test kargs, and install configs" |
| 121 | +fi |
0 commit comments