blob: d6674bca30051ec97ec936e204a7b32b424c161d [file] [log] [blame]
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -07001# Copyright (C) 2011 The Android Open Source Project
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
15if test "$RADIOSRC" = ""
16then
17 RADIOSRC=radio.img
18fi
19if test "$BOOTLOADERSRC" = ""
20then
Jean-Baptiste Queru28b6c522012-04-02 12:17:56 -070021 BOOTLOADERSRC=bootloader.img
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070022fi
23rm -rf tmp
24mkdir -p tmp/$PRODUCT-$VERSION
Jean-Baptiste Querud06dd402012-04-27 18:31:48 -070025if test "$BOOTLOADERFILE" = ""
26then
27 unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC
28fi
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070029if test "$RADIO" != ""
30then
31 unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC
32fi
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070033if test "$CDMARADIO" != ""
34then
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070035 unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/radio-cdma.img
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070036fi
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070037cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip
Jean-Baptiste Querud06dd402012-04-27 18:31:48 -070038if test "$BOOTLOADERFILE" = ""
39then
40 cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
41else
42 cp $BOOTLOADERFILE tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
43fi
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070044if test "$RADIO" != ""
45then
46 cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
47fi
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070048if test "$CDMARADIO" != ""
49then
50 cp tmp/RADIO/radio-cdma.img tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img
51fi
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070052if test "$SLEEPDURATION" = ""
53then
54 SLEEPDURATION=5
55fi
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070056cat > tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
57#!/bin/sh
58
59# Copyright (C) 2011 The Android Open Source Project
60#
61# Licensed under the Apache License, Version 2.0 (the "License");
62# you may not use this file except in compliance with the License.
63# You may obtain a copy of the License at
64#
65# http://www.apache.org/licenses/LICENSE-2.0
66#
67# Unless required by applicable law or agreed to in writing, software
68# distributed under the License is distributed on an "AS IS" BASIS,
69# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70# See the License for the specific language governing permissions and
71# limitations under the License.
72
Jean-Baptiste Queru9ceee562012-06-26 08:35:16 -070073EOF
74if test "$ERASEALL" = "true"
75then
76cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
77fastboot erase boot
78fastboot erase cache
79fastboot erase recovery
80fastboot erase system
81fastboot erase userdata
82EOF
83fi
84cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070085fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
86fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070087sleep $SLEEPDURATION
88EOF
89if test "$RADIO" != ""
90then
91cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070092fastboot flash radio radio-$DEVICE-$RADIO.img
93fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070094sleep $SLEEPDURATION
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070095EOF
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -070096fi
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -070097if test "$CDMARADIO" != ""
98then
99cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
100fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
101fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700102sleep $SLEEPDURATION
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700103EOF
104fi
105cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
106fastboot -w update image-$PRODUCT-$VERSION.zip
107EOF
108chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh
Wug Freshb5e3c7d2012-09-10 09:35:32 -0700109cat > tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
110@ECHO OFF
111:: Copyright 2012 The Android Open Source Project
112::
113:: Licensed under the Apache License, Version 2.0 (the "License");
114:: you may not use this file except in compliance with the License.
115:: You may obtain a copy of the License at
116::
117:: http://www.apache.org/licenses/LICENSE-2.0
118::
119:: Unless required by applicable law or agreed to in writing, software
120:: distributed under the License is distributed on an "AS IS" BASIS,
121:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122:: See the License for the specific language governing permissions and
123:: limitations under the License.
124
125PATH=%PATH%;"%SYSTEMROOT%\System32"
126EOF
127if test "$ERASEALL" = "true"
128then
129cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
130fastboot erase boot
131fastboot erase cache
132fastboot erase recovery
133fastboot erase system
134fastboot erase userdata
135EOF
136fi
137cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
138fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
139fastboot reboot-bootloader
140ping -n $SLEEPDURATION 127.0.0.1 >nul
141EOF
142if test "$RADIO" != ""
143then
144cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
145fastboot flash radio radio-$DEVICE-$RADIO.img
146fastboot reboot-bootloader
147ping -n $SLEEPDURATION 127.0.0.1 >nul
148EOF
149fi
150if test "$CDMARADIO" != ""
151then
152cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
153fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
154fastboot reboot-bootloader
155ping -n $SLEEPDURATION 127.0.0.1 >nul
156EOF
157fi
158cat >> tmp/$PRODUCT-$VERSION/flash-all.bat << EOF
159fastboot -w update image-$PRODUCT-$VERSION.zip
160
161echo Press any key to exit...
162pause >nul
163exit
164EOF
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700165cat > tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
166#!/bin/sh
167
168# Copyright (C) 2011 The Android Open Source Project
169#
170# Licensed under the Apache License, Version 2.0 (the "License");
171# you may not use this file except in compliance with the License.
172# You may obtain a copy of the License at
173#
174# http://www.apache.org/licenses/LICENSE-2.0
175#
176# Unless required by applicable law or agreed to in writing, software
177# distributed under the License is distributed on an "AS IS" BASIS,
178# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179# See the License for the specific language governing permissions and
180# limitations under the License.
181
182fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
183fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700184sleep $SLEEPDURATION
185EOF
186if test "$RADIO" != ""
187then
188cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700189fastboot flash radio radio-$DEVICE-$RADIO.img
190fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700191sleep $SLEEPDURATION
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700192EOF
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700193fi
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700194if test "$CDMARADIO" != ""
195then
196cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
197fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
198fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700199sleep $SLEEPDURATION
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700200EOF
201fi
202chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh
203(cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION)
204mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz
205rm -rf tmp