diff options
author | Bill Yi <byi@google.com> | 2014-03-19 11:37:18 -0700 |
---|---|---|
committer | Bill Yi <byi@google.com> | 2014-03-19 12:01:01 -0700 |
commit | ecc033e56c42e0c19018c809acf1f6a8a7249e6f (patch) | |
tree | a1e52c09146895ff2ce0bdf60c34b2362537c0a0 | |
parent | 6a2995683de147791e516aae2ccb31fdfbe2ad30 (diff) | |
download | device_common-ecc033e56c42e0c19018c809acf1f6a8a7249e6f.tar.gz device_common-ecc033e56c42e0c19018c809acf1f6a8a7249e6f.tar.bz2 device_common-ecc033e56c42e0c19018c809acf1f6a8a7249e6f.zip |
Create a generate-packages.sh for all devices
Change-Id: Ib2da4b502853b2eed0d965ea18af22bd4b63496e
-rwxr-xr-x | generate-packages.sh | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/generate-packages.sh b/generate-packages.sh new file mode 100755 index 0000000..e4f45f1 --- /dev/null +++ b/generate-packages.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# Copyright 2012 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ $# != 6 ] +then + echo Usage: $0 BUILD_ID BUILD ROOTDEVICE DEVICE MANUFACTURER PRODUCT + echo Example: $0 1075408 KOT49Y mako mako lge occam +fi + +ZIP_TYPE=target_files # ota | target_files + +ZIP=$6-$ZIP_TYPE-$1.zip +BUILD=$2 + +ROOTDEVICE=$3 +DEVICE=$4 +MANUFACTURER=$5 + +cd ../$MANUFACTURER/$ROOTDEVICE/self-extractors || echo Error change dir + +EXTRACT_LIST_FILENAME=extract-lists.txt + +for COMPANY in `grep "[a-z|A-Z])" $EXTRACT_LIST_FILENAME | cut -f1 -d')'` +do + echo Processing files from $COMPANY + rm -rf tmp + FILEDIR=tmp/vendor/$COMPANY/$DEVICE/proprietary + mkdir -p $FILEDIR + mkdir -p tmp/vendor/$MANUFACTURER/$ROOTDEVICE + + TO_EXTRACT=`sed -n -e '/'"$COMPANY"'/,/;;/ p' $EXTRACT_LIST_FILENAME | tail -n+3 | head -n-2 | sed -e 's/\\\//g'` + + echo \ \ Extracting files from OTA package + for ONE_FILE in $TO_EXTRACT + do + if test ${ZIP_TYPE} = target_files + then + ONE_FILE=`echo $ONE_FILE | sed 's/system\//SYSTEM\//g'` + fi + echo \ \ \ \ Extracting $ONE_FILE + unzip -j -o $ZIP $ONE_FILE -d $FILEDIR > /dev/null || echo \ \ \ \ Error extracting $ONE_FILE + if test ${ONE_FILE,,} = system/vendor/bin/gpsd -o ${ONE_FILE,,} = system/vendor/bin/pvrsrvinit -o ${ONE_FILE,,} = system/bin/fRom + then + chmod a+x $FILEDIR/$(basename $ONE_FILE) || echo \ \ \ \ Error chmoding $ONE_FILE + fi + done + echo \ \ Setting up $COMPANY-specific makefiles + cp -R $COMPANY/staging/* tmp/vendor/$COMPANY/$DEVICE || echo \ \ \ \ Error copying makefiles + echo \ \ Setting up shared makefiles + cp -R root/* tmp/vendor/$MANUFACTURER/$ROOTDEVICE || echo \ \ \ \ Error copying makefiles + echo \ \ Generating self-extracting script + SCRIPT=extract-$COMPANY-$DEVICE.sh + cat PROLOGUE > tmp/$SCRIPT || echo \ \ \ \ Error generating script + cat $COMPANY/COPYRIGHT >> tmp/$SCRIPT || echo \ \ \ \ Error generating script + cat PART1 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script + cat $COMPANY/LICENSE >> tmp/$SCRIPT || echo \ \ \ \ Error generating script + cat PART2 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script + 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 + cat PART3 >> tmp/$SCRIPT || echo \ \ \ \ Error generating script + (cd tmp ; tar zc --owner=root --group=root vendor/ >> $SCRIPT || echo \ \ \ \ Error generating embedded tgz) + chmod a+x tmp/$SCRIPT || echo \ \ \ \ Error generating script + ARCHIVE=$COMPANY-$DEVICE-$BUILD-$(md5sum < tmp/$SCRIPT | cut -b -8 | tr -d \\n).tgz + rm -f $ARCHIVE + echo \ \ Generating final archive + (cd tmp ; tar --owner=root --group=root -z -c -f ../$ARCHIVE $SCRIPT || echo \ \ \ \ Error archiving script) + rm -rf tmp +done |