Add unpack_image() to tct/prepare/prepare.sh
authorAleksander Mistewicz <a.mistewicz@samsung.com>
Tue, 15 Dec 2015 11:20:53 +0000 (12:20 +0100)
committerAleksander Mistewicz <a.mistewicz@samsung.com>
Fri, 13 May 2016 12:09:42 +0000 (14:09 +0200)
Change-Id: Ic738cc7ec486a4d565d26feeead6c419e424cac5
Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
tct/prepare/prepare.sh

index 329ec1a..91c186e 100755 (executable)
@@ -14,6 +14,7 @@
 
 # Syntax is:
 #   * install_iserial $ID $IMAGE_MOUNTPOINT
+#   * unpack_image $IMAGE... $IMAGE_UNPACKED
 #
 # Author: Aleksander Mistewicz <a.mistewicz@samsung.com>
 
@@ -32,3 +33,16 @@ install_iserial() {
     sudo ln -s /usr/lib/systemd/system/iserial.service \
         "${IMAGE_MOUNTPOINT}/etc/systemd/system/multi-user.target.wants/iserial.service"
 }
+
+unpack_image() {
+    test $# -ge 2 || die "Too few arguments!"
+    eval DESTINATION=\$$#
+    test -d "${DESTINATION}" || mkdir -p "${DESTINATION}"
+
+    while [ $# -ge 2 ]; do
+        IMAGE="$1"
+        test -f "${IMAGE}" || die "The image does not exist or is not a regular file: ${IMAGE}!"
+        tar xvf "${IMAGE}" -C "${DESTINATION}" || die "tar: extracting files from archive failed!"
+        shift
+    done
+}