blob: 7e418f7e5fd4abc703851cbeb8154fee5b6271ec [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 Queru51c52072011-10-24 07:12:42 -070046DEVICES="crespo crespo4g stingray 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 Queru66247cd2011-06-10 10:04:50 -070049repo 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
84 MANUFACTURERNAME=$( find device -type d | grep [^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
85 for FILESTYLE in extract unzip
86 do
87 (
88 echo '#!/bin/sh'
89 echo
90 echo '# Copyright (C) 2010 The Android Open Source Project'
91 echo '#'
92 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
93 echo '# you may not use this file except in compliance with the License.'
94 echo '# You may obtain a copy of the License at'
95 echo '#'
96 echo '# http://www.apache.org/licenses/LICENSE-2.0'
97 echo '#'
98 echo '# Unless required by applicable law or agreed to in writing, software'
99 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
100 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
101 echo '# See the License for the specific language governing permissions and'
102 echo '# limitations under the License.'
103 echo
104 echo '# This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT'
105 echo
106 echo DEVICE=$DEVICENAME
107 echo MANUFACTURER=$MANUFACTURERNAME
108 echo
109 echo 'mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary'
110
111 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru1b83f682011-06-06 10:44:27 -0700112 grep -v '\.odex$' |
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700113 grep '>' |
114 cut -b 3- |
115 while read FULLPATH
116 do
117 if test $FILESTYLE = extract
118 then
119 echo adb pull $FULLPATH ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH)
120 else
121 echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary
122 fi
Jean-Baptiste Queru21927ce2011-10-01 11:35:35 -0700123 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 Querude8788e2010-08-17 19:31:25 -0700124 then
125 echo chmod 755 ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH)
126 fi
127 done
128 echo
129
130 echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/'
Jean-Baptiste Queru548297c2010-09-22 10:15:03 -0700131 echo 'device-vendor-blobs.mk'
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700132
133 echo '# Copyright (C) 2010 The Android Open Source Project'
134 echo '#'
135 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
136 echo '# you may not use this file except in compliance with the License.'
137 echo '# You may obtain a copy of the License at'
138 echo '#'
139 echo '# http://www.apache.org/licenses/LICENSE-2.0'
140 echo '#'
141 echo '# Unless required by applicable law or agreed to in writing, software'
142 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
143 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
144 echo '# See the License for the specific language governing permissions and'
145 echo '# limitations under the License.'
146 echo
147 echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/'
148 echo -n $FILESTYLE
149 echo '-files.sh - DO NOT EDIT'
150
151 FOUND=false
152 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru1b83f682011-06-06 10:44:27 -0700153 grep -v '\.odex$' |
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700154 grep '>' |
155 cut -b 3- |
156 while read FULLPATH
157 do
Jean-Baptiste Queru90e32d52010-09-24 14:14:26 -0700158 if test $(basename $FULLPATH) = libgps.so -o $(basename $FULLPATH) = libcamera.so -o $(basename $FULLPATH) = libsecril-client.so
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700159 then
160 if test $FOUND = false
161 then
162 echo
163 echo '# Prebuilt libraries that are needed to build open-source libraries'
164 echo 'PRODUCT_COPY_FILES := \\'
165 else
166 echo \ \\\\
167 fi
168 FOUND=true
169 echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):obj/lib/$(basename $FULLPATH)
170 fi
171 done
172 echo
173
174 FOUND=false
175 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru1b83f682011-06-06 10:44:27 -0700176 grep -v '\.odex$' |
Jean-Baptiste Queru4ef11672011-06-08 17:12:18 -0700177 grep -v '\.apk$' |
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700178 grep '>' |
179 cut -b 3- |
180 while read FULLPATH
181 do
182 if test $FOUND = false
183 then
184 echo
185 echo -n '# All the blobs necessary for '
186 echo $DEVICENAME
187 echo 'PRODUCT_COPY_FILES += \\'
188 else
189 echo \ \\\\
190 fi
191 FOUND=true
192 echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-)
193 done
194 echo
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700195
196 FOUND=false
197 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
198 grep '\.apk$' |
199 grep '>' |
200 cut -b 3- |
201 while read FULLPATH
202 do
203 if test $FOUND = false
204 then
205 echo
206 echo -n '# All the apks necessary for '
207 echo $DEVICENAME
208 echo 'PRODUCT_PACKAGES += \\'
209 else
210 echo \ \\\\
211 fi
212 FOUND=true
213 echo -n \ \ \ \
214 echo -n $(basename $FULLPATH) | sed 's/\.apk//g'
215 done
216 echo
217
Jean-Baptiste Queru70bda672011-06-10 13:41:18 -0700218 echo
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700219 echo 'EOF'
220
Jean-Baptiste Queru70bda672011-06-10 13:41:18 -0700221 echo
222
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700223 echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/'
224 echo 'proprietary/Android.mk'
225
226 echo '# Copyright (C) 2011 The Android Open Source Project'
227 echo '#'
228 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
229 echo '# you may not use this file except in compliance with the License.'
230 echo '# You may obtain a copy of the License at'
231 echo '#'
232 echo '# http://www.apache.org/licenses/LICENSE-2.0'
233 echo '#'
234 echo '# Unless required by applicable law or agreed to in writing, software'
235 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
236 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
237 echo '# See the License for the specific language governing permissions and'
238 echo '# limitations under the License.'
239 echo
240 echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/'
241 echo -n $FILESTYLE
242 echo '-files.sh - DO NOT EDIT'
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700243 echo
244 echo ifeq \(\\\$\(TARGET_DEVICE\),$DEVICENAME\)
245 echo LOCAL_PATH:=\\\$\(call my-dir\)
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700246
247 FOUND=false
248 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
249 grep '\.apk$' |
250 grep '>' |
251 cut -b 3- |
252 while read FULLPATH
253 do
254 if test $FOUND = false
255 then
256 echo
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700257 echo -n '# Module makefile rules for apks on '
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700258 echo $DEVICENAME
259 fi
260 FOUND=true
261 echo
262 echo -n '# '
263 echo $(basename $FULLPATH) | sed 's/\.apk//g'
264 echo
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700265 echo include \\\$\(CLEAR_VARS\)
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700266 echo
267 echo LOCAL_MODULE := $(basename $FULLPATH) | sed 's/\.apk//g'
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700268 echo LOCAL_SRC_FILES := \\\$\(LOCAL_MODULE\).apk
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700269 echo LOCAL_MODULE_CLASS := APPS
270 echo LOCAL_MODULE_TAGS := optional
271 echo LOCAL_CERTIFICATE := PRESIGNED
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700272 echo LOCAL_MODULE_SUFFIX := \\\$\(COMMON_ANDROID_PACKAGE_SUFFIX\)
273 echo include \\\$\(BUILD_PREBUILT\)
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700274 done
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700275 echo
276 echo endif
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700277 echo
278
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700279 echo 'EOF'
280 echo
281 echo './setup-makefiles.sh'
282
283 ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh
284 cp $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh
Jean-Baptiste Queru1a9cdef2011-04-15 15:28:48 -0700285 chmod a+x device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700286 done
287
288 (
289 cd device/$MANUFACTURERNAME/$DEVICENAME
290 git add .
Jean-Baptiste Queru2d580f22011-09-09 13:20:35 -0700291 git commit -m "$(echo -e 'auto-generated blob-handling scripts\n\nBug: 4295425')"
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700292 if test "$1" != "" -a "$2" != ""
293 then
294 echo uploading to server $1 branch $2
Jean-Baptiste Querue5583512011-07-30 20:48:01 -0700295 git push ssh://$1:29418/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700296 fi
297 )
298
299done
300
301echo * device/* |
302 tr \ \\n |
303 grep -v ^archive- |
304 grep -v ^device$ |
305 grep -v ^device/common$ |
306 xargs rm -rf