[INCOMPATIBLE CHANGE] Implement new deployment model
See https://wiki.gnome.org/OSTree/DeploymentModel2 This is a major rework of the on-disk filesystem layout, and the boot process. OSTree now explicitly supports upgrading kernels, and these upgrades are also atomic. The core concept of the new model is the "deployment list", which is an ordered list of bootable operating system trees. The deployment list is reflected in the bootloader configuration; which has a kernel argument that tells the initramfs (dracut) which operating system root to use. Invidiual notable changes that come along with this: 1) Operating systems should now come with their etc in usr/etc; OSTree will perform a 3-way merge at deployment time, and place etc in the actual root. This avoids the need for a bind mount, and is just a lot cleaner. 2) OSTree no longer bind mounts /root, /home, and /tmp. It is expected that the the OS/ has these as symbolic links into /var. At the moment, OSTree only supports managing syslinux; other bootloader backends will follow.
This commit is contained in:
1 parent
ecb3f0de03
commit
bb6eedfb25
33 files changed
+4236
-2126
No files matched your search
@@ -34,10 +34,18 @@ assert_streq () {
|
||||
test "$1" = "$2" || (echo 1>&2 "$1 != $2"; exit 1)
|
||||
}
|
||||
|
||||
assert_not_streq () {
|
||||
(! test "$1" = "$2") || (echo 1>&2 "$1 == $2"; exit 1)
|
||||
}
|
||||
|
||||
assert_has_file () {
|
||||
test -f "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
|
||||
}
|
||||
|
||||
assert_has_dir () {
|
||||
test -d "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
|
||||
}
|
||||
|
||||
assert_not_has_file () {
|
||||
if test -f "$1"; then
|
||||
echo 1>&2 "File '$1' exists"; exit 1
|
||||
@@ -50,6 +58,12 @@ assert_not_file_has_content () {
|
||||
fi
|
||||
}
|
||||
|
||||
assert_not_has_dir () {
|
||||
if test -d "$1"; then
|
||||
echo 1>&2 "Directory '$1' exists"; exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
assert_file_has_content () {
|
||||
if ! grep -q -e "$2" "$1"; then
|
||||
echo 1>&2 "File '$1' doesn't match regexp '$2'"; exit 1
|
||||
@@ -136,3 +150,86 @@ setup_fake_remote_repo1() {
|
||||
|
||||
export OSTREE="ostree --repo=repo"
|
||||
}
|
||||
|
||||
setup_os_repository () {
|
||||
mode=$1
|
||||
shift
|
||||
|
||||
oldpwd=`pwd`
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir testos-repo
|
||||
if test -n "$mode"; then
|
||||
ostree --repo=testos-repo init --mode=${mode}
|
||||
else
|
||||
ostree --repo=testos-repo init
|
||||
fi
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir osdata
|
||||
cd osdata
|
||||
mkdir -p boot usr/bin usr/lib/modules/3.6.0 usr/share usr/etc
|
||||
echo "a kernel" > boot/vmlinuz-3.6.0
|
||||
echo "an initramfs" > boot/initramfs-3.6.0
|
||||
echo "a kernel module" > usr/lib/modules/3.6.0/foofs.ko
|
||||
bootcsum=$(cat boot/vmlinuz-3-6.0 boot/initramfs-3.6.0 usr/lib/modules/3.6.0/foofs.ko | sha256sum | cut -f 1 -d ' ')
|
||||
export bootcsum
|
||||
mv boot/vmlinuz-3.6.0 boot/vmlinuz-3.6.0-${bootcsum}
|
||||
mv boot/initramfs-3.6.0 boot/initramfs-3.6.0-${bootcsum}
|
||||
|
||||
echo "an executable" > usr/bin/sh
|
||||
echo "some shared data" > usr/share/langs.txt
|
||||
echo "a library" > usr/lib/libfoo.so.0
|
||||
ln -s usr/bin bin
|
||||
cat > usr/etc/os-release <<EOF
|
||||
NAME=TestOS
|
||||
VERSION=42
|
||||
ID=testos
|
||||
VERSION_ID=42
|
||||
PRETTY_NAME="TestOS 42"
|
||||
EOF
|
||||
echo "a config file" > usr/etc/aconfigfile
|
||||
mkdir -p usr/etc/NetworkManager
|
||||
echo "a default daemon file" > usr/etc/NetworkManager/nm.conf
|
||||
|
||||
ostree --repo=${test_tmpdir}/testos-repo commit -b testos/buildmaster/x86_64-runtime -s "Build"
|
||||
|
||||
echo "a new executable" > usr/bin/sh
|
||||
ostree --repo=${test_tmpdir}/testos-repo commit -b testos/buildmaster/x86_64-runtime -s "Build"
|
||||
|
||||
ostree --repo=${test_tmpdir}/testos-repo fsck -q
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir sysroot
|
||||
ostree admin --sysroot=sysroot init-fs sysroot
|
||||
ostree admin --sysroot=sysroot os-init testos
|
||||
|
||||
# Stub syslinux configuration
|
||||
mkdir -p sysroot/boot/loader.0
|
||||
ln -s loader.0 sysroot/boot/loader
|
||||
touch sysroot/boot/loader/syslinux.cfg
|
||||
# And a compatibility symlink
|
||||
mkdir -p sysroot/boot/syslinux
|
||||
ln -s ../loader/syslinux.cfg sysroot/boot/syslinux/syslinux.cfg
|
||||
}
|
||||
|
||||
os_repository_new_commit ()
|
||||
{
|
||||
cd ${test_tmpdir}/osdata
|
||||
rm boot/*
|
||||
echo "new: a kernel" > boot/vmlinuz-3.6.0
|
||||
echo "new: an initramfs" > boot/initramfs-3.6.0
|
||||
echo "new: a kernel module" > usr/lib/modules/3.6.0/foofs.ko
|
||||
echo "new: another kernel module" > usr/lib/modules/3.6.0/othermod.ko
|
||||
bootcsum=$(cat boot/vmlinuz-3.6.0 boot/initramfs-3.6.0 usr/lib/modules/3.6.0/foofs.ko usr/lib/modules/3.6.0/othermod.ko | sha256sum | cut -f 1 -d ' ')
|
||||
export bootcsum
|
||||
mv boot/vmlinuz-3.6.0 boot/vmlinuz-3.6.0-${bootcsum}
|
||||
mv boot/initramfs-3.6.0 boot/initramfs-3.6.0-${bootcsum}
|
||||
|
||||
echo "a new default config file" > usr/etc/a-new-default-config-file
|
||||
mkdir -p usr/etc/new-default-dir
|
||||
echo "a new default dir and file" > usr/etc/new-default-dir/moo
|
||||
|
||||
ostree --repo=${test_tmpdir}/testos-repo commit -b testos/buildmaster/x86_64-runtime -s "Build"
|
||||
cd ${test_tmpdir}
|
||||
}
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2011 Colin Walters <walters@verbum.org>
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
set -e
|
||||
|
||||
. $(dirname $0)/libtest.sh
|
||||
|
||||
echo "1..1"
|
||||
|
||||
setup_os_repository "archive-z2"
|
||||
|
||||
echo "ok setup"
|
||||
|
||||
echo "1..7"
|
||||
|
||||
ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
|
||||
rev=$(ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
|
||||
export rev
|
||||
# This initial deployment gets kicked off with some kernel arguments
|
||||
ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
|
||||
echo "ok deploy command"
|
||||
|
||||
assert_not_has_dir sysroot/boot/loader.0
|
||||
assert_has_dir sysroot/boot/loader.1
|
||||
assert_has_dir sysroot/ostree/boot.1.1
|
||||
assert_has_file sysroot/boot/loader/entries/ostree-testos-${rev}-0.conf
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-${rev}-0.conf 'options.* root=LABEL=MOO'
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-${rev}-0.conf 'options.* quiet'
|
||||
assert_file_has_content sysroot/boot/ostree/testos-${bootcsum}/vmlinuz-3.6.0 'a kernel'
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/boot.1/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
|
||||
|
||||
echo "ok layout"
|
||||
|
||||
ostree admin --sysroot=sysroot deploy --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
# Need a new bootversion, sine we now have two deployments
|
||||
assert_has_dir sysroot/boot/loader.0
|
||||
assert_not_has_dir sysroot/boot/loader.1
|
||||
assert_has_dir sysroot/ostree/boot.0.1
|
||||
assert_not_has_dir sysroot/ostree/boot.0.0
|
||||
assert_not_has_dir sysroot/ostree/boot.1.0
|
||||
assert_not_has_dir sysroot/ostree/boot.1.1
|
||||
# Ensure we propagated kernel arguments from previous deployment
|
||||
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-${rev}-0.conf 'options.* root=LABEL=MOO'
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.1/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/boot.0/testos/${bootcsum}/0/etc/os-release 'NAME=TestOS'
|
||||
|
||||
echo "ok second deploy"
|
||||
|
||||
ostree admin --sysroot=sysroot deploy --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
# Keep the same bootversion
|
||||
assert_has_dir sysroot/boot/loader.0
|
||||
assert_not_has_dir sysroot/boot/loader.1
|
||||
# But swap subbootversion
|
||||
assert_has_dir sysroot/ostree/boot.0.0
|
||||
assert_not_has_dir sysroot/ostree/boot.0.1
|
||||
|
||||
echo "ok third deploy (swap)"
|
||||
|
||||
ostree admin --sysroot=sysroot deploy --os=otheros testos/buildmaster/x86_64-runtime
|
||||
assert_not_has_dir sysroot/boot/loader.0
|
||||
assert_has_dir sysroot/boot/loader.1
|
||||
assert_has_file sysroot/boot/loader/entries/ostree-testos-${rev}-0.conf
|
||||
assert_has_file sysroot/boot/loader/entries/ostree-otheros-${rev}-0.conf
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.1/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/deploy/otheros/deploy/${rev}.0/etc/os-release 'NAME=TestOS'
|
||||
|
||||
echo "ok independent deploy"
|
||||
|
||||
ostree admin --sysroot=sysroot deploy --retain --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
assert_has_dir sysroot/boot/loader.0
|
||||
assert_not_has_dir sysroot/boot/loader.1
|
||||
assert_has_file sysroot/boot/loader/entries/ostree-testos-${rev}-0.conf
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.2/etc/os-release 'NAME=TestOS'
|
||||
assert_has_file sysroot/boot/loader/entries/ostree-testos-${rev}-2.conf
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/os-release 'NAME=TestOS'
|
||||
|
||||
echo "ok fourth deploy (retain)"
|
||||
|
||||
echo "a new local config file" > sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/a-new-config-file
|
||||
rm sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/aconfigfile
|
||||
ln -s /ENOENT sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/a-new-broken-symlink
|
||||
ostree admin --sysroot=sysroot deploy --retain --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
linktarget=$(readlink sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/a-new-broken-symlink)
|
||||
test "${linktarget}" = /ENOENT
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/os-release 'NAME=TestOS'
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/a-new-config-file 'a new local config file'
|
||||
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.4/etc/aconfigfile
|
||||
|
||||
echo "ok deploy with modified /etc"
|
||||
|
||||
os_repository_new_commit
|
||||
ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmaster/x86_64-runtime
|
||||
newrev=$(ostree --repo=sysroot/ostree/repo rev-parse testos:testos/buildmaster/x86_64-runtime)
|
||||
export newrev
|
||||
assert_not_streq ${rev} ${newrev}
|
||||
|
||||
ostree admin --sysroot=sysroot deploy --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
|
||||
# New files in /usr/etc
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/a-new-default-config-file "a new default config file"
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/new-default-dir/moo "a new default dir and file"
|
||||
# And persist /etc changes from before
|
||||
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${rev}.3/etc/aconfigfile
|
||||
|
||||
echo "ok upgrade bare"
|
||||
|
||||
os_repository_new_commit
|
||||
ostree --repo=sysroot/ostree/repo remote add testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree admin --sysroot=sysroot upgrade --os=testos
|
||||
rev=${newrev}
|
||||
newrev=$(ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
|
||||
assert_not_streq ${rev} ${newrev}
|
||||
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
|
||||
|
||||
echo "ok upgrade"
|
||||
Reference in new issue
Block a user