1# Copyright (C) 2011 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15if test "$RADIOSRC" = "" 16then 17 RADIOSRC=radio.img 18fi 19if test "$BOOTLOADERSRC" = "" 20then 21 BOOTLOADERSRC=bootloader.img 22fi 23rm -rf tmp 24mkdir -p tmp/$PRODUCT-$VERSION 25if test "$BOOTLOADERFILE" = "" 26then 27 unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC 28fi 29if test "$RADIO" != "" 30then 31 unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC 32fi 33if test "$CDMARADIO" != "" 34then 35 unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/radio-cdma.img 36fi 37cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip 38if test "$BOOTLOADERFILE" = "" 39then 40 cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img 41else 42 cp $BOOTLOADERFILE tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img 43fi 44if test "$RADIO" != "" 45then 46 cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img 47fi 48if test "$CDMARADIO" != "" 49then 50 cp tmp/RADIO/radio-cdma.img tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img 51fi 52if test "$SLEEPDURATION" = "" 53then 54 SLEEPDURATION=5 55fi 56cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 57#!/bin/sh 58 59# Copyright (C) 2011 The Android Open Source Project 60# 61# Licensed under the Apache License, Version 2.0 (the "License"); 62# you may not use this file except in compliance with the License. 63# You may obtain a copy of the License at 64# 65# http://www.apache.org/licenses/LICENSE-2.0 66# 67# Unless required by applicable law or agreed to in writing, software 68# distributed under the License is distributed on an "AS IS" BASIS, 69# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 70# See the License for the specific language governing permissions and 71# limitations under the License. 72 73EOF 74if test "$ERASEALL" = "true" 75then 76cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 77fastboot erase boot 78fastboot erase cache 79fastboot erase recovery 80fastboot erase system 81fastboot erase userdata 82EOF 83fi 84cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 85fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img 86fastboot reboot-bootloader 87sleep $SLEEPDURATION 88EOF 89if test "$RADIO" != "" 90then 91cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 92fastboot flash radio radio-$DEVICE-$RADIO.img 93fastboot reboot-bootloader 94sleep $SLEEPDURATION 95EOF 96fi 97if test "$CDMARADIO" != "" 98then 99cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 100fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img 101fastboot reboot-bootloader 102sleep $SLEEPDURATION 103EOF 104fi 105cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF 106fastboot -w update image-$PRODUCT-$VERSION.zip 107EOF 108chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh 109cat > tmp/$PRODUCT-$VERSION/flash-all.bat << EOF 110@ECHO OFF 111:: Copyright 2012 The Android Open Source Project 112:: 113:: Licensed under the Apache License, Version 2.0 (the "License"); 114:: you may not use this file except in compliance with the License. 115:: You may obtain a copy of the License at 116:: 117:: http://www.apache.org/licenses/LICENSE-2.0 118:: 119:: Unless required by applicable law or agreed to in writing, software 120:: distributed under the License is distributed on an "AS IS" BASIS, 121:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122:: See the License for the specific language governing permissions and 123:: limitations under the License. 124 125PATH=%PATH%;"%SYSTEMROOT%\System32" 126EOF 127if test "$ERASEALL" = "true" 128then 129cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF 130fastboot erase boot 131fastboot erase cache 132fastboot erase recovery 133fastboot erase system 134fastboot erase userdata 135EOF 136fi 137cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF 138fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img 139fastboot reboot-bootloader 140ping -n $SLEEPDURATION 127.0.0.1 >nul 141EOF 142if test "$RADIO" != "" 143then 144cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF 145fastboot flash radio radio-$DEVICE-$RADIO.img 146fastboot reboot-bootloader 147ping -n $SLEEPDURATION 127.0.0.1 >nul 148EOF 149fi 150if test "$CDMARADIO" != "" 151then 152cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF 153fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img 154fastboot reboot-bootloader 155ping -n $SLEEPDURATION 127.0.0.1 >nul 156EOF 157fi 158cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF 159fastboot -w update image-$PRODUCT-$VERSION.zip 160 161echo Press any key to exit... 162pause >nul 163exit 164EOF 165cat > tmp/$PRODUCT-$VERSION/flash-base.sh << EOF 166#!/bin/sh 167 168# Copyright (C) 2011 The Android Open Source Project 169# 170# Licensed under the Apache License, Version 2.0 (the "License"); 171# you may not use this file except in compliance with the License. 172# You may obtain a copy of the License at 173# 174# http://www.apache.org/licenses/LICENSE-2.0 175# 176# Unless required by applicable law or agreed to in writing, software 177# distributed under the License is distributed on an "AS IS" BASIS, 178# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 179# See the License for the specific language governing permissions and 180# limitations under the License. 181 182fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img 183fastboot reboot-bootloader 184sleep $SLEEPDURATION 185EOF 186if test "$RADIO" != "" 187then 188cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF 189fastboot flash radio radio-$DEVICE-$RADIO.img 190fastboot reboot-bootloader 191sleep $SLEEPDURATION 192EOF 193fi 194if test "$CDMARADIO" != "" 195then 196cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF 197fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img 198fastboot reboot-bootloader 199sleep $SLEEPDURATION 200EOF 201fi 202chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh 203(cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION) 204mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz 205rm -rf tmp 206