Skip to content

Commit

Permalink
extract_utils: extract(): rename DEST variable to VENDOR_REPO_FILE
Browse files Browse the repository at this point in the history
* This denotes the path of the file that results from the extraction
  process, relative to the "proprietary" directory.
* This is a cleanup patch.

Change-Id: I38e759bb6ed697f0a31ca35a7aa9b9b92f8b6793
Signed-off-by: Vladimir Oltean <[email protected]>
  • Loading branch information
vladimiroltean authored and hungphan2001 committed May 28, 2019
1 parent f8160d5 commit b266776
Showing 1 changed file with 23 additions and 47 deletions.
70 changes: 23 additions & 47 deletions build/tools/extract_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ function oat2dex() {
java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$TMPDIR/$(basename "$OAT")"
java -jar "$SMALIJAR" assemble "$TMPDIR/dexout" -o "$TMPDIR/classes.dex"
fi
elif [[ "$LINEAGE_TARGET" =~ .jar$ ]]; then
elif [[ "$DOT_TARGET" =~ .jar$ ]]; then
JAROAT="$TMPDIR/system/framework/$ARCH/boot-$(basename ${OEM_TARGET%.*}).oat"
JARVDEX="/system/framework/boot-$(basename ${OEM_TARGET%.*}).vdex"
if [ ! -f "$JAROAT" ]; then
Expand Down Expand Up @@ -945,14 +945,14 @@ function extract() {
if [ ! -d "$OUTPUT_DIR/$DIR" ]; then
mkdir -p "$OUTPUT_DIR/$DIR"
fi
local DEST="$OUTPUT_DIR/${SPEC_DST_FILE}"
local VENDOR_REPO_FILE="$OUTPUT_DIR/${SPEC_DST_FILE}"

# 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"
if [ -f "${VENDOR_REPO_FILE}" ]; then
local PINNED="${VENDOR_REPO_FILE}"
else
local PINNED="$TMP_DIR/${SPEC_DST_FILE}"
fi
Expand All @@ -964,8 +964,8 @@ function extract() {
fi
if [ "$TMP_HASH" = "$HASH" ]; then
KEEP="1"
if [ ! -f "$DEST" ]; then
cp -p "$PINNED" "$DEST"
if [ ! -f "${VENDOR_REPO_FILE}" ]; then
cp -p "$PINNED" "${VENDOR_REPO_FILE}"
fi
fi
fi
Expand All @@ -974,19 +974,19 @@ function extract() {
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"
# Try dotos target first
adb pull "/$TARGET" "${VENDOR_REPO_FILE}"
# if file does not exist try OEM target
if [ "$?" != "0" ]; then
adb pull "/${SPEC_SRC_FILE}" "$DEST"
adb pull "/${SPEC_SRC_FILE}" "${VENDOR_REPO_FILE}"
fi
else
# Try OEM target first
if [ -f "$SRC/$FILE" ]; then
cp "$SRC/$FILE" "$DEST"
# if file does not exist try DOT target
elif [ -f "$SRC/$TARGET" ]; then
cp "$SRC/$TARGET" "$DEST"
# Try dotos target first
if [ -f "$SRC/$TARGET" ]; then
cp "$SRC/$TARGET" "${VENDOR_REPO_FILE}"
# if file does not exist try OEM target
elif [ -f "$SRC/${SPEC_SRC_FILE}" ]; then
cp "$SRC/${SPEC_SRC_FILE}" "${VENDOR_REPO_FILE}"
else
printf ' !! file not found in source\n'
continue
Expand All @@ -995,48 +995,24 @@ function extract() {

if [ "$?" == "0" ]; then
# Deodex apk|jar if that's the case
if [[ "$FULLY_DEODEXED" -ne "1" && "$DEST" =~ .(apk|jar)$ ]]; then
oat2dex "$DEST" "${SPEC_SRC_FILE}" "$SRC"
if [[ "$FULLY_DEODEXED" -ne "1" && "${VENDOR_REPO_FILE}" =~ .(apk|jar)$ ]]; then
oat2dex "${VENDOR_REPO_FILE}" "${SPEC_SRC_FILE}" "$SRC"
if [ -f "$TMPDIR/classes.dex" ]; then
zip -gjq "$DEST" "$TMPDIR/classes.dex"
zip -gjq "${VENDOR_REPO_FILE}" "$TMPDIR/classes.dex"
rm "$TMPDIR/classes.dex"
printf ' (updated %s from odex files)\n' "/${SPEC_SRC_FILE}"
fi
elif [[ "$DEST" =~ .xml$ ]]; then
fix_xml "$DEST"
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
local DEST_HASH=$(sha1sum "$DEST" | awk '{print $1}' )
if [ "$DEST_HASH" != "$HASH" ]; then
KEEP="1"
fi
fi
if [ "$KEEP" = "1" ]; then
local TMP_HASH=$(sha1sum "$TMP" | awk '{print $1}' )
if [ "$TMP_HASH" = "$HASH" ]; then
printf ' + (keeping pinned file with hash %s)\n' "$HASH"
cp -p "$TMP" "$DEST"
fi
fi
elif [[ "${VENDOR_REPO_FILE}" =~ .xml$ ]]; then
fix_xml "${VENDOR_REPO_FILE}"
fi
fi

if [ -f "$DEST" ]; then
if [ -f "${VENDOR_REPO_FILE}" ]; then
local TYPE="${DIR##*/}"
if [ "$TYPE" = "bin" -o "$TYPE" = "sbin" ]; then
chmod 755 "$DEST"
chmod 755 "${VENDOR_REPO_FILE}"
else
chmod 644 "$DEST"
chmod 644 "${VENDOR_REPO_FILE}"
fi
fi

Expand Down

0 comments on commit b266776

Please sign in to comment.