diff --git a/scripts/chroot.sh b/scripts/chroot.sh
index 593fbeee416ef17e67d85f4f3dceadcb6e6e4f21..d03f253ddfe9129ee862679a51f4579be3f21e1f 100755
--- a/scripts/chroot.sh
+++ b/scripts/chroot.sh
@@ -722,9 +722,9 @@ cat > ${DIR}/chroot_script.sh <<-__EOF__
 		esac
 
 		if [ ! "x${rfs_opt_scripts}" = "x" ] ; then
+			mkdir -p /opt/scripts/ || true
 
 			if [ -f /usr/bin/git ] ; then
-				mkdir -p /opt/scripts/ || true
 				qemu_command="git clone ${rfs_opt_scripts} /opt/scripts/ --depth 1"
 				qemu_warning
 				git clone -v ${rfs_opt_scripts} /opt/scripts/ --depth 1
@@ -943,7 +943,7 @@ fi
 #usually a qemu failure...
 if [ ! "x${rfs_opt_scripts}" = "x" ] ; then
 	#we might not have read permissions:
-	if [ -r ${tempdir}/ ] ; then
+	if [ -r ${tempdir}/opt/scripts/ ] ; then
 		if [ ! -f ${tempdir}/opt/scripts/.git/config ] ; then
 			echo "Log: ERROR: git clone of ${rfs_opt_scripts} failed.."
 			exit 1