2013-06-29 19:45:53 +04:00
#
2014-01-15 18:48:04 +04:00
# Copyright (C) 2011,2014 Colin Walters <walters@verbum.org>
2013-06-29 19:45:53 +04:00
#
# 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
2014-09-26 19:54:04 +04:00
echo "1..10"
2013-06-29 19:45:53 +04:00
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
2014-10-22 19:07:44 +04:00
ostree admin --sysroot= sysroot status | tee status.txt
assert_file_has_content status.txt 'Version: 1.0.10'
2014-11-25 23:21:11 +03:00
if test -f sysroot/boot/loader/syslinux.cfg; then
assert_file_has_content sysroot/boot/loader/syslinux.cfg 'TestOS 42 1.0.10'
fi
2013-06-29 19:45:53 +04:00
echo "ok deploy command"
2014-09-26 19:54:04 +04:00
ostree admin --sysroot= sysroot --print-current-dir > curdir
assert_file_has_content curdir ^` pwd ` /sysroot/ostree/deploy/testos/deploy/${ rev } .0$
echo "ok --print-current-dir"
2013-06-29 19:45:53 +04:00
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
assert_has_dir sysroot/ostree/boot.1.1
2013-09-20 06:41:33 +04:00
assert_has_file sysroot/boot/loader/entries/ostree-testos-0.conf
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* quiet'
2013-06-29 19:45:53 +04:00
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'
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
2014-10-22 19:07:44 +04:00
2013-06-29 19:45:53 +04:00
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
2013-09-20 06:41:33 +04:00
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'options.* root=LABEL=MOO'
2013-06-29 19:45:53 +04:00
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'
2013-08-22 02:48:00 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
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
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
echo "ok third deploy (swap)"
2014-01-09 03:29:05 +04:00
ostree admin --sysroot= sysroot os-init otheros
2013-06-29 19:45:53 +04:00
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
2013-09-20 06:41:33 +04:00
assert_has_file sysroot/boot/loader/entries/ostree-testos-1.conf
assert_has_file sysroot/boot/loader/entries/ostree-otheros-0.conf
2013-06-29 19:45:53 +04:00
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'
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
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
2013-09-20 06:41:33 +04:00
assert_has_file sysroot/boot/loader/entries/ostree-testos-0.conf
2013-06-29 19:45:53 +04:00
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ rev } .2/etc/os-release 'NAME=TestOS'
2013-09-20 06:41:33 +04:00
assert_has_file sysroot/boot/loader/entries/ostree-testos-2.conf
2013-06-29 19:45:53 +04:00
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ rev } .3/etc/os-release 'NAME=TestOS'
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
echo "ok fourth deploy (retain)"
echo "a new local config file" > sysroot/ostree/deploy/testos/deploy/${ rev } .3/etc/a-new-config-file
2013-10-15 22:11:43 +04:00
rm -r sysroot/ostree/deploy/testos/deploy/${ rev } .3/etc/testdirectory
2013-06-29 19:45:53 +04:00
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
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
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
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
echo "ok upgrade bare"
os_repository_new_commit
2013-09-05 22:50:36 +04:00
ostree --repo= sysroot/ostree/repo remote add --set= gpg-verify= false testos file://$( pwd ) /testos-repo testos/buildmaster/x86_64-runtime
2013-06-29 19:45:53 +04:00
ostree admin --sysroot= sysroot upgrade --os= testos
2013-07-23 17:19:24 +04:00
origrev = ${ rev }
2013-06-29 19:45:53 +04:00
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'
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-06-29 19:45:53 +04:00
echo "ok upgrade"
2013-07-23 17:19:24 +04:00
2013-09-17 06:37:00 +04:00
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ rev } .0/etc/os-release 'NAME=TestOS'
2013-07-23 17:19:24 +04:00
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ newrev } .0/etc/os-release 'NAME=TestOS'
2013-09-17 06:37:00 +04:00
ostree admin --sysroot= sysroot undeploy 1
2013-07-23 17:19:24 +04:00
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ newrev } .0/etc/os-release 'NAME=TestOS'
2013-09-17 06:37:00 +04:00
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${ rev } .0
2013-07-23 17:19:24 +04:00
ostree admin --sysroot= sysroot undeploy 0
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${ newrev } .0
2013-09-20 06:09:48 +04:00
ostree admin --sysroot= sysroot status
2013-07-23 17:19:24 +04:00
echo "ok undeploy"
2014-01-09 03:29:05 +04:00
if ostree admin --sysroot= sysroot deploy --os= unknown testos:testos/buildmaster/x86_64-runtime; then
assert_not_reached "Unexpected successful deploy of unknown OS"
fi
echo "ok deploy with unknown OS"
2014-08-03 22:32:52 +04:00
ostree admin --sysroot= sysroot deploy --os= testos --karg-append= console = /dev/foo --karg-append= console = /dev/bar testos:testos/buildmaster/x86_64-runtime
ostree admin --sysroot= sysroot deploy --os= testos testos:testos/buildmaster/x86_64-runtime
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'console=/dev/foo.*console=/dev/bar'
echo "ok deploy with multiple kernel args"
origrev = $( ostree --repo= sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
os_repository_new_commit 0 "test upgrade multiple kernel args"
ostree admin --sysroot= sysroot upgrade --os= testos
newrev = $( ostree --repo= sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
assert_not_streq ${ origrev } ${ newrev }
assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'console=/dev/foo.*console=/dev/bar'
echo "ok upgrade with multiple kernel args"