| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | type getarg >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || . /lib/dracut-lib.shscip-shell source . . `/lib/dracut-lib.sh`. |
| 4 | type getOverlayBaseDirectory >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || . /lib/kiwi-filesystem-lib.shscip-shell source . . `/lib/kiwi-filesystem-lib.sh`. |
| 5 | |
| 6 | [scip-shell system . . `[`. -z "${root}" ] && root=$(getarg root=) |
| 7 | |
| 8 | if [scip-shell system . . `[`. "${root%%:*}" = "overlay" ] ; then |
| 9 | overlayroot=${root} |
| 10 | fi |
| 11 | |
| 12 | # Generate sysroot unit only if overlay is requested |
| 13 | [scip-shell system . . `[`. "${overlayroot%%:*}" = "overlay" ] || exit 0 |
| 14 | |
| 15 | GENERATOR_DIR="$2" |
| 16 | [scip-shell system . . `[`. -z "$GENERATOR_DIR" ] && exit 1 |
| 17 | [scip-shell system . . `[`. -d "$GENERATOR_DIR" ] || mkdirscip-shell system . . mkdir. "$GENERATOR_DIR" |
| 18 | |
| 19 | OVERLAY_BASE="$(getOverlayBaseDirectory)" |
| 20 | ROOTFLAGS="$(getarg rootflags)" |
| 21 | |
| 22 | if getargbool 0 rd.root.overlay.readonly; then |
| 23 | { |
| 24 | echoscip-shell system . . echo. "[Unit]" |
| 25 | echoscip-shell system . . echo. "Before=initrd-root-fs.target" |
| 26 | echoscip-shell system . . echo. "DefaultDependencies=no" |
| 27 | echoscip-shell system . . echo. "After=run-overlay-rootfsbase.mount" |
| 28 | echoscip-shell system . . echo. "After=run-overlay.mount" |
| 29 | echoscip-shell system . . echo. "[Mount]" |
| 30 | echoscip-shell system . . echo. "Where=/sysroot" |
| 31 | echoscip-shell system . . echo. "What=${OVERLAY_BASE}/rootfsbase" |
| 32 | echoscip-shell system . . echo. "Options=bind" |
| 33 | echoscip-shell system . . echo. "Type=none" |
| 34 | _dev=ReadOnlyOS_rootfs |
| 35 | } > "$GENERATOR_DIR"/sysroot.mount |
| 36 | else |
| 37 | { |
| 38 | echoscip-shell system . . echo. "[Unit]" |
| 39 | echoscip-shell system . . echo. "Before=initrd-root-fs.target" |
| 40 | echoscip-shell system . . echo. "DefaultDependencies=no" |
| 41 | echoscip-shell system . . echo. "After=run-overlay-rootfsbase.mount" |
| 42 | echoscip-shell system . . echo. "After=run-overlay.mount" |
| 43 | echoscip-shell system . . echo. "[Mount]" |
| 44 | echoscip-shell system . . echo. "Where=/sysroot" |
| 45 | echoscip-shell system . . echo. "What=OverlayOS_rootfs" |
| 46 | echoscip-shell system . . echo. "Options=${ROOTFLAGS},lowerdir=${OVERLAY_BASE}/rootfsbase,upperdir=${OVERLAY_BASE}/overlayfs/rw,workdir=${OVERLAY_BASE}/overlayfs/work" |
| 47 | echoscip-shell system . . echo. "Type=overlay" |
| 48 | _dev=OverlayOS_rootfs |
| 49 | } > "$GENERATOR_DIR"/sysroot.mount |
| 50 | fi |
| 51 | |
| 52 | if [scip-shell system . . `[`. ! -e "$GENERATOR_DIR/initrd-root-fs.target.requires/sysroot.mount" ]; then |
| 53 | mkdirscip-shell system . . mkdir. -p "$GENERATOR_DIR"/initrd-root-fs.target.requires |
| 54 | lnscip-shell system . . ln. -s "$GENERATOR_DIR"/sysroot.mount \ |
| 55 | "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount |
| 56 | fi |
| 57 | |
| 58 | mkdirscip-shell system . . mkdir. -p "$GENERATOR_DIR/$_dev.device.d" |
| 59 | { |
| 60 | echoscip-shell system . . echo. "[Unit]" |
| 61 | echoscip-shell system . . echo. "JobTimeoutSec=3000" |
| 62 | } > "$GENERATOR_DIR/$_dev.device.d/timeout.conf" |