diff options
author | Xiaofeng Yan <xiaofeng.yan@windriver.com> | 2010-12-10 15:46:49 +0800 |
---|---|---|
committer | Saul Wold <Saul.Wold@intel.com> | 2010-12-10 22:01:40 -0800 |
commit | f39dae9f155b2f73c54fa5fc1bedd69f2ff87386 (patch) | |
tree | dbf5bac336c8f0ab39692a069a0a888178dd1662 | |
parent | bc61818ac096fff071540c174b6660ca31b9ba30 (diff) | |
download | poky-f39dae9f155b2f73c54fa5fc1bedd69f2ff87386.tar.gz |
creat-lsb-image: download lsb test suite and creat a image with lsb test suite
If we make a test with lsb test suite, then we must creat a large image with lsb test suite.
three function in this script:
1 download lsb test suite
2 creat a block file with 3G
3 install file system of poky-image-lsb, modules of driver and lsb test suite
Signed-off-by: Xiaofeng Yan <xiaofeng.yan@windriver.com>
-rwxr-xr-x | scripts/creat-lsb-image | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/scripts/creat-lsb-image b/scripts/creat-lsb-image new file mode 100755 index 0000000000..71d9215d41 --- /dev/null +++ b/scripts/creat-lsb-image | |||
@@ -0,0 +1,170 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # Copyright (c) 2005-2010 Wind River Systems, Inc. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify | ||
6 | # it under the terms of the GNU General Public License version 2 as | ||
7 | # published by the Free Software Foundation. | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
12 | # See the GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with this program; if not, write to the Free Software | ||
16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | |||
18 | |||
19 | red='\E[31;40m' | ||
20 | green='\E[32;40m' | ||
21 | USER=`whoami` | ||
22 | MACHINE=$1 | ||
23 | IMAGE_PATH=../build/tmp/deploy/images/ | ||
24 | |||
25 | |||
26 | ECHO() | ||
27 | { | ||
28 | echo -e "${green}$@" | ||
29 | tput sgr0 | ||
30 | } | ||
31 | |||
32 | exit_check() | ||
33 | { | ||
34 | if [ ! $? -eq 0 ]; then | ||
35 | exit $? | ||
36 | fi | ||
37 | } | ||
38 | |||
39 | usage() | ||
40 | { | ||
41 | ECHO "${red}usage:you should input one of the next commmands according to detailed target platform:" | ||
42 | ECHO "creat-lsb-image qemux86" | ||
43 | ECHO "creat-lsb-image qemux86-64" | ||
44 | ECHO "creat-lsb-image qemuppc" | ||
45 | } | ||
46 | |||
47 | #There should be a patameter to get machine type | ||
48 | if [ $# -ne 1 ]; then | ||
49 | usage | ||
50 | exit 1 | ||
51 | fi | ||
52 | |||
53 | #check lsb image | ||
54 | if [ ! -d $IMAGE_PATH ];then | ||
55 | ECHO "${red}There isn't image directory" | ||
56 | exit 1 | ||
57 | fi | ||
58 | ECHO "Enter directory $IMAGE_PATH" | ||
59 | cd $IMAGE_PATH | ||
60 | |||
61 | #get architecture | ||
62 | case $MACHINE in | ||
63 | qemux86) | ||
64 | ARCH=ia32 | ||
65 | PN=`find . -name poky-image-lsb-${MACHINE}\*.rootfs.tar.bz2 -type f | awk -F- 'BEGIN{ max=0;} {if( NR!=0 && $5>max ) max=$5 }END{ printf "%d" ,max ;}'` | ||
66 | if [ "XPN" == "X" ];then | ||
67 | ECHO "${red}Don't find lsb image on platform, Please run \"poky-image-lsb\" to generate lsb image" | ||
68 | exit 1 | ||
69 | fi | ||
70 | ;; | ||
71 | qemux86-64) | ||
72 | ARCH=x86_64 | ||
73 | PN=`find . -nam! e poky-image-lsb-${MACHINE}\*.rootfs.tar.bz2 -type f | awk -F- 'BEGIN{ max=0; } {if( NR!=0 && $6>max ) max=$6 }END{ printf "%d" ,max ;}'` | ||
74 | if [ "X${PN}" == "X" ];then | ||
75 | ECHO "${red}Don't find lsb image on platform, Please run \"poky-image-lsb\" to generate lsb image" | ||
76 | exit 1 | ||
77 | fi | ||
78 | ;; | ||
79 | qemuppc) | ||
80 | ARCH=ppc32 | ||
81 | PN=`find . -name poky-image-lsb-${MACHINE}\*.rootfs.tar.bz2 -type f | awk -F- 'BEGIN{ max=0;} {if( NR!=0 && $5>max ) max=$5 }END{ printf "%d" ,max ;}'` | ||
82 | if [ "XPN" == "X" ];then | ||
83 | ECHO "${red}Don't find lsb image on platform, Please run \"poky-image-lsb\" to generate lsb image" | ||
84 | fi | ||
85 | ;; | ||
86 | *) | ||
87 | ECHO "${red}Don't support lsb test for platform ${MACHINE}" | ||
88 | exit 1 | ||
89 | esac | ||
90 | |||
91 | if [ $PN -eq 0 ];then | ||
92 | ECHO "${red}Can't ${MACHINE} rootfs.tar.gz,Please run poky-image-lsb to get lsb image" | ||
93 | exit 1 | ||
94 | fi | ||
95 | |||
96 | #download lsb test suite | ||
97 | if [ ! -f lsb-dist-testkit-4.0.2-1.${ARCH}.tar.gz ];then | ||
98 | ECHO "Download lsb test suite, it could take some time..." | ||
99 | wget -c -t 5 http://ftp.linuxfoundation.org/pub/lsb/bundles/released-4.0.0/dist-testkit/lsb-dist-testkit-4.0.2-1.${ARCH}.tar.gz | ||
100 | exit_check | ||
101 | else | ||
102 | ECHO "Find lsb test suite for ${MACHINE}" | ||
103 | fi | ||
104 | |||
105 | #if [ -L poky-image-lsb-${MACHINE}.ext3 ];then | ||
106 | # /bin/rm poky-image-lsb-${MACHINE}.ext3 | ||
107 | # exit_check | ||
108 | #fi | ||
109 | |||
110 | #creat lsb image | ||
111 | if [ -f poky-image-lsb-${MACHINE}-test.ext3 ];then | ||
112 | if [ -d lsbtmp ];then | ||
113 | sudo umount lsbtmp | ||
114 | fi | ||
115 | ECHO "Remove old lsb image..." | ||
116 | /bin/rm poky-image-lsb-${MACHINE}-test.ext3 | ||
117 | fi | ||
118 | ECHO "creat a big ext3 file for lsb image with 3G..." | ||
119 | dd if=/dev/zero of=poky-image-lsb-${MACHINE}-test.ext3 bs=1M count=3000 | ||
120 | exit_check | ||
121 | ECHO "Format ext3 image,please input \"y\"" | ||
122 | mkfs.ext3 poky-image-lsb-${MACHINE}-test.ext3 | ||
123 | tune2fs -j poky-image-lsb-${MACHINE}-test.ext3 | ||
124 | |||
125 | |||
126 | ECHO "get a lsb image with lsb test suite" | ||
127 | if [ ! -d lsbtmp ];then | ||
128 | mkdir lsbtmp | ||
129 | fi | ||
130 | |||
131 | |||
132 | #install file system and lsb test suite to lsb image | ||
133 | sudo mount -o loop poky-image-lsb-${MACHINE}-test.ext3 lsbtmp | ||
134 | exit_check | ||
135 | |||
136 | ECHO " ->Install file system..." | ||
137 | sudo tar jxf poky-image-lsb-${MACHINE}-${PN}.rootfs.tar.bz2 -C lsbtmp | ||
138 | exit_check | ||
139 | |||
140 | ECHO " ->Install lsb test suite..." | ||
141 | sudo tar zxf lsb-dist-testkit-4.0.2-1.${ARCH}.tar.gz -C lsbtmp | ||
142 | exit_check | ||
143 | |||
144 | if [ -f modules-*-${MACHINE}.tgz ];then | ||
145 | ECHO " ->Install moules of driver..." | ||
146 | sudo tar zxf modules-*-${MACHINE}.tgz -C lsbtmp/ | ||
147 | fi | ||
148 | |||
149 | |||
150 | #mount lsbtmp | ||
151 | sudo umount lsbtmp | ||
152 | exit_check | ||
153 | sudo rm -rf lsbtmp | ||
154 | |||
155 | #change file attribute | ||
156 | sudo chown ${USER}:${USER} poky-image-lsb-${MACHINE}-test.ext3 | ||
157 | exit_check | ||
158 | sudo chmod 755 poky-image-lsb-${MACHINE}-test.ext3 | ||
159 | exit_check | ||
160 | |||
161 | #set up link | ||
162 | if [ -L poky-image-lsb-${MACHINE}.ext3 ];then | ||
163 | ECHO "Set up link" | ||
164 | /bin/rm poky-image-lsb-${MACHINE}.ext3 | ||
165 | exit_check | ||
166 | fi | ||
167 | ln -s poky-image-lsb-${MACHINE}-test.ext3 poky-image-lsb-${MACHINE}.ext3 | ||
168 | |||
169 | ECHO "LSB test environment is set successfully, Please run \"poky-qemu ${MACHINE}\" to start up lsb-image" | ||
170 | |||