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