Skip to content

Commit

Permalink
extract_utils: template: use quotation marks and variable curly brace…
Browse files Browse the repository at this point in the history
…s consistently

* This makes sure that multi-word arguments are passed correctly from
  extract-files.sh towards the common extract_utils helper. An example
  would be extract-files --section "Hello World".
* IMPORTANT: device repositories that use a device/common split
  typically do something like this to invoke the common script from the
  device one:

  ${MY_DIR}/../common/extract-files.sh $@

  This is incorrect because the quotation marks are missing, and will
  lead to incorrect parameter parsing. The correct way is:

  ${MY_DIR}/../common/extract-files.sh "$@"

* The curly braces are only for cosmetic consistency.

Change-Id: Idf0885546379f47e675ec5e9dfb304706e512129
Signed-off-by: Vladimir Oltean <[email protected]>
  • Loading branch information
vladimiroltean authored and mikeNG committed Mar 3, 2019
1 parent 5238ba8 commit 4931a06
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions build/templates/extract-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,41 @@ VENDOR=*** FILL IN VENDOR ****

# Load extract_utils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
if [[ ! -d "${MY_DIR}" ]]; then MY_DIR="${PWD}"; fi

LINEAGE_ROOT="$MY_DIR"/../../..
LINEAGE_ROOT="${MY_DIR}/../../.."

HELPER="$LINEAGE_ROOT"/vendor/lineage/build/tools/extract_utils.sh
if [ ! -f "$HELPER" ]; then
echo "Unable to find helper script at $HELPER"
HELPER="${LINEAGE_ROOT}/vendor/lineage/build/tools/extract_utils.sh"
if [ ! -f "${HELPER}" ]; then
echo "Unable to find helper script at ${HELPER}"
exit 1
fi
. "$HELPER"
source "${HELPER}"

# Default to sanitizing the vendor folder before extraction
CLEAN_VENDOR=true

while [ "$1" != "" ]; do
case $1 in
case "$1" in
-n | --no-cleanup ) CLEAN_VENDOR=false
;;
-s | --section ) shift
SECTION=$1
SECTION="$1"
CLEAN_VENDOR=false
;;
* ) SRC=$1
* ) SRC="$1"
;;
esac
shift
done

if [ -z "$SRC" ]; then
if [ -z "${SRC}" ]; then
SRC=adb
fi

# Initialize the helper
setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" false "$CLEAN_VENDOR"
setup_vendor "${DEVICE}" "${VENDOR}" "${LINEAGE_ROOT}" false "${CLEAN_VENDOR}"

extract "$MY_DIR"/proprietary-files.txt "$SRC" "$SECTION"
extract "${MY_DIR}/proprietary-files.txt" "${SRC}" "${SECTION}"

"$MY_DIR"/setup-makefiles.sh
"${MY_DIR}/setup-makefiles.sh"

0 comments on commit 4931a06

Please sign in to comment.