From fce744b0d9a648da5e2765af625c96370492f698 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 13 Dec 2021 09:39:23 +0800
Subject: [PATCH] update images and rootfs build shell script

---
 bsp/images/build.sh |   40 ++++++++++++++++++++++------------------
 1 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/bsp/images/build.sh b/bsp/images/build.sh
index b66b133..7000e39 100755
--- a/bsp/images/build.sh
+++ b/bsp/images/build.sh
@@ -66,19 +66,24 @@
     echo "Shell script exit now, do some clean work"
     echo ""
 
+    set +e
+
     mountpoint $MNT_POINT > /dev/null 2>&1
     if [ $? == 0 ] ; then
+        echo "umount ${MNT_POINT}"
         umount ${MNT_POINT}
     fi
 
     rm -rf ${MNT_POINT}
 
     if [ -L /dev/mapper/${LOOP_DEV}p1 ] ; then
+        echo "kpartx -dv /dev/${LOOP_DEV}"
         kpartx -dv /dev/${LOOP_DEV}
     fi
 
     losetup -a | grep "${LOOP_DEV}" > /dev/null 2>&1
     if [ $? == 0 ]  ; then
+        echo "losetup -d /dev/${LOOP_DEV}"
         losetup -d /dev/${LOOP_DEV}
     fi
 }
@@ -176,16 +181,16 @@
 }
 
 function do_image()
-{ 
-    mkdir -p ${MNT_POINT} 
+{
+    mkdir -p ${MNT_POINT}
 
-    generate_image 
+    generate_image
 
-    format_partition 
+    format_partition
 
-    install_sysimg 
+    install_sysimg
 
-    install_rootfs 
+    install_rootfs
 
     msg_banner " bzip2 compress system image "
     bzip2 ${IMAGE_NAME}
@@ -195,19 +200,18 @@
     printf "\n\n -- generate system image done --\n\n"
 }
 
-
 function do_root()
 {
     echo ""
-    if [[ $1 == "yes" ]] && [ `id -u` != 0 ] ; then 
+    if [[ $1 == "yes" ]] && [ `id -u` != 0 ] ; then
         echo "ERROR: This action must run as root!"
         echo ""
         exit;
-    elif [[ $1 != "yes" ]] && [ `id -u` == 0 ] ; then 
+    elif [[ $1 != "yes" ]] && [ `id -u` == 0 ] ; then
         echo "ERROR: This action cannot run as root!"
         echo ""
         exit;
-    fi  
+    fi
 }
 
 function do_usage()
@@ -228,22 +232,22 @@
 
 while getopts "bch" OPTNAME
 do
-    case "${OPTNAME}" in  
-        "b") 
+    case "${OPTNAME}" in
+        "b")
             break;
-            ;;  
+            ;;
 
-        "c") 
+        "c")
             do_root "yes"
             do_distclean
-            ;;  
+            ;;
 
         "*")
             do_usage
-            ;;  
+            ;;
     esac
 done
 
-do_root "yes" 
+do_root "yes"
 do_image
-
+exit;

--
Gitblit v1.9.1