mirror of
https://github.com/ostreedev/ostree.git
synced 2024-10-26 17:25:36 +03:00
8abad0b452
Before, we were writing the "bootversion", which is either 0 or 1, for all entries. This is completely wrong; the idea of the "version" field is to compare between entries. Fix this by writing out the inverted index - internally, index 0 is the *first* boot entry, so we give it the highest version number, and index N is the last, so give it version 0. Then fix the deployment sorting code to correctly reverse the version number comparison, so we read back the right order. In practice before this bug didn't matter because "normally" you only have at most two deployments. https://bugzilla.gnome.org/show_bug.cgi?id=706546
158 lines
7.3 KiB
Bash
Executable File
158 lines
7.3 KiB
Bash
Executable File
#!/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..8"
|
|
|
|
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'
|
|
|
|
ostree admin --sysroot=sysroot status
|
|
|
|
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"
|
|
|
|
ostree admin --sysroot=sysroot status
|
|
|
|
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
|
|
origrev=${rev}
|
|
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"
|
|
|
|
ostree admin --sysroot=sysroot status
|
|
|
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
|
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${origrev}.4/etc/os-release 'NAME=TestOS'
|
|
ostree admin --sysroot=sysroot undeploy 2
|
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
|
|
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${origrev}.4
|
|
|
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${origrev}.3/etc/os-release 'NAME=TestOS'
|
|
ostree admin --sysroot=sysroot undeploy 2
|
|
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${origrev}.3
|
|
|
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${newrev}.0/etc/os-release 'NAME=TestOS'
|
|
ostree admin --sysroot=sysroot undeploy 0
|
|
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${newrev}.0
|
|
|
|
echo "ok undeploy"
|