blob: a82e3d2a4ed306c921d5f3063892833cbb348163 [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
109cat > tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
110#!/bin/sh
111
112# Copyright (C) 2011 The Android Open Source Project
113#
114# Licensed under the Apache License, Version 2.0 (the "License");
115# you may not use this file except in compliance with the License.
116# You may obtain a copy of the License at
117#
118# http://www.apache.org/licenses/LICENSE-2.0
119#
120# Unless required by applicable law or agreed to in writing, software
121# distributed under the License is distributed on an "AS IS" BASIS,
122# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123# See the License for the specific language governing permissions and
124# limitations under the License.
125
126fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
127fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700128sleep $SLEEPDURATION
129EOF
130if test "$RADIO" != ""
131then
132cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700133fastboot flash radio radio-$DEVICE-$RADIO.img
134fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700135sleep $SLEEPDURATION
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700136EOF
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700137fi
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700138if test "$CDMARADIO" != ""
139then
140cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
141fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
142fastboot reboot-bootloader
Jean-Baptiste Queru9cb1b4a2012-04-19 08:44:21 -0700143sleep $SLEEPDURATION
Jean-Baptiste Queru36cbd9a2012-04-02 11:01:12 -0700144EOF
145fi
146chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh
147(cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION)
148mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz
149rm -rf tmp