/device/common/generate-blob-lists.sh

https://bitbucket.org/rlyspn/androidrr · Shell · 149 lines · 105 code · 15 blank · 29 comment · 17 complexity · 7090f14654856a6fcae958726f260813 MD5 · raw file

  1. #!/usr/bin/env bash
  2. # Copyright (C) 2010 The Android Open Source Project
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # This script auto-generates the lists of proprietary blobs necessary to build
  16. # the Android Open-Source Project code for a variety of hardware targets.
  17. # It needs to be run from the root of a source tree that can repo sync,
  18. # runs builds with and without the vendor tree, and uses the difference
  19. # to generate the lists.
  20. # It can optionally upload the results to a Gerrit server for review.
  21. # WARNING: It destroys the source tree. Don't leave anything precious there.
  22. # Caveat: this script does many full builds (2 per device). It takes a while
  23. # to run. It's best # suited for overnight runs on multi-CPU machines
  24. # with a lot of RAM.
  25. # Syntax: device/common/generate-blob-lists.sh -f|--force [<server> <branch>]
  26. #
  27. # If the server and branch paramters are both present, the script will upload
  28. # new files (if there's been any change) to the mentioned Gerrit server,
  29. # in the specified branch.
  30. if test "$1" != "-f" -a "$1" != "--force"
  31. then
  32. echo This script must be run with the --force option
  33. exit 1
  34. fi
  35. shift
  36. DEVICES="maguro toro toroplus grouper tilapia manta phantasm"
  37. export LC_ALL=C
  38. repo sync -j32 -n
  39. repo sync -j32 -n
  40. repo sync -j2 -l
  41. ARCHIVEDIR=archive-$(date +%s)
  42. if test -d archive-ref
  43. then
  44. cp -R archive-ref $ARCHIVEDIR
  45. else
  46. mkdir $ARCHIVEDIR
  47. . build/envsetup.sh
  48. for DEVICENAME in $DEVICES
  49. do
  50. rm -rf out
  51. lunch full_$DEVICENAME-user
  52. make -j32
  53. cat out/target/product/$DEVICENAME/installed-files.txt |
  54. cut -b 15- |
  55. sort -f > $ARCHIVEDIR/$DEVICENAME-with.txt
  56. done
  57. rm -rf device/lge/*
  58. rm -rf hardware/broadcom/nfc
  59. rm -rf hardware/msm7k
  60. rm -rf hardware/qcom/*
  61. rm -rf packages/apps/UnifiedEmail
  62. rm -rf vendor
  63. for DEVICENAME in $DEVICES
  64. do
  65. rm -rf out
  66. lunch full_$DEVICENAME-user
  67. make -j32
  68. cat out/target/product/$DEVICENAME/installed-files.txt |
  69. cut -b 15- |
  70. sort -f > $ARCHIVEDIR/$DEVICENAME-without.txt
  71. done
  72. fi
  73. for DEVICENAME in $DEVICES
  74. do
  75. MANUFACTURERNAME=$( find device -type d | grep ^[^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
  76. if test $(wc -l < $ARCHIVEDIR/$DEVICENAME-without.txt) != 0 -a $(wc -l < $ARCHIVEDIR/$DEVICENAME-with.txt) != 0
  77. then
  78. (
  79. echo '# Copyright (C) 2011 The Android Open Source Project'
  80. echo '#'
  81. echo '# Licensed under the Apache License, Version 2.0 (the "License");'
  82. echo '# you may not use this file except in compliance with the License.'
  83. echo '# You may obtain a copy of the License at'
  84. echo '#'
  85. echo '# http://www.apache.org/licenses/LICENSE-2.0'
  86. echo '#'
  87. echo '# Unless required by applicable law or agreed to in writing, software'
  88. echo '# distributed under the License is distributed on an "AS IS" BASIS,'
  89. echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
  90. echo '# See the License for the specific language governing permissions and'
  91. echo '# limitations under the License.'
  92. echo
  93. echo '# This file is generated by device/common/generate-blob-lists.sh - DO NOT EDIT'
  94. echo
  95. diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
  96. grep -v '\.odex$' |
  97. grep '>' |
  98. cut -b 3-
  99. ) > $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt
  100. cp $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt device/$MANUFACTURERNAME/$DEVICENAME/proprietary-blobs.txt
  101. (
  102. cd device/$MANUFACTURERNAME/$DEVICENAME
  103. git add .
  104. git commit -m "$(echo -e 'auto-generated blob list\n\nBug: 4295425')"
  105. if test "$1" != "" -a "$2" != ""
  106. then
  107. echo uploading to server $1 branch $2
  108. git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
  109. fi
  110. )
  111. else
  112. (
  113. cd device/$MANUFACTURERNAME/$DEVICENAME
  114. git commit --allow-empty -m "$(echo -e 'DO NOT SUBMIT - BROKEN BUILD\n\nBug: 4295425')"
  115. if test "$1" != "" -a "$2" != ""
  116. then
  117. echo uploading to server $1 branch $2
  118. git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
  119. fi
  120. )
  121. fi
  122. done
  123. if true
  124. then
  125. rm -rf out/
  126. elif ! test -d archive-ref
  127. then
  128. echo * device/* |
  129. tr \ \\n |
  130. grep -v ^archive- |
  131. grep -v ^device$ |
  132. grep -v ^device/common$ |
  133. xargs rm -rf
  134. fi