blob: 8c72e95f74eec35fa76212b3fe149336125ac216 [file] [log] [blame]
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -08001#!/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 lists of proprietary blobs necessary to build
18# the Android Open-Source Project code for a variety of hardware targets.
19
20# It needs to be run from the root of a source tree that can repo sync,
21# runs builds with and without the vendor tree, and uses the difference
22# to generate the lists.
23
24# It can optionally upload the results to a Gerrit server for review.
25
26# WARNING: It destroys the source tree. Don't leave anything precious there.
27
28# Caveat: this script does many full builds (2 per device). It takes a while
29# to run. It's best # suited for overnight runs on multi-CPU machines
30# with a lot of RAM.
31
32# Syntax: device/common/generate-blob-lists.sh -f|--force [<server> <branch>]
33#
34# If the server and branch paramters are both present, the script will upload
35# new files (if there's been any change) to the mentioned Gerrit server,
36# in the specified branch.
37
38if test "$1" != "-f" -a "$1" != "--force"
39then
40 echo This script must be run with the --force option
41 exit 1
42fi
43shift
44
Jean-Baptiste Queru839a25f2012-09-07 08:14:19 -070045DEVICES="maguro toro grouper"
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -080046export LC_ALL=C
47
Jean-Baptiste Queru411fad52012-02-15 09:33:26 -080048repo sync -j32 -n
49repo sync -j32 -n
50repo sync -j2 -l
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -080051
52ARCHIVEDIR=archive-$(date +%s)
53if test -d archive-ref
54then
55 cp -R archive-ref $ARCHIVEDIR
56else
57 mkdir $ARCHIVEDIR
58
59 . build/envsetup.sh
60 for DEVICENAME in $DEVICES
61 do
62 rm -rf out
63 lunch full_$DEVICENAME-user
64 make -j32
65 cat out/target/product/$DEVICENAME/installed-files.txt |
66 cut -b 15- |
67 sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt
68 done
Jean-Baptiste Queru68870a82012-09-07 07:39:22 -070069 rm -rf device/asus/tilapia
70 rm -rf device/lge
71 rm -rf device/moto
72 rm -rf device/samsung/manta
73 rm -rf device/samsung/crespo*
74 rm -rf device/samsung/toro*p*
Jean-Baptiste Querub9e07ed2012-09-11 13:38:27 -070075 rm -rf external/bluedroid
Jean-Baptiste Queru68870a82012-09-07 07:39:22 -070076 rm -rf external/eigen
77 rm -rf external/libnfc-nci
78 rm -rf hardware/broadcom/nfc
79 rm -rf hardware/msm7k
80 rm -rf hardware/qcom
81 rm -rf hardware/samsung_slsi
82 rm -rf packages/apps/Camera
83 rm -rf packages/apps/Gallery2
84 rm -rf packages/apps/Nfc
85 rm -rf packages/apps/PhoneCommon
Jean-Baptiste Queru308e2442012-09-04 11:20:41 -070086 rm -rf vendor
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -080087 for DEVICENAME in $DEVICES
88 do
89 rm -rf out
90 lunch full_$DEVICENAME-user
91 make -j32
92 cat out/target/product/$DEVICENAME/installed-files.txt |
93 cut -b 15- |
94 sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt
95 done
96fi
97
98for DEVICENAME in $DEVICES
99do
Jean-Baptiste Queru1dedf142012-06-25 12:42:59 -0700100 MANUFACTURERNAME=$( find device -type d | grep [^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -0800101 if test $(wc -l < $ARCHIVEDIR/$DEVICENAME-without.txt) != 0 -a $(wc -l < $ARCHIVEDIR/$DEVICENAME-with.txt) != 0
102 then
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -0800103 (
104 echo '# Copyright (C) 2011 The Android Open Source Project'
105 echo '#'
106 echo '# Licensed under the Apache License, Version 2.0 (the "License");'
107 echo '# you may not use this file except in compliance with the License.'
108 echo '# You may obtain a copy of the License at'
109 echo '#'
110 echo '# http://www.apache.org/licenses/LICENSE-2.0'
111 echo '#'
112 echo '# Unless required by applicable law or agreed to in writing, software'
113 echo '# distributed under the License is distributed on an "AS IS" BASIS,'
114 echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
115 echo '# See the License for the specific language governing permissions and'
116 echo '# limitations under the License.'
117 echo
118 echo '# This file is generated by device/common/generate-blob-lists.sh - DO NOT EDIT'
119 echo
120 diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
121 grep -v '\.odex$' |
122 grep '>' |
123 cut -b 3-
124 ) > $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt
125 cp $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt device/$MANUFACTURERNAME/$DEVICENAME/proprietary-blobs.txt
126
127 (
128 cd device/$MANUFACTURERNAME/$DEVICENAME
129 git add .
130 git commit -m "$(echo -e 'auto-generated blob list\n\nBug: 4295425')"
131 if test "$1" != "" -a "$2" != ""
132 then
133 echo uploading to server $1 branch $2
Jean-Baptiste Queru1db6a292012-07-19 13:11:09 -0700134 git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -0800135 fi
136 )
Jean-Baptiste Queru1dedf142012-06-25 12:42:59 -0700137 else
138 (
139 cd device/$MANUFACTURERNAME/$DEVICENAME
140 git commit --allow-empty -m "$(echo -e 'DO NOT SUBMIT - BROKEN BUILD\n\nBug: 4295425')"
141 if test "$1" != "" -a "$2" != ""
142 then
143 echo uploading to server $1 branch $2
Jean-Baptiste Queru1db6a292012-07-19 13:11:09 -0700144 git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
Jean-Baptiste Queru1dedf142012-06-25 12:42:59 -0700145 fi
146 )
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -0800147 fi
148done
149
Jean-Baptiste Queru411fad52012-02-15 09:33:26 -0800150if true
151then
152 rm -rf out/
153elif ! test -d archive-ref
Jean-Baptiste Queru602a4b12011-12-27 14:48:52 -0800154then
155 echo * device/* |
156 tr \ \\n |
157 grep -v ^archive- |
158 grep -v ^device$ |
159 grep -v ^device/common$ |
160 xargs rm -rf
161fi