Fix crash when the img file is not found

grep returns a non-zero error code when it fails, so if it does not find
the img file it will crash the script because it is expecting 0.
moved it to the awk command instead

Signed-off-by: henry <henry@speiser.net>
Change-Id: Ic6e8f8b9c470a985eee869c2eaaf30e95edf56c6
diff --git a/frc971/rockpi/build_rootfs.sh b/frc971/rockpi/build_rootfs.sh
index b94154d..a1d0a0a 100755
--- a/frc971/rockpi/build_rootfs.sh
+++ b/frc971/rockpi/build_rootfs.sh
@@ -23,7 +23,7 @@
   sudo umount "${PARTITION}"
 fi
 
-LOOPBACK="$(sudo losetup --list | grep "${IMAGE}" | awk '{print $1}')"
+LOOPBACK="$(sudo losetup --list | awk "/$IMAGE/"'{print $1}')"
 if [[ -n "${LOOPBACK}" ]]; then
   echo "Loop still exists..."
   sudo losetup -d "${LOOPBACK}"
@@ -59,6 +59,16 @@
 echo "Made uboot"
 popd
 
+function target_mkdir() {
+  target "install -d -m $2 -o $(echo $1 | sed 's/\.[^.]*//') -g $(echo $1 | sed 's/[^.]*\.//') $3"
+}
+
+function copyfile() {
+  sudo cp contents/$3 ${PARTITION}/$3
+  sudo chmod $2 ${PARTITION}/$3
+  target "chown $1 /$3"
+}
+
 
 # Now build the base set of partitions.
 NEW_IMAGE=0
@@ -151,16 +161,6 @@
 target "usermod -a -G video pi"
 target "localedef -i en_US -f UTF-8 en_US.UTF-8"
 
-function target_mkdir() {
-  target "install -d -m $2 -o $(echo $1 | sed 's/\.[^.]*//') -g $(echo $1 | sed 's/[^.]*\.//') $3"
-}
-
-function copyfile() {
-  sudo cp contents/$3 ${PARTITION}/$3
-  sudo chmod $2 ${PARTITION}/$3
-  target "chown $1 /$3"
-}
-
 copyfile root.root 644 etc/fstab
 copyfile root.root 440 etc/sudoers
 copyfile root.root 444 etc/default/cpufrequtils