PIPIPIG233666 | 17d7dcb | 2019-09-29 12:47:28 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright (C) 2016 The CyanogenMod Project |
Bruno Martins | 8194b8e | 2019-09-23 11:51:33 +0100 | [diff] [blame] | 4 | # Copyright (C) 2017-2019 The LineageOS Project |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | |
| 19 | PRODUCT_COPY_FILES_LIST=() |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 20 | PRODUCT_COPY_FILES_HASHES=() |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 21 | PRODUCT_COPY_FILES_FIXUP_HASHES=() |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 22 | PRODUCT_PACKAGES_LIST=() |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 23 | PRODUCT_PACKAGES_HASHES=() |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 24 | PRODUCT_PACKAGES_FIXUP_HASHES=() |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 25 | PACKAGE_LIST=() |
| 26 | VENDOR_STATE=-1 |
Louis Popi | a516c2f | 2016-07-25 15:51:13 +0200 | [diff] [blame] | 27 | VENDOR_RADIO_STATE=-1 |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 28 | COMMON=-1 |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 29 | ARCHES= |
| 30 | FULLY_DEODEXED=-1 |
| 31 | |
Rashed Abdel-Tawab | 11186d6 | 2017-08-05 23:11:35 -0400 | [diff] [blame] | 32 | TMPDIR=$(mktemp -d) |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 33 | |
| 34 | # |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 35 | # cleanup |
| 36 | # |
| 37 | # kill our tmpfiles with fire on exit |
| 38 | # |
| 39 | function cleanup() { |
| 40 | rm -rf "${TMPDIR:?}" |
| 41 | } |
| 42 | |
Gabriele M | 6c3c2c0 | 2017-10-11 12:55:51 +0200 | [diff] [blame] | 43 | trap cleanup 0 |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 44 | |
| 45 | # |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 46 | # setup_vendor |
| 47 | # |
| 48 | # $1: device name |
| 49 | # $2: vendor name |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 50 | # $3: Lineage root directory |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 51 | # $4: is common device - optional, default to false |
| 52 | # $5: cleanup - optional, default to true |
Rashed Abdel-Tawab | 5f17315 | 2016-10-01 20:33:00 -0400 | [diff] [blame] | 53 | # $6: custom vendor makefile name - optional, default to false |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 54 | # |
| 55 | # Must be called before any other functions can be used. This |
| 56 | # sets up the internal state for a new vendor configuration. |
| 57 | # |
| 58 | function setup_vendor() { |
| 59 | local DEVICE="$1" |
| 60 | if [ -z "$DEVICE" ]; then |
| 61 | echo "\$DEVICE must be set before including this script!" |
| 62 | exit 1 |
| 63 | fi |
| 64 | |
| 65 | export VENDOR="$2" |
| 66 | if [ -z "$VENDOR" ]; then |
| 67 | echo "\$VENDOR must be set before including this script!" |
| 68 | exit 1 |
| 69 | fi |
| 70 | |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 71 | export LINEAGE_ROOT="$3" |
| 72 | if [ ! -d "$LINEAGE_ROOT" ]; then |
| 73 | echo "\$LINEAGE_ROOT must be set and valid before including this script!" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 74 | exit 1 |
| 75 | fi |
| 76 | |
| 77 | export OUTDIR=vendor/"$VENDOR"/"$DEVICE" |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 78 | if [ ! -d "$LINEAGE_ROOT/$OUTDIR" ]; then |
| 79 | mkdir -p "$LINEAGE_ROOT/$OUTDIR" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 80 | fi |
| 81 | |
Rashed Abdel-Tawab | 5f17315 | 2016-10-01 20:33:00 -0400 | [diff] [blame] | 82 | VNDNAME="$6" |
| 83 | if [ -z "$VNDNAME" ]; then |
| 84 | VNDNAME="$DEVICE" |
| 85 | fi |
| 86 | |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 87 | export PRODUCTMK="$LINEAGE_ROOT"/"$OUTDIR"/"$VNDNAME"-vendor.mk |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 88 | export ANDROIDBP="$LINEAGE_ROOT"/"$OUTDIR"/Android.bp |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 89 | export ANDROIDMK="$LINEAGE_ROOT"/"$OUTDIR"/Android.mk |
| 90 | export BOARDMK="$LINEAGE_ROOT"/"$OUTDIR"/BoardConfigVendor.mk |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 91 | |
| 92 | if [ "$4" == "true" ] || [ "$4" == "1" ]; then |
| 93 | COMMON=1 |
| 94 | else |
| 95 | COMMON=0 |
| 96 | fi |
| 97 | |
Gabriele M | b6effb3 | 2017-05-01 18:22:04 +0200 | [diff] [blame] | 98 | if [ "$5" == "false" ] || [ "$5" == "0" ]; then |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 99 | VENDOR_STATE=1 |
Louis Popi | a516c2f | 2016-07-25 15:51:13 +0200 | [diff] [blame] | 100 | VENDOR_RADIO_STATE=1 |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 101 | else |
| 102 | VENDOR_STATE=0 |
Louis Popi | a516c2f | 2016-07-25 15:51:13 +0200 | [diff] [blame] | 103 | VENDOR_RADIO_STATE=0 |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 104 | fi |
| 105 | } |
| 106 | |
Vladimir Oltean | 9564328 | 2018-06-24 20:22:41 +0300 | [diff] [blame] | 107 | # Helper functions for parsing a spec. |
| 108 | # notes: an optional "|SHA1" that may appear in the format is stripped |
| 109 | # early from the spec in the parse_file_list function, and |
| 110 | # should not be present inside the input parameter passed |
| 111 | # to these functions. |
| 112 | |
| 113 | # |
| 114 | # input: spec in the form of "src[:dst][;args]" |
| 115 | # output: "src" |
| 116 | # |
| 117 | function src_file() { |
| 118 | local SPEC="$1" |
| 119 | local SPLIT=(${SPEC//:/ }) |
| 120 | local ARGS="$(target_args ${SPEC})" |
| 121 | # Regardless of there being a ":" delimiter or not in the spec, |
| 122 | # the source file is always either the first, or the only entry. |
| 123 | local SRC="${SPLIT[0]}" |
| 124 | # Remove target_args suffix, if present |
| 125 | echo "${SRC%;${ARGS}}" |
| 126 | } |
| 127 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 128 | # |
Vladimir Oltean | 6a7946b | 2018-06-24 20:09:55 +0300 | [diff] [blame] | 129 | # input: spec in the form of "src[:dst][;args]" |
| 130 | # output: "dst" if present, "src" otherwise. |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 131 | # |
| 132 | function target_file() { |
dianlujitao | 33ee596 | 2020-01-02 15:26:44 +0800 | [diff] [blame] | 133 | local SPEC="${1%%;*}" |
Vladimir Oltean | 6a7946b | 2018-06-24 20:09:55 +0300 | [diff] [blame] | 134 | local SPLIT=(${SPEC//:/ }) |
| 135 | local ARGS="$(target_args ${SPEC})" |
| 136 | local DST= |
| 137 | case ${#SPLIT[@]} in |
| 138 | 1) |
| 139 | # The spec doesn't have a : delimiter |
| 140 | DST="${SPLIT[0]}" |
| 141 | ;; |
| 142 | *) |
| 143 | # The spec actually has a src:dst format |
| 144 | DST="${SPLIT[1]}" |
| 145 | ;; |
| 146 | esac |
| 147 | # Remove target_args suffix, if present |
| 148 | echo "${DST%;${ARGS}}" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | # |
Vladimir Oltean | 6a7946b | 2018-06-24 20:09:55 +0300 | [diff] [blame] | 152 | # input: spec in the form of "src[:dst][;args]" |
| 153 | # output: "args" if present, "" otherwise. |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 154 | # |
| 155 | function target_args() { |
Vladimir Oltean | 6a7946b | 2018-06-24 20:09:55 +0300 | [diff] [blame] | 156 | local SPEC="$1" |
| 157 | local SPLIT=(${SPEC//;/ }) |
| 158 | local ARGS= |
| 159 | case ${#SPLIT[@]} in |
| 160 | 1) |
| 161 | # No ";" delimiter in the spec. |
| 162 | ;; |
| 163 | *) |
| 164 | # The "args" are whatever comes after the ";" character. |
| 165 | # Basically the spec stripped of whatever is to the left of ";". |
| 166 | ARGS="${SPEC#${SPLIT[0]};}" |
| 167 | ;; |
| 168 | esac |
| 169 | echo "${ARGS}" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | # |
| 173 | # prefix_match: |
| 174 | # |
Vladimir Oltean | 2654eaa | 2018-06-12 01:17:35 +0300 | [diff] [blame] | 175 | # input: |
| 176 | # - $1: prefix |
| 177 | # - (global variable) PRODUCT_PACKAGES_LIST: array of [src:]dst[;args] specs. |
| 178 | # output: |
| 179 | # - new array consisting of dst[;args] entries where $1 is a prefix of ${dst}. |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 180 | # |
| 181 | function prefix_match() { |
| 182 | local PREFIX="$1" |
Vladimir Oltean | a48b9fe | 2018-04-02 22:37:09 +0300 | [diff] [blame] | 183 | for LINE in "${PRODUCT_PACKAGES_LIST[@]}"; do |
| 184 | local FILE=$(target_file "$LINE") |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 185 | if [[ "$FILE" =~ ^"$PREFIX" ]]; then |
Vladimir Oltean | 2654eaa | 2018-06-12 01:17:35 +0300 | [diff] [blame] | 186 | local ARGS=$(target_args "$LINE") |
| 187 | if [ -z "${ARGS}" ]; then |
| 188 | echo "${FILE#$PREFIX}" |
| 189 | else |
| 190 | echo "${FILE#$PREFIX};${ARGS}" |
| 191 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 192 | fi |
| 193 | done |
| 194 | } |
| 195 | |
| 196 | # |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 197 | # prefix_match_file: |
| 198 | # |
| 199 | # $1: the prefix to match on |
| 200 | # $2: the file to match the prefix for |
| 201 | # |
| 202 | # Internal function which returns true if a filename contains the |
| 203 | # specified prefix. |
| 204 | # |
| 205 | function prefix_match_file() { |
| 206 | local PREFIX="$1" |
| 207 | local FILE="$2" |
| 208 | if [[ "$FILE" =~ ^"$PREFIX" ]]; then |
| 209 | return 0 |
| 210 | else |
| 211 | return 1 |
| 212 | fi |
| 213 | } |
| 214 | |
| 215 | # |
Rashed Abdel-Tawab | 1c29c37 | 2019-03-29 20:07:25 -0700 | [diff] [blame] | 216 | # suffix_match_file: |
| 217 | # |
| 218 | # $1: the suffix to match on |
| 219 | # $2: the file to match the suffix for |
| 220 | # |
| 221 | # Internal function which returns true if a filename contains the |
| 222 | # specified suffix. |
| 223 | # |
| 224 | function suffix_match_file() { |
| 225 | local SUFFIX="$1" |
| 226 | local FILE="$2" |
| 227 | if [[ "$FILE" = *"$SUFFIX" ]]; then |
| 228 | return 0 |
| 229 | else |
| 230 | return 1 |
| 231 | fi |
| 232 | } |
| 233 | |
| 234 | # |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 235 | # truncate_file |
| 236 | # |
| 237 | # $1: the filename to truncate |
| 238 | # $2: the argument to output the truncated filename to |
| 239 | # |
| 240 | # Internal function which truncates a filename by removing the first dir |
| 241 | # in the path. ex. vendor/lib/libsdmextension.so -> lib/libsdmextension.so |
| 242 | # |
| 243 | function truncate_file() { |
| 244 | local FILE="$1" |
| 245 | RETURN_FILE="$2" |
| 246 | local FIND="${FILE%%/*}" |
| 247 | local LOCATION="${#FIND}+1" |
| 248 | echo ${FILE:$LOCATION} |
| 249 | } |
| 250 | |
| 251 | # |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 252 | # write_product_copy_files: |
| 253 | # |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 254 | # $1: make treble compatible makefile - optional and deprecated, default to true |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 255 | # |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 256 | # Creates the PRODUCT_COPY_FILES section in the product makefile for all |
| 257 | # items in the list which do not start with a dash (-). |
| 258 | # |
| 259 | function write_product_copy_files() { |
| 260 | local COUNT=${#PRODUCT_COPY_FILES_LIST[@]} |
| 261 | local TARGET= |
| 262 | local FILE= |
| 263 | local LINEEND= |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 264 | local TREBLE_COMPAT=$1 |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 265 | |
| 266 | if [ "$COUNT" -eq "0" ]; then |
| 267 | return 0 |
| 268 | fi |
| 269 | |
| 270 | printf '%s\n' "PRODUCT_COPY_FILES += \\" >> "$PRODUCTMK" |
| 271 | for (( i=1; i<COUNT+1; i++ )); do |
| 272 | FILE="${PRODUCT_COPY_FILES_LIST[$i-1]}" |
| 273 | LINEEND=" \\" |
| 274 | if [ "$i" -eq "$COUNT" ]; then |
| 275 | LINEEND="" |
| 276 | fi |
| 277 | |
Vladimir Oltean | 6a7946b | 2018-06-24 20:09:55 +0300 | [diff] [blame] | 278 | TARGET=$(target_file "$FILE") |
Rashed Abdel-Tawab | 8aae50d | 2019-10-05 00:09:41 -0400 | [diff] [blame] | 279 | if prefix_match_file "product/" $TARGET ; then |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 280 | local OUTTARGET=$(truncate_file $TARGET) |
Rashed Abdel-Tawab | 8aae50d | 2019-10-05 00:09:41 -0400 | [diff] [blame] | 281 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_PRODUCT)/%s%s\n' \ |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 282 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
Rashed Abdel-Tawab | 8aae50d | 2019-10-05 00:09:41 -0400 | [diff] [blame] | 283 | elif prefix_match_file "system/product/" $TARGET ; then |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 284 | local OUTTARGET=$(truncate_file $TARGET) |
| 285 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_PRODUCT)/%s%s\n' \ |
| 286 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
| 287 | elif prefix_match_file "odm/" $TARGET ; then |
| 288 | local OUTTARGET=$(truncate_file $TARGET) |
| 289 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_ODM)/%s%s\n' \ |
| 290 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
Rashed Abdel-Tawab | 8aae50d | 2019-10-05 00:09:41 -0400 | [diff] [blame] | 291 | elif prefix_match_file "vendor/odm/" $TARGET ; then |
| 292 | local OUTTARGET=$(truncate_file $TARGET) |
| 293 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_ODM)/%s%s\n' \ |
| 294 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
| 295 | elif prefix_match_file "system/vendor/odm/" $TARGET ; then |
| 296 | local OUTTARGET=$(truncate_file $TARGET) |
| 297 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_ODM)/%s%s\n' \ |
| 298 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
| 299 | elif prefix_match_file "vendor/" $TARGET ; then |
| 300 | local OUTTARGET=$(truncate_file $TARGET) |
| 301 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_VENDOR)/%s%s\n' \ |
| 302 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
| 303 | elif prefix_match_file "system/vendor/" $TARGET ; then |
| 304 | local OUTTARGET=$(truncate_file $TARGET) |
| 305 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_VENDOR)/%s%s\n' \ |
| 306 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 307 | elif prefix_match_file "system/" $TARGET ; then |
| 308 | local OUTTARGET=$(truncate_file $TARGET) |
| 309 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_SYSTEM)/%s%s\n' \ |
| 310 | "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK" |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 311 | else |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 312 | printf ' %s/proprietary/%s:$(TARGET_COPY_OUT_SYSTEM)/%s%s\n' \ |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 313 | "$OUTDIR" "$TARGET" "$TARGET" "$LINEEND" >> "$PRODUCTMK" |
| 314 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 315 | done |
| 316 | return 0 |
| 317 | } |
| 318 | |
| 319 | # |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 320 | # write_blueprint_packages: |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 321 | # |
| 322 | # $1: The LOCAL_MODULE_CLASS for the given module list |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 323 | # $2: /system, /odm, /product, or /vendor partition |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 324 | # $3: type-specific extra flags |
| 325 | # $4: Name of the array holding the target list |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 326 | # |
| 327 | # Internal function which writes out the BUILD_PREBUILT stanzas |
| 328 | # for all modules in the list. This is called by write_product_packages |
| 329 | # after the modules are categorized. |
| 330 | # |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 331 | function write_blueprint_packages() { |
| 332 | |
| 333 | local CLASS="$1" |
| 334 | local PARTITION="$2" |
| 335 | local EXTRA="$3" |
| 336 | |
| 337 | # Yes, this is a horrible hack - we create a new array using indirection |
| 338 | local ARR_NAME="$4[@]" |
| 339 | local FILELIST=("${!ARR_NAME}") |
| 340 | |
| 341 | local FILE= |
| 342 | local ARGS= |
| 343 | local BASENAME= |
| 344 | local EXTENSION= |
| 345 | local PKGNAME= |
| 346 | local SRC= |
| 347 | |
| 348 | for P in "${FILELIST[@]}"; do |
| 349 | FILE=$(target_file "$P") |
| 350 | ARGS=$(target_args "$P") |
| 351 | |
| 352 | BASENAME=$(basename "$FILE") |
| 353 | DIRNAME=$(dirname "$FILE") |
| 354 | EXTENSION=${BASENAME##*.} |
| 355 | PKGNAME=${BASENAME%.*} |
| 356 | |
| 357 | # Add to final package list |
| 358 | PACKAGE_LIST+=("$PKGNAME") |
| 359 | |
| 360 | SRC="proprietary" |
| 361 | if [ "$PARTITION" = "system" ]; then |
| 362 | SRC+="/system" |
| 363 | elif [ "$PARTITION" = "vendor" ]; then |
| 364 | SRC+="/vendor" |
| 365 | elif [ "$PARTITION" = "product" ]; then |
| 366 | SRC+="/product" |
| 367 | elif [ "$PARTITION" = "odm" ]; then |
| 368 | SRC+="/odm" |
| 369 | fi |
| 370 | |
| 371 | if [ "$CLASS" = "SHARED_LIBRARIES" ]; then |
| 372 | printf 'cc_prebuilt_library_shared {\n' |
| 373 | printf '\tname: "%s",\n' "$PKGNAME" |
| 374 | printf '\towner: "%s",\n' "$VENDOR" |
| 375 | printf '\tstrip: {\n' |
| 376 | printf '\t\tnone: true,\n' |
| 377 | printf '\t},\n' |
| 378 | printf '\ttarget: {\n' |
| 379 | if [ "$EXTRA" = "both" ]; then |
| 380 | printf '\t\tandroid_arm: {\n' |
| 381 | printf '\t\t\tsrcs: ["%s/lib/%s"],\n' "$SRC" "$FILE" |
| 382 | printf '\t\t},\n' |
| 383 | printf '\t\tandroid_arm64: {\n' |
| 384 | printf '\t\t\tsrcs: ["%s/lib64/%s"],\n' "$SRC" "$FILE" |
| 385 | printf '\t\t},\n' |
| 386 | elif [ "$EXTRA" = "64" ]; then |
| 387 | printf '\t\tandroid_arm64: {\n' |
| 388 | printf '\t\t\tsrcs: ["%s/lib64/%s"],\n' "$SRC" "$FILE" |
| 389 | printf '\t\t},\n' |
| 390 | else |
| 391 | printf '\t\tandroid_arm: {\n' |
| 392 | printf '\t\t\tsrcs: ["%s/lib/%s"],\n' "$SRC" "$FILE" |
| 393 | printf '\t\t},\n' |
| 394 | fi |
| 395 | printf '\t},\n' |
| 396 | if [ "$EXTRA" != "none" ]; then |
| 397 | printf '\tcompile_multilib: "%s",\n' "$EXTRA" |
| 398 | fi |
| 399 | elif [ "$CLASS" = "APPS" ]; then |
| 400 | printf 'android_app_import {\n' |
| 401 | printf '\tname: "%s",\n' "$PKGNAME" |
| 402 | printf '\towner: "%s",\n' "$VENDOR" |
| 403 | if [ "$EXTRA" = "priv-app" ]; then |
| 404 | SRC="$SRC/priv-app" |
| 405 | else |
| 406 | SRC="$SRC/app" |
| 407 | fi |
| 408 | printf '\tapk: "%s/%s",\n' "$SRC" "$FILE" |
| 409 | if [ "$ARGS" = "PRESIGNED" ]; then |
| 410 | printf '\tpresigned: true,\n' |
| 411 | elif [ ! -z "$ARGS" ]; then |
| 412 | printf '\tcertificate: "%s",\n' "$ARGS" |
| 413 | else |
| 414 | printf '\tcertificate: "platform",\n' |
| 415 | fi |
| 416 | elif [ "$CLASS" = "JAVA_LIBRARIES" ]; then |
| 417 | printf 'dex_import {\n' |
| 418 | printf '\tname: "%s",\n' "$PKGNAME" |
| 419 | printf '\towner: "%s",\n' "$VENDOR" |
| 420 | printf '\tjars: ["%s/framework/%s"],\n' "$SRC" "$FILE" |
| 421 | elif [ "$CLASS" = "ETC" ]; then |
| 422 | if [ "$EXTENSION" = "xml" ]; then |
| 423 | printf 'prebuilt_etc_xml {\n' |
| 424 | else |
| 425 | printf 'prebuilt_etc {\n' |
| 426 | fi |
| 427 | printf '\tname: "%s",\n' "$PKGNAME" |
| 428 | printf '\towner: "%s",\n' "$VENDOR" |
| 429 | printf '\tsrc: "%s/etc/%s",\n' "$SRC" "$FILE" |
| 430 | elif [ "$CLASS" = "EXECUTABLES" ]; then |
| 431 | if [ "$EXTENSION" = "sh" ]; then |
| 432 | printf 'sh_binary {\n' |
| 433 | else |
| 434 | printf 'cc_prebuilt_binary {\n' |
| 435 | fi |
| 436 | printf '\tname: "%s",\n' "$PKGNAME" |
| 437 | printf '\towner: "%s",\n' "$VENDOR" |
| 438 | if [ "$ARGS" = "rootfs" ]; then |
| 439 | SRC="$SRC/rootfs" |
| 440 | if [ "$EXTRA" = "sbin" ]; then |
| 441 | SRC="$SRC/sbin" |
| 442 | printf '\tdist {\n' |
| 443 | printf '\t\tdest: "%s",\n' "root/sbin" |
| 444 | printf '\t},' |
| 445 | fi |
| 446 | else |
| 447 | SRC="$SRC/bin" |
| 448 | fi |
| 449 | printf '\tsrcs: ["%s/%s"],\n' "$SRC" "$FILE" |
| 450 | unset EXTENSION |
| 451 | else |
| 452 | printf '\tsrcs: ["%s/%s"],\n' "$SRC" "$FILE" |
| 453 | fi |
| 454 | if [ "$CLASS" = "APPS" ]; then |
| 455 | printf '\tdex_preopt: {\n' |
| 456 | printf '\t\tenabled: false,\n' |
| 457 | printf '\t},\n' |
| 458 | fi |
| 459 | if [ "$CLASS" = "SHARED_LIBRARIES" ] || [ "$CLASS" = "EXECUTABLES" ] || [ "$CLASS" = "ETC" ] ; then |
| 460 | if [ "$DIRNAME" != "." ]; then |
| 461 | printf '\tsub_dir: "%s",\n' "$DIRNAME" |
| 462 | fi |
| 463 | fi |
| 464 | if [ "$CLASS" = "SHARED_LIBRARIES" ] || [ "$CLASS" = "EXECUTABLES" ] ; then |
| 465 | printf '\tprefer: true,\n' |
| 466 | fi |
| 467 | if [ "$EXTRA" = "priv-app" ]; then |
| 468 | printf '\tprivileged: true,\n' |
| 469 | fi |
| 470 | if [ "$PARTITION" = "vendor" ]; then |
| 471 | printf '\tsoc_specific: true,\n' |
| 472 | elif [ "$PARTITION" = "product" ]; then |
| 473 | printf '\tproduct_specific: true,\n' |
| 474 | elif [ "$PARTITION" = "odm" ]; then |
| 475 | printf '\tdevice_specific: true,\n' |
| 476 | fi |
| 477 | printf '}\n\n' |
| 478 | done |
| 479 | } |
| 480 | |
| 481 | # |
| 482 | # write_makefile_packages: |
| 483 | # |
| 484 | # $1: The LOCAL_MODULE_CLASS for the given module list |
| 485 | # $2: /odm, /product, or /vendor partition |
| 486 | # $3: type-specific extra flags |
| 487 | # $4: Name of the array holding the target list |
| 488 | # |
| 489 | # Internal function which writes out the BUILD_PREBUILT stanzas |
| 490 | # for all modules in the list. This is called by write_product_packages |
| 491 | # after the modules are categorized. |
| 492 | # |
| 493 | function write_makefile_packages() { |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 494 | |
| 495 | local CLASS="$1" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 496 | local PARTITION="$2" |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 497 | local EXTRA="$3" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 498 | |
| 499 | # Yes, this is a horrible hack - we create a new array using indirection |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 500 | local ARR_NAME="$4[@]" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 501 | local FILELIST=("${!ARR_NAME}") |
| 502 | |
| 503 | local FILE= |
| 504 | local ARGS= |
| 505 | local BASENAME= |
| 506 | local EXTENSION= |
| 507 | local PKGNAME= |
| 508 | local SRC= |
| 509 | |
| 510 | for P in "${FILELIST[@]}"; do |
Vladimir Oltean | 6a7946b | 2018-06-24 20:09:55 +0300 | [diff] [blame] | 511 | FILE=$(target_file "$P") |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 512 | ARGS=$(target_args "$P") |
| 513 | |
| 514 | BASENAME=$(basename "$FILE") |
M1cha | 15f226c | 2017-01-04 09:00:11 +0100 | [diff] [blame] | 515 | DIRNAME=$(dirname "$FILE") |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 516 | EXTENSION=${BASENAME##*.} |
Mohd Faraz | d1d7235 | 2019-10-08 16:13:50 +0530 | [diff] [blame] | 517 | EXTENSION="."$EXTENSION |
| 518 | if [ "$EXTENSION" = ".jar" ]; then |
| 519 | EXTENSION="\$(COMMON_JAVA_PACKAGE_SUFFIX)" |
| 520 | elif [ "$EXTENSION" = ".apk" ]; then |
| 521 | EXTENSION="\$(COMMON_ANDROID_PACKAGE_SUFFIX)" |
| 522 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 523 | PKGNAME=${BASENAME%.*} |
| 524 | |
| 525 | # Add to final package list |
| 526 | PACKAGE_LIST+=("$PKGNAME") |
| 527 | |
| 528 | SRC="proprietary" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 529 | if [ "$PARTITION" = "system" ]; then |
| 530 | SRC+="/system" |
| 531 | elif [ "$PARTITION" = "vendor" ]; then |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 532 | SRC+="/vendor" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 533 | elif [ "$PARTITION" = "product" ]; then |
| 534 | SRC+="/product" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 535 | elif [ "$PARTITION" = "odm" ]; then |
| 536 | SRC+="/odm" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 537 | fi |
| 538 | |
| 539 | printf 'include $(CLEAR_VARS)\n' |
| 540 | printf 'LOCAL_MODULE := %s\n' "$PKGNAME" |
| 541 | printf 'LOCAL_MODULE_OWNER := %s\n' "$VENDOR" |
| 542 | if [ "$CLASS" = "SHARED_LIBRARIES" ]; then |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 543 | if [ "$EXTRA" = "both" ]; then |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 544 | printf 'LOCAL_SRC_FILES_64 := %s/lib64/%s\n' "$SRC" "$FILE" |
| 545 | printf 'LOCAL_SRC_FILES_32 := %s/lib/%s\n' "$SRC" "$FILE" |
| 546 | #if [ "$VENDOR_PKG" = "true" ]; then |
| 547 | # echo "LOCAL_MODULE_PATH_64 := \$(TARGET_OUT_VENDOR_SHARED_LIBRARIES)" |
| 548 | # echo "LOCAL_MODULE_PATH_32 := \$(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)" |
| 549 | #else |
| 550 | # echo "LOCAL_MODULE_PATH_64 := \$(TARGET_OUT_SHARED_LIBRARIES)" |
| 551 | # echo "LOCAL_MODULE_PATH_32 := \$(2ND_TARGET_OUT_SHARED_LIBRARIES)" |
| 552 | #fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 553 | elif [ "$EXTRA" = "64" ]; then |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 554 | printf 'LOCAL_SRC_FILES := %s/lib64/%s\n' "$SRC" "$FILE" |
| 555 | else |
| 556 | printf 'LOCAL_SRC_FILES := %s/lib/%s\n' "$SRC" "$FILE" |
| 557 | fi |
Steve Kondik | 03ce400 | 2016-07-29 00:00:16 -0700 | [diff] [blame] | 558 | if [ "$EXTRA" != "none" ]; then |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 559 | printf 'LOCAL_MULTILIB := %s\n' "$EXTRA" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 560 | fi |
| 561 | elif [ "$CLASS" = "APPS" ]; then |
Michael Bestas | 3f9b94c | 2018-01-25 21:05:36 +0200 | [diff] [blame] | 562 | if [ "$EXTRA" = "priv-app" ]; then |
| 563 | SRC="$SRC/priv-app" |
| 564 | else |
| 565 | SRC="$SRC/app" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 566 | fi |
| 567 | printf 'LOCAL_SRC_FILES := %s/%s\n' "$SRC" "$FILE" |
| 568 | local CERT=platform |
| 569 | if [ ! -z "$ARGS" ]; then |
| 570 | CERT="$ARGS" |
| 571 | fi |
| 572 | printf 'LOCAL_CERTIFICATE := %s\n' "$CERT" |
| 573 | elif [ "$CLASS" = "JAVA_LIBRARIES" ]; then |
| 574 | printf 'LOCAL_SRC_FILES := %s/framework/%s\n' "$SRC" "$FILE" |
Elektroschmock | 082e0ec | 2016-10-04 21:11:43 +0200 | [diff] [blame] | 575 | local CERT=platform |
| 576 | if [ ! -z "$ARGS" ]; then |
| 577 | CERT="$ARGS" |
| 578 | fi |
| 579 | printf 'LOCAL_CERTIFICATE := %s\n' "$CERT" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 580 | elif [ "$CLASS" = "ETC" ]; then |
| 581 | printf 'LOCAL_SRC_FILES := %s/etc/%s\n' "$SRC" "$FILE" |
| 582 | elif [ "$CLASS" = "EXECUTABLES" ]; then |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 583 | if [ "$ARGS" = "rootfs" ]; then |
| 584 | SRC="$SRC/rootfs" |
| 585 | if [ "$EXTRA" = "sbin" ]; then |
| 586 | SRC="$SRC/sbin" |
| 587 | printf '%s\n' "LOCAL_MODULE_PATH := \$(TARGET_ROOT_OUT_SBIN)" |
| 588 | printf '%s\n' "LOCAL_UNSTRIPPED_PATH := \$(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)" |
| 589 | fi |
| 590 | else |
| 591 | SRC="$SRC/bin" |
| 592 | fi |
| 593 | printf 'LOCAL_SRC_FILES := %s/%s\n' "$SRC" "$FILE" |
| 594 | unset EXTENSION |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 595 | else |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 596 | printf 'LOCAL_SRC_FILES := %s/%s\n' "$SRC" "$FILE" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 597 | fi |
| 598 | printf 'LOCAL_MODULE_TAGS := optional\n' |
| 599 | printf 'LOCAL_MODULE_CLASS := %s\n' "$CLASS" |
Hashbang173 | 3b3a0e1 | 2016-08-28 20:38:45 -0400 | [diff] [blame] | 600 | if [ "$CLASS" = "APPS" ]; then |
| 601 | printf 'LOCAL_DEX_PREOPT := false\n' |
| 602 | fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 603 | if [ ! -z "$EXTENSION" ]; then |
Mohd Faraz | d1d7235 | 2019-10-08 16:13:50 +0530 | [diff] [blame] | 604 | printf 'LOCAL_MODULE_SUFFIX := %s\n' "$EXTENSION" |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 605 | fi |
M1cha | 15f226c | 2017-01-04 09:00:11 +0100 | [diff] [blame] | 606 | if [ "$CLASS" = "SHARED_LIBRARIES" ] || [ "$CLASS" = "EXECUTABLES" ]; then |
| 607 | if [ "$DIRNAME" != "." ]; then |
| 608 | printf 'LOCAL_MODULE_RELATIVE_PATH := %s\n' "$DIRNAME" |
| 609 | fi |
| 610 | fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 611 | if [ "$EXTRA" = "priv-app" ]; then |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 612 | printf 'LOCAL_PRIVILEGED_MODULE := true\n' |
| 613 | fi |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 614 | if [ "$PARTITION" = "vendor" ]; then |
Ethan Chen | 5bc3c84 | 2018-02-17 20:03:54 -0800 | [diff] [blame] | 615 | printf 'LOCAL_VENDOR_MODULE := true\n' |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 616 | elif [ "$PARTITION" = "product" ]; then |
| 617 | printf 'LOCAL_PRODUCT_MODULE := true\n' |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 618 | elif [ "$PARTITION" = "odm" ]; then |
| 619 | printf 'LOCAL_ODM_MODULE := true\n' |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 620 | fi |
| 621 | printf 'include $(BUILD_PREBUILT)\n\n' |
| 622 | done |
| 623 | } |
| 624 | |
| 625 | # |
| 626 | # write_product_packages: |
| 627 | # |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 628 | # This function will create prebuilt entries in the |
| 629 | # Android.bp and associated PRODUCT_PACKAGES list in the |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 630 | # product makefile for all files in the blob list which |
| 631 | # start with a single dash (-) character. |
| 632 | # |
| 633 | function write_product_packages() { |
| 634 | PACKAGE_LIST=() |
| 635 | |
| 636 | local COUNT=${#PRODUCT_PACKAGES_LIST[@]} |
| 637 | |
| 638 | if [ "$COUNT" = "0" ]; then |
| 639 | return 0 |
| 640 | fi |
| 641 | |
| 642 | # Figure out what's 32-bit, what's 64-bit, and what's multilib |
| 643 | # I really should not be doing this in bash due to shitty array passing :( |
| 644 | local T_LIB32=( $(prefix_match "lib/") ) |
| 645 | local T_LIB64=( $(prefix_match "lib64/") ) |
| 646 | local MULTILIBS=( $(comm -12 <(printf '%s\n' "${T_LIB32[@]}") <(printf '%s\n' "${T_LIB64[@]}")) ) |
| 647 | local LIB32=( $(comm -23 <(printf '%s\n' "${T_LIB32[@]}") <(printf '%s\n' "${MULTILIBS[@]}")) ) |
Steve Kondik | 60ef86d | 2016-07-20 20:03:40 -0700 | [diff] [blame] | 648 | local LIB64=( $(comm -23 <(printf '%s\n' "${T_LIB64[@]}") <(printf '%s\n' "${MULTILIBS[@]}")) ) |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 649 | |
Steve Kondik | 03ce400 | 2016-07-29 00:00:16 -0700 | [diff] [blame] | 650 | if [ "${#MULTILIBS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 651 | write_blueprint_packages "SHARED_LIBRARIES" "" "both" "MULTILIBS" >> "$ANDROIDBP" |
Steve Kondik | 03ce400 | 2016-07-29 00:00:16 -0700 | [diff] [blame] | 652 | fi |
| 653 | if [ "${#LIB32[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 654 | write_blueprint_packages "SHARED_LIBRARIES" "" "32" "LIB32" >> "$ANDROIDBP" |
Steve Kondik | 03ce400 | 2016-07-29 00:00:16 -0700 | [diff] [blame] | 655 | fi |
| 656 | if [ "${#LIB64[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 657 | write_blueprint_packages "SHARED_LIBRARIES" "" "64" "LIB64" >> "$ANDROIDBP" |
Steve Kondik | 03ce400 | 2016-07-29 00:00:16 -0700 | [diff] [blame] | 658 | fi |
| 659 | |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 660 | local T_S_LIB32=( $(prefix_match "system/lib/") ) |
| 661 | local T_S_LIB64=( $(prefix_match "system/lib64/") ) |
| 662 | local S_MULTILIBS=( $(comm -12 <(printf '%s\n' "${T_S_LIB32[@]}") <(printf '%s\n' "${T_S_LIB64[@]}")) ) |
| 663 | local S_LIB32=( $(comm -23 <(printf '%s\n' "${T_S_LIB32[@]}") <(printf '%s\n' "${S_MULTILIBS[@]}")) ) |
| 664 | local S_LIB64=( $(comm -23 <(printf '%s\n' "${T_S_LIB64[@]}") <(printf '%s\n' "${S_MULTILIBS[@]}")) ) |
| 665 | |
| 666 | if [ "${#S_MULTILIBS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 667 | write_blueprint_packages "SHARED_LIBRARIES" "system" "both" "S_MULTILIBS" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 668 | fi |
| 669 | if [ "${#S_LIB32[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 670 | write_blueprint_packages "SHARED_LIBRARIES" "system" "32" "S_LIB32" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 671 | fi |
| 672 | if [ "${#S_LIB64[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 673 | write_blueprint_packages "SHARED_LIBRARIES" "system" "64" "S_LIB64" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 674 | fi |
| 675 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 676 | local T_V_LIB32=( $(prefix_match "vendor/lib/") ) |
| 677 | local T_V_LIB64=( $(prefix_match "vendor/lib64/") ) |
| 678 | local V_MULTILIBS=( $(comm -12 <(printf '%s\n' "${T_V_LIB32[@]}") <(printf '%s\n' "${T_V_LIB64[@]}")) ) |
| 679 | local V_LIB32=( $(comm -23 <(printf '%s\n' "${T_V_LIB32[@]}") <(printf '%s\n' "${V_MULTILIBS[@]}")) ) |
Steve Kondik | 60ef86d | 2016-07-20 20:03:40 -0700 | [diff] [blame] | 680 | local V_LIB64=( $(comm -23 <(printf '%s\n' "${T_V_LIB64[@]}") <(printf '%s\n' "${V_MULTILIBS[@]}")) ) |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 681 | |
| 682 | if [ "${#V_MULTILIBS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 683 | write_blueprint_packages "SHARED_LIBRARIES" "vendor" "both" "V_MULTILIBS" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 684 | fi |
| 685 | if [ "${#V_LIB32[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 686 | write_blueprint_packages "SHARED_LIBRARIES" "vendor" "32" "V_LIB32" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 687 | fi |
| 688 | if [ "${#V_LIB64[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 689 | write_blueprint_packages "SHARED_LIBRARIES" "vendor" "64" "V_LIB64" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 690 | fi |
| 691 | |
| 692 | local T_P_LIB32=( $(prefix_match "product/lib/") ) |
| 693 | local T_P_LIB64=( $(prefix_match "product/lib64/") ) |
| 694 | local P_MULTILIBS=( $(comm -12 <(printf '%s\n' "${T_P_LIB32[@]}") <(printf '%s\n' "${T_P_LIB64[@]}")) ) |
| 695 | local P_LIB32=( $(comm -23 <(printf '%s\n' "${T_P_LIB32[@]}") <(printf '%s\n' "${P_MULTILIBS[@]}")) ) |
| 696 | local P_LIB64=( $(comm -23 <(printf '%s\n' "${T_P_LIB64[@]}") <(printf '%s\n' "${P_MULTILIBS[@]}")) ) |
| 697 | |
| 698 | if [ "${#P_MULTILIBS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 699 | write_blueprint_packages "SHARED_LIBRARIES" "product" "both" "P_MULTILIBS" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 700 | fi |
| 701 | if [ "${#P_LIB32[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 702 | write_blueprint_packages "SHARED_LIBRARIES" "product" "32" "P_LIB32" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 703 | fi |
| 704 | if [ "${#P_LIB64[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 705 | write_blueprint_packages "SHARED_LIBRARIES" "product" "64" "P_LIB64" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 706 | fi |
| 707 | |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 708 | local T_O_LIB32=( $(prefix_match "odm/lib/") ) |
| 709 | local T_O_LIB64=( $(prefix_match "odm/lib64/") ) |
| 710 | local O_MULTILIBS=( $(comm -12 <(printf '%s\n' "${T_O_LIB32[@]}") <(printf '%s\n' "${T_O_LIB64[@]}")) ) |
| 711 | local O_LIB32=( $(comm -23 <(printf '%s\n' "${T_O_LIB32[@]}") <(printf '%s\n' "${O_MULTILIBS[@]}")) ) |
| 712 | local O_LIB64=( $(comm -23 <(printf '%s\n' "${T_O_LIB64[@]}") <(printf '%s\n' "${O_MULTILIBS[@]}")) ) |
| 713 | |
| 714 | if [ "${#O_MULTILIBS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 715 | write_blueprint_packages "SHARED_LIBRARIES" "odm" "both" "O_MULTILIBS" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 716 | fi |
| 717 | if [ "${#O_LIB32[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 718 | write_blueprint_packages "SHARED_LIBRARIES" "odm" "32" "O_LIB32" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 719 | fi |
| 720 | if [ "${#O_LIB64[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 721 | write_blueprint_packages "SHARED_LIBRARIES" "odm" "64" "O_LIB64" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 722 | fi |
| 723 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 724 | # Apps |
| 725 | local APPS=( $(prefix_match "app/") ) |
| 726 | if [ "${#APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 727 | write_blueprint_packages "APPS" "" "" "APPS" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 728 | fi |
| 729 | local PRIV_APPS=( $(prefix_match "priv-app/") ) |
| 730 | if [ "${#PRIV_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 731 | write_blueprint_packages "APPS" "" "priv-app" "PRIV_APPS" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 732 | fi |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 733 | local S_APPS=( $(prefix_match "system/app/") ) |
| 734 | if [ "${#S_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 735 | write_blueprint_packages "APPS" "system" "" "S_APPS" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 736 | fi |
| 737 | local S_PRIV_APPS=( $(prefix_match "system/priv-app/") ) |
| 738 | if [ "${#S_PRIV_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 739 | write_blueprint_packages "APPS" "system" "priv-app" "S_PRIV_APPS" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 740 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 741 | local V_APPS=( $(prefix_match "vendor/app/") ) |
| 742 | if [ "${#V_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 743 | write_blueprint_packages "APPS" "vendor" "" "V_APPS" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 744 | fi |
| 745 | local V_PRIV_APPS=( $(prefix_match "vendor/priv-app/") ) |
| 746 | if [ "${#V_PRIV_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 747 | write_blueprint_packages "APPS" "vendor" "priv-app" "V_PRIV_APPS" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 748 | fi |
| 749 | local P_APPS=( $(prefix_match "product/app/") ) |
| 750 | if [ "${#P_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 751 | write_blueprint_packages "APPS" "product" "" "P_APPS" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 752 | fi |
| 753 | local P_PRIV_APPS=( $(prefix_match "product/priv-app/") ) |
| 754 | if [ "${#P_PRIV_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 755 | write_blueprint_packages "APPS" "product" "priv-app" "P_PRIV_APPS" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 756 | fi |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 757 | local O_APPS=( $(prefix_match "odm/app/") ) |
| 758 | if [ "${#O_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 759 | write_blueprint_packages "APPS" "odm" "" "O_APPS" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 760 | fi |
| 761 | local O_PRIV_APPS=( $(prefix_match "odm/priv-app/") ) |
| 762 | if [ "${#O_PRIV_APPS[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 763 | write_blueprint_packages "APPS" "odm" "priv-app" "O_PRIV_APPS" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 764 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 765 | |
| 766 | # Framework |
| 767 | local FRAMEWORK=( $(prefix_match "framework/") ) |
| 768 | if [ "${#FRAMEWORK[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 769 | write_blueprint_packages "JAVA_LIBRARIES" "" "" "FRAMEWORK" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 770 | fi |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 771 | local S_FRAMEWORK=( $(prefix_match "system/framework/") ) |
| 772 | if [ "${#S_FRAMEWORK[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 773 | write_blueprint_packages "JAVA_LIBRARIES" "system" "" "S_FRAMEWORK" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 774 | fi |
Christian Oder | c16f327 | 2017-10-08 23:15:52 +0200 | [diff] [blame] | 775 | local V_FRAMEWORK=( $(prefix_match "vendor/framework/") ) |
Michael Bestas | a3f97c7 | 2018-02-27 22:31:55 +0200 | [diff] [blame] | 776 | if [ "${#V_FRAMEWORK[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 777 | write_blueprint_packages "JAVA_LIBRARIES" "vendor" "" "V_FRAMEWORK" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 778 | fi |
| 779 | local P_FRAMEWORK=( $(prefix_match "product/framework/") ) |
| 780 | if [ "${#P_FRAMEWORK[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 781 | write_blueprint_packages "JAVA_LIBRARIES" "product" "" "P_FRAMEWORK" >> "$ANDROIDBP" |
Christian Oder | c16f327 | 2017-10-08 23:15:52 +0200 | [diff] [blame] | 782 | fi |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 783 | local O_FRAMEWORK=( $(prefix_match "odm/framework/") ) |
| 784 | if [ "${#O_FRAMEWORK[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 785 | write_blueprint_packages "JAVA_LIBRARIES" "odm" "" "O_FRAMEWORK" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 786 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 787 | |
| 788 | # Etc |
| 789 | local ETC=( $(prefix_match "etc/") ) |
| 790 | if [ "${#ETC[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 791 | write_blueprint_packages "ETC" "" "" "ETC" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 792 | fi |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 793 | local S_ETC=( $(prefix_match "system/etc/") ) |
| 794 | if [ "${#ETC[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 795 | write_blueprint_packages "ETC" "system" "" "S_ETC" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 796 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 797 | local V_ETC=( $(prefix_match "vendor/etc/") ) |
| 798 | if [ "${#V_ETC[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 799 | write_blueprint_packages "ETC" "vendor" "" "V_ETC" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 800 | fi |
| 801 | local P_ETC=( $(prefix_match "product/etc/") ) |
| 802 | if [ "${#P_ETC[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 803 | write_blueprint_packages "ETC" "product" "" "P_ETC" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 804 | fi |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 805 | local O_ETC=( $(prefix_match "odm/etc/") ) |
| 806 | if [ "${#O_ETC[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 807 | write_blueprint_packages "ETC" "odm" "" "O_ETC" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 808 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 809 | |
| 810 | # Executables |
| 811 | local BIN=( $(prefix_match "bin/") ) |
| 812 | if [ "${#BIN[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 813 | write_blueprint_packages "EXECUTABLES" "" "" "BIN" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 814 | fi |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 815 | local S_BIN=( $(prefix_match "system/bin/") ) |
| 816 | if [ "${#BIN[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 817 | write_blueprint_packages "EXECUTABLES" "system" "" "S_BIN" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 8de76b2 | 2019-09-28 23:37:36 -0400 | [diff] [blame] | 818 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 819 | local V_BIN=( $(prefix_match "vendor/bin/") ) |
| 820 | if [ "${#V_BIN[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 821 | write_blueprint_packages "EXECUTABLES" "vendor" "" "V_BIN" >> "$ANDROIDBP" |
razorloves | b5c2c96 | 2019-07-29 02:21:34 -0500 | [diff] [blame] | 822 | fi |
| 823 | local P_BIN=( $(prefix_match "product/bin/") ) |
| 824 | if [ "${#P_BIN[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 825 | write_blueprint_packages "EXECUTABLES" "product" "" "P_BIN" >> "$ANDROIDBP" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 826 | fi |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 827 | local O_BIN=( $(prefix_match "odm/bin/") ) |
| 828 | if [ "${#O_BIN[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 829 | write_blueprint_packages "EXECUTABLES" "odm" "" "O_BIN" >> "$ANDROIDBP" |
Rashed Abdel-Tawab | 08e3a27 | 2019-09-20 07:32:39 -0700 | [diff] [blame] | 830 | fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 831 | local SBIN=( $(prefix_match "sbin/") ) |
| 832 | if [ "${#SBIN[@]}" -gt "0" ]; then |
Rashed Abdel-Tawab | 34b5cdc | 2019-09-20 10:30:38 -0700 | [diff] [blame] | 833 | write_makefile_packages "EXECUTABLES" "" "sbin" "SBIN" >> "$ANDROIDMK" |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 834 | fi |
| 835 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 836 | |
| 837 | # Actually write out the final PRODUCT_PACKAGES list |
| 838 | local PACKAGE_COUNT=${#PACKAGE_LIST[@]} |
| 839 | |
| 840 | if [ "$PACKAGE_COUNT" -eq "0" ]; then |
| 841 | return 0 |
| 842 | fi |
| 843 | |
| 844 | printf '\n%s\n' "PRODUCT_PACKAGES += \\" >> "$PRODUCTMK" |
| 845 | for (( i=1; i<PACKAGE_COUNT+1; i++ )); do |
| 846 | local LINEEND=" \\" |
| 847 | if [ "$i" -eq "$PACKAGE_COUNT" ]; then |
| 848 | LINEEND="" |
| 849 | fi |
| 850 | printf ' %s%s\n' "${PACKAGE_LIST[$i-1]}" "$LINEEND" >> "$PRODUCTMK" |
| 851 | done |
| 852 | } |
| 853 | |
| 854 | # |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 855 | # write_blueprint_header: |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 856 | # |
| 857 | # $1: file which will be written to |
| 858 | # |
| 859 | # writes out the copyright header with the current year. |
| 860 | # note that this is not an append operation, and should |
| 861 | # be executed first! |
| 862 | # |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 863 | function write_blueprint_header() { |
| 864 | if [ -f $1 ]; then |
| 865 | rm $1 |
| 866 | fi |
| 867 | |
| 868 | YEAR=$(date +"%Y") |
| 869 | |
| 870 | [ "$COMMON" -eq 1 ] && local DEVICE="$DEVICE_COMMON" |
| 871 | |
| 872 | printf "/**\n" > $1 |
| 873 | NUM_REGEX='^[0-9]+$' |
| 874 | if [[ ! $INITIAL_COPYRIGHT_YEAR =~ $NUM_REGEX ]] || [ $INITIAL_COPYRIGHT_YEAR -lt 2019 ]; then |
| 875 | BLUEPRINT_INITIAL_COPYRIGHT_YEAR=2019 |
| 876 | else |
| 877 | BLUEPRINT_INITIAL_COPYRIGHT_YEAR=$INITIAL_COPYRIGHT_YEAR |
| 878 | fi |
| 879 | |
| 880 | if [ $BLUEPRINT_INITIAL_COPYRIGHT_YEAR -eq $YEAR ]; then |
| 881 | printf " * Copyright (C) $YEAR The LineageOS Project\n" >> $1 |
| 882 | elif [ $BLUEPRINT_INITIAL_COPYRIGHT_YEAR -le 2019 ]; then |
| 883 | printf " * Copyright (C) 2019-$YEAR The LineageOS Project\n" >> $1 |
| 884 | else |
| 885 | printf " * Copyright (C) $BLUEPRINT_INITIAL_COPYRIGHT_YEAR-$YEAR The LineageOS Project\n" >> $1 |
| 886 | fi |
| 887 | |
| 888 | cat << EOF >> $1 |
| 889 | * |
| 890 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 891 | * you may not use this file except in compliance with the License. |
| 892 | * You may obtain a copy of the License at |
| 893 | * |
| 894 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 895 | * |
| 896 | * Unless required by applicable law or agreed to in writing, software |
| 897 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 898 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 899 | * See the License for the specific language governing permissions and |
| 900 | * limitations under the License. |
| 901 | * |
| 902 | * This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh |
| 903 | */ |
| 904 | |
| 905 | EOF |
| 906 | } |
| 907 | |
| 908 | # |
| 909 | # write_makefile_header: |
| 910 | # |
| 911 | # $1: file which will be written to |
| 912 | # |
| 913 | # writes out the copyright header with the current year. |
| 914 | # note that this is not an append operation, and should |
| 915 | # be executed first! |
| 916 | # |
| 917 | function write_makefile_header() { |
Matt Mower | 8945f5e | 2017-01-07 14:08:17 -0600 | [diff] [blame] | 918 | if [ -f $1 ]; then |
| 919 | rm $1 |
| 920 | fi |
| 921 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 922 | YEAR=$(date +"%Y") |
| 923 | |
| 924 | [ "$COMMON" -eq 1 ] && local DEVICE="$DEVICE_COMMON" |
| 925 | |
Matt Mower | 8945f5e | 2017-01-07 14:08:17 -0600 | [diff] [blame] | 926 | NUM_REGEX='^[0-9]+$' |
| 927 | if [[ $INITIAL_COPYRIGHT_YEAR =~ $NUM_REGEX ]] && [ $INITIAL_COPYRIGHT_YEAR -le $YEAR ]; then |
| 928 | if [ $INITIAL_COPYRIGHT_YEAR -lt 2016 ]; then |
| 929 | printf "# Copyright (C) $INITIAL_COPYRIGHT_YEAR-2016 The CyanogenMod Project\n" > $1 |
| 930 | elif [ $INITIAL_COPYRIGHT_YEAR -eq 2016 ]; then |
| 931 | printf "# Copyright (C) 2016 The CyanogenMod Project\n" > $1 |
| 932 | fi |
| 933 | if [ $YEAR -eq 2017 ]; then |
| 934 | printf "# Copyright (C) 2017 The LineageOS Project\n" >> $1 |
| 935 | elif [ $INITIAL_COPYRIGHT_YEAR -eq $YEAR ]; then |
| 936 | printf "# Copyright (C) $YEAR The LineageOS Project\n" >> $1 |
| 937 | elif [ $INITIAL_COPYRIGHT_YEAR -le 2017 ]; then |
| 938 | printf "# Copyright (C) 2017-$YEAR The LineageOS Project\n" >> $1 |
| 939 | else |
| 940 | printf "# Copyright (C) $INITIAL_COPYRIGHT_YEAR-$YEAR The LineageOS Project\n" >> $1 |
| 941 | fi |
| 942 | else |
| 943 | printf "# Copyright (C) $YEAR The LineageOS Project\n" > $1 |
| 944 | fi |
| 945 | |
| 946 | cat << EOF >> $1 |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 947 | # |
| 948 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 949 | # you may not use this file except in compliance with the License. |
| 950 | # You may obtain a copy of the License at |
| 951 | # |
| 952 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 953 | # |
| 954 | # Unless required by applicable law or agreed to in writing, software |
| 955 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 956 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 957 | # See the License for the specific language governing permissions and |
| 958 | # limitations under the License. |
| 959 | |
| 960 | # This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh |
| 961 | |
| 962 | EOF |
| 963 | } |
| 964 | |
| 965 | # |
| 966 | # write_headers: |
| 967 | # |
| 968 | # $1: devices falling under common to be added to guard - optional |
Rashed Abdel-Tawab | d53bff1 | 2016-10-02 01:00:54 -0400 | [diff] [blame] | 969 | # $2: custom guard - optional |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 970 | # |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 971 | # Calls write_makefile_header for each of the makefiles and |
| 972 | # write_blueprint_header for Android.bp and creates the initial |
| 973 | # path declaration and device guard for the Android.mk |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 974 | # |
| 975 | function write_headers() { |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 976 | write_makefile_header "$ANDROIDMK" |
Rashed Abdel-Tawab | d53bff1 | 2016-10-02 01:00:54 -0400 | [diff] [blame] | 977 | |
| 978 | GUARD="$2" |
| 979 | if [ -z "$GUARD" ]; then |
| 980 | GUARD="TARGET_DEVICE" |
| 981 | fi |
| 982 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 983 | cat << EOF >> "$ANDROIDMK" |
| 984 | LOCAL_PATH := \$(call my-dir) |
| 985 | |
| 986 | EOF |
| 987 | if [ "$COMMON" -ne 1 ]; then |
| 988 | cat << EOF >> "$ANDROIDMK" |
Rashed Abdel-Tawab | d53bff1 | 2016-10-02 01:00:54 -0400 | [diff] [blame] | 989 | ifeq (\$($GUARD),$DEVICE) |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 990 | |
| 991 | EOF |
| 992 | else |
| 993 | if [ -z "$1" ]; then |
| 994 | echo "Argument with devices to be added to guard must be set!" |
| 995 | exit 1 |
| 996 | fi |
| 997 | cat << EOF >> "$ANDROIDMK" |
Rashed Abdel-Tawab | d53bff1 | 2016-10-02 01:00:54 -0400 | [diff] [blame] | 998 | ifneq (\$(filter $1,\$($GUARD)),) |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 999 | |
| 1000 | EOF |
| 1001 | fi |
| 1002 | |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 1003 | write_makefile_header "$BOARDMK" |
| 1004 | write_makefile_header "$PRODUCTMK" |
| 1005 | write_blueprint_header "$ANDROIDBP" |
| 1006 | |
| 1007 | cat << EOF >> "$ANDROIDBP" |
| 1008 | soong_namespace { |
| 1009 | } |
| 1010 | |
| 1011 | EOF |
| 1012 | |
| 1013 | [ "$COMMON" -eq 1 ] && local DEVICE="$DEVICE_COMMON" |
| 1014 | cat << EOF >> "$PRODUCTMK" |
| 1015 | PRODUCT_SOONG_NAMESPACES += \\ |
| 1016 | vendor/$VENDOR/$DEVICE |
| 1017 | |
| 1018 | EOF |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | # |
| 1022 | # write_footers: |
| 1023 | # |
| 1024 | # Closes the inital guard and any other finalization tasks. Must |
| 1025 | # be called as the final step. |
| 1026 | # |
| 1027 | function write_footers() { |
| 1028 | cat << EOF >> "$ANDROIDMK" |
| 1029 | endif |
| 1030 | EOF |
| 1031 | } |
| 1032 | |
| 1033 | # Return success if adb is up and not in recovery |
| 1034 | function _adb_connected { |
| 1035 | { |
Steve Kondik | 7561d19 | 2016-09-01 21:40:27 -0700 | [diff] [blame] | 1036 | if [[ "$(adb get-state)" == device ]] |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1037 | then |
| 1038 | return 0 |
| 1039 | fi |
| 1040 | } 2>/dev/null |
| 1041 | |
| 1042 | return 1 |
| 1043 | }; |
| 1044 | |
| 1045 | # |
Bruno Martins | 3b96ba5 | 2016-07-27 15:00:05 +0100 | [diff] [blame] | 1046 | # parse_file_list: |
| 1047 | # |
| 1048 | # $1: input file |
Rashed Abdel-Tawab | 855fbdd | 2017-04-04 02:48:18 -0400 | [diff] [blame] | 1049 | # $2: blob section in file - optional |
Bruno Martins | 3b96ba5 | 2016-07-27 15:00:05 +0100 | [diff] [blame] | 1050 | # |
| 1051 | # Sets PRODUCT_PACKAGES and PRODUCT_COPY_FILES while parsing the input file |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1052 | # |
| 1053 | function parse_file_list() { |
Bruno Martins | 3b96ba5 | 2016-07-27 15:00:05 +0100 | [diff] [blame] | 1054 | if [ -z "$1" ]; then |
| 1055 | echo "An input file is expected!" |
| 1056 | exit 1 |
| 1057 | elif [ ! -f "$1" ]; then |
| 1058 | echo "Input file "$1" does not exist!" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1059 | exit 1 |
| 1060 | fi |
| 1061 | |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1062 | if [ -n "$2" ]; then |
| 1063 | echo "Using section \"$2\"" |
Rashed Abdel-Tawab | 855fbdd | 2017-04-04 02:48:18 -0400 | [diff] [blame] | 1064 | LIST=$TMPDIR/files.txt |
Vladimir Oltean | 5238ba8 | 2019-01-19 00:44:07 +0200 | [diff] [blame] | 1065 | # Match all lines starting with first line found to start* with '#' |
| 1066 | # comment and contain** $2, and ending with first line to be empty*. |
| 1067 | # *whitespaces (tabs, spaces) at the beginning of lines are discarded |
| 1068 | # **the $2 match is case-insensitive |
| 1069 | cat $1 | sed -n '/^[[:space:]]*#.*'"$2"'/I,/^[[:space:]]*$/ p' > $LIST |
Rashed Abdel-Tawab | 855fbdd | 2017-04-04 02:48:18 -0400 | [diff] [blame] | 1070 | else |
| 1071 | LIST=$1 |
| 1072 | fi |
| 1073 | |
| 1074 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1075 | PRODUCT_PACKAGES_LIST=() |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1076 | PRODUCT_PACKAGES_HASHES=() |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1077 | PRODUCT_PACKAGES_FIXUP_HASHES=() |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1078 | PRODUCT_COPY_FILES_LIST=() |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1079 | PRODUCT_COPY_FILES_HASHES=() |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1080 | PRODUCT_COPY_FILES_FIXUP_HASHES=() |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1081 | |
| 1082 | while read -r line; do |
| 1083 | if [ -z "$line" ]; then continue; fi |
| 1084 | |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1085 | # If the line has a pipe delimiter, a sha1 hash should follow. |
| 1086 | # This indicates the file should be pinned and not overwritten |
| 1087 | # when extracting files. |
| 1088 | local SPLIT=(${line//\|/ }) |
| 1089 | local COUNT=${#SPLIT[@]} |
| 1090 | local SPEC=${SPLIT[0]} |
| 1091 | local HASH="x" |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1092 | local FIXUP_HASH="x" |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1093 | if [ "$COUNT" -gt "1" ]; then |
| 1094 | HASH=${SPLIT[1]} |
| 1095 | fi |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1096 | if [ "$COUNT" -gt "2" ]; then |
| 1097 | FIXUP_HASH=${SPLIT[2]} |
| 1098 | fi |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1099 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1100 | # if line starts with a dash, it needs to be packaged |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1101 | if [[ "$SPEC" =~ ^- ]]; then |
| 1102 | PRODUCT_PACKAGES_LIST+=("${SPEC#-}") |
| 1103 | PRODUCT_PACKAGES_HASHES+=("$HASH") |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1104 | PRODUCT_PACKAGES_FIXUP_HASHES+=("$FIXUP_HASH") |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1105 | else |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1106 | PRODUCT_COPY_FILES_LIST+=("$SPEC") |
| 1107 | PRODUCT_COPY_FILES_HASHES+=("$HASH") |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1108 | PRODUCT_COPY_FILES_FIXUP_HASHES+=("$FIXUP_HASH") |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1109 | fi |
| 1110 | |
Rashed Abdel-Tawab | 855fbdd | 2017-04-04 02:48:18 -0400 | [diff] [blame] | 1111 | done < <(egrep -v '(^#|^[[:space:]]*$)' "$LIST" | LC_ALL=C sort | uniq) |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | # |
| 1115 | # write_makefiles: |
| 1116 | # |
| 1117 | # $1: file containing the list of items to extract |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 1118 | # $2: make treble compatible makefile - optional |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1119 | # |
| 1120 | # Calls write_product_copy_files and write_product_packages on |
Rashed Abdel-Tawab | 42752d4 | 2019-09-20 07:06:09 -0700 | [diff] [blame] | 1121 | # the given file and appends to the Android.bp as well as |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1122 | # the product makefile. |
| 1123 | # |
| 1124 | function write_makefiles() { |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1125 | parse_file_list "$1" |
Rashed Abdel-Tawab | 0ca7643 | 2017-10-07 14:18:39 -0400 | [diff] [blame] | 1126 | write_product_copy_files "$2" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1127 | write_product_packages |
| 1128 | } |
| 1129 | |
| 1130 | # |
Louis Popi | a516c2f | 2016-07-25 15:51:13 +0200 | [diff] [blame] | 1131 | # append_firmware_calls_to_makefiles: |
| 1132 | # |
| 1133 | # Appends to Android.mk the calls to all images present in radio folder |
| 1134 | # (filesmap file used by releasetools to map firmware images should be kept in the device tree) |
| 1135 | # |
| 1136 | function append_firmware_calls_to_makefiles() { |
| 1137 | cat << EOF >> "$ANDROIDMK" |
| 1138 | ifeq (\$(LOCAL_PATH)/radio, \$(wildcard \$(LOCAL_PATH)/radio)) |
| 1139 | |
| 1140 | RADIO_FILES := \$(wildcard \$(LOCAL_PATH)/radio/*) |
| 1141 | \$(foreach f, \$(notdir \$(RADIO_FILES)), \\ |
| 1142 | \$(call add-radio-file,radio/\$(f))) |
| 1143 | \$(call add-radio-file,../../../device/$VENDOR/$DEVICE/radio/filesmap) |
| 1144 | |
| 1145 | endif |
| 1146 | |
| 1147 | EOF |
| 1148 | } |
| 1149 | |
| 1150 | # |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1151 | # get_file: |
| 1152 | # |
| 1153 | # $1: input file |
| 1154 | # $2: target file/folder |
| 1155 | # $3: source of the file (can be "adb" or a local folder) |
| 1156 | # |
| 1157 | # Silently extracts the input file to defined target |
| 1158 | # Returns success if file can be pulled from the device or found locally |
| 1159 | # |
| 1160 | function get_file() { |
| 1161 | local SRC="$3" |
| 1162 | |
| 1163 | if [ "$SRC" = "adb" ]; then |
| 1164 | # try to pull |
| 1165 | adb pull "$1" "$2" >/dev/null 2>&1 && return 0 |
| 1166 | |
| 1167 | return 1 |
| 1168 | else |
| 1169 | # try to copy |
Vladimir Oltean | d577325 | 2018-06-25 00:05:56 +0300 | [diff] [blame] | 1170 | cp -r "$SRC/$1" "$2" 2>/dev/null && return 0 |
| 1171 | cp -r "$SRC/${1#/system}" "$2" 2>/dev/null && return 0 |
Vladimir Oltean | 78d690d | 2019-01-06 19:38:31 +0200 | [diff] [blame] | 1172 | cp -r "$SRC/system/$1" "$2" 2>/dev/null && return 0 |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1173 | |
| 1174 | return 1 |
| 1175 | fi |
| 1176 | }; |
| 1177 | |
| 1178 | # |
| 1179 | # oat2dex: |
| 1180 | # |
| 1181 | # $1: extracted apk|jar (to check if deodex is required) |
| 1182 | # $2: odexed apk|jar to deodex |
| 1183 | # $3: source of the odexed apk|jar |
| 1184 | # |
| 1185 | # Convert apk|jar .odex in the corresposing classes.dex |
| 1186 | # |
| 1187 | function oat2dex() { |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 1188 | local LINEAGE_TARGET="$1" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1189 | local OEM_TARGET="$2" |
| 1190 | local SRC="$3" |
| 1191 | local TARGET= |
| 1192 | local OAT= |
XiNGRZ | 4a2b65f | 2019-12-24 10:37:13 +0800 | [diff] [blame] | 1193 | local HOST="$(uname | tr '[:upper:]' '[:lower:]')" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1194 | |
| 1195 | if [ -z "$BAKSMALIJAR" ] || [ -z "$SMALIJAR" ]; then |
Bruno Martins | 8194b8e | 2019-09-23 11:51:33 +0100 | [diff] [blame] | 1196 | export BAKSMALIJAR="$LINEAGE_ROOT"/prebuilts/tools-lineage/common/smali/baksmali.jar |
| 1197 | export SMALIJAR="$LINEAGE_ROOT"/prebuilts/tools-lineage/common/smali/smali.jar |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1198 | fi |
| 1199 | |
Joe Maples | 9be579f | 2018-01-05 14:51:33 -0500 | [diff] [blame] | 1200 | if [ -z "$VDEXEXTRACTOR" ]; then |
Han Wang | ae82c34 | 2020-03-10 09:40:47 +0200 | [diff] [blame] | 1201 | export VDEXEXTRACTOR="$LINEAGE_ROOT"/prebuilts/tools-lineage/${HOST}-x86/bin/vdexExtractor |
Joe Maples | 9be579f | 2018-01-05 14:51:33 -0500 | [diff] [blame] | 1202 | fi |
| 1203 | |
codeworkx | 1c29bf6 | 2018-09-23 12:36:57 +0200 | [diff] [blame] | 1204 | if [ -z "$CDEXCONVERTER" ]; then |
Han Wang | ae82c34 | 2020-03-10 09:40:47 +0200 | [diff] [blame] | 1205 | export CDEXCONVERTER="$LINEAGE_ROOT"/prebuilts/tools-lineage/${HOST}-x86/bin/compact_dex_converter |
codeworkx | 1c29bf6 | 2018-09-23 12:36:57 +0200 | [diff] [blame] | 1206 | fi |
| 1207 | |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1208 | # Extract existing boot.oats to the temp folder |
| 1209 | if [ -z "$ARCHES" ]; then |
Sam Mortimer | 2e994ce | 2016-10-05 09:50:49 -0700 | [diff] [blame] | 1210 | echo "Checking if system is odexed and locating boot.oats..." |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1211 | for ARCH in "arm64" "arm" "x86_64" "x86"; do |
Sam Mortimer | 2e994ce | 2016-10-05 09:50:49 -0700 | [diff] [blame] | 1212 | mkdir -p "$TMPDIR/system/framework/$ARCH" |
Vladimir Oltean | d577325 | 2018-06-25 00:05:56 +0300 | [diff] [blame] | 1213 | if get_file "/system/framework/$ARCH" "$TMPDIR/system/framework/" "$SRC"; then |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1214 | ARCHES+="$ARCH " |
Sam Mortimer | 2e994ce | 2016-10-05 09:50:49 -0700 | [diff] [blame] | 1215 | else |
| 1216 | rmdir "$TMPDIR/system/framework/$ARCH" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1217 | fi |
| 1218 | done |
| 1219 | fi |
| 1220 | |
| 1221 | if [ -z "$ARCHES" ]; then |
| 1222 | FULLY_DEODEXED=1 && return 0 # system is fully deodexed, return |
| 1223 | fi |
| 1224 | |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 1225 | if [ ! -f "$LINEAGE_TARGET" ]; then |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1226 | return; |
| 1227 | fi |
| 1228 | |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 1229 | if grep "classes.dex" "$LINEAGE_TARGET" >/dev/null; then |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1230 | return 0 # target apk|jar is already odexed, return |
| 1231 | fi |
| 1232 | |
| 1233 | for ARCH in $ARCHES; do |
Sam Mortimer | 2e994ce | 2016-10-05 09:50:49 -0700 | [diff] [blame] | 1234 | BOOTOAT="$TMPDIR/system/framework/$ARCH/boot.oat" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1235 | |
| 1236 | local OAT="$(dirname "$OEM_TARGET")/oat/$ARCH/$(basename "$OEM_TARGET" ."${OEM_TARGET##*.}").odex" |
Rashed Abdel-Tawab | 54b5d5e | 2017-08-23 15:13:17 -0400 | [diff] [blame] | 1237 | local VDEX="$(dirname "$OEM_TARGET")/oat/$ARCH/$(basename "$OEM_TARGET" ."${OEM_TARGET##*.}").vdex" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1238 | |
| 1239 | if get_file "$OAT" "$TMPDIR" "$SRC"; then |
Rashed Abdel-Tawab | 54b5d5e | 2017-08-23 15:13:17 -0400 | [diff] [blame] | 1240 | if get_file "$VDEX" "$TMPDIR" "$SRC"; then |
Joe Maples | 9be579f | 2018-01-05 14:51:33 -0500 | [diff] [blame] | 1241 | "$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$TMPDIR/$(basename "$VDEX")" > /dev/null |
Rashed Abdel-Tawab | 19c36cd | 2018-03-15 12:55:22 -0700 | [diff] [blame] | 1242 | CLASSES=$(ls "$TMPDIR/$(basename "${OEM_TARGET%.*}")_classes"*) |
| 1243 | for CLASS in $CLASSES; do |
| 1244 | NEWCLASS=$(echo "$CLASS" | sed 's/.*_//;s/cdex/dex/') |
| 1245 | # Check if we have to deal with CompactDex |
| 1246 | if [[ "$CLASS" == *.cdex ]]; then |
| 1247 | "$CDEXCONVERTER" "$CLASS" &>/dev/null |
| 1248 | mv "$CLASS.new" "$TMPDIR/$NEWCLASS" |
| 1249 | else |
| 1250 | mv "$CLASS" "$TMPDIR/$NEWCLASS" |
| 1251 | fi |
| 1252 | done |
Joe Maples | 9be579f | 2018-01-05 14:51:33 -0500 | [diff] [blame] | 1253 | else |
| 1254 | java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$TMPDIR/$(basename "$OAT")" |
| 1255 | java -jar "$SMALIJAR" assemble "$TMPDIR/dexout" -o "$TMPDIR/classes.dex" |
Rashed Abdel-Tawab | 54b5d5e | 2017-08-23 15:13:17 -0400 | [diff] [blame] | 1256 | fi |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 1257 | elif [[ "$LINEAGE_TARGET" =~ .jar$ ]]; then |
Gabriele M | 4cf635a | 2017-01-05 22:10:00 +0100 | [diff] [blame] | 1258 | JAROAT="$TMPDIR/system/framework/$ARCH/boot-$(basename ${OEM_TARGET%.*}).oat" |
Luca Stefani | f6096e9 | 2018-10-07 12:44:53 +0200 | [diff] [blame] | 1259 | JARVDEX="/system/framework/boot-$(basename ${OEM_TARGET%.*}).vdex" |
Gabriele M | 4cf635a | 2017-01-05 22:10:00 +0100 | [diff] [blame] | 1260 | if [ ! -f "$JAROAT" ]; then |
Luca Stefani | f6096e9 | 2018-10-07 12:44:53 +0200 | [diff] [blame] | 1261 | JAROAT=$BOOTOAT |
Gabriele M | 4cf635a | 2017-01-05 22:10:00 +0100 | [diff] [blame] | 1262 | fi |
Joe Maples | 9be579f | 2018-01-05 14:51:33 -0500 | [diff] [blame] | 1263 | # try to extract classes.dex from boot.vdex for frameworks jars |
| 1264 | # fallback to boot.oat if vdex is not available |
Luca Stefani | f6096e9 | 2018-10-07 12:44:53 +0200 | [diff] [blame] | 1265 | if get_file "$JARVDEX" "$TMPDIR" "$SRC"; then |
Luca Stefani | 99a66bf | 2018-10-31 19:16:05 +0100 | [diff] [blame] | 1266 | "$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$TMPDIR/$(basename "$JARVDEX")" > /dev/null |
Rashed Abdel-Tawab | 19c36cd | 2018-03-15 12:55:22 -0700 | [diff] [blame] | 1267 | CLASSES=$(ls "$TMPDIR/$(basename "${JARVDEX%.*}")_classes"*) |
| 1268 | for CLASS in $CLASSES; do |
| 1269 | NEWCLASS=$(echo "$CLASS" | sed 's/.*_//;s/cdex/dex/') |
| 1270 | # Check if we have to deal with CompactDex |
| 1271 | if [[ "$CLASS" == *.cdex ]]; then |
| 1272 | "$CDEXCONVERTER" "$CLASS" &>/dev/null |
| 1273 | mv "$CLASS.new" "$TMPDIR/$NEWCLASS" |
| 1274 | else |
| 1275 | mv "$CLASS" "$TMPDIR/$NEWCLASS" |
| 1276 | fi |
| 1277 | done |
Joe Maples | 9be579f | 2018-01-05 14:51:33 -0500 | [diff] [blame] | 1278 | else |
| 1279 | java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$JAROAT/$OEM_TARGET" |
| 1280 | java -jar "$SMALIJAR" assemble "$TMPDIR/dexout" -o "$TMPDIR/classes.dex" |
| 1281 | fi |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1282 | else |
| 1283 | continue |
| 1284 | fi |
| 1285 | |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1286 | done |
| 1287 | |
| 1288 | rm -rf "$TMPDIR/dexout" |
| 1289 | } |
| 1290 | |
| 1291 | # |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1292 | # init_adb_connection: |
| 1293 | # |
| 1294 | # Starts adb server and waits for the device |
| 1295 | # |
| 1296 | function init_adb_connection() { |
| 1297 | adb start-server # Prevent unexpected starting server message from adb get-state in the next line |
| 1298 | if ! _adb_connected; then |
| 1299 | echo "No device is online. Waiting for one..." |
| 1300 | echo "Please connect USB and/or enable USB debugging" |
| 1301 | until _adb_connected; do |
| 1302 | sleep 1 |
| 1303 | done |
| 1304 | echo "Device Found." |
| 1305 | fi |
| 1306 | |
| 1307 | # Retrieve IP and PORT info if we're using a TCP connection |
| 1308 | TCPIPPORT=$(adb devices | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+[^0-9]+' \ |
| 1309 | | head -1 | awk '{print $1}') |
| 1310 | adb root &> /dev/null |
| 1311 | sleep 0.3 |
| 1312 | if [ -n "$TCPIPPORT" ]; then |
| 1313 | # adb root just killed our connection |
| 1314 | # so reconnect... |
| 1315 | adb connect "$TCPIPPORT" |
| 1316 | fi |
| 1317 | adb wait-for-device &> /dev/null |
| 1318 | sleep 0.3 |
| 1319 | } |
| 1320 | |
| 1321 | # |
Luca Stefani | 3a03012 | 2016-07-30 12:08:25 +0200 | [diff] [blame] | 1322 | # fix_xml: |
| 1323 | # |
| 1324 | # $1: xml file to fix |
| 1325 | # |
| 1326 | function fix_xml() { |
| 1327 | local XML="$1" |
| 1328 | local TEMP_XML="$TMPDIR/`basename "$XML"`.temp" |
| 1329 | |
Dobroslaw Kijowski | 65f03f1 | 2017-05-18 12:35:02 +0200 | [diff] [blame] | 1330 | grep -a '^<?xml version' "$XML" > "$TEMP_XML" |
| 1331 | grep -av '^<?xml version' "$XML" >> "$TEMP_XML" |
Luca Stefani | 3a03012 | 2016-07-30 12:08:25 +0200 | [diff] [blame] | 1332 | |
| 1333 | mv "$TEMP_XML" "$XML" |
| 1334 | } |
| 1335 | |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1336 | function get_hash() { |
| 1337 | local FILE="$1" |
| 1338 | |
| 1339 | if [ "$(uname)" == "Darwin" ]; then |
| 1340 | shasum "${FILE}" | awk '{print $1}' |
| 1341 | else |
| 1342 | sha1sum "${FILE}" | awk '{print $1}' |
| 1343 | fi |
| 1344 | } |
| 1345 | |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1346 | function print_spec() { |
| 1347 | local SPEC_PRODUCT_PACKAGE="$1" |
| 1348 | local SPEC_SRC_FILE="$2" |
| 1349 | local SPEC_DST_FILE="$3" |
| 1350 | local SPEC_ARGS="$4" |
| 1351 | local SPEC_HASH="$5" |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1352 | local SPEC_FIXUP_HASH="$6" |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1353 | |
| 1354 | local PRODUCT_PACKAGE="" |
| 1355 | if [ ${SPEC_PRODUCT_PACKAGE} = true ]; then |
| 1356 | PRODUCT_PACKAGE="-" |
| 1357 | fi |
| 1358 | local SRC="" |
| 1359 | if [ ! -z "${SPEC_SRC_FILE}" ] && [ "${SPEC_SRC_FILE}" != "${SPEC_DST_FILE}" ]; then |
| 1360 | SRC="${SPEC_SRC_FILE}:" |
| 1361 | fi |
| 1362 | local DST="" |
| 1363 | if [ ! -z "${SPEC_DST_FILE}" ]; then |
| 1364 | DST="${SPEC_DST_FILE}" |
| 1365 | fi |
| 1366 | local ARGS="" |
| 1367 | if [ ! -z "${SPEC_ARGS}" ]; then |
| 1368 | ARGS=";${SPEC_ARGS}" |
| 1369 | fi |
| 1370 | local HASH="" |
| 1371 | if [ ! -z "${SPEC_HASH}" ] && [ "${SPEC_HASH}" != "x" ]; then |
| 1372 | HASH="|${SPEC_HASH}" |
| 1373 | fi |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1374 | local FIXUP_HASH="" |
| 1375 | if [ ! -z "${SPEC_FIXUP_HASH}" ] && [ "${SPEC_FIXUP_HASH}" != "x" ] && [ "${SPEC_FIXUP_HASH}" != "${SPEC_HASH}" ]; then |
| 1376 | FIXUP_HASH="|${SPEC_FIXUP_HASH}" |
| 1377 | fi |
| 1378 | printf '%s%s%s%s%s%s\n' "${PRODUCT_PACKAGE}" "${SRC}" "${DST}" "${ARGS}" "${HASH}" "${FIXUP_HASH}" |
| 1379 | } |
| 1380 | |
| 1381 | # To be overridden by device-level extract-files.sh |
| 1382 | # Parameters: |
| 1383 | # $1: spec name of a blob. Can be used for filtering. |
| 1384 | # If the spec is "src:dest", then $1 is "dest". |
| 1385 | # If the spec is "src", then $1 is "src". |
| 1386 | # $2: path to blob file. Can be used for fixups. |
| 1387 | # |
| 1388 | function blob_fixup() { |
| 1389 | : |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1390 | } |
| 1391 | |
Luca Stefani | 3a03012 | 2016-07-30 12:08:25 +0200 | [diff] [blame] | 1392 | # |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1393 | # extract: |
| 1394 | # |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1395 | # Positional parameters: |
| 1396 | # $1: file containing the list of items to extract (aka proprietary-files.txt) |
Dan Pasanen | 7dc287f | 2017-03-21 09:06:11 -0500 | [diff] [blame] | 1397 | # $2: path to extracted system folder, an ota zip file, or "adb" to extract from device |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1398 | # $3: section in list file to extract - optional. Setting section via $3 is deprecated. |
| 1399 | # |
| 1400 | # Non-positional parameters (coming after $2): |
| 1401 | # --section: preferred way of selecting the portion to parse and extract from |
| 1402 | # proprietary-files.txt |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1403 | # --kang: if present, this option will activate the printing of hashes for the |
| 1404 | # extracted blobs. Useful with --section for subsequent pinning of |
| 1405 | # blobs taken from other origins. |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1406 | # |
| 1407 | function extract() { |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1408 | # Consume positional parameters |
| 1409 | local PROPRIETARY_FILES_TXT="$1"; shift |
| 1410 | local SRC="$1"; shift |
| 1411 | local SECTION="" |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1412 | local KANG=false |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1413 | |
| 1414 | # Consume optional, non-positional parameters |
| 1415 | while [ "$#" -gt 0 ]; do |
| 1416 | case "$1" in |
| 1417 | -s|--section) |
| 1418 | SECTION="$2"; shift |
| 1419 | ;; |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1420 | -k|--kang) |
| 1421 | KANG=true |
| 1422 | DISABLE_PINNING=1 |
| 1423 | ;; |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1424 | *) |
| 1425 | # Backwards-compatibility with the old behavior, where $3, if |
| 1426 | # present, denoted an optional positional ${SECTION} argument. |
| 1427 | # Users of ${SECTION} are encouraged to migrate from setting it as |
| 1428 | # positional $3, to non-positional --section ${SECTION}, the |
| 1429 | # reason being that it doesn't scale to have more than 1 optional |
| 1430 | # positional argument. |
| 1431 | SECTION="$1" |
| 1432 | ;; |
| 1433 | esac |
| 1434 | shift |
| 1435 | done |
| 1436 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1437 | if [ -z "$OUTDIR" ]; then |
| 1438 | echo "Output dir not set!" |
| 1439 | exit 1 |
| 1440 | fi |
| 1441 | |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1442 | parse_file_list "${PROPRIETARY_FILES_TXT}" "${SECTION}" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1443 | |
| 1444 | # Allow failing, so we can try $DEST and/or $FILE |
| 1445 | set +e |
| 1446 | |
| 1447 | local FILELIST=( ${PRODUCT_COPY_FILES_LIST[@]} ${PRODUCT_PACKAGES_LIST[@]} ) |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1448 | local HASHLIST=( ${PRODUCT_COPY_FILES_HASHES[@]} ${PRODUCT_PACKAGES_HASHES[@]} ) |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1449 | local FIXUP_HASHLIST=( ${PRODUCT_COPY_FILES_FIXUP_HASHES[@]} ${PRODUCT_PACKAGES_FIXUP_HASHES[@]} ) |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1450 | local PRODUCT_COPY_FILES_COUNT=${#PRODUCT_COPY_FILES_LIST[@]} |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1451 | local COUNT=${#FILELIST[@]} |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 1452 | local OUTPUT_ROOT="$LINEAGE_ROOT"/"$OUTDIR"/proprietary |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1453 | local OUTPUT_TMP="$TMPDIR"/"$OUTDIR"/proprietary |
| 1454 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1455 | if [ "$SRC" = "adb" ]; then |
| 1456 | init_adb_connection |
| 1457 | fi |
| 1458 | |
Dan Pasanen | 7dc287f | 2017-03-21 09:06:11 -0500 | [diff] [blame] | 1459 | if [ -f "$SRC" ] && [ "${SRC##*.}" == "zip" ]; then |
conbold | 575c635 | 2017-11-10 16:33:38 +0100 | [diff] [blame] | 1460 | DUMPDIR="$TMPDIR"/system_dump |
Dan Pasanen | 7dc287f | 2017-03-21 09:06:11 -0500 | [diff] [blame] | 1461 | |
| 1462 | # Check if we're working with the same zip that was passed last time. |
| 1463 | # If so, let's just use what's already extracted. |
| 1464 | MD5=`md5sum "$SRC"| awk '{print $1}'` |
| 1465 | OLDMD5=`cat "$DUMPDIR"/zipmd5.txt` |
| 1466 | |
| 1467 | if [ "$MD5" != "$OLDMD5" ]; then |
| 1468 | rm -rf "$DUMPDIR" |
| 1469 | mkdir "$DUMPDIR" |
| 1470 | unzip "$SRC" -d "$DUMPDIR" |
| 1471 | echo "$MD5" > "$DUMPDIR"/zipmd5.txt |
| 1472 | |
| 1473 | # Stop if an A/B OTA zip is detected. We cannot extract these. |
| 1474 | if [ -a "$DUMPDIR"/payload.bin ]; then |
| 1475 | echo "A/B style OTA zip detected. This is not supported at this time. Stopping..." |
| 1476 | exit 1 |
Dan Pasanen | 7dc287f | 2017-03-21 09:06:11 -0500 | [diff] [blame] | 1477 | fi |
dianlujitao | fc48634 | 2020-04-21 23:03:20 +0800 | [diff] [blame] | 1478 | |
| 1479 | for PARTITION in "system" "odm" "product" "vendor" |
| 1480 | do |
| 1481 | # If OTA is block based, extract it. |
dianlujitao | ee95f24 | 2020-04-21 23:01:13 +0800 | [diff] [blame] | 1482 | if [ -a "$DUMPDIR"/"$PARTITION".new.dat.br ]; then |
| 1483 | echo "Converting "$PARTITION".new.dat.br to "$PARTITION".new.dat" |
| 1484 | brotli -d "$DUMPDIR"/"$PARTITION".new.dat.br |
| 1485 | rm "$DUMPDIR"/"$PARTITION".new.dat.br |
| 1486 | fi |
dianlujitao | fc48634 | 2020-04-21 23:03:20 +0800 | [diff] [blame] | 1487 | if [ -a "$DUMPDIR"/"$PARTITION".new.dat ]; then |
| 1488 | echo "Converting "$PARTITION".new.dat to "$PARTITION".img" |
| 1489 | python "$LINEAGE_ROOT"/vendor/lineage/build/tools/sdat2img.py "$DUMPDIR"/"$PARTITION".transfer.list "$DUMPDIR"/"$PARTITION".new.dat "$DUMPDIR"/"$PARTITION".img 2>&1 |
| 1490 | rm -rf "$DUMPDIR"/"$PARTITION".new.dat "$DUMPDIR"/"$PARTITION" |
| 1491 | mkdir "$DUMPDIR"/"$PARTITION" "$DUMPDIR"/tmp |
| 1492 | echo "Requesting sudo access to mount the "$PARTITION".img" |
| 1493 | sudo mount -o loop "$DUMPDIR"/"$PARTITION".img "$DUMPDIR"/tmp |
| 1494 | cp -r "$DUMPDIR"/tmp/* "$DUMPDIR"/"$PARTITION"/ |
| 1495 | sudo umount "$DUMPDIR"/tmp |
| 1496 | rm -rf "$DUMPDIR"/tmp "$DUMPDIR"/"$PARTITION".img |
| 1497 | fi |
| 1498 | done |
Dan Pasanen | 7dc287f | 2017-03-21 09:06:11 -0500 | [diff] [blame] | 1499 | fi |
| 1500 | |
| 1501 | SRC="$DUMPDIR" |
| 1502 | fi |
| 1503 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1504 | if [ "$VENDOR_STATE" -eq "0" ]; then |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 1505 | echo "Cleaning output directory ($OUTPUT_ROOT).." |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1506 | rm -rf "${OUTPUT_TMP:?}" |
| 1507 | mkdir -p "${OUTPUT_TMP:?}" |
Adrian DC | 3c6bdac | 2017-01-15 14:03:26 +0100 | [diff] [blame] | 1508 | if [ -d "$OUTPUT_ROOT" ]; then |
| 1509 | mv "${OUTPUT_ROOT:?}/"* "${OUTPUT_TMP:?}/" |
| 1510 | fi |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1511 | VENDOR_STATE=1 |
| 1512 | fi |
| 1513 | |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1514 | echo "Extracting ${COUNT} files in ${PROPRIETARY_FILES_TXT} from ${SRC}:" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1515 | |
| 1516 | for (( i=1; i<COUNT+1; i++ )); do |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 1517 | |
Vladimir Oltean | da3b644 | 2018-06-24 20:41:30 +0300 | [diff] [blame] | 1518 | local SPEC_SRC_FILE=$(src_file "${FILELIST[$i-1]}") |
Vladimir Oltean | 411e069 | 2018-06-24 20:38:04 +0300 | [diff] [blame] | 1519 | local SPEC_DST_FILE=$(target_file "${FILELIST[$i-1]}") |
Vladimir Oltean | d652a06 | 2018-06-24 20:42:01 +0300 | [diff] [blame] | 1520 | local SPEC_ARGS=$(target_args "${FILELIST[$i-1]}") |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1521 | local OUTPUT_DIR= |
| 1522 | local TMP_DIR= |
| 1523 | local SRC_FILE= |
| 1524 | local DST_FILE= |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1525 | local IS_PRODUCT_PACKAGE=false |
| 1526 | |
| 1527 | # Note: this relies on the fact that the ${FILELIST[@]} array |
| 1528 | # contains first ${PRODUCT_COPY_FILES_LIST[@]}, then ${PRODUCT_PACKAGES_LIST[@]}. |
| 1529 | if [ "${i}" -gt "${PRODUCT_COPY_FILES_COUNT}" ]; then |
| 1530 | IS_PRODUCT_PACKAGE=true |
| 1531 | fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 1532 | |
Vladimir Oltean | d652a06 | 2018-06-24 20:42:01 +0300 | [diff] [blame] | 1533 | if [ "${SPEC_ARGS}" = "rootfs" ]; then |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1534 | OUTPUT_DIR="${OUTPUT_ROOT}/rootfs" |
| 1535 | TMP_DIR="${OUTPUT_TMP}/rootfs" |
| 1536 | SRC_FILE="/${SPEC_SRC_FILE}" |
| 1537 | DST_FILE="/${SPEC_DST_FILE}" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1538 | else |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1539 | OUTPUT_DIR="${OUTPUT_ROOT}" |
| 1540 | TMP_DIR="${OUTPUT_TMP}" |
| 1541 | SRC_FILE="/system/${SPEC_SRC_FILE}" |
| 1542 | DST_FILE="/system/${SPEC_DST_FILE}" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1543 | fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 1544 | |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1545 | # Strip the file path in the vendor repo of "system", if present |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1546 | local BLOB_DISPLAY_NAME="${DST_FILE#/system/}" |
dianlujitao | db1caf4 | 2020-04-06 12:43:16 +0800 | [diff] [blame] | 1547 | local VENDOR_REPO_FILE="$OUTPUT_DIR/${BLOB_DISPLAY_NAME}" |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1548 | mkdir -p $(dirname "${VENDOR_REPO_FILE}") |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 1549 | |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1550 | # Check pinned files |
Vladimir Oltean | b2c3821 | 2019-01-17 02:47:02 +0200 | [diff] [blame] | 1551 | local HASH="$(echo ${HASHLIST[$i-1]} | awk '{ print tolower($0); }')" |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1552 | local FIXUP_HASH="$(echo ${FIXUP_HASHLIST[$i-1]} | awk '{ print tolower($0); }')" |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1553 | local KEEP="" |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1554 | if [ "$DISABLE_PINNING" != "1" ] && [ "$HASH" != "x" ]; then |
Vladimir Oltean | d674771 | 2018-06-24 20:46:42 +0300 | [diff] [blame] | 1555 | if [ -f "${VENDOR_REPO_FILE}" ]; then |
| 1556 | local PINNED="${VENDOR_REPO_FILE}" |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1557 | else |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1558 | local PINNED="${TMP_DIR}${DST_FILE#/system}" |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1559 | fi |
| 1560 | if [ -f "$PINNED" ]; then |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1561 | local TMP_HASH=$(get_hash "${PINNED}") |
| 1562 | if [ "${TMP_HASH}" = "${HASH}" ] || [ "${TMP_HASH}" = "${FIXUP_HASH}" ]; then |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1563 | KEEP="1" |
Vladimir Oltean | d674771 | 2018-06-24 20:46:42 +0300 | [diff] [blame] | 1564 | if [ ! -f "${VENDOR_REPO_FILE}" ]; then |
| 1565 | cp -p "$PINNED" "${VENDOR_REPO_FILE}" |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1566 | fi |
| 1567 | fi |
| 1568 | fi |
| 1569 | fi |
| 1570 | |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1571 | if [ "${KANG}" = false ]; then |
| 1572 | printf ' - %s\n' "${BLOB_DISPLAY_NAME}" |
| 1573 | fi |
| 1574 | |
Gabriele M | e6df25b | 2017-10-11 00:58:59 +0200 | [diff] [blame] | 1575 | if [ "$KEEP" = "1" ]; then |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1576 | printf ' + keeping pinned file with hash %s\n' "${HASH}" |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1577 | else |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1578 | FOUND=false |
| 1579 | # Try Lineage target first. |
| 1580 | # Also try to search for files stripped of |
| 1581 | # the "/system" prefix, if we're actually extracting |
| 1582 | # from a system image. |
Vladimir Oltean | d577325 | 2018-06-25 00:05:56 +0300 | [diff] [blame] | 1583 | for CANDIDATE in "${DST_FILE}" "${SRC_FILE}"; do |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1584 | get_file ${CANDIDATE} ${VENDOR_REPO_FILE} ${SRC} && { |
| 1585 | FOUND=true |
| 1586 | break |
| 1587 | } |
| 1588 | done |
| 1589 | |
| 1590 | if [ "${FOUND}" = false ]; then |
Vladimir Oltean | c503446 | 2019-01-17 03:04:16 +0200 | [diff] [blame] | 1591 | printf ' !! %s: file not found in source\n' "${BLOB_DISPLAY_NAME}" |
Vladimir Oltean | b8084ec | 2018-10-18 00:44:02 +0300 | [diff] [blame] | 1592 | continue |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1593 | fi |
| 1594 | fi |
Steve Kondik | a991cf1 | 2016-07-28 12:13:12 -0700 | [diff] [blame] | 1595 | |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1596 | # Blob fixup pipeline has 2 parts: one that is fixed and |
| 1597 | # one that is user-configurable |
| 1598 | local PRE_FIXUP_HASH=$(get_hash ${VENDOR_REPO_FILE}) |
| 1599 | # Deodex apk|jar if that's the case |
| 1600 | if [[ "$FULLY_DEODEXED" -ne "1" && "${VENDOR_REPO_FILE}" =~ .(apk|jar)$ ]]; then |
| 1601 | oat2dex "${VENDOR_REPO_FILE}" "${SRC_FILE}" "$SRC" |
| 1602 | if [ -f "$TMPDIR/classes.dex" ]; then |
dianlujitao | 0b501d5 | 2020-04-06 12:45:36 +0800 | [diff] [blame] | 1603 | touch -t 200901010000 "$TMPDIR/classes"* |
Rashed Abdel-Tawab | 19c36cd | 2018-03-15 12:55:22 -0700 | [diff] [blame] | 1604 | zip -gjq "${VENDOR_REPO_FILE}" "$TMPDIR/classes"* |
| 1605 | rm "$TMPDIR/classes"* |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1606 | printf ' (updated %s from odex files)\n' "${SRC_FILE}" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1607 | fi |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1608 | elif [[ "${VENDOR_REPO_FILE}" =~ .xml$ ]]; then |
| 1609 | fix_xml "${VENDOR_REPO_FILE}" |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1610 | fi |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1611 | # Now run user-supplied fixup function |
| 1612 | blob_fixup "${BLOB_DISPLAY_NAME}" "${VENDOR_REPO_FILE}" |
| 1613 | local POST_FIXUP_HASH=$(get_hash ${VENDOR_REPO_FILE}) |
Luca Stefani | 7f9fff2 | 2016-07-18 13:47:55 +0200 | [diff] [blame] | 1614 | |
Vladimir Oltean | d674771 | 2018-06-24 20:46:42 +0300 | [diff] [blame] | 1615 | if [ -f "${VENDOR_REPO_FILE}" ]; then |
Vladimir Oltean | 5f15e3e | 2018-06-24 21:06:12 +0300 | [diff] [blame] | 1616 | local DIR=$(dirname "${VENDOR_REPO_FILE}") |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1617 | local TYPE="${DIR##*/}" |
| 1618 | if [ "$TYPE" = "bin" -o "$TYPE" = "sbin" ]; then |
Vladimir Oltean | d674771 | 2018-06-24 20:46:42 +0300 | [diff] [blame] | 1619 | chmod 755 "${VENDOR_REPO_FILE}" |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1620 | else |
Vladimir Oltean | d674771 | 2018-06-24 20:46:42 +0300 | [diff] [blame] | 1621 | chmod 644 "${VENDOR_REPO_FILE}" |
Steve Kondik | 48f8df8 | 2016-08-14 03:55:08 -0700 | [diff] [blame] | 1622 | fi |
| 1623 | fi |
| 1624 | |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1625 | if [ "${KANG}" = true ]; then |
Vladimir Oltean | 4818c23 | 2019-01-17 03:07:34 +0200 | [diff] [blame] | 1626 | print_spec "${IS_PRODUCT_PACKAGE}" "${SPEC_SRC_FILE}" "${SPEC_DST_FILE}" "${SPEC_ARGS}" "${PRE_FIXUP_HASH}" "${POST_FIXUP_HASH}" |
| 1627 | fi |
| 1628 | |
| 1629 | # Check and print whether the fixup pipeline actually did anything. |
| 1630 | # This isn't done right after the fixup pipeline because we want this print |
| 1631 | # to come after print_spec above, when in kang mode. |
| 1632 | if [ "${PRE_FIXUP_HASH}" != "${POST_FIXUP_HASH}" ]; then |
| 1633 | printf " + Fixed up %s\n" "${BLOB_DISPLAY_NAME}" |
| 1634 | # Now sanity-check the spec for this blob. |
| 1635 | if [ "${KANG}" = false ] && [ "${FIXUP_HASH}" = "x" ] && [ "${HASH}" != "x" ]; then |
| 1636 | printf "WARNING: The %s file was fixed up, but it is pinned.\n" ${BLOB_DISPLAY_NAME} |
| 1637 | printf "This is a mistake and you want to either remove the hash completely, or add an extra one.\n" |
| 1638 | fi |
Vladimir Oltean | bec92eb | 2019-01-17 03:05:52 +0200 | [diff] [blame] | 1639 | fi |
| 1640 | |
Steve Kondik | 4e2aaab | 2016-07-15 10:39:58 -0700 | [diff] [blame] | 1641 | done |
| 1642 | |
| 1643 | # Don't allow failing |
| 1644 | set -e |
| 1645 | } |
Louis Popi | a516c2f | 2016-07-25 15:51:13 +0200 | [diff] [blame] | 1646 | |
| 1647 | # |
| 1648 | # extract_firmware: |
| 1649 | # |
| 1650 | # $1: file containing the list of items to extract |
| 1651 | # $2: path to extracted radio folder |
| 1652 | # |
| 1653 | function extract_firmware() { |
| 1654 | if [ -z "$OUTDIR" ]; then |
| 1655 | echo "Output dir not set!" |
| 1656 | exit 1 |
| 1657 | fi |
| 1658 | |
| 1659 | parse_file_list "$1" |
| 1660 | |
| 1661 | # Don't allow failing |
| 1662 | set -e |
| 1663 | |
| 1664 | local FILELIST=( ${PRODUCT_COPY_FILES_LIST[@]} ) |
| 1665 | local COUNT=${#FILELIST[@]} |
| 1666 | local SRC="$2" |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 1667 | local OUTPUT_DIR="$LINEAGE_ROOT"/"$OUTDIR"/radio |
Louis Popi | a516c2f | 2016-07-25 15:51:13 +0200 | [diff] [blame] | 1668 | |
| 1669 | if [ "$VENDOR_RADIO_STATE" -eq "0" ]; then |
| 1670 | echo "Cleaning firmware output directory ($OUTPUT_DIR).." |
| 1671 | rm -rf "${OUTPUT_DIR:?}/"* |
| 1672 | VENDOR_RADIO_STATE=1 |
| 1673 | fi |
| 1674 | |
| 1675 | echo "Extracting $COUNT files in $1 from $SRC:" |
| 1676 | |
| 1677 | for (( i=1; i<COUNT+1; i++ )); do |
| 1678 | local FILE="${FILELIST[$i-1]}" |
| 1679 | printf ' - %s \n' "/radio/$FILE" |
| 1680 | |
| 1681 | if [ ! -d "$OUTPUT_DIR" ]; then |
| 1682 | mkdir -p "$OUTPUT_DIR" |
| 1683 | fi |
| 1684 | cp "$SRC/$FILE" "$OUTPUT_DIR/$FILE" |
| 1685 | chmod 644 "$OUTPUT_DIR/$FILE" |
| 1686 | done |
| 1687 | } |
Rashed Abdel-Tawab | 1c29c37 | 2019-03-29 20:07:25 -0700 | [diff] [blame] | 1688 | |
| 1689 | function extract_img_data() { |
| 1690 | local image_file="$1" |
| 1691 | local out_dir="$2" |
| 1692 | local logFile="$TMPDIR/debugfs.log" |
| 1693 | |
| 1694 | if [ ! -d "$out_dir" ]; then |
| 1695 | mkdir -p "$out_dir" |
| 1696 | fi |
| 1697 | |
| 1698 | if [[ "$HOST_OS" == "Darwin" ]]; then |
| 1699 | debugfs -R "rdump / \"$out_dir\"" "$image_file" &> "$logFile" || { |
| 1700 | echo "[-] Failed to extract data from '$image_file'" |
| 1701 | abort 1 |
| 1702 | } |
| 1703 | else |
| 1704 | debugfs -R 'ls -p' "$image_file" 2>/dev/null | cut -d '/' -f6 | while read -r entry |
| 1705 | do |
| 1706 | debugfs -R "rdump \"$entry\" \"$out_dir\"" "$image_file" >> "$logFile" 2>&1 || { |
| 1707 | echo "[-] Failed to extract data from '$image_file'" |
| 1708 | abort 1 |
| 1709 | } |
| 1710 | done |
| 1711 | fi |
| 1712 | |
| 1713 | local symlink_err="rdump: Attempt to read block from filesystem resulted in short read while reading symlink" |
| 1714 | if grep -Fq "$symlink_err" "$logFile"; then |
| 1715 | echo "[-] Symlinks have not been properly processed from $image_file" |
| 1716 | echo "[!] If you don't have a compatible debugfs version, modify 'execute-all.sh' to disable 'USE_DEBUGFS' flag" |
| 1717 | abort 1 |
| 1718 | fi |
| 1719 | } |
| 1720 | |
| 1721 | declare -ra VENDOR_SKIP_FILES=( |
| 1722 | "bin/toybox_vendor" |
| 1723 | "bin/toolbox" |
| 1724 | "bin/grep" |
| 1725 | "build.prop" |
| 1726 | "compatibility_matrix.xml" |
| 1727 | "default.prop" |
| 1728 | "etc/NOTICE.xml.gz" |
| 1729 | "etc/vintf/compatibility_matrix.xml" |
| 1730 | "etc/vintf/manifest.xml" |
| 1731 | "etc/wifi/wpa_supplicant.conf" |
| 1732 | "manifest.xml" |
| 1733 | "overlay/DisplayCutoutEmulationCorner/DisplayCutoutEmulationCornerOverlay.apk" |
| 1734 | "overlay/DisplayCutoutEmulationDouble/DisplayCutoutEmulationDoubleOverlay.apk" |
| 1735 | "overlay/DisplayCutoutEmulationTall/DisplayCutoutEmulationTallOverlay.apk" |
| 1736 | "overlay/DisplayCutoutNoCutout/NoCutoutOverlay.apk" |
| 1737 | "overlay/framework-res__auto_generated_rro.apk" |
| 1738 | "overlay/SysuiDarkTheme/SysuiDarkThemeOverlay.apk" |
| 1739 | ) |
| 1740 | |
| 1741 | function array_contains() { |
| 1742 | local element |
| 1743 | for element in "${@:2}"; do [[ "$element" == "$1" ]] && return 0; done |
| 1744 | return 1 |
| 1745 | } |
| 1746 | |
| 1747 | function generate_prop_list_from_image() { |
| 1748 | local image_file="$1" |
| 1749 | local image_dir="$TMPDIR/image-temp" |
| 1750 | local output_list="$2" |
| 1751 | local output_list_tmp="$TMPDIR/_proprietary-blobs.txt" |
| 1752 | local -n skipped_vendor_files="$3" |
| 1753 | |
| 1754 | extract_img_data "$image_file" "$image_dir" |
| 1755 | |
| 1756 | find "$image_dir" -not -type d | sed "s#^$image_dir/##" | while read -r FILE |
| 1757 | do |
| 1758 | # Skip VENDOR_SKIP_FILES since it will be re-generated at build time |
| 1759 | if array_contains "$FILE" "${VENDOR_SKIP_FILES[@]}"; then |
| 1760 | continue |
| 1761 | fi |
| 1762 | # Skip device defined skipped files since they will be re-generated at build time |
| 1763 | if array_contains "$FILE" "${skipped_vendor_files[@]}"; then |
| 1764 | continue |
| 1765 | fi |
| 1766 | if suffix_match_file ".apk" "$FILE" ; then |
| 1767 | echo "-vendor/$FILE" >> "$output_list_tmp" |
| 1768 | else |
| 1769 | echo "vendor/$FILE" >> "$output_list_tmp" |
| 1770 | fi |
| 1771 | done |
| 1772 | |
| 1773 | # Sort merged file with all lists |
| 1774 | sort -u "$output_list_tmp" > "$output_list" |
| 1775 | |
| 1776 | # Clean-up |
| 1777 | rm -f "$output_list_tmp" |
| 1778 | } |