summaryrefslogtreecommitdiffstats
path: root/qt-ostree
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2016-07-05 13:36:51 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2016-07-18 12:31:56 +0000
commit98829283a7b91b71ad63448e6f035d2fb56a2ac3 (patch)
tree789c4326cc355663af732f5d762500c62ef471fa /qt-ostree
parent82f05821239c2e3100332ec1a37851000c5d6696 (diff)
Add {find,path}_in_sysroot convenience functions
Change-Id: I09e977e81f4cf648ab8a5617712800ee864735a3 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'qt-ostree')
-rwxr-xr-xqt-ostree/qt-ostree35
1 files changed, 26 insertions, 9 deletions
diff --git a/qt-ostree/qt-ostree b/qt-ostree/qt-ostree
index 24af5cd..defa94e 100755
--- a/qt-ostree/qt-ostree
+++ b/qt-ostree/qt-ostree
@@ -499,13 +499,34 @@ clean_workdir()
cd ${WORKDIR}/
# Remove immutable attribute.
- chattr -if ${OTA_SYSROOT}/ostree/deploy/*/deploy/* || /bin/true
+ chattr -if ${OTA_SYSROOT}/ostree/deploy/*/deploy/* || true
rm -rf ${OTA_SYSROOT}
rm -rf ${GENERATED_TREE}
chmod -x ${ROOT}/ostree-grub-generator
}
+find_in_sysroot()
+{
+ target=${1}
+ target_path=$(find ${GENERATED_TREE} -type f -name ${target})
+ if [ -z "${target_path}" ] ; then
+ qt_ostree_error "Failed to find \"${target}\" in the provided sysroot"
+ fi
+}
+
+# Doc: call find_in_sysroot() before using path_in_sysroot(). Combining these
+# two functions would result in executing handle_non_zero_exit() when a target
+# file is not found. And instead of getting a normal error message we would also
+# get an error message from handle_non_zero_exit(), when using the "combined"
+# version within command substitutions: path=$(find_in_sysroot "some-file").
+path_in_sysroot()
+{
+ target=${1}
+ target_path=$(find ${GENERATED_TREE} -type f -name ${target})
+ echo ${target_path}
+}
+
organize_boot_files()
{
if [ $(ls ${GENERATED_TREE}/boot/ | wc -l) != 0 ]; then
@@ -555,11 +576,8 @@ organize_boot_files()
GRUB2_CFG_GENERATOR=${ROOT}/ostree-grub-generator
fi
chmod +x ${GRUB2_CFG_GENERATOR}
- generator_path=$(find ${GENERATED_TREE} -name ostree-grub-generator)
- if [ -z "${generator_path}" ] ; then
- qt_ostree_error "Failed to find ostree-grub-generator in the sysroot".
- fi
- cp ${GRUB2_CFG_GENERATOR} "${generator_path}"
+ find_in_sysroot "ostree-grub-generator"
+ cp ${GRUB2_CFG_GENERATOR} $(path_in_sysroot "ostree-grub-generator")
fi
}
@@ -612,9 +630,8 @@ adjust_sysroot_layout()
convert_to_ostree_sysroot()
{
cd ${GENERATED_TREE}
- if [[ ! -e usr/bin/ostree || ! -e usr/sbin/ostree-remount ]] ; then
- qt_ostree_error "The provided sysroot does not contain required binaries"
- fi
+ find_in_sysroot "ostree"
+ find_in_sysroot "ostree-remount"
organize_boot_files