Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # Copyright (C) 2010 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # This script auto-generates the scripts that manage the handling of the |
| 18 | # proprietary blobs necessary to build the Android Open-Source Project code |
Jean-Baptiste Queru | e80457e | 2010-09-26 07:11:27 -0700 | [diff] [blame] | 19 | # for passion and crespo targets |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 20 | |
| 21 | # It needs to be run from the root of a source tree that can repo sync, |
| 22 | # runs builds with and without the vendor tree, and uses the difference |
| 23 | # to generate the scripts. |
| 24 | |
| 25 | # It can optionally upload the results to a Gerrit server for review. |
| 26 | |
| 27 | # WARNING: It destroys the source tree. Don't leave anything precious there. |
| 28 | |
| 29 | # Caveat: this script does many full builds (2 per device). It takes a while |
| 30 | # to run. It's best # suited for overnight runs on multi-CPU machines |
| 31 | # with a lot of RAM. |
| 32 | |
| 33 | # Syntax: device/common/generate-blob-scripts.sh -f|--force [<server> <branch>] |
| 34 | # |
| 35 | # If the server and branch paramters are both present, the script will upload |
| 36 | # new files (if there's been any change) to the mentioned Gerrit server, |
| 37 | # in the specified branch. |
| 38 | |
| 39 | if test "$1" != "-f" -a "$1" != "--force" |
| 40 | then |
| 41 | echo This script must be run with the --force option |
| 42 | exit 1 |
| 43 | fi |
| 44 | shift |
| 45 | |
Jean-Baptiste Queru | 0f9f60a | 2011-06-02 08:59:48 -0700 | [diff] [blame] | 46 | DEVICES="crespo crespo4g stingray wingray tuna toro panda" |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 47 | |
| 48 | ARCHIVEDIR=archive-$(date +%s) |
| 49 | mkdir $ARCHIVEDIR |
| 50 | |
| 51 | repo sync |
| 52 | repo sync |
| 53 | repo sync |
Jean-Baptiste Queru | 4b168d3 | 2011-04-21 19:31:21 -0700 | [diff] [blame] | 54 | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 55 | . build/envsetup.sh |
| 56 | for DEVICENAME in $DEVICES |
| 57 | do |
| 58 | rm -rf out |
| 59 | lunch full_$DEVICENAME-user |
Jean-Baptiste Queru | 923fa91 | 2010-10-19 17:48:31 -0700 | [diff] [blame] | 60 | make -j32 |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 61 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 62 | cut -b 15- | |
Jean-Baptiste Queru | 923fa91 | 2010-10-19 17:48:31 -0700 | [diff] [blame] | 63 | sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 64 | done |
| 65 | rm -rf vendor |
| 66 | for DEVICENAME in $DEVICES |
| 67 | do |
| 68 | rm -rf out |
| 69 | lunch full_$DEVICENAME-user |
Jean-Baptiste Queru | 923fa91 | 2010-10-19 17:48:31 -0700 | [diff] [blame] | 70 | make -j32 |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 71 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 72 | cut -b 15- | |
Jean-Baptiste Queru | 923fa91 | 2010-10-19 17:48:31 -0700 | [diff] [blame] | 73 | sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 74 | done |
| 75 | |
| 76 | for DEVICENAME in $DEVICES |
| 77 | do |
| 78 | MANUFACTURERNAME=$( find device -type d | grep [^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / ) |
| 79 | for FILESTYLE in extract unzip |
| 80 | do |
| 81 | ( |
| 82 | echo '#!/bin/sh' |
| 83 | echo |
| 84 | echo '# Copyright (C) 2010 The Android Open Source Project' |
| 85 | echo '#' |
| 86 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 87 | echo '# you may not use this file except in compliance with the License.' |
| 88 | echo '# You may obtain a copy of the License at' |
| 89 | echo '#' |
| 90 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 91 | echo '#' |
| 92 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 93 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 94 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 95 | echo '# See the License for the specific language governing permissions and' |
| 96 | echo '# limitations under the License.' |
| 97 | echo |
| 98 | echo '# This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT' |
| 99 | echo |
| 100 | echo DEVICE=$DEVICENAME |
| 101 | echo MANUFACTURER=$MANUFACTURERNAME |
| 102 | echo |
| 103 | echo 'mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary' |
| 104 | |
| 105 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
Jean-Baptiste Queru | 1b83f68 | 2011-06-06 10:44:27 -0700 | [diff] [blame] | 106 | grep -v '\.odex$' | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 107 | grep '>' | |
| 108 | cut -b 3- | |
| 109 | while read FULLPATH |
| 110 | do |
| 111 | if test $FILESTYLE = extract |
| 112 | then |
| 113 | echo adb pull $FULLPATH ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH) |
| 114 | else |
| 115 | echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary |
| 116 | fi |
Jean-Baptiste Queru | bfe57a1 | 2010-09-24 13:53:17 -0700 | [diff] [blame] | 117 | if test $(basename $FULLPATH) = akmd -o $(basename $FULLPATH) = mm-venc-omx-test -o $(basename $FULLPATH) = parse_radio_log -o $(basename $FULLPATH) = akmd8973 -o $(basename $FULLPATH) = gpsd -o $(basename $FULLPATH) = pvrsrvinit |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 118 | then |
| 119 | echo chmod 755 ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH) |
| 120 | fi |
| 121 | done |
| 122 | echo |
| 123 | |
| 124 | echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/' |
Jean-Baptiste Queru | 548297c | 2010-09-22 10:15:03 -0700 | [diff] [blame] | 125 | echo 'device-vendor-blobs.mk' |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 126 | |
| 127 | echo '# Copyright (C) 2010 The Android Open Source Project' |
| 128 | echo '#' |
| 129 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 130 | echo '# you may not use this file except in compliance with the License.' |
| 131 | echo '# You may obtain a copy of the License at' |
| 132 | echo '#' |
| 133 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 134 | echo '#' |
| 135 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 136 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 137 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 138 | echo '# See the License for the specific language governing permissions and' |
| 139 | echo '# limitations under the License.' |
| 140 | echo |
| 141 | echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/' |
| 142 | echo -n $FILESTYLE |
| 143 | echo '-files.sh - DO NOT EDIT' |
| 144 | |
| 145 | FOUND=false |
| 146 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
Jean-Baptiste Queru | 1b83f68 | 2011-06-06 10:44:27 -0700 | [diff] [blame] | 147 | grep -v '\.odex$' | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 148 | grep '>' | |
| 149 | cut -b 3- | |
| 150 | while read FULLPATH |
| 151 | do |
Jean-Baptiste Queru | 90e32d5 | 2010-09-24 14:14:26 -0700 | [diff] [blame] | 152 | if test $(basename $FULLPATH) = libgps.so -o $(basename $FULLPATH) = libcamera.so -o $(basename $FULLPATH) = libsecril-client.so |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 153 | then |
| 154 | if test $FOUND = false |
| 155 | then |
| 156 | echo |
| 157 | echo '# Prebuilt libraries that are needed to build open-source libraries' |
| 158 | echo 'PRODUCT_COPY_FILES := \\' |
| 159 | else |
| 160 | echo \ \\\\ |
| 161 | fi |
| 162 | FOUND=true |
| 163 | echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):obj/lib/$(basename $FULLPATH) |
| 164 | fi |
| 165 | done |
| 166 | echo |
| 167 | |
| 168 | FOUND=false |
| 169 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
Jean-Baptiste Queru | 1b83f68 | 2011-06-06 10:44:27 -0700 | [diff] [blame] | 170 | grep -v '\.odex$' | |
Jean-Baptiste Queru | 4ef1167 | 2011-06-08 17:12:18 -0700 | [diff] [blame] | 171 | grep -v '\.apk$' | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 172 | grep '>' | |
| 173 | cut -b 3- | |
| 174 | while read FULLPATH |
| 175 | do |
| 176 | if test $FOUND = false |
| 177 | then |
| 178 | echo |
| 179 | echo -n '# All the blobs necessary for ' |
| 180 | echo $DEVICENAME |
| 181 | echo 'PRODUCT_COPY_FILES += \\' |
| 182 | else |
| 183 | echo \ \\\\ |
| 184 | fi |
| 185 | FOUND=true |
| 186 | echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-) |
| 187 | done |
| 188 | echo |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 189 | |
| 190 | FOUND=false |
| 191 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 192 | grep '\.apk$' | |
| 193 | grep '>' | |
| 194 | cut -b 3- | |
| 195 | while read FULLPATH |
| 196 | do |
| 197 | if test $FOUND = false |
| 198 | then |
| 199 | echo |
| 200 | echo -n '# All the apks necessary for ' |
| 201 | echo $DEVICENAME |
| 202 | echo 'PRODUCT_PACKAGES += \\' |
| 203 | else |
| 204 | echo \ \\\\ |
| 205 | fi |
| 206 | FOUND=true |
| 207 | echo -n \ \ \ \ |
| 208 | echo -n $(basename $FULLPATH) | sed 's/\.apk//g' |
| 209 | done |
| 210 | echo |
| 211 | |
| 212 | echo 'EOF' |
| 213 | |
| 214 | echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/' |
| 215 | echo 'proprietary/Android.mk' |
| 216 | |
| 217 | echo '# Copyright (C) 2011 The Android Open Source Project' |
| 218 | echo '#' |
| 219 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 220 | echo '# you may not use this file except in compliance with the License.' |
| 221 | echo '# You may obtain a copy of the License at' |
| 222 | echo '#' |
| 223 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 224 | echo '#' |
| 225 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 226 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 227 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 228 | echo '# See the License for the specific language governing permissions and' |
| 229 | echo '# limitations under the License.' |
| 230 | echo |
| 231 | echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/' |
| 232 | echo -n $FILESTYLE |
| 233 | echo '-files.sh - DO NOT EDIT' |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame^] | 234 | echo |
| 235 | echo ifeq \(\\\$\(TARGET_DEVICE\),$DEVICENAME\) |
| 236 | echo LOCAL_PATH:=\\\$\(call my-dir\) |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 237 | |
| 238 | FOUND=false |
| 239 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 240 | grep '\.apk$' | |
| 241 | grep '>' | |
| 242 | cut -b 3- | |
| 243 | while read FULLPATH |
| 244 | do |
| 245 | if test $FOUND = false |
| 246 | then |
| 247 | echo |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame^] | 248 | echo -n '# Module makefile rules for apks on ' |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 249 | echo $DEVICENAME |
| 250 | fi |
| 251 | FOUND=true |
| 252 | echo |
| 253 | echo -n '# ' |
| 254 | echo $(basename $FULLPATH) | sed 's/\.apk//g' |
| 255 | echo |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame^] | 256 | echo include \\\$\(CLEAR_VARS\) |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 257 | echo |
| 258 | echo LOCAL_MODULE := $(basename $FULLPATH) | sed 's/\.apk//g' |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame^] | 259 | echo LOCAL_SRC_FILES := \\\$\(LOCAL_MODULE\).apk |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 260 | echo LOCAL_MODULE_CLASS := APPS |
| 261 | echo LOCAL_MODULE_TAGS := optional |
| 262 | echo LOCAL_CERTIFICATE := PRESIGNED |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame^] | 263 | echo LOCAL_MODULE_SUFFIX := \\\$\(COMMON_ANDROID_PACKAGE_SUFFIX\) |
| 264 | echo include \\\$\(BUILD_PREBUILT\) |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 265 | done |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame^] | 266 | echo |
| 267 | echo endif |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 268 | echo |
| 269 | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 270 | echo 'EOF' |
| 271 | echo |
| 272 | echo './setup-makefiles.sh' |
| 273 | |
| 274 | ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh |
| 275 | cp $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh |
Jean-Baptiste Queru | 1a9cdef | 2011-04-15 15:28:48 -0700 | [diff] [blame] | 276 | chmod a+x device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 277 | done |
| 278 | |
| 279 | ( |
| 280 | cd device/$MANUFACTURERNAME/$DEVICENAME |
| 281 | git add . |
| 282 | git commit -m "auto-generated blob-handling scripts" |
| 283 | if test "$1" != "" -a "$2" != "" |
| 284 | then |
| 285 | echo uploading to server $1 branch $2 |
| 286 | git push ssh://$1:29418/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2 |
| 287 | fi |
| 288 | ) |
| 289 | |
| 290 | done |
| 291 | |
| 292 | echo * device/* | |
| 293 | tr \ \\n | |
| 294 | grep -v ^archive- | |
| 295 | grep -v ^device$ | |
| 296 | grep -v ^device/common$ | |
| 297 | xargs rm -rf |