Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 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 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 | |
| 38 | if test "$1" != "-f" -a "$1" != "--force" |
| 39 | then |
| 40 | echo This script must be run with the --force option |
| 41 | exit 1 |
| 42 | fi |
| 43 | shift |
| 44 | |
Jean-Baptiste Queru | 411fad5 | 2012-02-15 09:33:26 -0800 | [diff] [blame] | 45 | repo sync -j32 -n |
| 46 | repo sync -j32 -n |
| 47 | repo sync -j2 -l |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 48 | |
Jean-Baptiste Queru | fcba24a | 2013-04-15 07:39:59 -0700 | [diff] [blame] | 49 | DEVICES=$(for i in device/*/*/proprietary-blobs.txt ; do basename $(dirname $i) ; done) |
| 50 | |
| 51 | export LC_ALL=C |
| 52 | |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 53 | ARCHIVEDIR=archive-$(date +%s) |
| 54 | if test -d archive-ref |
| 55 | then |
| 56 | cp -R archive-ref $ARCHIVEDIR |
| 57 | else |
| 58 | mkdir $ARCHIVEDIR |
| 59 | |
| 60 | . build/envsetup.sh |
| 61 | for DEVICENAME in $DEVICES |
| 62 | do |
| 63 | rm -rf out |
Jean-Baptiste Queru | c1bc4b2 | 2013-03-22 15:53:56 -0700 | [diff] [blame] | 64 | lunch aosp_$DEVICENAME-user |
Conley Owens | 6a29956 | 2013-10-16 17:00:32 -0700 | [diff] [blame] | 65 | make -j64 |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 66 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 67 | cut -b 15- | |
| 68 | sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt |
| 69 | done |
Jean-Baptiste Queru | 308e244 | 2012-09-04 11:20:41 -0700 | [diff] [blame] | 70 | rm -rf vendor |
Jean-Baptiste Queru | 8a9017d | 2013-04-11 11:28:11 -0700 | [diff] [blame] | 71 | rm -rf hardware/qcom/gps |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 72 | for DEVICENAME in $DEVICES |
| 73 | do |
| 74 | rm -rf out |
Jean-Baptiste Queru | c1bc4b2 | 2013-03-22 15:53:56 -0700 | [diff] [blame] | 75 | lunch aosp_$DEVICENAME-user |
Conley Owens | 6a29956 | 2013-10-16 17:00:32 -0700 | [diff] [blame] | 76 | make -j64 |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 77 | cat out/target/product/$DEVICENAME/installed-files.txt | |
| 78 | cut -b 15- | |
| 79 | sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt |
| 80 | done |
| 81 | fi |
| 82 | |
| 83 | for DEVICENAME in $DEVICES |
| 84 | do |
Jean-Baptiste Queru | 0a793bd | 2012-10-10 14:13:16 -0700 | [diff] [blame] | 85 | MANUFACTURERNAME=$( find device -type d | grep ^[^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / ) |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 86 | if test $(wc -l < $ARCHIVEDIR/$DEVICENAME-without.txt) != 0 -a $(wc -l < $ARCHIVEDIR/$DEVICENAME-with.txt) != 0 |
| 87 | then |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 88 | ( |
| 89 | echo '# Copyright (C) 2011 The Android Open Source Project' |
| 90 | echo '#' |
| 91 | echo '# Licensed under the Apache License, Version 2.0 (the "License");' |
| 92 | echo '# you may not use this file except in compliance with the License.' |
| 93 | echo '# You may obtain a copy of the License at' |
| 94 | echo '#' |
| 95 | echo '# http://www.apache.org/licenses/LICENSE-2.0' |
| 96 | echo '#' |
| 97 | echo '# Unless required by applicable law or agreed to in writing, software' |
| 98 | echo '# distributed under the License is distributed on an "AS IS" BASIS,' |
| 99 | echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' |
| 100 | echo '# See the License for the specific language governing permissions and' |
| 101 | echo '# limitations under the License.' |
| 102 | echo |
| 103 | echo '# This file is generated by device/common/generate-blob-lists.sh - DO NOT EDIT' |
| 104 | echo |
| 105 | diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt | |
| 106 | grep -v '\.odex$' | |
| 107 | grep '>' | |
| 108 | cut -b 3- |
| 109 | ) > $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt |
| 110 | cp $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt device/$MANUFACTURERNAME/$DEVICENAME/proprietary-blobs.txt |
| 111 | |
| 112 | ( |
| 113 | cd device/$MANUFACTURERNAME/$DEVICENAME |
| 114 | git add . |
Jean-Baptiste Queru | 73b09c0 | 2013-05-20 07:57:39 -0700 | [diff] [blame] | 115 | git commit -m "$(echo -e 'auto-generated blob list for '$DEVICENAME'\n\nBug: 4295425')" |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 116 | if test "$1" != "" -a "$2" != "" |
| 117 | then |
| 118 | echo uploading to server $1 branch $2 |
Jean-Baptiste Queru | 1db6a29 | 2012-07-19 13:11:09 -0700 | [diff] [blame] | 119 | git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 120 | fi |
| 121 | ) |
Jean-Baptiste Queru | 1dedf14 | 2012-06-25 12:42:59 -0700 | [diff] [blame] | 122 | else |
| 123 | ( |
| 124 | cd device/$MANUFACTURERNAME/$DEVICENAME |
| 125 | git commit --allow-empty -m "$(echo -e 'DO NOT SUBMIT - BROKEN BUILD\n\nBug: 4295425')" |
| 126 | if test "$1" != "" -a "$2" != "" |
| 127 | then |
| 128 | echo uploading to server $1 branch $2 |
Jean-Baptiste Queru | 1db6a29 | 2012-07-19 13:11:09 -0700 | [diff] [blame] | 129 | git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs |
Jean-Baptiste Queru | 1dedf14 | 2012-06-25 12:42:59 -0700 | [diff] [blame] | 130 | fi |
| 131 | ) |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 132 | fi |
| 133 | done |
| 134 | |
Jean-Baptiste Queru | 411fad5 | 2012-02-15 09:33:26 -0800 | [diff] [blame] | 135 | if true |
| 136 | then |
| 137 | rm -rf out/ |
| 138 | elif ! test -d archive-ref |
Jean-Baptiste Queru | 602a4b1 | 2011-12-27 14:48:52 -0800 | [diff] [blame] | 139 | then |
| 140 | echo * device/* | |
| 141 | tr \ \\n | |
| 142 | grep -v ^archive- | |
| 143 | grep -v ^device$ | |
| 144 | grep -v ^device/common$ | |
| 145 | xargs rm -rf |
| 146 | fi |