--- /dev/null
+#!/bin/bash
+
+CONFIG_PATH=update.cfg
+BACKGROUND_COPY_LIST=/hal/etc/upgrade/background_copy.list
+
+
+function is_cloned() {
+ [[ $(device_board_get_partition_ab_cloned) == "1" ]]
+}
+
+function get_part_labels() {
+ echo -e "${1}_a\n${1}_b"
+}
+
+function current_part_with_suffix() {
+ echo "${1}_$(current_suffix)"
+}
+
+function opposite_part_with_suffix() {
+ echo "${1}_$(opposite_suffix)"
+}
+
+function current_suffix() {
+ device_board_get_current_partition
+}
+
+function opposite_suffix() {
+ if [[ $(current_suffix) == "a" ]]; then
+ echo "b"
+ else
+ echo "a"
+ fi
+}
+
+function verify_part() {
+ PARTLABEL="$1"
+ SIZE="$2"
+ SHA="$3"
+ device=$(blkid -t PARTLABEL="$PARTLABEL" -o device)
+ CUR_SHA1=$(head -c "$SIZE" "$device" | sha1sum | awk '{print $1}')
+ [[ "$CUR_SHA1" == "$SHA" ]]
+}
+
+function verify_update() {
+ echo -e "\n\nVerify update"
+ echo "Current slot: $(device_board_get_current_partition)"
+ while read -r LABEL_NAME DELTA_NAME TYPE DEV OFFSET OLD_SIZE NEW_SIZE OLD_SHA NEW_SHA
+ do
+ PARTLABEL=$(current_part_with_suffix "$LABEL_NAME")
+ echo -n "Checking $LABEL_NAME ($PARTLABEL): "
+ if verify_part "$PARTLABEL" "$NEW_SIZE" "$NEW_SHA"; then
+ echo "OK"
+ else
+ echo "Incorrect checksum"
+ fi
+ done < <(sed -e '/^#/d' -e '/^$/d' "$CONFIG_PATH")
+}
+
+function verify_clone() {
+ echo -e "\n\nVerify clone"
+ echo "Opposite slot: $(opposite_suffix)"
+ while read -r LABEL_NAME
+ do
+ read -r SIZE SHA < <(awk "/$LABEL_NAME/ {print \$7 \" \" \$9}" $CONFIG_PATH)
+ PARTLABEL=$(opposite_part_with_suffix "$LABEL_NAME")
+ echo -n "Checking $LABEL_NAME ($PARTLABEL): "
+ if verify_part "$PARTLABEL" "$SIZE" "$SHA"; then
+ echo "OK"
+ else
+ echo "Incorrect checksum"
+ fi
+
+ done < <(sed -e '/^#/d' -e '/^$/d' "$BACKGROUND_COPY_LIST")
+}
+
+if ! is_cloned; then
+ clone_partitions.sh
+fi
+
+verify_update
+verify_clone
--- /dev/null
+#!/bin/bash
+
+DEST_DIR=/opt/usr/verifier
+CHECKER_SH=checker.sh
+
+
+if [ "$#" != "1" ] || [ ! -f "$1" ]; then
+ echo "Use:"
+ echo " $0 <delta_file>"
+ exit 1
+fi
+
+UPLOAD_FILES=( checker.sh update.cfg )
+
+echo "Extract update.cfg from $1"
+tar xvf "${1}" update.cfg
+
+echo "Upload files"
+{ sleep 0.2; echo tizen; } | sdb shell su -c "mkdir -p $DEST_DIR && chmod 777 $DEST_DIR"
+for FILE in "${UPLOAD_FILES[@]}"; do
+ sdb push "$FILE" "$DEST_DIR"
+done
+
+{ sleep 0.2; echo tizen; } | sdb shell su -c "chmod +x $DEST_DIR/$CHECKER_SH"
+
+echo "Run verifier"
+{ sleep 0.2; echo tizen; } | sdb shell su -c "cd $DEST_DIR && $DEST_DIR/$CHECKER_SH"
+