PageRenderTime 3246ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/brian0218/rk3066_r-box_android4.2.2_sdk
Shell | 146 lines | 102 code | 15 blank | 29 comment | 17 complexity | 600f177cbb5935a82bdc91c761c9e434 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"
  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 hardware/broadcom/nfc
  58. rm -rf packages/apps/UnifiedEmail
  59. rm -rf vendor
  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-without.txt
  68. done
  69. fi
  70. for DEVICENAME in $DEVICES
  71. do
  72. MANUFACTURERNAME=$( find device -type d | grep ^[^/]\*/[^/]\*/$DEVICENAME\$ | cut -f 2 -d / )
  73. if test $(wc -l < $ARCHIVEDIR/$DEVICENAME-without.txt) != 0 -a $(wc -l < $ARCHIVEDIR/$DEVICENAME-with.txt) != 0
  74. then
  75. (
  76. echo '# Copyright (C) 2011 The Android Open Source Project'
  77. echo '#'
  78. echo '# Licensed under the Apache License, Version 2.0 (the "License");'
  79. echo '# you may not use this file except in compliance with the License.'
  80. echo '# You may obtain a copy of the License at'
  81. echo '#'
  82. echo '# http://www.apache.org/licenses/LICENSE-2.0'
  83. echo '#'
  84. echo '# Unless required by applicable law or agreed to in writing, software'
  85. echo '# distributed under the License is distributed on an "AS IS" BASIS,'
  86. echo '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
  87. echo '# See the License for the specific language governing permissions and'
  88. echo '# limitations under the License.'
  89. echo
  90. echo '# This file is generated by device/common/generate-blob-lists.sh - DO NOT EDIT'
  91. echo
  92. diff $ARCHIVEDIR/$DEVICENAME-without.txt $ARCHIVEDIR/$DEVICENAME-with.txt |
  93. grep -v '\.odex$' |
  94. grep '>' |
  95. cut -b 3-
  96. ) > $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt
  97. cp $ARCHIVEDIR/$DEVICENAME-proprietary-blobs.txt device/$MANUFACTURERNAME/$DEVICENAME/proprietary-blobs.txt
  98. (
  99. cd device/$MANUFACTURERNAME/$DEVICENAME
  100. git add .
  101. git commit -m "$(echo -e 'auto-generated blob list\n\nBug: 4295425')"
  102. if test "$1" != "" -a "$2" != ""
  103. then
  104. echo uploading to server $1 branch $2
  105. git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
  106. fi
  107. )
  108. else
  109. (
  110. cd device/$MANUFACTURERNAME/$DEVICENAME
  111. git commit --allow-empty -m "$(echo -e 'DO NOT SUBMIT - BROKEN BUILD\n\nBug: 4295425')"
  112. if test "$1" != "" -a "$2" != ""
  113. then
  114. echo uploading to server $1 branch $2
  115. git push $1/device/$MANUFACTURERNAME/$DEVICENAME.git HEAD:refs/for/$2/autoblobs
  116. fi
  117. )
  118. fi
  119. done
  120. if true
  121. then
  122. rm -rf out/
  123. elif ! test -d archive-ref
  124. then
  125. echo * device/* |
  126. tr \ \\n |
  127. grep -v ^archive- |
  128. grep -v ^device$ |
  129. grep -v ^device/common$ |
  130. xargs rm -rf
  131. fi