summaryrefslogtreecommitdiffstats
path: root/build/tools
diff options
context:
space:
mode:
authorLouis Popi <theh2o64@gmail.com>2016-07-25 15:51:13 +0200
committerBruno Martins <bgcngm@gmail.com>2016-08-05 08:31:55 +0100
commita516c2f0ac555f2d9b7284a2b89909373a25b6a5 (patch)
tree9ab080f1ea5223f0cb1de8a9a70763a090dd2e3b /build/tools
parent3a03012242c8303b3616e0630c42992070920fc7 (diff)
downloadvendor_replicant-a516c2f0ac555f2d9b7284a2b89909373a25b6a5.zip
vendor_replicant-a516c2f0ac555f2d9b7284a2b89909373a25b6a5.tar.gz
vendor_replicant-a516c2f0ac555f2d9b7284a2b89909373a25b6a5.tar.bz2
cm: extract_utils: Add a firmware extraction method
Change-Id: If14f6932cbdccf45ca0cc91c403e951363e91260
Diffstat (limited to 'build/tools')
-rw-r--r--build/tools/extract_utils.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/build/tools/extract_utils.sh b/build/tools/extract_utils.sh
index 309a8a9..2e93ca7 100644
--- a/build/tools/extract_utils.sh
+++ b/build/tools/extract_utils.sh
@@ -19,6 +19,7 @@ PRODUCT_COPY_FILES_LIST=()
PRODUCT_PACKAGES_LIST=()
PACKAGE_LIST=()
VENDOR_STATE=-1
+VENDOR_RADIO_STATE=-1
COMMON=-1
ARCHES=
FULLY_DEODEXED=-1
@@ -74,8 +75,10 @@ function setup_vendor() {
if [ "$5" == "true" ] || [ "$5" == "1" ]; then
VENDOR_STATE=1
+ VENDOR_RADIO_STATE=1
else
VENDOR_STATE=0
+ VENDOR_RADIO_STATE=0
fi
}
@@ -538,6 +541,26 @@ function write_makefiles() {
}
#
+# append_firmware_calls_to_makefiles:
+#
+# Appends to Android.mk the calls to all images present in radio folder
+# (filesmap file used by releasetools to map firmware images should be kept in the device tree)
+#
+function append_firmware_calls_to_makefiles() {
+ cat << EOF >> "$ANDROIDMK"
+ifeq (\$(LOCAL_PATH)/radio, \$(wildcard \$(LOCAL_PATH)/radio))
+
+RADIO_FILES := \$(wildcard \$(LOCAL_PATH)/radio/*)
+\$(foreach f, \$(notdir \$(RADIO_FILES)), \\
+ \$(call add-radio-file,radio/\$(f)))
+\$(call add-radio-file,../../../device/$VENDOR/$DEVICE/radio/filesmap)
+
+endif
+
+EOF
+}
+
+#
# get_file:
#
# $1: input file
@@ -770,3 +793,45 @@ function extract() {
# Don't allow failing
set -e
}
+
+#
+# extract_firmware:
+#
+# $1: file containing the list of items to extract
+# $2: path to extracted radio folder
+#
+function extract_firmware() {
+ if [ -z "$OUTDIR" ]; then
+ echo "Output dir not set!"
+ exit 1
+ fi
+
+ parse_file_list "$1"
+
+ # Don't allow failing
+ set -e
+
+ local FILELIST=( ${PRODUCT_COPY_FILES_LIST[@]} )
+ local COUNT=${#FILELIST[@]}
+ local SRC="$2"
+ local OUTPUT_DIR="$CM_ROOT"/"$OUTDIR"/radio
+
+ if [ "$VENDOR_RADIO_STATE" -eq "0" ]; then
+ echo "Cleaning firmware output directory ($OUTPUT_DIR).."
+ rm -rf "${OUTPUT_DIR:?}/"*
+ VENDOR_RADIO_STATE=1
+ fi
+
+ echo "Extracting $COUNT files in $1 from $SRC:"
+
+ for (( i=1; i<COUNT+1; i++ )); do
+ local FILE="${FILELIST[$i-1]}"
+ printf ' - %s \n' "/radio/$FILE"
+
+ if [ ! -d "$OUTPUT_DIR" ]; then
+ mkdir -p "$OUTPUT_DIR"
+ fi
+ cp "$SRC/$FILE" "$OUTPUT_DIR/$FILE"
+ chmod 644 "$OUTPUT_DIR/$FILE"
+ done
+}