Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 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 | |
| 15 | if test "$RADIOSRC" = "" |
| 16 | then |
| 17 | RADIOSRC=radio.img |
| 18 | fi |
| 19 | if test "$BOOTLOADERSRC" = "" |
| 20 | then |
Jean-Baptiste Queru | 28b6c52 | 2012-04-02 12:17:56 -0700 | [diff] [blame] | 21 | BOOTLOADERSRC=bootloader.img |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 22 | fi |
| 23 | rm -rf tmp |
| 24 | mkdir -p tmp/$PRODUCT-$VERSION |
Jean-Baptiste Queru | d06dd40 | 2012-04-27 18:31:48 -0700 | [diff] [blame] | 25 | if test "$BOOTLOADERFILE" = "" |
| 26 | then |
| 27 | unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC |
| 28 | fi |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 29 | if test "$RADIO" != "" |
| 30 | then |
| 31 | unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC |
| 32 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 33 | if test "$CDMARADIO" != "" |
| 34 | then |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 35 | unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/radio-cdma.img |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 36 | fi |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 37 | cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip |
Jean-Baptiste Queru | d06dd40 | 2012-04-27 18:31:48 -0700 | [diff] [blame] | 38 | if test "$BOOTLOADERFILE" = "" |
| 39 | then |
| 40 | cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img |
| 41 | else |
| 42 | cp $BOOTLOADERFILE tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img |
| 43 | fi |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 44 | if test "$RADIO" != "" |
| 45 | then |
| 46 | cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img |
| 47 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 48 | if test "$CDMARADIO" != "" |
| 49 | then |
| 50 | cp tmp/RADIO/radio-cdma.img tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img |
| 51 | fi |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 52 | if test "$SLEEPDURATION" = "" |
| 53 | then |
| 54 | SLEEPDURATION=5 |
| 55 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 56 | cat > 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 | |
Jean-Baptiste Queru | 9ceee56 | 2012-06-26 08:35:16 -0700 | [diff] [blame] | 73 | EOF |
| 74 | if test "$ERASEALL" = "true" |
| 75 | then |
| 76 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 77 | fastboot erase boot |
| 78 | fastboot erase cache |
| 79 | fastboot erase recovery |
| 80 | fastboot erase system |
| 81 | fastboot erase userdata |
| 82 | EOF |
| 83 | fi |
| 84 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 85 | fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img |
| 86 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 87 | sleep $SLEEPDURATION |
| 88 | EOF |
| 89 | if test "$RADIO" != "" |
| 90 | then |
| 91 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 92 | fastboot flash radio radio-$DEVICE-$RADIO.img |
| 93 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 94 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 95 | EOF |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 96 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 97 | if test "$CDMARADIO" != "" |
| 98 | then |
| 99 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 100 | fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img |
| 101 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 102 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 103 | EOF |
| 104 | fi |
| 105 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 106 | fastboot -w update image-$PRODUCT-$VERSION.zip |
| 107 | EOF |
| 108 | chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh |
Wug Fresh | b5e3c7d | 2012-09-10 09:35:32 -0700 | [diff] [blame] | 109 | cat > 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 | |
| 125 | PATH=%PATH%;"%SYSTEMROOT%\System32" |
| 126 | EOF |
| 127 | if test "$ERASEALL" = "true" |
| 128 | then |
| 129 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 130 | fastboot erase boot |
| 131 | fastboot erase cache |
| 132 | fastboot erase recovery |
| 133 | fastboot erase system |
| 134 | fastboot erase userdata |
| 135 | EOF |
| 136 | fi |
| 137 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 138 | fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img |
| 139 | fastboot reboot-bootloader |
| 140 | ping -n $SLEEPDURATION 127.0.0.1 >nul |
| 141 | EOF |
| 142 | if test "$RADIO" != "" |
| 143 | then |
| 144 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 145 | fastboot flash radio radio-$DEVICE-$RADIO.img |
| 146 | fastboot reboot-bootloader |
| 147 | ping -n $SLEEPDURATION 127.0.0.1 >nul |
| 148 | EOF |
| 149 | fi |
| 150 | if test "$CDMARADIO" != "" |
| 151 | then |
| 152 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 153 | fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img |
| 154 | fastboot reboot-bootloader |
| 155 | ping -n $SLEEPDURATION 127.0.0.1 >nul |
| 156 | EOF |
| 157 | fi |
| 158 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 159 | fastboot -w update image-$PRODUCT-$VERSION.zip |
| 160 | |
| 161 | echo Press any key to exit... |
| 162 | pause >nul |
| 163 | exit |
| 164 | EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 165 | cat > 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 | |
| 182 | fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img |
| 183 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 184 | sleep $SLEEPDURATION |
| 185 | EOF |
| 186 | if test "$RADIO" != "" |
| 187 | then |
| 188 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 189 | fastboot flash radio radio-$DEVICE-$RADIO.img |
| 190 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 191 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 192 | EOF |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 193 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 194 | if test "$CDMARADIO" != "" |
| 195 | then |
| 196 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
| 197 | fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img |
| 198 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 199 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 200 | EOF |
| 201 | fi |
| 202 | chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh |
| 203 | (cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION) |
| 204 | mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz |
| 205 | rm -rf tmp |