OSDN Git Service

Allow packaging factory images from a separate bootloader file
[android-x86/device-common.git] / generate-factory-images-common.sh
1 # 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
15 if test "$RADIOSRC" = ""
16 then
17   RADIOSRC=radio.img
18 fi
19 if test "$BOOTLOADERSRC" = ""
20 then
21   BOOTLOADERSRC=bootloader.img
22 fi
23 rm -rf tmp
24 mkdir -p tmp/$PRODUCT-$VERSION
25 if test "$BOOTLOADERFILE" = ""
26 then
27   unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$BOOTLOADERSRC
28 fi
29 if test "$RADIO" != ""
30 then
31   unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/$RADIOSRC
32 fi
33 if test "$CDMARADIO" != ""
34 then
35   unzip -d tmp ${SRCPREFIX}$PRODUCT-target_files-$BUILD.zip RADIO/radio-cdma.img
36 fi
37 cp ${SRCPREFIX}$PRODUCT-img-$BUILD.zip tmp/$PRODUCT-$VERSION/image-$PRODUCT-$VERSION.zip
38 if test "$BOOTLOADERFILE" = ""
39 then
40   cp tmp/RADIO/$BOOTLOADERSRC tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
41 else
42   cp $BOOTLOADERFILE tmp/$PRODUCT-$VERSION/bootloader-$DEVICE-$BOOTLOADER.img
43 fi
44 if test "$RADIO" != ""
45 then
46   cp tmp/RADIO/$RADIOSRC tmp/$PRODUCT-$VERSION/radio-$DEVICE-$RADIO.img
47 fi
48 if test "$CDMARADIO" != ""
49 then
50   cp tmp/RADIO/radio-cdma.img tmp/$PRODUCT-$VERSION/radio-cdma-$DEVICE-$CDMARADIO.img
51 fi
52 if test "$SLEEPDURATION" = ""
53 then
54   SLEEPDURATION=5
55 fi
56 cat > 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
73 fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
74 fastboot reboot-bootloader
75 sleep $SLEEPDURATION
76 EOF
77 if test "$RADIO" != ""
78 then
79 cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
80 fastboot flash radio radio-$DEVICE-$RADIO.img
81 fastboot reboot-bootloader
82 sleep $SLEEPDURATION
83 EOF
84 fi
85 if test "$CDMARADIO" != ""
86 then
87 cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
88 fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
89 fastboot reboot-bootloader
90 sleep $SLEEPDURATION
91 EOF
92 fi
93 cat >> tmp/$PRODUCT-$VERSION/flash-all.sh << EOF
94 fastboot -w update image-$PRODUCT-$VERSION.zip
95 EOF
96 chmod a+x tmp/$PRODUCT-$VERSION/flash-all.sh
97 cat > tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
98 #!/bin/sh
99
100 # Copyright (C) 2011 The Android Open Source Project
101 #
102 # Licensed under the Apache License, Version 2.0 (the "License");
103 # you may not use this file except in compliance with the License.
104 # You may obtain a copy of the License at
105 #
106 #      http://www.apache.org/licenses/LICENSE-2.0
107 #
108 # Unless required by applicable law or agreed to in writing, software
109 # distributed under the License is distributed on an "AS IS" BASIS,
110 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111 # See the License for the specific language governing permissions and
112 # limitations under the License.
113
114 fastboot flash bootloader bootloader-$DEVICE-$BOOTLOADER.img
115 fastboot reboot-bootloader
116 sleep $SLEEPDURATION
117 EOF
118 if test "$RADIO" != ""
119 then
120 cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
121 fastboot flash radio radio-$DEVICE-$RADIO.img
122 fastboot reboot-bootloader
123 sleep $SLEEPDURATION
124 EOF
125 fi
126 if test "$CDMARADIO" != ""
127 then
128 cat >> tmp/$PRODUCT-$VERSION/flash-base.sh << EOF
129 fastboot flash radio-cdma radio-cdma-$DEVICE-$CDMARADIO.img
130 fastboot reboot-bootloader
131 sleep $SLEEPDURATION
132 EOF
133 fi
134 chmod a+x tmp/$PRODUCT-$VERSION/flash-base.sh
135 (cd tmp ; tar zcvf ../$PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION)
136 mv $PRODUCT-$VERSION-factory.tgz $PRODUCT-$VERSION-factory-$(sha1sum < $PRODUCT-$VERSION-factory.tgz | cut -b -8).tgz
137 rm -rf tmp