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