#!/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=alcatel
DEVICE=ttab
-function extract() {
- for FILE in `egrep -v '(^#|^$)' $1`; do
- 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 $2/$DIR ]; then
- mkdir -p $2/$DIR
- fi
- if [ "$SRC" = "adb" ]; then
- # Try CM target first
- adb pull /system/$DEST $2/$DEST
- # if file does not exist try OEM target
- if [ "$?" != "0" ]; then
- adb pull /system/$FILE $2/$DEST
- fi
- else
- cp $SRC/system/$FILE $2/$DEST
- # if file dot not exist try destination
- if [ "$?" != "0" ]
- then
- cp $SRC/system/$DEST $2/$DEST
- fi
- fi
- done
-}
+# 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
fi
fi
-DEVBASE=../../../vendor/$VENDOR/$DEVICE/proprietary
-rm -rf $DEVBASE/*
+# Initialize the helper
+setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" true
-extract ../../$VENDOR/$DEVICE/proprietary-files.txt $DEVBASE
+extract "$MY_DIR"/proprietary-files.txt "$SRC"
-./setup-makefiles.sh
\ No newline at end of file
+"$MY_DIR"/setup-makefiles.sh
#!/bin/bash
-
-VENDOR=alcatel
-DEVICE=ttab
-OUTDIR=vendor/$VENDOR/$DEVICE
-MAKEFILE=../../../$OUTDIR/$DEVICE-vendor-blobs.mk
-
-(cat << EOF) > $MAKEFILE
-# Copyright (C) 2013-2016, The CyanogenMod Project
-# Copyright (C) 2017, The LineageOS Project
+# 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.
# 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
+set -e
-LOCAL_PATH := vendor/$VENDOR/$DEVICE
-
-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 [ -n "$DEST" ]; then
- FILE=$DEST
- fi
- echo " \$(LOCAL_PATH)/proprietary/$FILE:system/$FILE$LINEEND" >> $MAKEFILE
-done
+VENDOR=alcatel
+DEVICE=ttab
-(cat << EOF) > ../../../$OUTDIR/$DEVICE-vendor.mk
-# Copyright (C) 2013-2016, The CyanogenMod Project
-# 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.
+# 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"/../../..
-# Pick up overlay for features that depend on non-open-source files
-DEVICE_PACKAGE_OVERLAYS := vendor/$VENDOR/$DEVICE/overlay
+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"
-\$(call inherit-product, vendor/$VENDOR/$DEVICE/$DEVICE-vendor-blobs.mk)
-EOF
+# Initialize the helper
+setup_vendor "$DEVICE" "$VENDOR" "$LINEAGE_ROOT" true
-(cat << EOF) > ../../../$OUTDIR/BoardConfigVendor.mk
-# Copyright (C) 2013-2016, The CyanogenMod Project
-# 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.
+# Copyright headers and guards
+write_headers "ttab"
-# This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
+# The standard blobs
+write_makefiles "$MY_DIR"/proprietary-files.txt
-EOF
\ No newline at end of file
+# Done
+write_footers