Add recovery image generate tool
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Thu, 16 Jul 2020 11:34:50 +0000 (11:34 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Mon, 20 Jul 2020 18:16:42 +0000 (18:16 +0000)
- Merge boot, platform, config to result
- Target image must be tar.gz format
- Config file name : recovery.cfg -> Filesystem label, bin name, blk dev
- Result file name : tizen-recovery.img

Change-Id: I1bd5fa4eac713e95e23d0efff11b96439633d988
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
recovery/scripts/generate_package.sh [new file with mode: 0755]
recovery/target/rpi/boot/.gitignore [new file with mode: 0644]
recovery/target/rpi/cfg/recovery.cfg [new file with mode: 0755]
recovery/target/rpi/platform/.gitignore [new file with mode: 0644]

diff --git a/recovery/scripts/generate_package.sh b/recovery/scripts/generate_package.sh
new file mode 100755 (executable)
index 0000000..2711cec
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+function __setup__() {
+       TARGET_DIR="$(readlink -m $1)/recovery/target/$2"
+       if [ ! -d "$TARGET_DIR" ]; then
+               echo "[ERROR] : $TARGET_DIR not exist, please check tota_upg_path and target"
+               exit
+       fi
+
+       TEMP_DIR="$TARGET_DIR/tmp"
+       RESULT_DIR="$TARGET_DIR/result"
+       BOOT_DIR="$TARGET_DIR/boot"
+       PLATFORM_DIR="$TARGET_DIR/platform"
+       CONFIG_DIR="$TARGET_DIR/cfg"
+
+       CONFIG_NAME="recovery.cfg"
+       IMAGE_NAME="tizen-recovery.img"
+
+       CONFIG_PATH="$CONFIG_DIR/$CONFIG_NAME"
+
+       # Setup prerequiste
+       rm -rf $TEMP_DIR $RESULT_DIR
+       mkdir -p $TEMP_DIR $RESULT_DIR
+
+       echo "[INFO] Target directory : $TARGET_DIR"
+       echo "[INFO] Result directory : $RESULT_DIR"
+}
+
+function __unpack__() {
+       image_dirs=("$BOOT_DIR/*.tar.gz" "$PLATFORM_DIR/*.tar.gz")
+
+       for image_dir in ${image_dirs[@]}; do
+               for image in $image_dir; do
+                       tar -zvxf $image --directory=$TEMP_DIR
+                       if [ $? -ne 0 ]; then
+                               echo "[ERROR] Failed to extract $image, please check image file"
+                               exit
+                       fi
+                       echo "[INFO] Success to extract : $image"
+               done
+       done
+}
+
+function __pack__() {
+       while read LABEL BINARY DEV
+       do
+               # Ignore empty or comment line
+               if [ -z "$LABEL" ] || [[ "$LABEL" == "#"* ]]; then
+                       continue
+               fi
+
+               if [ ! -f "$TEMP_DIR/$BINARY" ]; then
+                       echo "[ERROR] not found $BINARY, please check image file"
+                       exit
+               fi
+       done < "$CONFIG_PATH"
+       echo "[INFO] Success to check all image file exists"
+
+       cp $CONFIG_PATH $TEMP_DIR
+       cd $TEMP_DIR
+       mksquashfs * $IMAGE_NAME
+       chmod 777 $IMAGE_NAME
+       mv $IMAGE_NAME $RESULT_DIR
+}
+
+function __cleanup__() {
+       rm -rf $TEMP_DIR
+       if [ $? -ne 0 ]; then
+               echo "[WARN] Failed to remove $TEMP_DIR"
+               exit
+       fi
+}
+
+if [ $# -lt 2 ]; then
+       echo "Usage : generate_package.sh TOTA_UPG_PATH TARGET"
+       echo " TARGET > rpi"
+       exit
+fi
+
+__setup__ $1 $2
+__unpack__
+
+__pack__
+__cleanup__
diff --git a/recovery/target/rpi/boot/.gitignore b/recovery/target/rpi/boot/.gitignore
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/recovery/target/rpi/cfg/recovery.cfg b/recovery/target/rpi/cfg/recovery.cfg
new file mode 100755 (executable)
index 0000000..08894da
--- /dev/null
@@ -0,0 +1,7 @@
+BOOT                   boot.img                /dev/mmcblk0p1
+rootfs                 rootfs.img              /dev/mmcblk0p2
+system-data            system-data.img         /dev/mmcblk0p3
+user                   user.img                /dev/mmcblk0p5
+modules                        modules.img             /dev/mmcblk0p6
+ramdisk                        ramdisk.img             /dev/mmcblk0p7
+ramdisk-recovery       ramdisk-recovery.img    /dev/mmcblk0p8
\ No newline at end of file
diff --git a/recovery/target/rpi/platform/.gitignore b/recovery/target/rpi/platform/.gitignore
new file mode 100644 (file)
index 0000000..e69de29