diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | README.md | 16 | ||||
| -rwxr-xr-x | make_rootfs.sh | 57 | ||||
| -rwxr-xr-x | ostree_commit.sh | 8 | ||||
| -rwxr-xr-x | ostree_delta.sh | 7 |
5 files changed, 91 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75b7505 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +repo/ +rootfs/ +delta-update-file diff --git a/README.md b/README.md new file mode 100644 index 0000000..52266d8 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# ostree-demo + +roughing out a quick demo to try out ostree for deploying ubuntu + +# delta test - adding nethack + + sudo ./make_rootfs.sh + sudo ./make_rootfs.sh with-app + + sudo ./ostree_commit.sh rootfs/20250504.182708/ + sudo ./ostree_commit.sh rootfs/20250504.183218/ + + sudo ./ostree_delta.sh rootfs^ rootfs + + du -sh delta-update-file + 60K delta-update-file diff --git a/make_rootfs.sh b/make_rootfs.sh new file mode 100755 index 0000000..811c5cb --- /dev/null +++ b/make_rootfs.sh @@ -0,0 +1,57 @@ +#!/bin/bash -xe + +IMAGE_VERSION=$( date +%Y%m%d.%H%M%S ) + +function unmount_pseudo_filesystems(){ + set +e + for dir in dev sys proc; do umount -v "$root"/"$dir"; done + set -e +} + +function on_exit(){ + set +e + unmount_pseudo_filesystems + umount -v "$root" +} +trap on_exit EXIT + +root=rootfs/"$IMAGE_VERSION" + +mkdir -p "$root" + +# bootstrap the OS + +debootstrap noble "$root" + +for dir in /proc /sys /dev; do + mount --bind "$dir" "$root"/"$dir" +done + +export DEBIAN_FRONTEND=noninteractive + +chroot "$root" locale-gen en_US.UTF-8 + +chroot "$root" apt-get update + +# Install a kernel and bootloader + +chroot "$root" apt-get -y --no-install-recommends install linux-generic-hwe-24.04 grub-efi + +if [ "$1" == "with-app" ]; then + # Install an application + chroot "$root" apt-get update + chroot "$root" apt-get install -y software-properties-common + chroot "$root" add-apt-repository -y universe + chroot "$root" apt-get update + chroot "$root" apt-get -y install nethack-console +fi + + +# Cleanup + +chroot "$root" apt-get clean + +unmount_pseudo_filesystems + +rm -rf "$root"/dev/* +rm -rf "$root"/var/lib/apt/lists/* diff --git a/ostree_commit.sh b/ostree_commit.sh new file mode 100755 index 0000000..23a04e0 --- /dev/null +++ b/ostree_commit.sh @@ -0,0 +1,8 @@ +#!/bin/bash -xe + +ROOTFS_DIR=$1 + +[ ! -d repo ] && \ + ostree --repo=repo init + +ostree --repo=repo commit --branch=rootfs "$ROOTFS_DIR" diff --git a/ostree_delta.sh b/ostree_delta.sh new file mode 100755 index 0000000..2a23b56 --- /dev/null +++ b/ostree_delta.sh @@ -0,0 +1,7 @@ +#!/bin/bash -xe + +FROM_REF=$1 +TO_REF=$2 + +ostree --repo=repo static-delta generate --min-fallback-size=0 \ + --filename=delta-update-file --from="$FROM_REF" "$TO_REF" |
