OSDN Git Service

Remove passion
[android-x86/device-common.git] / generate-blob-scripts.sh
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 passion and crespo 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="crespo crespo4g stingray wingray tuna toro"
47
48 ARCHIVEDIR=archive-$(date +%s)
49 mkdir $ARCHIVEDIR
50
51 repo sync
52 repo sync
53 repo sync
54
55 . build/envsetup.sh
56 for DEVICENAME in $DEVICES
57 do
58   rm -rf out
59   lunch full_$DEVICENAME-user
60   make -j32
61   cat out/target/product/$DEVICENAME/installed-files.txt |
62     cut -b 15- |
63     sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt
64 done
65 rm -rf vendor
66 for DEVICENAME in $DEVICES
67 do
68   rm -rf out
69   lunch full_$DEVICENAME-user
70   make -j32
71   cat out/target/product/$DEVICENAME/installed-files.txt |
72     cut -b 15- |
73     sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt
74 done
75
76 for DEVICENAME in $DEVICES
77 do
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 |
106       grep -v Nfc\.apk\$ |
107       grep -v Tag\.apk\$ |
108       grep -v libnfc\.so\$ |
109       grep -v libnfc_jni\.so\$ |
110       grep '>' |
111       cut -b 3- |
112       while read FULLPATH
113       do
114         if test $FILESTYLE = extract
115         then
116           echo adb pull $FULLPATH ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH)
117         else
118           echo unzip -j -o ../../../\${DEVICE}_update.zip $(echo $FULLPATH | cut -b 2-) -d ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary
119         fi
120         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
121         then
122           echo chmod 755 ../../../vendor/\$MANUFACTURER/\$DEVICE/proprietary/$(basename $FULLPATH)
123         fi
124       done
125     echo
126
127     echo -n '(cat << EOF) | sed s/__DEVICE__/$DEVICE/g | sed s/__MANUFACTURER__/$MANUFACTURER/g > ../../../vendor/$MANUFACTURER/$DEVICE/'
128     echo 'device-vendor-blobs.mk'
129
130     echo '# Copyright (C) 2010 The Android Open Source Project'
131     echo '#'
132     echo '# Licensed under the Apache License, Version 2.0 (the "License");'
133     echo '# you may not use this file except in compliance with the License.'
134     echo '# You may obtain a copy of the License at'
135     echo '#'
136     echo '#      http://www.apache.org/licenses/LICENSE-2.0'
137     echo '#'
138     echo '# Unless required by applicable law or agreed to in writing, software'
139     echo '# distributed under the License is distributed on an "AS IS" BASIS,'
140     echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
141     echo '# See the License for the specific language governing permissions and'
142     echo '# limitations under the License.'
143     echo
144     echo -n '# This file is generated by device/__MANUFACTURER__/__DEVICE__/'
145     echo -n $FILESTYLE
146     echo '-files.sh - DO NOT EDIT'
147
148     FOUND=false
149     diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
150       grep -v Nfc\.apk\$ |
151       grep -v Tag\.apk\$ |
152       grep -v libnfc\.so\$ |
153       grep -v libnfc_jni\.so\$ |
154       grep '>' |
155       cut -b 3- |
156       while read FULLPATH
157       do
158         if test $(basename $FULLPATH) = libgps.so -o $(basename $FULLPATH) = libcamera.so -o $(basename $FULLPATH) = libsecril-client.so
159         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 |
176       grep -v Nfc\.apk\$ |
177       grep -v Tag\.apk\$ |
178       grep -v libnfc\.so\$ |
179       grep -v libnfc_jni\.so\$ |
180       grep '>' |
181       cut -b 3- |
182       while read FULLPATH
183       do
184         if test $FOUND = false
185         then
186           echo
187           echo -n '# All the blobs necessary for '
188           echo $DEVICENAME
189           echo 'PRODUCT_COPY_FILES += \\'
190         else
191           echo \ \\\\
192         fi
193         FOUND=true
194         echo -n \ \ \ \ vendor/__MANUFACTURER__/__DEVICE__/proprietary/$(basename $FULLPATH):$(echo $FULLPATH | cut -b 2-)
195       done
196     echo
197     echo 'EOF'
198     echo
199     echo './setup-makefiles.sh'
200
201     ) > $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh
202     cp $ARCHIVEDIR/$DEVICENAME-$FILESTYLE-files.sh device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh
203     chmod a+x device/$MANUFACTURERNAME/$DEVICENAME/$FILESTYLE-files.sh
204   done
205
206   (
207     cd device/$MANUFACTURERNAME/$DEVICENAME
208     git add .
209     git commit -m "auto-generated blob-handling scripts"
210     if test "$1" != "" -a "$2" != ""
211     then
212       echo uploading to server $1 branch $2
213       git push ssh://$1:29418/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2
214     fi
215   )
216
217 done
218
219 echo * device/* |
220   tr \  \\n |
221   grep -v ^archive- |
222   grep -v ^device$ |
223   grep -v ^device/common$ |
224   xargs rm -rf