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 | 2a977f7 | 2011-06-10 10:22:20 -0700 | [diff] [blame] | 19 | # for a variety of hardware 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 | 7d45265 | 2012-01-23 15:38:47 -0800 | [diff] [blame] | 46 | DEVICES="crespo crespo4g stingray wingray panda toro torospr maguro" |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 47 | |
Jean-Baptiste Queru | 66247cd | 2011-06-10 10:04:50 -0700 | [diff] [blame] | 48 | repo sync |
| 49 | repo sync |
| 50 | repo sync |
| 51 | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 52 | ARCHIVEDIR=archive-$(date +%s) |
Jean-Baptiste Queru | 66247cd | 2011-06-10 10:04:50 -0700 | [diff] [blame] | 53 | if test -d archive-ref |
| 54 | then |
| 55 | cp -R archive-ref $ARCHIVEDIR |
| 56 | else |
| 57 | mkdir $ARCHIVEDIR |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 58 | |
Jean-Baptiste Queru | 66247cd | 2011-06-10 10:04:50 -0700 | [diff] [blame] | 59 | . build/envsetup.sh |
| 60 | for DEVICENAME in $DEVICES |
| 61 | do |
| 62 | rm -rf out |
| 63 | lunch full_$DEVICENAME-user |
| 64 | make -j32 |
| 65 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 66 | cut -b 15- | |
| 67 | sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt |
| 68 | done |
| 69 | rm -rf vendor |
| 70 | for DEVICENAME in $DEVICES |
| 71 | do |
| 72 | rm -rf out |
| 73 | lunch full_$DEVICENAME-user |
| 74 | make -j32 |
| 75 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 76 | cut -b 15- | |
| 77 | sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt |
| 78 | done |
| 79 | fi |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 80 | |
| 81 | for DEVICENAME in $DEVICES |
| 82 | do |
| 83 | MANUFACTURERNAME=$( find device -type d | grep [^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / ) |
| 84 | for FILESTYLE in extract unzip |
| 85 | do |
| 86 | ( |
| 87 | echo '#!/bin/sh' |
| 88 | echo |
| 89 | echo '# Copyright (C) 2010 The Android Open Source Project' |
| 90 | echo '#' |
| 91 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 92 | echo '# you may not use this file except in compliance with the License.' |
| 93 | echo '# You may obtain a copy of the License at' |
| 94 | echo '#' |
| 95 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 96 | echo '#' |
| 97 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 98 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 99 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 100 | echo '# See the License for the specific language governing permissions and' |
| 101 | echo '# limitations under the License.' |
| 102 | echo |
| 103 | echo '# This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT' |
| 104 | echo |
| 105 | echo DEVICE=$DEVICENAME |
| 106 | echo MANUFACTURER=$MANUFACTURERNAME |
| 107 | echo |
| 108 | echo 'mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary' |
| 109 | |
| 110 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
Jean-Baptiste Queru | 1b83f68 | 2011-06-06 10:44:27 -0700 | [diff] [blame] | 111 | grep -v '\.odex$' | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 112 | grep '>' | |
| 113 | cut -b 3- | |
| 114 | while read FULLPATH |
| 115 | do |
| 116 | if test $FILESTYLE = extract |
| 117 | then |
| 118 | echo adb pull $FULLPATH ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH) |
| 119 | else |
| 120 | echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary |
| 121 | fi |
Jean-Baptiste Queru | 21927ce | 2011-10-01 11:35:35 -0700 | [diff] [blame] | 122 | 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 -o $(basename $FULLPATH) = fRom |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 123 | then |
| 124 | echo chmod 755 ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH) |
| 125 | fi |
| 126 | done |
| 127 | echo |
| 128 | |
| 129 | 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] | 130 | echo 'device-vendor-blobs.mk' |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 131 | |
| 132 | echo '# Copyright (C) 2010 The Android Open Source Project' |
| 133 | echo '#' |
| 134 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 135 | echo '# you may not use this file except in compliance with the License.' |
| 136 | echo '# You may obtain a copy of the License at' |
| 137 | echo '#' |
| 138 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 139 | echo '#' |
| 140 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 141 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 142 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 143 | echo '# See the License for the specific language governing permissions and' |
| 144 | echo '# limitations under the License.' |
| 145 | echo |
| 146 | echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/' |
| 147 | echo -n $FILESTYLE |
| 148 | echo '-files.sh - DO NOT EDIT' |
| 149 | |
| 150 | FOUND=false |
| 151 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
Jean-Baptiste Queru | 1b83f68 | 2011-06-06 10:44:27 -0700 | [diff] [blame] | 152 | grep -v '\.odex$' | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 153 | grep '>' | |
| 154 | cut -b 3- | |
| 155 | while read FULLPATH |
| 156 | do |
Jean-Baptiste Queru | 90e32d5 | 2010-09-24 14:14:26 -0700 | [diff] [blame] | 157 | 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] | 158 | then |
| 159 | if test $FOUND = false |
| 160 | then |
| 161 | echo |
| 162 | echo '# Prebuilt libraries that are needed to build open-source libraries' |
| 163 | echo 'PRODUCT_COPY_FILES := \\' |
| 164 | else |
| 165 | echo \ \\\\ |
| 166 | fi |
| 167 | FOUND=true |
| 168 | echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):obj/lib/$(basename $FULLPATH) |
| 169 | fi |
| 170 | done |
| 171 | echo |
| 172 | |
| 173 | FOUND=false |
| 174 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
Jean-Baptiste Queru | 1b83f68 | 2011-06-06 10:44:27 -0700 | [diff] [blame] | 175 | grep -v '\.odex$' | |
Jean-Baptiste Queru | 4ef1167 | 2011-06-08 17:12:18 -0700 | [diff] [blame] | 176 | grep -v '\.apk$' | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 177 | grep '>' | |
| 178 | cut -b 3- | |
| 179 | while read FULLPATH |
| 180 | do |
| 181 | if test $FOUND = false |
| 182 | then |
| 183 | echo |
| 184 | echo -n '# All the blobs necessary for ' |
| 185 | echo $DEVICENAME |
| 186 | echo 'PRODUCT_COPY_FILES += \\' |
| 187 | else |
| 188 | echo \ \\\\ |
| 189 | fi |
| 190 | FOUND=true |
| 191 | echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-) |
| 192 | done |
| 193 | echo |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 194 | |
| 195 | FOUND=false |
| 196 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 197 | grep '\.apk$' | |
| 198 | grep '>' | |
| 199 | cut -b 3- | |
| 200 | while read FULLPATH |
| 201 | do |
| 202 | if test $FOUND = false |
| 203 | then |
| 204 | echo |
| 205 | echo -n '# All the apks necessary for ' |
| 206 | echo $DEVICENAME |
| 207 | echo 'PRODUCT_PACKAGES += \\' |
| 208 | else |
| 209 | echo \ \\\\ |
| 210 | fi |
| 211 | FOUND=true |
| 212 | echo -n \ \ \ \ |
| 213 | echo -n $(basename $FULLPATH) | sed 's/\.apk//g' |
| 214 | done |
| 215 | echo |
| 216 | |
Jean-Baptiste Queru | 70bda67 | 2011-06-10 13:41:18 -0700 | [diff] [blame] | 217 | echo |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 218 | echo 'EOF' |
| 219 | |
Jean-Baptiste Queru | 70bda67 | 2011-06-10 13:41:18 -0700 | [diff] [blame] | 220 | echo |
| 221 | |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 222 | echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/' |
| 223 | echo 'proprietary/Android.mk' |
| 224 | |
| 225 | echo '# Copyright (C) 2011 The Android Open Source Project' |
| 226 | echo '#' |
| 227 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 228 | echo '# you may not use this file except in compliance with the License.' |
| 229 | echo '# You may obtain a copy of the License at' |
| 230 | echo '#' |
| 231 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 232 | echo '#' |
| 233 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 234 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 235 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 236 | echo '# See the License for the specific language governing permissions and' |
| 237 | echo '# limitations under the License.' |
| 238 | echo |
| 239 | echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/' |
| 240 | echo -n $FILESTYLE |
| 241 | echo '-files.sh - DO NOT EDIT' |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame] | 242 | echo |
| 243 | echo ifeq \(\\\$\(TARGET_DEVICE\),$DEVICENAME\) |
| 244 | echo LOCAL_PATH:=\\\$\(call my-dir\) |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 245 | |
| 246 | FOUND=false |
| 247 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 248 | grep '\.apk$' | |
| 249 | grep '>' | |
| 250 | cut -b 3- | |
| 251 | while read FULLPATH |
| 252 | do |
| 253 | if test $FOUND = false |
| 254 | then |
| 255 | echo |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame] | 256 | echo -n '# Module makefile rules for apks on ' |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 257 | echo $DEVICENAME |
| 258 | fi |
| 259 | FOUND=true |
| 260 | echo |
| 261 | echo -n '# ' |
| 262 | echo $(basename $FULLPATH) | sed 's/\.apk//g' |
| 263 | echo |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame] | 264 | echo include \\\$\(CLEAR_VARS\) |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 265 | echo |
| 266 | echo LOCAL_MODULE := $(basename $FULLPATH) | sed 's/\.apk//g' |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame] | 267 | echo LOCAL_SRC_FILES := \\\$\(LOCAL_MODULE\).apk |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 268 | echo LOCAL_MODULE_CLASS := APPS |
| 269 | echo LOCAL_MODULE_TAGS := optional |
| 270 | echo LOCAL_CERTIFICATE := PRESIGNED |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame] | 271 | echo LOCAL_MODULE_SUFFIX := \\\$\(COMMON_ANDROID_PACKAGE_SUFFIX\) |
| 272 | echo include \\\$\(BUILD_PREBUILT\) |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 273 | done |
Jean-Baptiste Queru | 74426d8 | 2011-06-10 09:40:04 -0700 | [diff] [blame] | 274 | echo |
| 275 | echo endif |
Jean-Baptiste Queru | c6df0e5 | 2011-06-09 15:44:26 -0700 | [diff] [blame] | 276 | echo |
| 277 | |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 278 | echo 'EOF' |
| 279 | echo |
| 280 | echo './setup-makefiles.sh' |
| 281 | |
| 282 | ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh |
| 283 | 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] | 284 | chmod a+x device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 285 | done |
| 286 | |
| 287 | ( |
| 288 | cd device/$MANUFACTURERNAME/$DEVICENAME |
| 289 | git add . |
Jean-Baptiste Queru | 2d580f2 | 2011-09-09 13:20:35 -0700 | [diff] [blame] | 290 | git commit -m "$(echo -e 'auto-generated blob-handling scripts\n\nBug: 4295425')" |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 291 | if test "$1" != "" -a "$2" != "" |
| 292 | then |
| 293 | echo uploading to server $1 branch $2 |
Jean-Baptiste Queru | e558351 | 2011-07-30 20:48:01 -0700 | [diff] [blame] | 294 | git push ssh://$1:29418/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 295 | fi |
| 296 | ) |
| 297 | |
| 298 | done |
| 299 | |
| 300 | echo * device/* | |
| 301 | tr \ \\n | |
| 302 | grep -v ^archive- | |
| 303 | grep -v ^device$ | |
| 304 | grep -v ^device/common$ | |
| 305 | xargs rm -rf |