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 |
| 19 | # for dream, passion and sapphire targets |
| 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 | |
| 46 | DEVICES="passion crespo" |
| 47 | |
| 48 | ARCHIVEDIR=archive-$(date +%s) |
| 49 | mkdir $ARCHIVEDIR |
| 50 | |
| 51 | repo sync |
| 52 | repo sync |
| 53 | repo sync |
| 54 | . build/envsetup.sh |
| 55 | for DEVICENAME in $DEVICES |
| 56 | do |
| 57 | rm -rf out |
| 58 | lunch full_$DEVICENAME-user |
| 59 | make -j8 |
| 60 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 61 | cut -b 15- | |
| 62 | sort > $ARCHIVEDIR/$DEVICENAME-with.txt |
| 63 | done |
| 64 | rm -rf vendor |
| 65 | for DEVICENAME in $DEVICES |
| 66 | do |
| 67 | rm -rf out |
| 68 | lunch full_$DEVICENAME-user |
| 69 | make -j8 |
| 70 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 71 | cut -b 15- | |
| 72 | sort > $ARCHIVEDIR/$DEVICENAME-without.txt |
| 73 | done |
| 74 | |
| 75 | for DEVICENAME in $DEVICES |
| 76 | do |
| 77 | MANUFACTURERNAME=$( find device -type d | grep [^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / ) |
| 78 | for FILESTYLE in extract unzip |
| 79 | do |
| 80 | ( |
| 81 | echo '#!/bin/sh' |
| 82 | echo |
| 83 | echo '# Copyright (C) 2010 The Android Open Source Project' |
| 84 | echo '#' |
| 85 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 86 | echo '# you may not use this file except in compliance with the License.' |
| 87 | echo '# You may obtain a copy of the License at' |
| 88 | echo '#' |
| 89 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 90 | echo '#' |
| 91 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 92 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 93 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 94 | echo '# See the License for the specific language governing permissions and' |
| 95 | echo '# limitations under the License.' |
| 96 | echo |
| 97 | echo '# This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT' |
| 98 | echo |
| 99 | echo DEVICE=$DEVICENAME |
| 100 | echo MANUFACTURER=$MANUFACTURERNAME |
| 101 | echo |
| 102 | echo 'mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary' |
| 103 | |
| 104 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 105 | grep '>' | |
| 106 | cut -b 3- | |
| 107 | while read FULLPATH |
| 108 | do |
| 109 | if test $FILESTYLE = extract |
| 110 | then |
| 111 | echo adb pull $FULLPATH ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH) |
| 112 | else |
| 113 | echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary |
| 114 | fi |
Jean-Baptiste Queru | bfe57a1 | 2010-09-24 13:53:17 -0700 | [diff] [blame] | 115 | 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] | 116 | then |
| 117 | echo chmod 755 ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH) |
| 118 | fi |
| 119 | done |
| 120 | echo |
| 121 | |
| 122 | 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] | 123 | echo 'device-vendor-blobs.mk' |
Jean-Baptiste Queru | de8788e | 2010-08-17 19:31:25 -0700 | [diff] [blame] | 124 | |
| 125 | echo '# Copyright (C) 2010 The Android Open Source Project' |
| 126 | echo '#' |
| 127 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 128 | echo '# you may not use this file except in compliance with the License.' |
| 129 | echo '# You may obtain a copy of the License at' |
| 130 | echo '#' |
| 131 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 132 | echo '#' |
| 133 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 134 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 135 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 136 | echo '# See the License for the specific language governing permissions and' |
| 137 | echo '# limitations under the License.' |
| 138 | echo |
| 139 | echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/' |
| 140 | echo -n $FILESTYLE |
| 141 | echo '-files.sh - DO NOT EDIT' |
| 142 | |
| 143 | FOUND=false |
| 144 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 145 | grep '>' | |
| 146 | cut -b 3- | |
| 147 | while read FULLPATH |
| 148 | do |
Jean-Baptiste Queru | 90e32d5 | 2010-09-24 14:14:26 -0700 | [diff] [blame^] | 149 | 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] | 150 | then |
| 151 | if test $FOUND = false |
| 152 | then |
| 153 | echo |
| 154 | echo '# Prebuilt libraries that are needed to build open-source libraries' |
| 155 | echo 'PRODUCT_COPY_FILES := \\' |
| 156 | else |
| 157 | echo \ \\\\ |
| 158 | fi |
| 159 | FOUND=true |
| 160 | echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):obj/lib/$(basename $FULLPATH) |
| 161 | fi |
| 162 | done |
| 163 | echo |
| 164 | |
| 165 | FOUND=false |
| 166 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 167 | grep '>' | |
| 168 | cut -b 3- | |
| 169 | while read FULLPATH |
| 170 | do |
| 171 | if test $FOUND = false |
| 172 | then |
| 173 | echo |
| 174 | echo -n '# All the blobs necessary for ' |
| 175 | echo $DEVICENAME |
| 176 | echo 'PRODUCT_COPY_FILES += \\' |
| 177 | else |
| 178 | echo \ \\\\ |
| 179 | fi |
| 180 | FOUND=true |
| 181 | echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-) |
| 182 | done |
| 183 | echo |
| 184 | echo 'EOF' |
| 185 | echo |
| 186 | echo './setup-makefiles.sh' |
| 187 | |
| 188 | ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh |
| 189 | cp $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh |
| 190 | done |
| 191 | |
| 192 | ( |
| 193 | cd device/$MANUFACTURERNAME/$DEVICENAME |
| 194 | git add . |
| 195 | git commit -m "auto-generated blob-handling scripts" |
| 196 | if test "$1" != "" -a "$2" != "" |
| 197 | then |
| 198 | echo uploading to server $1 branch $2 |
| 199 | git push ssh://$1:29418/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2 |
| 200 | fi |
| 201 | ) |
| 202 | |
| 203 | done |
| 204 | |
| 205 | echo * device/* | |
| 206 | tr \ \\n | |
| 207 | grep -v ^archive- | |
| 208 | grep -v ^device$ | |
| 209 | grep -v ^device/common$ | |
| 210 | xargs rm -rf |