Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 1 | # Copyright 2011 The Android Open Source Project |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 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 | |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 15 | # Use the default values if they weren't explicitly set |
| 16 | if test "$XLOADERSRC" = "" |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 17 | then |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 18 | XLOADERSRC=xloader.img |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 19 | fi |
| 20 | if test "$BOOTLOADERSRC" = "" |
| 21 | then |
Jean-Baptiste Queru | 28b6c52 | 2012-04-02 12:17:56 -0700 | [diff] [blame] | 22 | BOOTLOADERSRC=bootloader.img |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 23 | fi |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 24 | if test "$RADIOSRC" = "" |
| 25 | then |
| 26 | RADIOSRC=radio.img |
| 27 | fi |
| 28 | if test "$SLEEPDURATION" = "" |
| 29 | then |
| 30 | SLEEPDURATION=5 |
| 31 | fi |
| 32 | |
| 33 | # Prepare the staging directory |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 34 | rm -rf tmp |
| 35 | mkdir -p tmp/$PRODUCT-$VERSION |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 36 | |
| 37 | # Extract the bootloader(s) and radio(s) as necessary |
| 38 | if test "$XLOADER" != "" |
| 39 | then |
| 40 | unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$XLOADERSRC |
| 41 | fi |
Jean-Baptiste Queru | d06dd40 | 2012-04-27 18:31:48 -0700 | [diff] [blame] | 42 | if test "$BOOTLOADERFILE" = "" |
| 43 | then |
| 44 | unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC |
| 45 | fi |
Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 46 | if test "$RADIO" != "" -a "$RADIOFILE" = "" |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 47 | then |
| 48 | unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC |
| 49 | fi |
Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 50 | if test "$CDMARADIO" != "" -a "$CDMARADIOFILE" = "" |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 51 | then |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 52 | 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] | 53 | fi |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 54 | |
| 55 | # Copy the various images in their staging location |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 56 | cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip |
Jean-Baptiste Queru | 241b668 | 2012-11-02 08:48:35 -0700 | [diff] [blame] | 57 | if test "$XLOADER" != "" |
| 58 | then |
| 59 | cp tmp/RADIO/$XLOADERSRC tmp/$PRODUCT-$VERSION/xloader-$DEVICE-$XLOADER.img |
| 60 | fi |
Jean-Baptiste Queru | d06dd40 | 2012-04-27 18:31:48 -0700 | [diff] [blame] | 61 | if test "$BOOTLOADERFILE" = "" |
| 62 | then |
| 63 | cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img |
| 64 | else |
| 65 | cp $BOOTLOADERFILE tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img |
| 66 | fi |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 67 | if test "$RADIO" != "" |
| 68 | then |
Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 69 | if test "$RADIOFILE" = "" |
| 70 | then |
| 71 | cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img |
| 72 | else |
| 73 | cp $RADIOFILE tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img |
| 74 | fi |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 75 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 76 | if test "$CDMARADIO" != "" |
| 77 | then |
Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 78 | if test "$CDMARADIOFILE" = "" |
| 79 | then |
| 80 | cp tmp/RADIO/radio-cdma.img tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img |
| 81 | else |
| 82 | cp $CDMARADIOFILE tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img |
| 83 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 84 | fi |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 85 | |
| 86 | # Write flash-all.sh |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 87 | cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 88 | #!/bin/sh |
| 89 | |
Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 90 | # Copyright 2012 The Android Open Source Project |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 91 | # |
| 92 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 93 | # you may not use this file except in compliance with the License. |
| 94 | # You may obtain a copy of the License at |
| 95 | # |
| 96 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 97 | # |
| 98 | # Unless required by applicable law or agreed to in writing, software |
| 99 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 100 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 101 | # See the License for the specific language governing permissions and |
| 102 | # limitations under the License. |
| 103 | |
Jean-Baptiste Queru | 9ceee56 | 2012-06-26 08:35:16 -0700 | [diff] [blame] | 104 | EOF |
Jean-Baptiste Queru | a705531 | 2012-11-19 08:30:28 -0800 | [diff] [blame] | 105 | if test "$UNLOCKBOOTLOADER" = "true" |
| 106 | then |
| 107 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 108 | fastboot oem unlock |
| 109 | EOF |
| 110 | fi |
Jean-Baptiste Queru | 9ceee56 | 2012-06-26 08:35:16 -0700 | [diff] [blame] | 111 | if test "$ERASEALL" = "true" |
| 112 | then |
| 113 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 114 | fastboot erase boot |
| 115 | fastboot erase cache |
| 116 | fastboot erase recovery |
| 117 | fastboot erase system |
| 118 | fastboot erase userdata |
| 119 | EOF |
| 120 | fi |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 121 | if test "$XLOADER" != "" |
| 122 | then |
| 123 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 124 | fastboot flash xloader xloader-$DEVICE-$XLOADER.img |
| 125 | EOF |
| 126 | fi |
Jean-Baptiste Queru | 9ceee56 | 2012-06-26 08:35:16 -0700 | [diff] [blame] | 127 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 128 | fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img |
Jean-Baptiste Queru | 2466e5e | 2012-10-01 17:34:18 -0700 | [diff] [blame] | 129 | EOF |
| 130 | if test "$TWINBOOTLOADERS" = "true" |
| 131 | then |
| 132 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 133 | fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img |
| 134 | EOF |
| 135 | fi |
| 136 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 137 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 138 | sleep $SLEEPDURATION |
| 139 | EOF |
| 140 | if test "$RADIO" != "" |
| 141 | then |
| 142 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 143 | fastboot flash radio radio-$DEVICE-$RADIO.img |
| 144 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 145 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 146 | EOF |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 147 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 148 | if test "$CDMARADIO" != "" |
| 149 | then |
| 150 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 151 | fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img |
| 152 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 153 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 154 | EOF |
| 155 | fi |
| 156 | cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF |
| 157 | fastboot -w update image-$PRODUCT-$VERSION.zip |
| 158 | EOF |
| 159 | chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 160 | |
| 161 | # Write flash-all.bat |
Wug Fresh | b5e3c7d | 2012-09-10 09:35:32 -0700 | [diff] [blame] | 162 | cat > tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 163 | @ECHO OFF |
| 164 | :: Copyright 2012 The Android Open Source Project |
| 165 | :: |
| 166 | :: Licensed under the Apache License, Version 2.0 (the "License"); |
| 167 | :: you may not use this file except in compliance with the License. |
| 168 | :: You may obtain a copy of the License at |
| 169 | :: |
| 170 | :: http://www.apache.org/licenses/LICENSE-2.0 |
| 171 | :: |
| 172 | :: Unless required by applicable law or agreed to in writing, software |
| 173 | :: distributed under the License is distributed on an "AS IS" BASIS, |
| 174 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 175 | :: See the License for the specific language governing permissions and |
| 176 | :: limitations under the License. |
| 177 | |
| 178 | PATH=%PATH%;"%SYSTEMROOT%\System32" |
| 179 | EOF |
Jean-Baptiste Queru | a705531 | 2012-11-19 08:30:28 -0800 | [diff] [blame] | 180 | if test "$UNLOCKBOOTLOADER" = "true" |
| 181 | then |
| 182 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 183 | fastboot oem unlock |
| 184 | EOF |
| 185 | fi |
Wug Fresh | b5e3c7d | 2012-09-10 09:35:32 -0700 | [diff] [blame] | 186 | if test "$ERASEALL" = "true" |
| 187 | then |
| 188 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 189 | fastboot erase boot |
| 190 | fastboot erase cache |
| 191 | fastboot erase recovery |
| 192 | fastboot erase system |
| 193 | fastboot erase userdata |
| 194 | EOF |
| 195 | fi |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 196 | if test "$XLOADER" != "" |
| 197 | then |
| 198 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 199 | fastboot flash xloader xloader-$DEVICE-$XLOADER.img |
| 200 | EOF |
| 201 | fi |
Wug Fresh | b5e3c7d | 2012-09-10 09:35:32 -0700 | [diff] [blame] | 202 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 203 | fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img |
Jean-Baptiste Queru | 2466e5e | 2012-10-01 17:34:18 -0700 | [diff] [blame] | 204 | EOF |
| 205 | if test "$TWINBOOTLOADERS" = "true" |
| 206 | then |
| 207 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 208 | fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img |
| 209 | EOF |
| 210 | fi |
| 211 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
Wug Fresh | b5e3c7d | 2012-09-10 09:35:32 -0700 | [diff] [blame] | 212 | fastboot reboot-bootloader |
| 213 | ping -n $SLEEPDURATION 127.0.0.1 >nul |
| 214 | EOF |
| 215 | if test "$RADIO" != "" |
| 216 | then |
| 217 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 218 | fastboot flash radio radio-$DEVICE-$RADIO.img |
| 219 | fastboot reboot-bootloader |
| 220 | ping -n $SLEEPDURATION 127.0.0.1 >nul |
| 221 | EOF |
| 222 | fi |
| 223 | if test "$CDMARADIO" != "" |
| 224 | then |
| 225 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 226 | fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img |
| 227 | fastboot reboot-bootloader |
| 228 | ping -n $SLEEPDURATION 127.0.0.1 >nul |
| 229 | EOF |
| 230 | fi |
| 231 | cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF |
| 232 | fastboot -w update image-$PRODUCT-$VERSION.zip |
| 233 | |
| 234 | echo Press any key to exit... |
| 235 | pause >nul |
| 236 | exit |
| 237 | EOF |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 238 | |
| 239 | # Write flash-base.sh |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 240 | cat > tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
| 241 | #!/bin/sh |
| 242 | |
Jean-Baptiste Queru | fdec704 | 2012-09-11 14:18:35 -0700 | [diff] [blame] | 243 | # Copyright 2012 The Android Open Source Project |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 244 | # |
| 245 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 246 | # you may not use this file except in compliance with the License. |
| 247 | # You may obtain a copy of the License at |
| 248 | # |
| 249 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 250 | # |
| 251 | # Unless required by applicable law or agreed to in writing, software |
| 252 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 253 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 254 | # See the License for the specific language governing permissions and |
| 255 | # limitations under the License. |
| 256 | |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 257 | EOF |
| 258 | if test "$XLOADER" != "" |
| 259 | then |
| 260 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
| 261 | fastboot flash xloader xloader-$DEVICE-$XLOADER.img |
| 262 | EOF |
| 263 | fi |
| 264 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 265 | fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img |
Jean-Baptiste Queru | 2466e5e | 2012-10-01 17:34:18 -0700 | [diff] [blame] | 266 | EOF |
| 267 | if test "$TWINBOOTLOADERS" = "true" |
| 268 | then |
| 269 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
| 270 | fastboot flash bootloader2 bootloader-$DEVICE-$BOOTLOADER.img |
| 271 | EOF |
| 272 | fi |
| 273 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 274 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 275 | sleep $SLEEPDURATION |
| 276 | EOF |
| 277 | if test "$RADIO" != "" |
| 278 | then |
| 279 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 280 | fastboot flash radio radio-$DEVICE-$RADIO.img |
| 281 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 282 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 283 | EOF |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 284 | fi |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 285 | if test "$CDMARADIO" != "" |
| 286 | then |
| 287 | cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF |
| 288 | fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img |
| 289 | fastboot reboot-bootloader |
Jean-Baptiste Queru | 9cb1b4a | 2012-04-19 08:44:21 -0700 | [diff] [blame] | 290 | sleep $SLEEPDURATION |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 291 | EOF |
| 292 | fi |
| 293 | chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 294 | |
| 295 | # Create the distributable package |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 296 | (cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION) |
| 297 | mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz |
Jean-Baptiste Queru | 8422277 | 2012-10-01 16:13:55 -0700 | [diff] [blame] | 298 | |
| 299 | # Clean up |
Jean-Baptiste Queru | 36cbd9a | 2012-04-02 11:01:12 -0700 | [diff] [blame] | 300 | rm -rf tmp |