From 8f6d37fc0cd21d199eb444dc9b4331f26af60926 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Mon, 26 Oct 2015 21:23:44 -0500
Subject: [PATCH] scripts/chroot: dont break qemu

fixes: https://github.com/RobertCNelson/omap-image-builder/issues/63
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 scripts/chroot.sh | 54 +++++++++++++++++++++++------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/scripts/chroot.sh b/scripts/chroot.sh
index 19c0b63b5..d62468676 100755
--- a/scripts/chroot.sh
+++ b/scripts/chroot.sh
@@ -1054,33 +1054,6 @@ if [ -n "${chroot_after_hook}" -a -r "${DIR}/${chroot_after_hook}" ] ; then
 	chroot_after_hook=""
 fi
 
-#add /boot/uEnv.txt update script
-if [ -d "${tempdir}/etc/kernel/postinst.d/" ] ; then
-	if [ ! -f "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt" ] ; then
-		sudo cp -v "${OIB_DIR}/target/other/zz-uenv_txt" "${tempdir}/etc/kernel/postinst.d/"
-		sudo chmod +x "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt"
-	fi
-fi
-
-if [ -f "${tempdir}/usr/bin/qemu-arm-static" ] ; then
-	sudo rm -f "${tempdir}/usr/bin/qemu-arm-static" || true
-fi
-
-echo "${rfs_username}:${rfs_password}" > /tmp/user_password.list
-sudo mv /tmp/user_password.list "${DIR}/deploy/${export_filename}/user_password.list"
-
-#Fixes:
-if [ -d "${tempdir}/etc/ssh/" -a "x${keep_ssh_keys}" = "x" ] ; then
-	#Remove pre-generated ssh keys, these will be regenerated on first bootup...
-	sudo rm -rf "${tempdir}"/etc/ssh/ssh_host_* || true
-	sudo touch "${tempdir}/etc/ssh/ssh.regenerate" || true
-fi
-
-#ID.txt:
-if [ -f "${tempdir}/etc/dogtag" ] ; then
-	sudo cp "${tempdir}/etc/dogtag" "${DIR}/deploy/${export_filename}/ID.txt"
-fi
-
 cat > "${DIR}/cleanup_script.sh" <<-__EOF__
 	#!/bin/sh -e
 	export LC_ALL=C
@@ -1136,6 +1109,33 @@ sudo mv "${DIR}/cleanup_script.sh" "${tempdir}/cleanup_script.sh"
 sudo chroot "${tempdir}" /bin/sh -e cleanup_script.sh
 echo "Log: Complete: [sudo chroot ${tempdir} /bin/sh -e cleanup_script.sh]"
 
+#add /boot/uEnv.txt update script
+if [ -d "${tempdir}/etc/kernel/postinst.d/" ] ; then
+	if [ ! -f "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt" ] ; then
+		sudo cp -v "${OIB_DIR}/target/other/zz-uenv_txt" "${tempdir}/etc/kernel/postinst.d/"
+		sudo chmod +x "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt"
+	fi
+fi
+
+if [ -f "${tempdir}/usr/bin/qemu-arm-static" ] ; then
+	sudo rm -f "${tempdir}/usr/bin/qemu-arm-static" || true
+fi
+
+echo "${rfs_username}:${rfs_password}" > /tmp/user_password.list
+sudo mv /tmp/user_password.list "${DIR}/deploy/${export_filename}/user_password.list"
+
+#Fixes:
+if [ -d "${tempdir}/etc/ssh/" -a "x${keep_ssh_keys}" = "x" ] ; then
+	#Remove pre-generated ssh keys, these will be regenerated on first bootup...
+	sudo rm -rf "${tempdir}"/etc/ssh/ssh_host_* || true
+	sudo touch "${tempdir}/etc/ssh/ssh.regenerate" || true
+fi
+
+#ID.txt:
+if [ -f "${tempdir}/etc/dogtag" ] ; then
+	sudo cp "${tempdir}/etc/dogtag" "${DIR}/deploy/${export_filename}/ID.txt"
+fi
+
 report_size
 chroot_umount
 
-- 
GitLab