blob: 0cd62a8920e507c729e2c56550cc0459bdae9b79 [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 Querue80457e2010-09-26 07:11:27 -070019# for passion and crespo 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 Queru0f9f60a2011-06-02 08:59:48 -070046DEVICES="crespo crespo4g stingray wingray tuna toro panda"
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -070047
48ARCHIVEDIR=archive-$(date +%s)
49mkdir $ARCHIVEDIR
50
51repo sync
52repo sync
53repo sync
Jean-Baptiste Queru4b168d32011-04-21 19:31:21 -070054
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -070055. build/envsetup.sh
56for DEVICENAME in $DEVICES
57do
58 rm -rf out
59 lunch full_$DEVICENAME-user
Jean-Baptiste Queru923fa912010-10-19 17:48:31 -070060 make -j32
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -070061 cat out/target/product/$DEVICENAME/installed-files.txt |
62 cut -b 15- |
Jean-Baptiste Queru923fa912010-10-19 17:48:31 -070063 sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -070064done
65rm -rf vendor
66for DEVICENAME in $DEVICES
67do
68 rm -rf out
69 lunch full_$DEVICENAME-user
Jean-Baptiste Queru923fa912010-10-19 17:48:31 -070070 make -j32
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -070071 cat out/target/product/$DEVICENAME/installed-files.txt |
72 cut -b 15- |
Jean-Baptiste Queru923fa912010-10-19 17:48:31 -070073 sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -070074done
75
76for DEVICENAME in $DEVICES
77do
78 MANUFACTURERNAME=$( find device -type d | grep [^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
79 for FILESTYLE in extract unzip
80 do
81 (
82 echo '#!/bin/sh'
83 echo
84 echo '# Copyright (C) 2010 The Android Open Source Project'
85 echo '#'
86 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
87 echo '# you may not use this file except in compliance with the License.'
88 echo '# You may obtain a copy of the License at'
89 echo '#'
90 echo '# http://www.apache.org/licenses/LICENSE-2.0'
91 echo '#'
92 echo '# Unless required by applicable law or agreed to in writing, software'
93 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
94 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
95 echo '# See the License for the specific language governing permissions and'
96 echo '# limitations under the License.'
97 echo
98 echo '# This file is generated by device/common/generate-blob-scripts.sh - DO NOT EDIT'
99 echo
100 echo DEVICE=$DEVICENAME
101 echo MANUFACTURER=$MANUFACTURERNAME
102 echo
103 echo 'mkdir -p ../../../vendor/$MANUFACTURER/$DEVICE/proprietary'
104
105 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru1b83f682011-06-06 10:44:27 -0700106 grep -v '\.odex$' |
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700107 grep '>' |
108 cut -b 3- |
109 while read FULLPATH
110 do
111 if test $FILESTYLE = extract
112 then
113 echo adb pull $FULLPATH ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH)
114 else
115 echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary
116 fi
Jean-Baptiste Querubfe57a12010-09-24 13:53:17 -0700117 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 Querude8788e2010-08-17 19:31:25 -0700118 then
119 echo chmod 755 ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH)
120 fi
121 done
122 echo
123
124 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 -0700125 echo 'device-vendor-blobs.mk'
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700126
127 echo '# Copyright (C) 2010 The Android Open Source Project'
128 echo '#'
129 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
130 echo '# you may not use this file except in compliance with the License.'
131 echo '# You may obtain a copy of the License at'
132 echo '#'
133 echo '# http://www.apache.org/licenses/LICENSE-2.0'
134 echo '#'
135 echo '# Unless required by applicable law or agreed to in writing, software'
136 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
137 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
138 echo '# See the License for the specific language governing permissions and'
139 echo '# limitations under the License.'
140 echo
141 echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/'
142 echo -n $FILESTYLE
143 echo '-files.sh - DO NOT EDIT'
144
145 FOUND=false
146 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru1b83f682011-06-06 10:44:27 -0700147 grep -v '\.odex$' |
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700148 grep '>' |
149 cut -b 3- |
150 while read FULLPATH
151 do
Jean-Baptiste Queru90e32d52010-09-24 14:14:26 -0700152 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 -0700153 then
154 if test $FOUND = false
155 then
156 echo
157 echo '# Prebuilt libraries that are needed to build open-source libraries'
158 echo 'PRODUCT_COPY_FILES := \\'
159 else
160 echo \ \\\\
161 fi
162 FOUND=true
163 echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):obj/lib/$(basename $FULLPATH)
164 fi
165 done
166 echo
167
168 FOUND=false
169 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
Jean-Baptiste Queru1b83f682011-06-06 10:44:27 -0700170 grep -v '\.odex$' |
Jean-Baptiste Queru4ef11672011-06-08 17:12:18 -0700171 grep -v '\.apk$' |
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700172 grep '>' |
173 cut -b 3- |
174 while read FULLPATH
175 do
176 if test $FOUND = false
177 then
178 echo
179 echo -n '# All the blobs necessary for '
180 echo $DEVICENAME
181 echo 'PRODUCT_COPY_FILES += \\'
182 else
183 echo \ \\\\
184 fi
185 FOUND=true
186 echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-)
187 done
188 echo
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700189
190 FOUND=false
191 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
192 grep '\.apk$' |
193 grep '>' |
194 cut -b 3- |
195 while read FULLPATH
196 do
197 if test $FOUND = false
198 then
199 echo
200 echo -n '# All the apks necessary for '
201 echo $DEVICENAME
202 echo 'PRODUCT_PACKAGES += \\'
203 else
204 echo \ \\\\
205 fi
206 FOUND=true
207 echo -n \ \ \ \
208 echo -n $(basename $FULLPATH) | sed 's/\.apk//g'
209 done
210 echo
211
212 echo 'EOF'
213
214 echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/'
215 echo 'proprietary/Android.mk'
216
217 echo '# Copyright (C) 2011 The Android Open Source Project'
218 echo '#'
219 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
220 echo '# you may not use this file except in compliance with the License.'
221 echo '# You may obtain a copy of the License at'
222 echo '#'
223 echo '# http://www.apache.org/licenses/LICENSE-2.0'
224 echo '#'
225 echo '# Unless required by applicable law or agreed to in writing, software'
226 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
227 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
228 echo '# See the License for the specific language governing permissions and'
229 echo '# limitations under the License.'
230 echo
231 echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/'
232 echo -n $FILESTYLE
233 echo '-files.sh - DO NOT EDIT'
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700234 echo
235 echo ifeq \(\\\$\(TARGET_DEVICE\),$DEVICENAME\)
236 echo LOCAL_PATH:=\\\$\(call my-dir\)
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700237
238 FOUND=false
239 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
240 grep '\.apk$' |
241 grep '>' |
242 cut -b 3- |
243 while read FULLPATH
244 do
245 if test $FOUND = false
246 then
247 echo
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700248 echo -n '# Module makefile rules for apks on '
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700249 echo $DEVICENAME
250 fi
251 FOUND=true
252 echo
253 echo -n '# '
254 echo $(basename $FULLPATH) | sed 's/\.apk//g'
255 echo
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700256 echo include \\\$\(CLEAR_VARS\)
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700257 echo
258 echo LOCAL_MODULE := $(basename $FULLPATH) | sed 's/\.apk//g'
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700259 echo LOCAL_SRC_FILES := \\\$\(LOCAL_MODULE\).apk
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700260 echo LOCAL_MODULE_CLASS := APPS
261 echo LOCAL_MODULE_TAGS := optional
262 echo LOCAL_CERTIFICATE := PRESIGNED
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700263 echo LOCAL_MODULE_SUFFIX := \\\$\(COMMON_ANDROID_PACKAGE_SUFFIX\)
264 echo include \\\$\(BUILD_PREBUILT\)
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700265 done
Jean-Baptiste Queru74426d82011-06-10 09:40:04 -0700266 echo
267 echo endif
Jean-Baptiste Queruc6df0e52011-06-09 15:44:26 -0700268 echo
269
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700270 echo 'EOF'
271 echo
272 echo './setup-makefiles.sh'
273
274 ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh
275 cp $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh
Jean-Baptiste Queru1a9cdef2011-04-15 15:28:48 -0700276 chmod a+x device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh
Jean-Baptiste Querude8788e2010-08-17 19:31:25 -0700277 done
278
279 (
280 cd device/$MANUFACTURERNAME/$DEVICENAME
281 git add .
282 git commit -m "auto-generated blob-handling scripts"
283 if test "$1" != "" -a "$2" != ""
284 then
285 echo uploading to server $1 branch $2
286 git push ssh://$1:29418/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2
287 fi
288 )
289
290done
291
292echo * device/* |
293 tr \ \\n |
294 grep -v ^archive- |
295 grep -v ^device$ |
296 grep -v ^device/common$ |
297 xargs rm -rf