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