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