2013-07-07 21:45:18 +04:00
#!/bin/bash
#
# Copyright (C) 2011,2013 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.
2016-01-27 19:44:10 +03:00
set -euo pipefail
2013-07-07 21:45:18 +04:00
. $( dirname $0 ) /libtest.sh
2015-07-14 20:30:05 +03:00
# Exports OSTREE_SYSROOT so --sysroot not needed.
2013-09-01 01:04:48 +04:00
setup_os_repository "archive-z2" "syslinux"
2013-07-07 21:45:18 +04:00
2016-03-02 18:28:04 +03:00
echo "1..3"
2013-07-07 21:45:18 +04:00
2015-11-09 15:03:35 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo pull-local --remote= testos testos-repo testos/buildmaster/x86_64-runtime
2015-03-03 15:13:54 +03:00
rev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
2013-07-07 21:45:18 +04:00
export rev
# This initial deployment gets kicked off with some kernel arguments
2015-11-09 15:03:35 +03:00
${ CMD_PREFIX } ostree admin deploy --karg= root = LABEL = MOO --karg= quiet --os= testos testos:testos/buildmaster/x86_64-runtime
2013-07-07 21:45:18 +04:00
assert_has_dir sysroot/boot/ostree/testos-${ bootcsum }
echo "ok deploy command"
# Commit + upgrade twice, so that we'll rotate out the original deployment
2013-09-20 16:09:06 +04:00
bootcsum1 = ${ bootcsum }
2013-07-07 21:45:18 +04:00
os_repository_new_commit
2015-11-09 15:03:35 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo remote add --set= gpg-verify= false testos file://$( pwd ) /testos-repo testos/buildmaster/x86_64-runtime
${ CMD_PREFIX } ostree admin upgrade --os= testos
2013-09-20 16:09:06 +04:00
bootcsum2 = ${ bootcsum }
os_repository_new_commit "1"
bootcsum3 = ${ bootcsum }
2015-11-09 15:03:35 +03:00
${ CMD_PREFIX } ostree admin upgrade --os= testos
2013-07-07 21:45:18 +04:00
2015-03-03 15:13:54 +03:00
newrev = $( ${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
2013-07-07 21:45:18 +04:00
assert_not_streq ${ rev } ${ newrev }
2013-09-20 16:09:06 +04:00
assert_not_streq ${ bootcsum1 } ${ bootcsum2 }
assert_not_streq ${ bootcsum2 } ${ bootcsum3 }
assert_not_has_dir sysroot/boot/ostree/testos-${ bootcsum1 }
2013-07-07 21:45:18 +04:00
assert_has_dir sysroot/boot/ostree/testos-${ bootcsum }
2013-09-20 16:09:06 +04:00
assert_has_dir sysroot/boot/ostree/testos-${ bootcsum2 }
2013-07-07 21:45:18 +04:00
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ newrev } .0/etc/os-release 'NAME=TestOS'
echo "ok deploy and GC /boot"
2013-07-16 00:13:12 +04:00
2015-11-09 15:03:35 +03:00
${ CMD_PREFIX } ostree admin cleanup
2013-07-16 00:13:12 +04:00
assert_has_dir sysroot/boot/ostree/testos-${ bootcsum }
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${ newrev } .0/etc/os-release 'NAME=TestOS'
echo "ok manual cleanup"