2017-01-19 14:23:30 +03:00
# This file is to be sourced, not executed
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
#
2018-01-30 22:26:26 +03:00
# SPDX-License-Identifier: LGPL-2.0+
#
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
2021-12-07 04:20:55 +03:00
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
2013-06-29 19:45:53 +04:00
2016-01-27 19:44:10 +03:00
set -euo pipefail
2013-06-29 19:45:53 +04:00
2023-10-12 20:22:00 +03:00
echo " 1.. $(( 30 + ${ extra_admin_tests :- 0 } )) "
2019-08-06 04:59:38 +03:00
mkdir sysrootmin
${ CMD_PREFIX } ostree admin init-fs --modern sysrootmin
assert_has_dir sysrootmin/boot
assert_has_dir sysrootmin/ostree/repo
assert_not_has_dir sysrootmin/home
rm sysrootmin -rf
echo "ok init-fs --modern"
2017-08-23 19:15:46 +03:00
2015-05-28 03:08:44 +03:00
function validate_bootloader( ) {
2016-04-01 14:51:18 +03:00
cd ${ test_tmpdir } ;
bootloader = ""
if test -f sysroot/boot/syslinux/syslinux.cfg; then
bootloader = "syslinux"
elif test -f sysroot/boot/grub2/grub.cfg; then
bootloader = "grub2"
fi
if test -n " ${ bootloader } " ; then
$( dirname $0 ) /bootloader-entries-crosscheck.py sysroot ${ bootloader }
fi
cd -
2015-05-28 03:08:44 +03:00
}
2017-09-05 22:43:04 +03:00
# Test generate_deployment_refs()
assert_ostree_deployment_refs( ) {
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo refs ostree | sort > ostree-refs.txt
( for v in " $@ " ; do echo $v ; done ) | sort > ostree-refs-expected.txt
diff -u ostree-refs{ -expected,} .txt
}
2016-03-03 00:26:09 +03:00
orig_mtime = $( stat -c '%.Y' sysroot/ostree/deploy)
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo pull-local --remote= testos testos-repo testos/buildmain/x86_64-runtime
rev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos/buildmain/x86_64-runtime)
2013-06-29 19:45:53 +04:00
export rev
2019-08-06 04:59:38 +03:00
# This initial deployment gets kicked off with some kernel arguments
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --karg= root = LABEL = MOO --karg= quiet --os= testos testos:testos/buildmain/x86_64-runtime
2016-03-03 00:26:09 +03:00
new_mtime = $( stat -c '%.Y' sysroot/ostree/deploy)
assert_not_streq " ${ orig_mtime } " " ${ new_mtime } "
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status | tee status.txt
2017-06-01 13:43:50 +03:00
assert_not_file_has_content status.txt "pending"
assert_not_file_has_content status.txt "rollback"
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-06-29 19:45:53 +04:00
2021-03-11 04:36:13 +03:00
# Test the bootable and linux keys
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo --print-metadata-key= ostree.linux show testos:testos/buildmain/x86_64-runtime >out.txt
2021-03-11 04:36:13 +03:00
assert_file_has_content_literal out.txt 3.6.0
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo --print-metadata-key= ostree.bootable show testos:testos/buildmain/x86_64-runtime >out.txt
2021-03-11 04:36:13 +03:00
assert_file_has_content_literal out.txt true
2013-06-29 19:45:53 +04:00
echo "ok deploy command"
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin --print-current-dir > curdir
2019-04-02 05:01:49 +03:00
assert_file_has_content curdir ^` pwd ` /sysroot/ostree/deploy/testos/deploy/${ rev } \. 0$
2014-09-26 19:54:04 +04:00
echo "ok --print-current-dir"
2023-10-12 20:22:00 +03:00
if ${ CMD_PREFIX } ostree admin deploy --stateroot= nosuchroot testos:testos/buildmain/x86_64-runtime 2>err.txt; then
fatal "deployed to nonexistent root"
fi
assert_file_has_content err.txt "error:.*No such stateroot: nosuchroot"
echo "ok nice error for deploy with no stateroot"
2017-09-05 22:43:04 +03:00
# Test layout of bootloader config and refs
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
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-1-testos.conf
assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.conf 'options.* root=LABEL=MOO'
assert_file_has_content sysroot/boot/loader/entries/ostree-1-testos.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'
2017-09-05 22:43:04 +03:00
assert_ostree_deployment_refs 1/1/0
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2013-06-29 19:45:53 +04:00
echo "ok layout"
2021-05-07 17:42:37 +03:00
if ${ CMD_PREFIX } ostree admin deploy --stage --os= testos testos:testos/buildmain/x86_64-runtime 2>err.txt; then
2018-05-01 23:36:03 +03:00
fatal "staged when not booted"
fi
2021-03-17 17:03:49 +03:00
assert_file_has_content_literal err.txt "Cannot stage deployment: Not currently booted into an OSTree system"
2018-05-01 23:36:03 +03:00
echo "ok staging does not work when not booted"
2016-03-03 00:26:09 +03:00
orig_mtime = $( stat -c '%.Y' sysroot/ostree/deploy)
2023-08-17 23:48:05 +03:00
${ CMD_PREFIX } ostree admin deploy --stateroot= testos testos:testos/buildmain/x86_64-runtime
2016-03-03 00:26:09 +03:00
new_mtime = $( stat -c '%.Y' sysroot/ostree/deploy)
assert_not_streq " ${ orig_mtime } " " ${ new_mtime } "
2013-06-29 19:45:53 +04:00
# 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
2018-06-27 17:45:43 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.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'
2017-09-05 22:43:04 +03:00
assert_ostree_deployment_refs 0/1/{ 0,1}
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-08-22 02:48:00 +04:00
2013-06-29 19:45:53 +04:00
echo "ok second deploy"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos testos:testos/buildmain/x86_64-runtime
2013-06-29 19:45:53 +04:00
# 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
2017-09-05 22:43:04 +03:00
assert_ostree_deployment_refs 0/0/{ 0,1}
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-06-29 19:45:53 +04:00
echo "ok third deploy (swap)"
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin os-init otheros
2014-01-09 03:29:05 +04:00
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= otheros testos/buildmain/x86_64-runtime
2013-06-29 19:45:53 +04:00
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-2-testos.conf
assert_has_file sysroot/boot/loader/entries/ostree-3-otheros.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'
2017-09-05 22:43:04 +03:00
assert_ostree_deployment_refs 1/1/{ 0,1,2}
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-06-29 19:45:53 +04:00
echo "ok independent deploy"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --retain --os= testos testos:testos/buildmain/x86_64-runtime
2013-06-29 19:45:53 +04:00
assert_has_dir sysroot/boot/loader.0
assert_not_has_dir sysroot/boot/loader.1
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-4-testos.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'
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-2-testos.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'
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2017-09-05 22:43:04 +03:00
assert_ostree_deployment_refs 0/1/{ 0,1,2,3}
2015-05-28 03:08:44 +03:00
validate_bootloader
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
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --retain --os= testos testos:testos/buildmain/x86_64-runtime
2017-08-23 19:15:46 +03:00
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
2018-04-11 20:31:18 +03:00
link = sysroot/ostree/deploy/testos/deploy/${ rev } .4/etc/a-new-broken-symlink
if ! test -L ${ link } ; then
ls -al ${ link }
fatal " Not a symlink: ${ link } "
fi
linktarget = $( readlink ${ link } )
assert_streq " ${ linktarget } " /ENOENT
2013-06-29 19:45:53 +04:00
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
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-06-29 19:45:53 +04:00
echo "ok deploy with modified /etc"
2017-08-23 19:15:46 +03:00
# we now have 5 deployments, let's bring that back down to 1
for i in $( seq 4) ; do
${ CMD_PREFIX } ostree admin undeploy 0
done
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-1-testos.conf
assert_not_has_file sysroot/boot/loader/entries/ostree-2-testos.conf
assert_not_has_file sysroot/boot/loader/entries/ostree-3-otheros.conf
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --not-as-default --os= otheros testos:testos/buildmain/x86_64-runtime
2017-08-23 19:15:46 +03:00
assert_has_dir sysroot/boot/loader.0
assert_not_has_dir sysroot/boot/loader.1
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-2-testos.conf
assert_has_file sysroot/boot/loader/entries/ostree-1-otheros.conf
2017-08-23 19:15:46 +03:00
${ CMD_PREFIX } ostree admin status
validate_bootloader
echo "ok deploy --not-as-default"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --retain-rollback --os= otheros testos:testos/buildmain/x86_64-runtime
2017-08-23 19:15:46 +03:00
assert_not_has_dir sysroot/boot/loader.0
assert_has_dir sysroot/boot/loader.1
2018-06-27 17:45:43 +03:00
assert_has_file sysroot/boot/loader/entries/ostree-3-otheros.conf
assert_has_file sysroot/boot/loader/entries/ostree-2-testos.conf
assert_has_file sysroot/boot/loader/entries/ostree-1-otheros.conf
2017-08-23 19:15:46 +03:00
${ CMD_PREFIX } ostree admin status
validate_bootloader
echo "ok deploy --retain-rollback"
2023-08-02 18:25:58 +03:00
${ CMD_PREFIX } ostree admin status
assert_file_has_content sysroot/boot/loader/entries/ostree-3-otheros.conf "^title.*TestOS 42 1.0.10"
${ CMD_PREFIX } ostree admin set-default 1
assert_file_has_content sysroot/boot/loader/entries/ostree-3-testos.conf "^title.*TestOS 42 1.0.10"
${ CMD_PREFIX } ostree admin set-default 1
assert_file_has_content sysroot/boot/loader/entries/ostree-3-otheros.conf "^title.*TestOS 42 1.0.10"
echo "ok set-default"
2013-06-29 19:45:53 +04:00
os_repository_new_commit
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo pull-local --remote= testos testos-repo testos/buildmain/x86_64-runtime
newrev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos:testos/buildmain/x86_64-runtime)
2013-06-29 19:45:53 +04:00
export newrev
assert_not_streq ${ rev } ${ newrev }
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos testos:testos/buildmain/x86_64-runtime
2013-06-29 19:45:53 +04:00
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
2017-08-23 19:15:46 +03:00
assert_not_has_file sysroot/ostree/deploy/testos/deploy/${ rev } .4/etc/aconfigfile
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-06-29 19:45:53 +04:00
echo "ok upgrade bare"
os_repository_new_commit
2018-05-04 00:29:06 +03:00
if env OSTREE_EX_STAGE_DEPLOYMENTS = 1 ${ CMD_PREFIX } ostree admin upgrade --os= testos 2>err.txt; then
fatal "staged when not booted"
fi
echo "ok upgrade failed when staged"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo remote add --set= gpg-verify= false testos file://$( pwd ) /testos-repo testos/buildmain/x86_64-runtime
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos
2013-07-23 17:19:24 +04:00
origrev = ${ rev }
2013-06-29 19:45:53 +04:00
rev = ${ newrev }
2021-05-07 17:42:37 +03:00
newrev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos/buildmain/x86_64-runtime)
2013-06-29 19:45:53 +04:00
assert_not_streq ${ rev } ${ newrev }
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ newrev } .0/etc/os-release 'NAME=TestOS'
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2016-01-27 05:34:31 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo refs testos:testos > reftest.txt
2021-05-07 17:42:37 +03:00
assert_file_has_content reftest.txt testos:buildmain/x86_64-runtime
2013-06-29 19:45:53 +04:00
echo "ok upgrade"
2013-07-23 17:19:24 +04:00
2015-07-14 20:30:05 +03:00
originfile = $( ${ CMD_PREFIX } ostree admin --print-current-dir) .origin
2015-01-16 21:07:26 +03:00
cp ${ originfile } saved-origin
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin set-origin --index= 0 bacon --set= gpg-verify= false http://tasty.com
2021-05-07 17:42:37 +03:00
assert_file_has_content " ${ originfile } " "bacon:testos/buildmain/x86_64-runtime"
2015-03-03 15:13:54 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo remote list -u > remotes.txt
2019-04-02 05:01:49 +03:00
assert_file_has_content remotes.txt 'bacon.*http://tasty\.com'
2015-01-16 21:07:26 +03:00
cp saved-origin ${ originfile }
2015-05-28 03:08:44 +03:00
validate_bootloader
2015-01-16 21:07:26 +03:00
echo "ok set-origin"
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'
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin 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
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin undeploy 0
2013-07-23 17:19:24 +04:00
assert_not_has_dir sysroot/ostree/deploy/testos/deploy/${ newrev } .0
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin status
2015-05-28 03:08:44 +03:00
validate_bootloader
2013-07-23 17:19:24 +04:00
echo "ok undeploy"
2014-01-09 03:29:05 +04:00
2021-05-07 17:42:37 +03:00
if ${ CMD_PREFIX } ostree admin deploy --os= unknown testos:testos/buildmain/x86_64-runtime; then
2014-01-09 03:29:05 +04:00
assert_not_reached "Unexpected successful deploy of unknown OS"
fi
echo "ok deploy with unknown OS"
2014-08-03 22:32:52 +04:00
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos --karg-append= console = /dev/foo --karg-append= console = /dev/bar testos:testos/buildmain/x86_64-runtime
${ CMD_PREFIX } ostree admin deploy --os= testos testos:testos/buildmain/x86_64-runtime
2018-06-27 17:45:43 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-4-testos.conf 'console=/dev/foo.*console=/dev/bar'
2015-05-28 03:08:44 +03:00
validate_bootloader
2014-08-03 22:32:52 +04:00
echo "ok deploy with multiple kernel args"
2021-05-07 17:42:37 +03:00
origrev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos/buildmain/x86_64-runtime)
2014-08-03 22:32:52 +04:00
os_repository_new_commit 0 "test upgrade multiple kernel args"
2015-07-14 20:30:05 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos
2021-05-07 17:42:37 +03:00
newrev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos/buildmain/x86_64-runtime)
2014-08-03 22:32:52 +04:00
assert_not_streq ${ origrev } ${ newrev }
2018-06-27 17:45:43 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-4-testos.conf 'console=/dev/foo.*console=/dev/bar'
2015-05-28 03:08:44 +03:00
validate_bootloader
2014-08-03 22:32:52 +04:00
echo "ok upgrade with multiple kernel args"
2015-10-06 18:33:18 +03:00
2019-03-01 17:16:55 +03:00
os_repository_new_commit
${ CMD_PREFIX } ostree admin upgrade --os= testos
2019-09-02 12:36:12 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-4-testos.conf " ^title TestOS 42 ${ version } (ostree:testos:0) $"
2021-05-07 17:42:37 +03:00
os_repository_new_commit 0 0 testos/buildmain/x86_64-runtime 42
2019-03-01 17:16:55 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos
2019-09-02 12:36:12 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-4-testos.conf " ^title TestOS 42 (ostree:testos:0) $"
2019-03-01 17:16:55 +03:00
echo "ok no duplicate version strings in title"
2015-10-06 18:33:18 +03:00
# Test upgrade with and without --override-commit
# See https://github.com/GNOME/ostree/pull/147
2020-05-20 17:45:45 +03:00
sleep 1
os_repository_new_commit
2020-05-20 19:37:44 +03:00
# upgrade to the latest
${ CMD_PREFIX } ostree admin upgrade --os= testos
2021-05-07 17:42:37 +03:00
head_rev = $( ${ CMD_PREFIX } ostree rev-parse --repo= sysroot/ostree/repo testos/buildmain/x86_64-runtime)
prev_rev = $( ${ CMD_PREFIX } ostree rev-parse --repo= sysroot/ostree/repo testos/buildmain/x86_64-runtime^)
2015-10-06 18:33:18 +03:00
assert_not_streq ${ head_rev } ${ prev_rev }
2020-05-20 19:37:44 +03:00
# Don't use `ostree admin status | head -n 1` directly here because `head`
# exiting early might cause SIGPIPE to ostree, which with `set -euo pipefail`
# will cause us to exit. See: https://github.com/ostreedev/ostree/pull/2110.
${ CMD_PREFIX } ostree admin status > status-out.txt
head -n 1 < status-out.txt > status.txt
assert_file_has_content status.txt " .* testos ${ head_rev } .* "
# now, check that we can't downgrade to an older commit without --allow-downgrade
2020-05-14 22:05:45 +03:00
if ${ CMD_PREFIX } ostree admin upgrade --os= testos --override-commit= ${ prev_rev } 2> err.txt; then
2020-05-20 18:57:10 +03:00
cat err.txt
2020-05-14 22:05:45 +03:00
fatal "downgraded without --allow-downgrade?"
fi
assert_file_has_content err.txt "Upgrade.*is chronologically older"
2015-10-06 18:33:18 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos --override-commit= ${ prev_rev } --allow-downgrade
2020-05-20 19:37:44 +03:00
${ CMD_PREFIX } ostree admin status > status-out.txt
head -n 1 < status-out.txt > status.txt
assert_file_has_content status.txt " .* testos ${ prev_rev } .* "
2015-10-06 18:33:18 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos
2020-05-20 19:37:44 +03:00
${ CMD_PREFIX } ostree admin status > status-out.txt
head -n 1 < status-out.txt > status.txt
assert_file_has_content status.txt " .* testos ${ head_rev } .* "
2015-10-06 18:33:18 +03:00
echo "ok upgrade with and without override-commit"
2017-05-30 21:07:13 +03:00
2020-05-14 22:05:45 +03:00
# check that we can still upgrade to a rev that's not the tip of the branch but
# that's still newer than the deployment
sleep 1
os_repository_new_commit
sleep 1
os_repository_new_commit
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree pull --repo= sysroot/ostree/repo --commit-metadata-only --depth= -1 testos:testos/buildmain/x86_64-runtime
curr_rev = $( ${ CMD_PREFIX } ostree rev-parse --repo= sysroot/ostree/repo testos/buildmain/x86_64-runtime)
prev_rev = $( ${ CMD_PREFIX } ostree rev-parse --repo= sysroot/ostree/repo testos/buildmain/x86_64-runtime^)
2020-05-14 22:05:45 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos --override-commit= ${ prev_rev }
echo "ok upgrade to newer version older than branch tip"
2017-10-19 21:28:02 +03:00
${ CMD_PREFIX } ostree --repo= ${ test_tmpdir } /testos-repo commit --add-metadata-string " version= ${ version } " \
2021-05-07 17:42:37 +03:00
--add-metadata-string 'ostree.source-title=libtest os_repository_new_commit()' -b testos/buildmain/x86_64-runtime \
2017-10-19 21:28:02 +03:00
-s "Build" --tree= dir = ${ test_tmpdir } /osdata
${ CMD_PREFIX } ostree admin upgrade --os= testos
${ CMD_PREFIX } ostree admin status | tee status.txt
assert_file_has_content_literal status.txt '`- libtest os_repository_new_commit()'
echo "ok source title"
2017-05-30 21:07:13 +03:00
deployment = $( ${ CMD_PREFIX } ostree admin --sysroot= sysroot --print-current-dir)
${ CMD_PREFIX } ostree --sysroot= sysroot remote add --set= gpg-verify= false remote-test-physical file://$( pwd ) /testos-repo
assert_not_has_file ${ deployment } /etc/ostree/remotes.d/remote-test-physical.conf testos-repo
assert_file_has_content sysroot/ostree/repo/config remote-test-physical
echo "ok remote add physical sysroot"
# Now a hack...symlink ${deployment}/sysroot to the sysroot in lieu of a bind
# mount which we can't do in unit tests.
ln -sr sysroot ${ deployment } /sysroot
ln -s sysroot/ostree ${ deployment } /ostree
${ CMD_PREFIX } ostree --sysroot= ${ deployment } remote add --set= gpg-verify= false remote-test-nonphysical file://$( pwd ) /testos-repo
assert_not_file_has_content sysroot/ostree/repo/config remote-test-nonphysical
assert_file_has_content ${ deployment } /etc/ostree/remotes.d/remote-test-nonphysical.conf testos-repo
echo "ok remote add nonphysical sysroot"
2017-08-03 05:07:26 +03:00
2017-09-08 18:18:10 +03:00
# Test that setting add-remotes-config-dir to false adds a remote in the
# config file rather than the remotes config dir even though this is a
# "system" repo.
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo config set core.add-remotes-config-dir false
${ CMD_PREFIX } ostree --sysroot= ${ deployment } remote add --set= gpg-verify= false remote-test-config-dir file://$( pwd ) /testos-repo
assert_not_has_file ${ deployment } /etc/ostree/remotes.d/remote-test-config-dir.conf testos-repo
assert_file_has_content sysroot/ostree/repo/config remote-test-config-dir
echo "ok remote add nonphysical sysroot add-remotes-config-dir false"
2017-08-03 05:07:26 +03:00
if env OSTREE_SYSROOT_DEBUG = " ${ OSTREE_SYSROOT_DEBUG } ,test-fifreeze " \
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos testos:testos/buildmain/x86_64-runtime 2>err.txt; then
2017-08-03 05:07:26 +03:00
fatal "fifreeze-test exited successfully?"
fi
assert_file_has_content err.txt "fifreeze watchdog was run"
assert_file_has_content err.txt "During fsfreeze-thaw: aborting due to test-fifreeze"
echo "ok fifreeze test"