Home | History | Annotate | Download | only in common
      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 
     45 DEVICES="maguro toro toroplus grouper manta mako"
     46 export LC_ALL=C
     47 
     48 repo sync -j32 -n
     49 repo sync -j32 -n
     50 repo sync -j2 -l
     51 
     52 ARCHIVEDIR=archive-$(date +%s)
     53 if test -d archive-ref
     54 then
     55   cp -R archive-ref $ARCHIVEDIR
     56 else
     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
     69   rm -rf device/asus/tilapia
     70   rm -rf hardware/broadcom/nfc
     71   rm -rf packages/apps/UnifiedEmail
     72   rm -rf vendor
     73   for DEVICENAME in $DEVICES
     74   do
     75     rm -rf out
     76     lunch full_$DEVICENAME-user
     77     make -j32
     78     cat out/target/product/$DEVICENAME/installed-files.txt |
     79       cut -b 15- |
     80       sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt
     81   done
     82 fi
     83 
     84 for DEVICENAME in $DEVICES
     85 do
     86   MANUFACTURERNAME=$( find device -type d | grep ^[^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
     87   if test $(wc -l < $ARCHIVEDIR/$DEVICENAME-without.txt) != 0 -a $(wc -l < $ARCHIVEDIR/$DEVICENAME-with.txt) != 0
     88   then
     89     (
     90       echo '# Copyright (C) 2011 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-lists.sh - DO NOT EDIT'
    105       echo
    106       diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
    107         grep -v '\.odex$' |
    108         grep '>' |
    109         cut -b 3-
    110     ) > $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt
    111     cp $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt device/$MANUFACTURERNAME/$DEVICENAME/proprietary-blobs.txt
    112 
    113     (
    114       cd device/$MANUFACTURERNAME/$DEVICENAME
    115       git add .
    116       git commit -m "$(echo -e 'auto-generated blob list\n\nBug: 4295425')"
    117       if test "$1" != "" -a "$2" != ""
    118       then
    119         echo uploading to server $1 branch $2
    120         git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
    121       fi
    122     )
    123   else
    124     (
    125       cd device/$MANUFACTURERNAME/$DEVICENAME
    126       git commit --allow-empty -m "$(echo -e 'DO NOT SUBMIT - BROKEN BUILD\n\nBug: 4295425')"
    127       if test "$1" != "" -a "$2" != ""
    128       then
    129         echo uploading to server $1 branch $2
    130         git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
    131       fi
    132     )
    133   fi
    134 done
    135 
    136 if true
    137 then
    138   rm -rf out/
    139 elif ! test -d archive-ref
    140 then
    141   echo * device/* |
    142     tr \  \\n |
    143     grep -v ^archive- |
    144     grep -v ^device$ |
    145     grep -v ^device/common$ |
    146     xargs rm -rf
    147 fi
    148