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