summaryrefslogtreecommitdiff
path: root/hooks/build-os-post/90-ostree-path-mangles
diff options
context:
space:
mode:
authorPhilip J Freeman <elektron@halo.nu>2025-05-31 12:34:14 -0700
committerPhilip J Freeman <elektron@halo.nu>2025-05-31 15:47:31 -0700
commit34105077c777b0d2c5c69f39921f376b84ce1443 (patch)
tree606152d6f739a0ee7fd8e5127e79b595f3fe8c85 /hooks/build-os-post/90-ostree-path-mangles
parent5392080129b1093f36533e47c155f618c283ea57 (diff)
Deploying a demo amd64 debian-based OS via ostree
This is a prototype outline for building and deploying a debian based OS with ostree. For purposes of demonstration, the OS runs from a bootable USB device on a UEFI capable amd64 machine. Once a USB device is created and booted, the OS can be updated using a simple shell script. <https://ostreedev.github.io/ostree/> <https://www.nin.wiki/Halo_numbers>
Diffstat (limited to 'hooks/build-os-post/90-ostree-path-mangles')
-rwxr-xr-xhooks/build-os-post/90-ostree-path-mangles47
1 files changed, 47 insertions, 0 deletions
diff --git a/hooks/build-os-post/90-ostree-path-mangles b/hooks/build-os-post/90-ostree-path-mangles
new file mode 100755
index 0000000..b2709f3
--- /dev/null
+++ b/hooks/build-os-post/90-ostree-path-mangles
@@ -0,0 +1,47 @@
+#!/bin/bash -xe
+set -o pipefail
+
+# remove everything from dev and var
+rm -rf "${root:?}"/dev/* "${root:?}"/var/*
+
+# add sysroot mountpoint and ostree link to root
+mkdir -p "${root:?}"/sysroot
+ln -s /sysroot/ostree "${root:?}"/ostree
+
+# add tmpfiles config to create expected directory structure
+cat > "${root:?}"/etc/tmpfiles.d/var.conf << EOF
+d /var/log/journal 0755 root root -
+L /var/home - - - - ../sysroot/home
+d /var/opt 0755 root root -
+d /var/srv 0755 root root -
+d /var/roothome 0700 root root -
+d /var/usrlocal 0755 root root -
+d /var/usrlocal/bin 0755 root root -
+d /var/usrlocal/etc 0755 root root -
+d /var/usrlocal/games 0755 root root -
+d /var/usrlocal/include 0755 root root -
+d /var/usrlocal/lib 0755 root root -
+d /var/usrlocal/man 0755 root root -
+d /var/usrlocal/sbin 0755 root root -
+d /var/usrlocal/share 0755 root root -
+d /var/usrlocal/src 0755 root root -
+d /var/mnt 0755 root root -
+d /run/media 0755 root root -
+d /var/games 0755 root root -
+EOF
+
+# move /etc to /usr/etc
+mv "${root:?}"/etc "${root:?}"/usr/etc
+mkdir "${root:?}"/etc # do we need this?
+
+# link persistent directories to /var
+for dir in home opt srv mnt tmp; do
+ rmdir "${root:?}"/"$dir"
+ ln -s /var/"$dir" "${root:?}"/"$dir"
+done
+
+rm -rf "${root:?}"/root
+ln -s /var/roothome "${root:?}"/root
+
+rm -rf "${root:?}"/usr/local
+ln -s /var/usrlocal "${root:?}"/usr/local