Update to use lineage vendor blob extraction utility from cm-14.1

This commit is contained in:
ggow
2019-04-23 09:50:34 +01:00
parent bb4711aabf
commit ef3e408f54
2 changed files with 83 additions and 398 deletions
+48 -41
View File
@@ -1,49 +1,56 @@
#!/bin/bash
#
# Copyright (C) 2018 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
VENDOR=amazon
DEVICE=ford
DEVICE_COMMON=ford
if [ $# -eq 1 ]; then
COPY_FROM=$1
test ! -d "$COPY_FROM" && echo error reading dir "$COPY_FROM" && exit 1
# Load extractutils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
LINEAGE_ROOT="$MY_DIR"/../../..
HELPER="$LINEAGE_ROOT"/vendor/cm/build/tools/extract_utils.sh
if [ ! -f "$HELPER" ]; then
echo "Unable to find helper script at $HELPER"
exit 1
fi
. "$HELPER"
if [ $# -eq 0 ]; then
SRC=adb
else
if [ $# -eq 1 ]; then
SRC=$1
else
echo "$0: bad number of arguments"
echo ""
echo "usage: $0 [PATH_TO_EXPANDED_ROM]"
echo ""
echo "If PATH_TO_EXPANDED_ROM is not specified, blobs will be extracted from"
echo "the device using adb pull."
exit 1
fi
fi
test -z "$DEVICE" && echo device not set && exit 2
test -z "$VENDOR" && echo vendor not set && exit 2
test -z "$VENDORDEVICEDIR" && VENDORDEVICEDIR=$DEVICE
export VENDORDEVICEDIR
# Initialize the helper
setup_vendor "$DEVICE_COMMON" "$VENDOR" "$LINEAGE_ROOT" true
BASE=../../../vendor/$VENDOR/$VENDORDEVICEDIR/proprietary
rm -rf $BASE/*
extract "$MY_DIR"/proprietary-files.txt "$SRC"
for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
echo "Extracting /system/$FILE ..."
OLDIFS=$IFS IFS=":" PARSING_ARRAY=($FILE) IFS=$OLDIFS
FILE=`echo ${PARSING_ARRAY[0]} | sed -e "s/^-//g"`
DEST=${PARSING_ARRAY[1]}
if [ -z $DEST ]
then
DEST=$FILE
fi
DIR=`dirname $FILE`
if [ ! -d $BASE/$DIR ]; then
mkdir -p $BASE/$DIR
fi
if [ "$COPY_FROM" = "" ]; then
adb pull /system/$FILE $BASE/$DEST
# if file dot not exist try destination
if [ "$?" != "0" ]
then
adb pull /system/$DEST $BASE/$DEST
fi
else
cp $COPY_FROM/$FILE $BASE/$DEST
# if file does not exist try destination
if [ "$?" != "0" ]
then
cp $COPY_FROM/$DEST $BASE/$DEST
fi
fi
done
./setup-makefiles.sh
"$MY_DIR"/setup-makefiles.sh
+35 -357
View File
@@ -1,366 +1,44 @@
#!/bin/bash
# Copyright (C) 2017 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
VENDOR=amazon
DEVICE=ford
OUTDIR=vendor/$VENDOR/$DEVICE
MAKEFILE=../../../$OUTDIR/$DEVICE-vendor-blobs.mk
DEVICE_COMMON=ford
(cat << EOF) > $MAKEFILE
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Load extractutils and do some sanity checks
MY_DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$MY_DIR" ]]; then MY_DIR="$PWD"; fi
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
LINEAGE_ROOT="$MY_DIR"/../../..
PRODUCT_COPY_FILES += \\
EOF
LINEEND=" \\"
COUNT=`wc -l proprietary-files.txt | awk {'print $1'}`
DISM=`egrep -c '(^#|^$)' proprietary-files.txt`
COUNT=`expr $COUNT - $DISM`
for FILE in `egrep -v '(^#|^$)' ../$DEVICE/proprietary-files.txt`; do
COUNT=`expr $COUNT - 1`
if [ $COUNT = "0" ]; then
LINEEND=""
fi
# Split the file from the destination (format is "file[:destination]")
OLDIFS=$IFS IFS=":" PARSING_ARRAY=($FILE) IFS=$OLDIFS
FILE=${PARSING_ARRAY[0]}
DEST=${PARSING_ARRAY[1]}
if [ -z "$DEST" ]; then
if [[ ! "$FILE" =~ ^-.* ]]; then
echo " $OUTDIR/proprietary/$FILE:system/$FILE$LINEEND" >> $MAKEFILE
fi
else
if [[ ! "$FILE" =~ ^-.* ]]; then
echo " $OUTDIR/proprietary/$DEST:system/$DEST$LINEEND" >> $MAKEFILE
fi
fi
done
(cat << EOF) > ../../../$OUTDIR/$DEVICE-vendor.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
# Pick up overlay for features that depend on non-open-source files
DEVICE_PACKAGE_OVERLAYS += vendor/$VENDOR/$DEVICE/overlay
\$(call inherit-product, vendor/$VENDOR/$DEVICE/$DEVICE-vendor-blobs.mk)
EOF
(cat << EOF) > ../../../$OUTDIR/BoardConfigVendor.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
EOF
if [ -d ../../../${OUTDIR}/proprietary/app ]; then
(cat << EOF) > ../../../${OUTDIR}/proprietary/app/Android.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
LOCAL_PATH := \$(call my-dir)
EOF
echo "ifeq (\$(TARGET_DEVICE),$DEVICE)" >> ../../../${OUTDIR}/proprietary/app/Android.mk
echo "" >> ../../../${OUTDIR}/proprietary/app/Android.mk
echo "# Prebuilt APKs" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "PRODUCT_PACKAGES += \\" >> ../../../$OUTDIR/$DEVICE-vendor.mk
LINEEND=" \\"
COUNT=`ls -1 ../../../${OUTDIR}/proprietary/app/*.apk | wc -l`
for APK in `ls ../../../${OUTDIR}/proprietary/app/*apk`; do
COUNT=`expr $COUNT - 1`
if [ $COUNT = "0" ]; then
LINEEND=""
fi
apkname=`basename $APK`
apkmodulename=`echo $apkname|sed -e 's/\.apk$//gi'`
(cat << EOF) >> ../../../${OUTDIR}/proprietary/app/Android.mk
include \$(CLEAR_VARS)
LOCAL_MODULE := $apkmodulename
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $apkname
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := \$(COMMON_ANDROID_PACKAGE_SUFFIX)
include \$(BUILD_PREBUILT)
EOF
echo " $apkmodulename$LINEEND" >> ../../../$OUTDIR/$DEVICE-vendor.mk
done
echo "" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "endif" >> ../../../${OUTDIR}/proprietary/app/Android.mk
HELPER="$LINEAGE_ROOT"/vendor/cm/build/tools/extract_utils.sh
if [ ! -f "$HELPER" ]; then
echo "Unable to find helper script at $HELPER"
exit 1
fi
. "$HELPER"
if [ -d ../../../${OUTDIR}/proprietary/framework ]; then
(cat << EOF) > ../../../${OUTDIR}/proprietary/framework/Android.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Initialize the helper
setup_vendor "$DEVICE_COMMON" "$VENDOR" "$LINEAGE_ROOT" true
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
# Copyright headers and guards
write_headers "ttab"
LOCAL_PATH := \$(call my-dir)
# The standard blobs
write_makefiles "$MY_DIR"/proprietary-files.txt
EOF
echo "ifeq (\$(TARGET_DEVICE),$DEVICE)" >> ../../../${OUTDIR}/proprietary/framework/Android.mk
echo "" >> ../../../${OUTDIR}/proprietary/framework/Android.mk
echo "# Prebuilt jars" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "PRODUCT_PACKAGES += \\" >> ../../../$OUTDIR/$DEVICE-vendor.mk
LINEEND=" \\"
COUNT=`ls -1 ../../../${OUTDIR}/proprietary/framework/*.jar | wc -l`
for JAR in `ls ../../../${OUTDIR}/proprietary/framework/*jar`; do
COUNT=`expr $COUNT - 1`
if [ $COUNT = "0" ]; then
LINEEND=""
fi
jarname=`basename $JAR`
jarmodulename=`echo $jarname|sed -e 's/\.jar$//gi'`
(cat << EOF) >> ../../../${OUTDIR}/proprietary/framework/Android.mk
include \$(CLEAR_VARS)
LOCAL_MODULE := $jarmodulename
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $jarname
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_SUFFIX := \$(COMMON_JAVA_PACKAGE_SUFFIX)
include \$(BUILD_PREBUILT)
EOF
echo " $jarmodulename$LINEEND" >> ../../../$OUTDIR/$DEVICE-vendor.mk
done
echo "" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "endif" >> ../../../${OUTDIR}/proprietary/framework/Android.mk
fi
if [ -d ../../../${OUTDIR}/proprietary/priv-app ]; then
(cat << EOF) > ../../../${OUTDIR}/proprietary/priv-app/Android.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
LOCAL_PATH := \$(call my-dir)
EOF
echo "ifeq (\$(TARGET_DEVICE),$DEVICE)" >> ../../../${OUTDIR}/proprietary/priv-app/Android.mk
echo "" >> ../../../${OUTDIR}/proprietary/priv-app/Android.mk
echo "# Prebuilt privileged APKs" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "PRODUCT_PACKAGES += \\" >> ../../../$OUTDIR/$DEVICE-vendor.mk
LINEEND=" \\"
COUNT=`ls -1 ../../../${OUTDIR}/proprietary/priv-app/*.apk | wc -l`
for APK in `ls ../../../${OUTDIR}/proprietary/priv-app/*apk`; do
COUNT=`expr $COUNT - 1`
if [ $COUNT = "0" ]; then
LINEEND=""
fi
privapkname=`basename $APK`
privmodulename=`echo $privapkname|sed -e 's/\.apk$//gi'`
(cat << EOF) >> ../../../${OUTDIR}/proprietary/priv-app/Android.mk
include \$(CLEAR_VARS)
LOCAL_MODULE := $privmodulename
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $privapkname
LOCAL_CERTIFICATE := platform
LOCAL_MODULE_CLASS := APPS
LOCAL_PRIVILEGED_MODULE := true
LOCAL_MODULE_SUFFIX := \$(COMMON_ANDROID_PACKAGE_SUFFIX)
include \$(BUILD_PREBUILT)
EOF
echo " $privmodulename$LINEEND" >> ../../../$OUTDIR/$DEVICE-vendor.mk
done
echo "" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "endif" >> ../../../${OUTDIR}/proprietary/priv-app/Android.mk
fi
LIBS=`cat proprietary-files.txt | grep '\-lib' | cut -d'-' -f2 | head -1`
if [ -f ../../../${OUTDIR}/proprietary/${LIBS} ]; then
(cat << EOF) > ../../../$OUTDIR/proprietary/lib/Android.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
LOCAL_PATH := \$(call my-dir)
EOF
echo "ifeq (\$(TARGET_DEVICE),$DEVICE)" >> ../../../${OUTDIR}/proprietary/lib/Android.mk
echo "" >> ../../../${OUTDIR}/proprietary/lib/Android.mk
echo "# Prebuilt libs needed for compilation" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "PRODUCT_PACKAGES += \\" >> ../../../$OUTDIR/$DEVICE-vendor.mk
LINEEND=" \\"
COUNT=`cat proprietary-files.txt | grep '\-lib' | wc -l`
for LIB in `cat proprietary-files.txt | grep '\-lib' | cut -d'/' -f2`;do
COUNT=`expr $COUNT - 1`
if [ $COUNT = "0" ]; then
LINEEND=""
fi
libname=`basename $LIB`
libmodulename=`echo $libname|sed -e 's/\.so$//gi'`
(cat << EOF) >> ../../../${OUTDIR}/proprietary/lib/Android.mk
include \$(CLEAR_VARS)
LOCAL_MODULE := $libmodulename
LOCAL_MODULE_OWNER := oppo
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $libname
LOCAL_MODULE_PATH := \$(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
include \$(BUILD_PREBUILT)
EOF
echo " $libmodulename$LINEEND" >> ../../../$OUTDIR/$DEVICE-vendor.mk
done
echo "" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "endif" >> ../../../${OUTDIR}/proprietary/lib/Android.mk
fi
VENDORLIBS=`cat proprietary-files.txt | grep '\-vendor\/lib' | cut -d'-' -f2 | head -1`
if [ -f ../../../${OUTDIR}/proprietary/${VENDORLIBS} ]; then
(cat << EOF) > ../../../$OUTDIR/proprietary/vendor/lib/Android.mk
# Copyright (C) 2014 The Gummy ROM Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
LOCAL_PATH := \$(call my-dir)
EOF
echo "ifeq (\$(TARGET_DEVICE),$DEVICE)" >> ../../../${OUTDIR}/proprietary/vendor/lib/Android.mk
echo "" >> ../../../${OUTDIR}/proprietary/vendor/lib/Android.mk
echo "# Prebuilt vendor/libs needed for compilation" >> ../../../$OUTDIR/$DEVICE-vendor.mk
echo "PRODUCT_PACKAGES += \\" >> ../../../$OUTDIR/$DEVICE-vendor.mk
LINEEND=" \\"
COUNT=`cat proprietary-files.txt | grep '\-vendor\/lib' | wc -l`
for VENDORLIB in `cat proprietary-files.txt | grep '\-vendor\/lib' | cut -d'/' -f3`;do
COUNT=`expr $COUNT - 1`
if [ $COUNT = "0" ]; then
LINEEND=""
fi
vendorlibname=`basename $VENDORLIB`
vendorlibmodulename=`echo $vendorlibname|sed -e 's/\.so$//gi'`
(cat << EOF) >> ../../../${OUTDIR}/proprietary/vendor/lib/Android.mk
include \$(CLEAR_VARS)
LOCAL_MODULE := $vendorlibmodulename
LOCAL_MODULE_OWNER := oppo
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $vendorlibname
LOCAL_MODULE_PATH := \$(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
LOCAL_MODULE_SUFFIX := .so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
include \$(BUILD_PREBUILT)
EOF
echo " $vendorlibmodulename$LINEEND" >> ../../../$OUTDIR/$DEVICE-vendor.mk
done
echo "endif" >> ../../../${OUTDIR}/proprietary/vendor/lib/Android.mk
fi
# Done
write_footers