Remove the specific logic for dzImage
authorKichan Kwon <k_c.kwon@samsung.com>
Mon, 15 Jul 2019 02:49:24 +0000 (11:49 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Tue, 16 Jul 2019 00:42:15 +0000 (09:42 +0900)
Change-Id: I9f9a5874be3b83e3b67ff08d7f8f09395bfa7e89
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
mk_delta/common/bin/CreatePatch.py
mk_delta/common/bin/dzImagescript.sh [deleted file]

index 318d47e..88ecb8a 100755 (executable)
@@ -99,7 +99,6 @@ MEM_FILE = "NULL"
 
 SUPPORT_RENAME = "TRUE" #Use appropriate name
 SUPPORT_CONTAINERS = "FALSE"
-SUPPORT_DZIMAGE = "TRUE"
 SUPPORT_VERBATIM = "TRUE"
 
 TEST_MODE = "FALSE"
@@ -224,12 +223,6 @@ def SS_update_cfg(DELTA_BIN, UPDATE_CFG_PATH):
 def SS_mk_delta_img(BASE_OLD, BASE_NEW, OUT_DIR, DELTA_BIN, UPDATE_CFG_PATH):
        #for sizes
 
-       ZIMAGE_SCRIPT = COMMON_BIN_PATH+'./dzImagescript.sh'
-       ZIMAGE_OLD = BASE_OLD+'_unpacked'
-       ZIMAGE_NEW = BASE_NEW+'_unpacked'
-       DZIMAGE_HEADER = 'UnpackdzImage'
-       DZIMAGE_SEP = ':'
-
        oldsize_d= os.path.getsize(BASE_OLD)
        newsize_d= os.path.getsize(BASE_NEW)
        SHA_BIN_DEST= hash_file(BASE_NEW)
@@ -256,59 +249,9 @@ def SS_mk_delta_img(BASE_OLD, BASE_NEW, OUT_DIR, DELTA_BIN, UPDATE_CFG_PATH):
                                f.write(line)
                f.close()
 
-       #Any validation checks required?
-       if (DELTA_BIN == "zImage" or DELTA_BIN == "dzImage" or DELTA_BIN == "KERNEL" or DELTA_BIN == "BOOT" or DELTA_BIN == "boot" or DELTA_BIN == "recovery") and SUPPORT_DZIMAGE == "TRUE":
-
-               #Unpack Old and New Images for creating delta
-               subprocess.call([ZIMAGE_SCRIPT, '-u', BASE_OLD])
-               subprocess.call([ZIMAGE_SCRIPT, '-u', BASE_NEW])
-
-               DeltaFiles = []
-               Old_files, Old_dirs = Get_Files(ZIMAGE_OLD)
-               New_files, New_dirs = Get_Files(ZIMAGE_NEW)
-
-               patchLoc = '%s/%s_temp' % (OUT_DIR, DELTA_BIN)
-               ensure_dir_exists(patchLoc)
-
-               for elt in New_files:
-                       if elt in Old_files:
-                               src_file = ZIMAGE_OLD+'/'+elt
-                               dst_file = ZIMAGE_NEW+'/'+elt
-                               if not filecmp.cmp(src_file, dst_file):
-                                       patch = '%s/%s' % (patchLoc,elt)
-                                       DeltaFiles.append(patch)
-                                       subprocess.call([DIFF_UTIL,src_file,dst_file,patch])
-                                       logging.info('Make dz Image %s <--> %s ==> %s %s' % (src_file, dst_file , DELTA_BIN, patch))
-
-               #Append all delta files to make image.delta
-
-               #HEADER FORMAT MAGICNAME:FILECOUNT:[FILENAME:FILESIZE:][FILECONTENT/S]
-               HeaderStr = DZIMAGE_HEADER+DZIMAGE_SEP+'%d' % len(DeltaFiles)
-               HeaderStr = HeaderStr+DZIMAGE_SEP
-
-               with open(OUT_DIR+'/'+DELTA, 'w') as DeltaFile:
-                       for fname in DeltaFiles:
-                               DeltaSize = os.path.getsize(fname)
-                               HeaderStr = HeaderStr+path_leaf(fname)+DZIMAGE_SEP+'%d' % DeltaSize
-                               HeaderStr = HeaderStr+DZIMAGE_SEP
-                       #Using 128 bytes as max Header.
-                       logging.info('zImage Header - %s' % HeaderStr.ljust(128,'0'))
-                       DeltaFile.write(HeaderStr.ljust(128,'0'))
-                       for fname in DeltaFiles:
-                               with open(fname) as infile:
-                                       DeltaFile.write(infile.read())
-                                       infile.close()
-
-               DeltaFile.close()
-               shutil.rmtree(patchLoc)
-               shutil.rmtree(ZIMAGE_OLD)
-               shutil.rmtree(ZIMAGE_NEW)
-               #Do we need to incorprate Max memory required for backup??
-
-       else:
-               patchLoc = '%s/%s' % (OUT_DIR, DELTA)
-               logging.info('Make Delta Image %s <--> %s ==> %s %s' % (BASE_OLD, BASE_NEW , DELTA_BIN, patchLoc))
-               subprocess.call([DIFF_UTIL,BASE_OLD,BASE_NEW,patchLoc])
+       patchLoc = '%s/%s' % (OUT_DIR, DELTA)
+       logging.info('Make Delta Image %s <--> %s ==> %s %s' % (BASE_OLD, BASE_NEW , DELTA_BIN, patchLoc))
+       subprocess.call([DIFF_UTIL,BASE_OLD,BASE_NEW,patchLoc])
 
 
 
diff --git a/mk_delta/common/bin/dzImagescript.sh b/mk_delta/common/bin/dzImagescript.sh
deleted file mode 100755 (executable)
index f96bc4f..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-#!/bin/bash
-
-pname="${0##*/}"
-args=("$@")
-cur_dir="$(pwd)"
-
-# file names:
-decompression_code="decompression_code"
-piggy_gz_piggy_trailer="piggy.gz+piggy_trailer"
-piggy="piggy"
-piggy_gz="piggy.gz"
-padding_piggy="padding_piggy"
-piggy_trailer="piggy_trailer"
-ramfs_gz_part3="initramfs.cpio+part3"
-ramfs_cpio_gz="initramfs.cpio.gz"
-padding3="padding3"
-part3="part3"
-kernel_img="kernel.img"
-ramfs_cpio="initramfs.cpio"
-ramfs_dir="initramfs"
-sizes="sizes"
-ramfs_part3="ramfs+part3"
-ramfs_list="initramfs_list"
-cpio_t="cpio-t"
-
-
-cpio="cpio_set0"
-
-# We dup2 stderr to 3 so an error path is always available (even
-# during commands where stderr is redirected to /dev/null).  If option
-# -v is set, we dup2 sterr to 9 also so commands (and some of their
-# results if redirected to &9) are printed also.
-exec 9>/dev/null                # kill diagnostic ouput (will be >&2 if -v)
-exec 3>&2                       # an always open error channel
-
-#
-########### Start of functions
-#
-
-# Emit an error message and abort
-fatal(){
-    # Syntax: fatal <string ...>
-    # Output error message, then abort
-    echo >&3
-    echo >&3 "$pname: $*"
-    kill $$
-    exit 1
-}
-
-# Execute a command, displaying the command if -v:
-cmd(){
-    # Syntax: cmd <command> <args...>
-    # Execute <command>, echo command line if -v
-    echo >&9 "$*"
-    "$@"
-}
-
-# Execute a required command, displaying the command if -v, abort on
-# error:
-rqd(){
-    # Syntax: cmd <command> <args...>
-    # Execute <command>, echo commandline if -v, abort on error
-    cmd "$@" || fatal "$* failed."
-}
-
-findByteSequence(){
-    # Syntax: findByteSequence <fname> [<string, default: gzip header>]
-    # Returns: position (offset) on stdout, empty string if nothing found
-    file="$1"
-    local opt
-    if [ "$2" = "lzma" ]; then
-        srch=$'\x5d....\xff\xff\xff\xff\xff'
-        opt=
-    else
-        srch="${2:-$'\x1f\x8b\x08'}" # Default: search for gzip header
-        opt="-F"
-    fi
-    pos=$(LC_ALL=C grep $opt -a --byte-offset -m 1 --only-matching -e "$srch" -- "$file")
-    echo ${pos%%:*}
-}
-
-getFileSize(){
-    # Syntax: getFileSize <file>
-    # Returns size of the file on stdout.
-    # Aborts if file doesn't exist.
-    rqd stat -c %s "$1"
-}
-checkNUL(){
-    # Syntax: checkNUL file offset
-    # Returns true (0) if byte there is 0x0.
-    [ "$(rqd 2>/dev/null dd if="$1" skip=$2 bs=1 count=1)" = $'\0' ]
-}
-
-gunzipWithTrailer(){
-    # Syntax gunzipWithTrailer <file> <gzip name, sans .gz> <padding> <trailer>
-    #
-    # <file>: the input file
-    # <gzip name, sans .gz>, <padding>, <trailer>:
-    #   The output files.  For the gzipped part, both the
-    #   compressed and the uncompressed output is generated, so we have
-    #   4 output files.
-    local file="$1"
-    local gz_result="$2.gz"
-    local result="$2"
-    local padding="$3"
-    local trailer="$4"
-    local tmpfile="/tmp/gunzipWithTrailer.$$.gz"
-    local original_size=$(getFileSize "$file")
-    local d=$(( (original_size+1) / 2))
-    local direction fini at_min=0
-    local results_at_min=()
-    local size=$d
-    local at_min=
-    echo "Separating gzipped part from trailer in  "$file""
-    echo -n "Trying size: $size"
-    while :; do
-        rqd dd if="$file" of="$tmpfile" bs=$size count=1 2>/dev/null
-        cmd gunzip >/dev/null 2>&1 -c "$tmpfile"
-        res=$?
-        if [ "$d" -eq 1 ]; then
-            : $((at_min++))
-            results_at_min[$size]=1
-            [ "$at_min" -gt 3 ] && break
-        fi
-        d=$(((d+1)/2))
-        case $res in
-                # 1: too small
-            1) size=$((size+d)); direction="↑";;
-                # 2: trailing garbage
-            2) size=$((size-d)); direction="↓";;
-                # OK
-            0) break;;
-            *) fatal "gunzip returned $res while checking "$file"";;
-        esac
-        echo -n "  $size"
-    done
-    if [ "$at_min" -gt 3 ]; then
-        echo -e "\ngunzip result is oscillating between 'too small' and 'too large' at size: ${!results_at_min[*]}"
-        echo -n "Trying lower nearby values:  "
-        fini=
-        for ((d=1; d < 30; d++)); do
-            : $((size--))
-            echo -n "  $size"
-            rqd dd if="$file" of="$tmpfile" bs=$size count=1 2>/dev/null
-            if cmd gunzip >/dev/null 2>&1 -c "$tmpfile"; then
-                echo -n " - OK"
-                fini=1
-                break
-            fi
-        done
-        [ -z "$fini" ] && fatal 'oscillating gunzip result, giving up.'
-    fi
-    # We've found the end of the gzipped part.  This is not the real
-    # end since gzip allows for some trailing padding to be appended
-    # before it barfs.  First, go back until we find a non-null
-    # character:
-    echo -ne "\npadding check (may take some time): "
-    real_end=$((size-1))
-    while checkNUL "$file" $real_end; do
-        : $((real_end--))
-    done
-    # Second, try if gunzip still succeeds.  If not, add trailing
-    # null(s) until it succeeds:
-    while :; do
-        rqd dd if="$file" of="$tmpfile" bs=$real_end count=1 2>/dev/null
-        gunzip >/dev/null 2>&1 -c "$tmpfile"
-        case $? in
-            # 1: too small
-            1) : $((real_end++));;
-            *) break;;
-        esac
-    done
-    real_next_start=$size
-    # Now, skip NULs forward until we reach a non-null byte.  This is
-    # considered as being the start of the next part.
-    while checkNUL "$file" $real_next_start; do
-        : $((real_next_start++))
-    done
-    echo $((real_next_start - real_end))
-    echo
-    rm "$tmpfile"
-    # Using the numbers we got so far, create the output files which
-    # reflect the parts we've found so far:
-    rqd dd 2>&9 if="$file" of="$gz_result" bs=$real_end count=1
-    rqd dd 2>&9 if="$file" of="$padding" skip=$real_end bs=1 count=$((real_next_start - real_end))
-    rqd dd 2>&9 if="$file" of="$trailer" bs=$real_next_start skip=1
-    rqd gunzip -c "$gz_result" > "$result"
-}
-
-
-unpack()(
-    [ -d "$unpacked" ] && echo "\
-Warning: there is aready an unpacking directory.  If you have files added on
-your own there, the  repacking result may not reflect the result of the
-current unpacking process."
-    rqd mkdir -p "$unpacked"
-    rqd cd "$unpacked"
-    sizes="$unpacked/sizes"
-    echo "# Unpacking sizes" > "$sizes"
-
-    piggy_start=$(findByteSequence "$cur_dir/$zImage")
-    if [ -z "$piggy_start" ]; then
-        fatal "Can't find a gzip header in file '$zImage'"
-    fi
-
-    rqd dd 2>&9 if="$cur_dir/$zImage" bs="$piggy_start" count=1 of="$decompression_code"
-    rqd dd 2>&9 if="$cur_dir/$zImage" bs="$piggy_start" skip=1 of="$piggy_gz_piggy_trailer"
-
-    gunzipWithTrailer  "$piggy_gz_piggy_trailer" \
-        "$piggy" "$padding_piggy" "$piggy_trailer"
-
-    echo
-       sudo rm -rf "piggy.gz" "piggy.gz+piggy_trailer" "sizes"
-    echo "Success."
-    echo "The unpacked files and the initramfs directory are in "$unpacked""
-)
-
-#### start of main program
-while getopts xv12345sgrpuhtz-: argv; do
-    case $argv in
-        p|u|z|1|2|3|4|5|t|r|g) eval opt_$argv=1;;
-        v) exec 9>&2; opt_v=1;;
-        s) cpio="cpio";;
-        x) set -x;;
-        -) if [ "$OPTARG" = "version" ]; then
-              echo "$pname $version"
-              exit 0
-           else
-              echo "Wrong Usage, use -u to unpack"
-           fi;;
-        h|-) echo "Wrong Usage, use -u to unpack";;
-        *) fatal "Illegal option";;
-    esac
-done
-shift $((OPTIND-1))
-zImage="${1:-zImage}"
-unpacked="$cur_dir/${zImage}_unpacked"
-packing="$cur_dir/${zImage}_packing"
-shift
-if [ -n "$*" ]; then
-    fatal "Excess arguments: '$*'"
-fi
-
-if [ -n "$opt_u" ]; then
-    [ -f "$zImage" ] || fatal "file '$zImage': not found"
-    unpack
-fi
-if [ -z "$opt_u" ]; then
-    echo >&2 "$pname: Need at least -u option."
-    echo >&2 "$pname: Type '$pname --help' for usage info."
-    exit 1
-fi
-
-exit
-