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