Radix cross Linux Build System

Cross-platform build system is designed to build distributions of different operating systems for a set of target devices

39 Commits   2 Branches   2 Tags
Index: write-efiboot-image
===================================================================
--- write-efiboot-image	(revision 33)
+++ write-efiboot-image	(revision 34)
@@ -6,6 +6,7 @@
 sbindir=`cd $(dirname ${BASH_SOURCE[0]}) >/dev/null 2>&1 && pwd`
 
 # 13 = permission denied (should be root)
+# 14 = required tools is not installed in system
 # 92 = Cannot create '/tmp/...' directory
 EXITSTATUS=0
 
@@ -70,9 +71,24 @@
 FDISK=`PATH=/sbin:/usr/sbin:$PATH which fdisk`
 if [ "`basename ${FDISK}`" != "fdisk" ] ; then
   echo "ERROR: fdisk utility is not found in the system"
-  exit 1
+  EXITSTATUS=14
+  exit $EXITSTATUS
 fi
 
+BC=`PATH=/bin:/usr/bin:$PATH which bc`
+if [ "`basename ${BC}`" != "bc" ] ; then
+  echo "ERROR: bc utility is not found in the system"
+  EXITSTATUS=14
+  exit $EXITSTATUS
+fi
+
+DD=`PATH=/bin:/usr/bin:$PATH which dd`
+if [ "`basename ${DD}`" != "dd" ] ; then
+  echo "ERROR: dd utility is not found in the system"
+  EXITSTATUS=14
+  exit $EXITSTATUS
+fi
+
 PARTPROBE=`PATH=/sbin:/usr/sbin:$PATH which partprobe`
 if [ "`basename ${PARTPROBE}`" != "partprobe" ] ; then
   PARTPROBE=
@@ -215,12 +231,12 @@
   local title=$4
   local PCT=0
 
-  ( while [ "x`ps -eo pid | grep $pid`" != "x" ] ; do
-      kill -USR1 "$pid" 2>/dev/null
-      line=`tail -n1 $ddout | grep "bytes"`
-      bytes=`echo "$line" | cut -f 1 -d ' '`
-      if [ "x$bytes" != "x" ] ; then
-        let "PCT = bytes * 100 / isize"
+  ( while [ "x`ps -eo pid | grep ${pid}`" != "x" ] ; do
+      kill -USR1 "${pid}" 2>/dev/null
+      line=`tail -n1 ${ddout} | grep "bytes"`
+      bytes=`echo "${line}" | cut -f 1 -d ' '`
+      if [ "x${bytes}" != "x" ] ; then
+        PCT=`echo "${bytes} * 100 / ${isize}" | ${BC}`
       fi
       cat << EOF
 XXX
@@ -231,7 +247,7 @@
 EOF
       usleep 300
     done
-    if [ "x`ps -eo pid | grep $pid`" = "x" ] ; then
+    if [ "x`ps -eo pid | grep ${pid}`" = "x" ] ; then
       cat << EOF
 XXX
 100
@@ -526,7 +542,7 @@
   fi
   cnt=$(echo "${disk_size_in_bytes} / 512" | bc)
   rm -f ${DDOUTPUT}
-  LANG=en_US.UTF-8 dd if=/dev/zero of=${DEVICE} of=disk bs=512 count=${cnt} >> ${DDOUTPUT} 2>&1 & \
+  LANG=en_US.UTF-8 ${DD} if=/dev/zero of=${DEVICE} of=disk bs=512 count=${cnt} >> ${DDOUTPUT} 2>&1 & \
     waitdd $! ${DDOUTPUT} ${disk_size_in_bytes} "Create empty disk image"
   rm -f ${DDOUTPUT}
 fi
@@ -736,9 +752,9 @@
 fi
 rm -f ${DDOUTPUT}
 LANG=en_US.UTF-8 \
-  dd if=${EFI32FS_IMAGE} of=${DEVICE} \
-     bs=${unit_size} count=${efi32fs_size_in_sectors} \
-     seek=${efi32fs_start_sector} conv=notrunc >> ${DDOUTPUT} 2>&1 & \
+  ${DD} if=${EFI32FS_IMAGE} of=${DEVICE} \
+        bs=${unit_size} count=${efi32fs_size_in_sectors} \
+        seek=${efi32fs_start_sector} conv=notrunc >> ${DDOUTPUT} 2>&1 & \
     waitdd $! ${DDOUTPUT} ${efi32fs_size_in_bytes} "EFI boot image recording..."
 rm -f ${DDOUTPUT}
 
@@ -752,9 +768,9 @@
 fi
 rm -f ${DDOUTPUT}
 LANG=en_US.UTF-8 \
-  dd if=${EXT4FS_IMAGE} of=${DEVICE} \
-     bs=${unit_size} count=${ext4fs_size_in_sectors} \
-     seek=${ext4fs_start_sector} conv=notrunc >> ${DDOUTPUT} 2>&1 & \
+  ${DD} if=${EXT4FS_IMAGE} of=${DEVICE} \
+        bs=${unit_size} count=${ext4fs_size_in_sectors} \
+        seek=${ext4fs_start_sector} conv=notrunc >> ${DDOUTPUT} 2>&1 & \
     waitdd $! ${DDOUTPUT} ${ext4fs_size_in_bytes} "ROOT filesystem image recording..."
 rm -f ${DDOUTPUT}