summaryrefslogtreecommitdiff
path: root/extract_utils.sh
diff options
context:
space:
mode:
authorGabriele M <moto.falcon.git@gmail.com>2017-10-11 00:58:59 +0200
committerBruno Martins <bgcngm@gmail.com>2017-11-13 12:27:13 +0000
commitfb2a99fd47d019f4ac85bd6f8fc492027d75e4c5 (patch)
treea685137c99596c8c2428be6d08f92eb38661ff6f /extract_utils.sh
parent1e8c5b6aa043479499c7da928fde945832207894 (diff)
extract_utils: Fix pinning when not cleaning vendor dir
Skip the extraction of pinned files if the ones currently available have the expected sha1. If we don't, we will overwrite pinned files with potentially incorrect files when the current vendor files are not moved to a temporary directory (i.e. when not cleaning vendor). Change-Id: I640d6bf2ed98eb366a4df17f0ebeaec81cb5274b
Diffstat (limited to 'extract_utils.sh')
-rw-r--r--extract_utils.sh60
1 files changed, 27 insertions, 33 deletions
diff --git a/extract_utils.sh b/extract_utils.sh
index e335bf3..e41af24 100644
--- a/extract_utils.sh
+++ b/extract_utils.sh
@@ -966,7 +966,33 @@ function extract() {
fi
local DEST="$OUTPUT_DIR/$FROM"
- if [ "$SRC" = "adb" ]; then
+ # Check pinned files
+ local HASH="${HASHLIST[$i-1]}"
+ local KEEP=""
+ if [ "$DISABLE_PINNING" != "1" ] && [ ! -z "$HASH" ] && [ "$HASH" != "x" ]; then
+ if [ -f "$DEST" ]; then
+ local PINNED="$DEST"
+ else
+ local PINNED="$TMP_DIR/$FROM"
+ fi
+ if [ -f "$PINNED" ]; then
+ if [ "$(uname)" == "Darwin" ]; then
+ local TMP_HASH=$(shasum "$PINNED" | awk '{print $1}' )
+ else
+ local TMP_HASH=$(sha1sum "$PINNED" | awk '{print $1}' )
+ fi
+ if [ "$TMP_HASH" = "$HASH" ]; then
+ KEEP="1"
+ if [ ! -f "$DEST" ]; then
+ cp -p "$PINNED" "$DEST"
+ fi
+ fi
+ fi
+ fi
+
+ if [ "$KEEP" = "1" ]; then
+ printf ' + (keeping pinned file with hash %s)\n' "$HASH"
+ elif [ "$SRC" = "adb" ]; then
# Try Lineage target first
adb pull "/$TARGET" "$DEST"
# if file does not exist try OEM target
@@ -999,38 +1025,6 @@ function extract() {
fi
fi
- # Check pinned files
- local HASH="${HASHLIST[$i-1]}"
- if [ "$DISABLE_PINNING" != "1" ] && [ ! -z "$HASH" ] && [ "$HASH" != "x" ]; then
- local KEEP=""
- local TMP="$TMP_DIR/$FROM"
- if [ -f "$TMP" ]; then
- if [ ! -f "$DEST" ]; then
- KEEP="1"
- else
- if [ "$(uname)" == "Darwin" ]; then
- local DEST_HASH=$(shasum "$DEST" | awk '{print $1}' )
- else
- local DEST_HASH=$(sha1sum "$DEST" | awk '{print $1}' )
- fi
- if [ "$DEST_HASH" != "$HASH" ]; then
- KEEP="1"
- fi
- fi
- if [ "$KEEP" = "1" ]; then
- if [ "$(uname)" == "Darwin" ]; then
- local TMP_HASH=$(shasum "$TMP" | awk '{print $1}' )
- else
- local TMP_HASH=$(sha1sum "$TMP" | awk '{print $1}' )
- fi
- if [ "$TMP_HASH" = "$HASH" ]; then
- printf ' + (keeping pinned file with hash %s)\n' "$HASH"
- cp -p "$TMP" "$DEST"
- fi
- fi
- fi
- fi
-
if [ -f "$DEST" ]; then
local TYPE="${DIR##*/}"
if [ "$TYPE" = "bin" -o "$TYPE" = "sbin" ]; then