init: Copy HAL layer files if required 12/257012/2 accepted/tizen/unified/20210421.101203 submit/tizen/20210420.084041
authorDongwoo Lee <dwoo08.lee@samsung.com>
Fri, 9 Apr 2021 04:38:56 +0000 (13:38 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 20 Apr 2021 02:30:35 +0000 (11:30 +0900)
To support the case that HAL image is separated, it checks whether the
files in the hal file list exist, and, if not, copying it from HAL
image.

Change-Id: I768a9192cf92eea80d74960429b217eb9485fb7f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
src/initrd-recovery/00-initrd-recovery.list.in
src/initrd-recovery/init

index 64402ef17f305031305574ea50abfe1659770b9c..7ba7d2b9c8213827292cd729fbf4404c6c690404 100644 (file)
@@ -12,6 +12,7 @@ WITHLIBS="
 /usr/bin/sleep
 /usr/bin/sync
 /usr/bin/umount
+/usr/bin/dirname
 /usr/sbin/blkid
 "
 
index 6a55fa2dd9e221c0a652bec937b7202d35e17d8b..fdccb71482a28e5650bd21bdc9205b990670bc37 100755 (executable)
@@ -3,13 +3,16 @@
 export PATH=/usr/bin:/bin:/usr/sbin:/sbin
 
 INFORM_PATH=/mnt/inform
+HAL_PATH=/mnt/hal
 
 SYNC="/bin/sync"
 MKDIR="/bin/mkdir"
 MOUNT="/bin/mount"
 UMOUNT="/bin/umount"
+DIRNAME="/bin/dirname"
 REBOOT="/sbin/reboot"
 BLKID="/usr/sbin/blkid"
+CP="/bin/cp"
 
 #------------------------------------------------
 #       mount_partitions
@@ -36,6 +39,58 @@ mount_inform() {
     fi
 }
 
+#------------------------------------------------
+#       mkdir_p_parent
+#------------------------------------------------
+mkdir_p_parent() {
+    dst_dir=`"$DIRNAME" "$1"`
+    if [ ! -d "$dst_dir" -a ! -L "$dst_dir" ]; then
+        "$MKDIR" -p "$dst_dir"
+    fi
+}
+
+#------------------------------------------------
+#       copy_hal_data
+#------------------------------------------------
+copy_hal_data() {
+    if [ ! -e "/hal/.hal_list" ]; then
+        return
+    fi
+
+    need_copy=0
+    while read file
+    do
+        dst="/hal/${file}"
+
+        if [ ! -e $dst ]; then
+            need_copy=1
+            break
+        fi
+    done < /hal/.hal_list
+
+    PART_HAL=$("$BLKID" -L "hal" -o device)
+    if [ "$need_copy" = "1" -a "z$PART_HAL" != "z" ]; then
+        #mount hal partition
+        "$MKDIR" -p ${HAL_PATH}
+        "$MOUNT" ${PART_HAL} ${HAL_PATH} -o ro
+
+        #Load list and copy
+        while read file
+        do
+            src="${HAL_PATH}/$file"
+            dst="/hal/${file}"
+
+            mkdir_p_parent $dst
+
+            "$CP" -f "$src" "$dst"
+
+        done < /hal/.hal_list
+
+        #Done
+        "$UMOUNT" ${HAL_PATH}
+    fi
+}
+
 #------------------------------------------------
 #       do_reboot
 #------------------------------------------------
@@ -57,6 +112,7 @@ echo "You entered into /sbin/init on initrd"
 
 mount_partitions
 mount_inform
+copy_hal_data
 
 cd /