2016-08-24 14:26:47 +03:00
#!/bin/bash
. $( dirname $0 ) /libtest.sh
2018-01-09 22:40:07 +03:00
echo "1..10"
2016-08-24 14:26:47 +03:00
setup_os_repository "archive-z2" "uboot"
cd ${ test_tmpdir }
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo remote add --set= gpg-verify= false testos $( cat httpd-address) /ostree/testos-repo
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= sysroot/ostree/repo pull testos testos/buildmain/x86_64-runtime
${ CMD_PREFIX } ostree admin deploy --karg= root = LABEL = rootfs --os= testos testos:testos/buildmain/x86_64-runtime
2016-08-24 14:26:47 +03:00
2024-02-28 17:40:34 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-1.conf 'root=LABEL=rootfs'
assert_not_file_has_content sysroot/boot/loader/entries/ostree-1.conf 'init='
2016-08-24 14:26:47 +03:00
echo "ok deployment with initramfs"
2017-03-07 15:57:26 +03:00
pull_test_tree( ) {
kernel_contents = $1
initramfs_contents = $2
2018-01-09 22:40:07 +03:00
devicetree_contents = $3
2017-03-07 15:57:26 +03:00
2018-01-09 22:40:07 +03:00
printf "TEST SETUP:\n kernel: %s\n initramfs: %s\n devicetree: %s\n layout: %s\n" \
" $kernel_contents " " $initramfs_contents " " $devicetree_contents " " $layout "
2017-03-07 15:57:26 +03:00
2018-01-09 22:40:07 +03:00
rm -rf ${ test_tmpdir } /osdata/usr/lib/modules/3.6.0/{ initramfs.img,vmlinuz,devicetree} \
2017-03-07 15:57:26 +03:00
${ test_tmpdir } /osdata/usr/lib/ostree-boot \
${ test_tmpdir } /osdata/boot
if [ " $layout " = "/usr/lib/modules" ] ; then
# Fedora compatible layout
cd ${ test_tmpdir } /osdata/usr/lib/modules/3.6.0
echo -n " $kernel_contents " > vmlinuz
[ -n " $initramfs_contents " ] && echo -n " $initramfs_contents " > initramfs.img
2018-01-09 22:40:07 +03:00
[ -n " $devicetree_contents " ] && echo -n " $devicetree_contents " > devicetree
2017-03-07 15:57:26 +03:00
elif [ " $layout " = "/usr/lib/ostree-boot" ] || [ " $layout " = "/boot" ] ; then
# "Legacy" layout
mkdir -p " ${ test_tmpdir } /osdata/ $layout "
cd " ${ test_tmpdir } /osdata/ $layout "
2018-01-09 22:40:07 +03:00
bootcsum = $( echo -n " $kernel_contents $initramfs_contents $devicetree_contents " \
2017-03-07 15:57:26 +03:00
| sha256sum | cut -f 1 -d ' ' )
echo -n " $kernel_contents " > vmlinuz-${ bootcsum }
[ -n " $initramfs_contents " ] && echo -n " $initramfs_contents " > initramfs-${ bootcsum }
2018-01-09 22:40:07 +03:00
[ -n " $devicetree_contents " ] && echo -n " $devicetree_contents " > devicetree-${ bootcsum }
2017-03-07 15:57:26 +03:00
else
exit 1
fi
cd -
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree --repo= ${ test_tmpdir } /testos-repo commit --tree= dir = osdata/ -b testos/buildmain/x86_64-runtime
${ CMD_PREFIX } ostree pull testos:testos/buildmain/x86_64-runtime
2017-03-07 15:57:26 +03:00
}
get_key_from_bootloader_conf( ) {
conffile = $1
key = $2
assert_file_has_content " $conffile " " ^ $key "
awk " /^ $key / { print \$2 } " " $conffile "
}
for layout in /usr/lib/modules /usr/lib/ostree-boot /boot;
do
pull_test_tree "the kernel only"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos --karg= root = /dev/sda2 --karg= rootwait testos:testos/buildmain/x86_64-runtime
2024-02-28 17:40:34 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'rootwait'
assert_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'init='
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'initrd'
2017-03-07 15:57:26 +03:00
echo " ok switching to bootdir with no initramfs layout= $layout "
2016-08-24 14:26:47 +03:00
2017-03-07 15:57:26 +03:00
pull_test_tree "the kernel" "initramfs to assist the kernel"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos --karg-none --karg= root = LABEL = rootfs testos:testos/buildmain/x86_64-runtime
2024-02-28 17:40:34 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'initrd'
assert_file_has_content sysroot/boot/$( get_key_from_bootloader_conf sysroot/boot/loader/entries/ostree-2.conf "initrd" ) "initramfs to assist the kernel"
assert_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'root=LABEL=rootfs'
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'rootwait'
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'init='
2016-08-24 14:26:47 +03:00
2017-03-07 15:57:26 +03:00
echo " ok switching from no initramfs to initramfs enabled sysroot layout= $layout "
2018-01-09 22:40:07 +03:00
pull_test_tree "the kernel" "" "my .dtb file"
2021-05-07 17:42:37 +03:00
${ CMD_PREFIX } ostree admin deploy --os= testos testos:testos/buildmain/x86_64-runtime
2018-01-09 22:40:07 +03:00
2024-02-28 17:40:34 +03:00
assert_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'init='
assert_file_has_content sysroot/boot/" $( get_key_from_bootloader_conf sysroot/boot/loader/entries/ostree-2.conf 'devicetree' ) " "my \.dtb file"
assert_not_file_has_content sysroot/boot/loader/entries/ostree-2.conf 'initrd'
2018-01-09 22:40:07 +03:00
echo " ok switching from initramfs to no initramfs sysroot with devicetree layout= $layout "
2017-03-07 15:57:26 +03:00
done