Bill Yi | ecc033e | 2014-03-19 11:37:18 -0700 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright 2012 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 | if [ $# != 6 ] |
| 18 | then |
| 19 | echo Usage: $0 BUILD_ID BUILD ROOTDEVICE DEVICE MANUFACTURER PRODUCT |
| 20 | echo Example: $0 1075408 KOT49Y mako mako lge occam |
| 21 | fi |
| 22 | |
| 23 | ZIP_TYPE=target_files # ota | target_files |
| 24 | |
| 25 | ZIP=$6-$ZIP_TYPE-$1.zip |
| 26 | BUILD=$2 |
| 27 | |
| 28 | ROOTDEVICE=$3 |
| 29 | DEVICE=$4 |
| 30 | MANUFACTURER=$5 |
| 31 | |
| 32 | cd ../$MANUFACTURER/$ROOTDEVICE/self-extractors || echo Error change dir |
| 33 | |
| 34 | EXTRACT_LIST_FILENAME=extract-lists.txt |
| 35 | |
| 36 | for COMPANY in `grep "[a-z|A-Z])" $EXTRACT_LIST_FILENAME | cut -f1 -d')'` |
| 37 | do |
| 38 | echo Processing files from $COMPANY |
| 39 | rm -rf tmp |
| 40 | FILEDIR=tmp/vendor/$COMPANY/$DEVICE/proprietary |
| 41 | mkdir -p $FILEDIR |
| 42 | mkdir -p tmp/vendor/$MANUFACTURER/$ROOTDEVICE |
| 43 | |
| 44 | TO_EXTRACT=`sed -n -e '/'"$COMPANY"'/,/;;/ p' $EXTRACT_LIST_FILENAME | tail -n+3 | head -n-2 | sed -e 's/\\\//g'` |
| 45 | |
| 46 | echo \ \ Extracting files from OTA package |
| 47 | for ONE_FILE in $TO_EXTRACT |
| 48 | do |
| 49 | if test ${ZIP_TYPE} = target_files |
| 50 | then |
| 51 | ONE_FILE=`echo $ONE_FILE | sed 's/system\//SYSTEM\//g'` |
| 52 | fi |
| 53 | echo \ \ \ \ Extracting $ONE_FILE |
| 54 | unzip -j -o $ZIP $ONE_FILE -d $FILEDIR > /dev/null || echo \ \ \ \ Error extracting $ONE_FILE |
| 55 | if test ${ONE_FILE,,} = system/vendor/bin/gpsd -o ${ONE_FILE,,} = system/vendor/bin/pvrsrvinit -o ${ONE_FILE,,} = system/bin/fRom |
| 56 | then |
| 57 | chmod a+x $FILEDIR/$(basename $ONE_FILE) || echo \ \ \ \ Error chmoding $ONE_FILE |
| 58 | fi |
| 59 | done |
| 60 | echo \ \ Setting up $COMPANY-specific makefiles |
| 61 | cp -R $COMPANY/staging/* tmp/vendor/$COMPANY/$DEVICE || echo \ \ \ \ Error copying makefiles |
| 62 | echo \ \ Setting up shared makefiles |
| 63 | cp -R root/* tmp/vendor/$MANUFACTURER/$ROOTDEVICE || echo \ \ \ \ Error copying makefiles |
| 64 | echo \ \ Generating self-extracting script |
| 65 | SCRIPT=extract-$COMPANY-$DEVICE.sh |
| 66 | cat PROLOGUE > tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 67 | cat $COMPANY/COPYRIGHT >> tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 68 | cat PART1 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 69 | cat $COMPANY/LICENSE >> tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 70 | cat PART2 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 71 | echo tail -n +$(expr 2 + $(cat PROLOGUE $COMPANY/COPYRIGHT PART1 $COMPANY/LICENSE PART2 PART3 | wc -l)) \$0 \| tar zxv >> tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 72 | cat PART3 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 73 | (cd tmp ; tar zc --owner=root --group=root vendor/ >> $SCRIPT || echo \ \ \ \ Error generating embedded tgz) |
| 74 | chmod a+x tmp/$SCRIPT || echo \ \ \ \ Error generating script |
| 75 | ARCHIVE=$COMPANY-$DEVICE-$BUILD-$(md5sum < tmp/$SCRIPT | cut -b -8 | tr -d \\n).tgz |
| 76 | rm -f $ARCHIVE |
| 77 | echo \ \ Generating final archive |
| 78 | (cd tmp ; tar --owner=root --group=root -z -c -f ../$ARCHIVE $SCRIPT || echo \ \ \ \ Error archiving script) |
| 79 | rm -rf tmp |
| 80 | done |