diff options
-rwxr-xr-x | scripts/creat-lsb-image | 198 | ||||
-rwxr-xr-x | scripts/create-lsb-image | 228 |
2 files changed, 228 insertions, 198 deletions
diff --git a/scripts/creat-lsb-image b/scripts/creat-lsb-image deleted file mode 100755 index 657784cba4..0000000000 --- a/scripts/creat-lsb-image +++ /dev/null | |||
@@ -1,198 +0,0 @@ | |||
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 | ARCH=$1 | ||
23 | MACHINE_ARCH=` bitbake -e | grep ^MACHINE_ARCH | cut -d '=' -f2 | cut -d '"' -f2` | ||
24 | IMAGE_PATH=` bitbake -e | grep ^COREBASE | cut -d '=' -f2 | cut -d '"' -f2`/build/tmp/deploy/images/ | ||
25 | |||
26 | |||
27 | ECHO() | ||
28 | { | ||
29 | echo -e "${green}$@" | ||
30 | tput sgr0 | ||
31 | } | ||
32 | |||
33 | exit_check() | ||
34 | { | ||
35 | if [ ! $? -eq 0 ]; then | ||
36 | exit $? | ||
37 | fi | ||
38 | } | ||
39 | |||
40 | usage() | ||
41 | { | ||
42 | ECHO "${red}usage:you should input one of the next commmands according to detailed target platform:" | ||
43 | ECHO "creat-lsb-image x86" | ||
44 | ECHO "creat-lsb-image x86_64" | ||
45 | ECHO "creat-lsb-image ppc32" | ||
46 | } | ||
47 | |||
48 | #There should be a patameter to get machine type | ||
49 | if [ $# -ne 1 ]; then | ||
50 | usage | ||
51 | exit 1 | ||
52 | fi | ||
53 | |||
54 | #check lsb image | ||
55 | if [ ! -d $IMAGE_PATH ];then | ||
56 | ECHO "${red}There isn't image directory" | ||
57 | exit 1 | ||
58 | fi | ||
59 | ECHO "Enter directory $IMAGE_PATH" | ||
60 | cd $IMAGE_PATH | ||
61 | |||
62 | #get architecture | ||
63 | PN=`find . -name core-image-lsb-${MACHINE_ARCH}\*.rootfs.tar.bz2 -type f | awk -F- 'BEGIN{ max=0;} {if( NR!=0 && $5>max ) max=$5 }END{ printf "%d" ,max ;}'` | ||
64 | if [ "XPN" == "X" ];then | ||
65 | ECHO "${red}Don't find lsb image on platform, Please run \"core-image-lsb\" to generate lsb image" | ||
66 | exit 1 | ||
67 | fi | ||
68 | |||
69 | if [ $PN -eq 0 ];then | ||
70 | ECHO "${red}Can't ${MACHINE_ARCH} rootfs.tar.gz,Please run core-image-lsb to get lsb image" | ||
71 | exit 1 | ||
72 | fi | ||
73 | #set varible ARCH | ||
74 | if [ ${ARCH} == x86 ];then | ||
75 | T_ARCH=ia32 | ||
76 | P_ARCH=i486 | ||
77 | elif [ ${ARCH} == x86_64 ];then | ||
78 | T_ARCH=ia64 | ||
79 | P_ARCH=ia64 | ||
80 | else | ||
81 | P_ARCH=ppc | ||
82 | T_ARCH=${ARCH} | ||
83 | fi | ||
84 | |||
85 | #umount lsbtmp | ||
86 | if [ -d lsbtmp ];then | ||
87 | sudo umount lsbtmp | ||
88 | fi | ||
89 | |||
90 | #download lsb test suite | ||
91 | mkdir -p lsb-test-suite-${MACHINE_ARCH} | ||
92 | if [ -d lsb-test-suite-${MACHINE_ARCH} ];then | ||
93 | cd lsb-test-suite-${MACHINE_ARCH} | ||
94 | ECHO "Download lsb test suite, it could take some time..." | ||
95 | wget -c -t 5 http://ftp.linuxfoundation.org/pub/lsb/bundles/released-4.1.0/dist-testkit/lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz | ||
96 | exit_check | ||
97 | ECHO "Download lsb-xdg-utils-4.0.0-2.${P_ARCH}.rpm" | ||
98 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/lsbdev/released-4.1.0/binary/${T_ARCH}/lsb-xdg-utils-4.0.0-2.${P_ARCH}.rpm | ||
99 | exit_check | ||
100 | ECHO "Downlocad lsb-apache-2.2.8-2.lsb4.${P_ARCH}.rpm" | ||
101 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-apache-2.2.14-3.lsb4.${P_ARCH}.rpm | ||
102 | exit_check | ||
103 | ECHO "Downlocad lsb-tcl-8.5.1-2.lsb4.${P_ARCH}.rpm" | ||
104 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-tcl-8.5.7-6.lsb4.${P_ARCH}.rpm | ||
105 | exit_check | ||
106 | ECHO "Downlocad lsb-expect-5.43.0-7.lsb4.${P_ARCH}.rpm" | ||
107 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-expect-5.43.0-11.lsb4.${P_ARCH}.rpm | ||
108 | exit_check | ||
109 | ECHO "Downlocad lsb-groff-1.19.2-4.lsb4.${P_ARCH}.rpm" | ||
110 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-groff-1.20.1-5.lsb4.${P_ARCH}.rpm | ||
111 | exit_check | ||
112 | ECHO "Downlocad lsb-raptor-1.4.16-2.lsb4.${P_ARCH}.rpm" | ||
113 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-raptor-1.4.19-3.lsb4.${P_ARCH}.rpm | ||
114 | exit_check | ||
115 | ECHO "Downlocad lsb-xpdf-1.01-7.lsb4.${P_ARCH}.rpm" | ||
116 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-xpdf-1.01-10.lsb4.${P_ARCH}.rpm | ||
117 | exit_check | ||
118 | ECHO "Downlocad lsb-samba-3.0.28a-3.lsb4.${P_ARCH}.rpm" | ||
119 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-samba-3.4.3-5.lsb4.${P_ARCH}.rpm | ||
120 | exit_check | ||
121 | ECHO "Downlocad lsb-rsync-3.0.0-2.lsb4.${P_ARCH}.rpm" | ||
122 | wget -c -t 5 http://ftp.linux-foundation.org/pub/lsb/app-battery/released-4.1.0/${T_ARCH}/lsb-rsync-3.0.6-3.lsb4.${P_ARCH}.rpm | ||
123 | exit_check | ||
124 | else | ||
125 | ECHO "Can't find lsb test suite for ${MACHINE_ARCH}" | ||
126 | fi | ||
127 | cd .. | ||
128 | if [ -L core-image-lsb-${MACHINE_ARCH}.ext3 ];then | ||
129 | /bin/rm core-image-lsb-${MACHINE_ARCH}.ext3 | ||
130 | exit_check | ||
131 | fi | ||
132 | |||
133 | #creat lsb image | ||
134 | if [ -f core-image-lsb-${MACHINE_ARCH}-test.ext3 ];then | ||
135 | if [ -d lsbtmp ];then | ||
136 | sudo umount lsbtmp | ||
137 | fi | ||
138 | ECHO "Remove old lsb image..." | ||
139 | /bin/rm core-image-lsb-${MACHINE_ARCH}-test.ext3 | ||
140 | fi | ||
141 | ECHO "creat a big ext3 file for lsb image with 5G..." | ||
142 | dd if=/dev/zero of=core-image-lsb-${MACHINE_ARCH}-test.ext3 bs=1M count=5000 | ||
143 | exit_check | ||
144 | ECHO "Format ext3 image,please input \"y\"" | ||
145 | mkfs.ext3 core-image-lsb-${MACHINE_ARCH}-test.ext3 | ||
146 | tune2fs -j core-image-lsb-${MACHINE_ARCH}-test.ext3 | ||
147 | |||
148 | |||
149 | ECHO "get a lsb image with lsb test suite" | ||
150 | if [ ! -d lsbtmp ];then | ||
151 | mkdir lsbtmp | ||
152 | fi | ||
153 | |||
154 | |||
155 | #install file system and lsb test suite to lsb image | ||
156 | sudo mount -o loop core-image-lsb-${MACHINE_ARCH}-test.ext3 lsbtmp | ||
157 | exit_check | ||
158 | |||
159 | ECHO " ->Install file system..." | ||
160 | sudo tar jxf core-image-lsb-${MACHINE_ARCH}-${PN}.rootfs.tar.bz2 -C lsbtmp | ||
161 | exit_check | ||
162 | |||
163 | ECHO " ->Install lsb test suite..." | ||
164 | cd lsb-test-suite-${MACHINE_ARCH} | ||
165 | sudo tar zxf lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz -C ../lsbtmp | ||
166 | exit_check | ||
167 | sudo mkdir ../lsbtmp/lsb-Application | ||
168 | sudo cp *.rpm ../lsbtmp/lsb-Application | ||
169 | exit_check | ||
170 | cd .. | ||
171 | |||
172 | if [ -f modules-*-${MACHINE_ARCH}.tgz ];then | ||
173 | ECHO " ->Install moules of driver..." | ||
174 | sudo tar zxf modules-*-${MACHINE_ARCH}.tgz -C lsbtmp/ | ||
175 | fi | ||
176 | |||
177 | |||
178 | #unmount lsbtmp | ||
179 | sudo umount lsbtmp | ||
180 | exit_check | ||
181 | sudo rm -rf lsbtmp | ||
182 | |||
183 | #change file attribute | ||
184 | sudo chown ${USER}:${USER} core-image-lsb-${MACHINE_ARCH}-test.ext3 | ||
185 | exit_check | ||
186 | sudo chmod 755 core-image-lsb-${MACHINE_ARCH}-test.ext3 | ||
187 | exit_check | ||
188 | |||
189 | #set up link | ||
190 | if [ -L core-image-lsb-${MACHINE_ARCH}.ext3 ];then | ||
191 | ECHO "Set up link" | ||
192 | /bin/rm core-image-lsb-${MACHINE_ARCH}.ext3 | ||
193 | exit_check | ||
194 | fi | ||
195 | ln -s core-image-lsb-${MACHINE_ARCH}-test.ext3 core-image-lsb-${MACHINE_ARCH}.ext3 | ||
196 | |||
197 | ECHO "LSB test environment is set successfully, Please run this image on platform ${MACHINE_ARCH}" | ||
198 | |||
diff --git a/scripts/create-lsb-image b/scripts/create-lsb-image new file mode 100755 index 0000000000..94cb337678 --- /dev/null +++ b/scripts/create-lsb-image | |||
@@ -0,0 +1,228 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # Copyright (C) 2010-2011 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 | |||
22 | #Get current owner | ||
23 | OWNER=`whoami` | ||
24 | #Get group | ||
25 | GROUP=`id -gn ${USER}` | ||
26 | MACHINE_ARCH=`bitbake -e | sed -n 's/^MACHINE_ARCH=\"\(.*\)\"/\1/p'` | ||
27 | DEPLOY_DIR_IMAGE=`bitbake -e | sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p'` | ||
28 | #Get value of varibale MACHINE_INE and DEPLOY_DIR_IMAGE | ||
29 | LSB_IMAGE=poky-image-lsb-${MACHINE_ARCH}-test.ext3 | ||
30 | |||
31 | ECHO() | ||
32 | { | ||
33 | echo -e "${green}$@" | ||
34 | tput sgr0 | ||
35 | } | ||
36 | |||
37 | ERROR() | ||
38 | { | ||
39 | echo -e "${red}$@" | ||
40 | tput sgr0 | ||
41 | exit 1 | ||
42 | } | ||
43 | |||
44 | exit_check() | ||
45 | { | ||
46 | [ $? -ne 0 ] && exit $? | ||
47 | } | ||
48 | |||
49 | usage() | ||
50 | { | ||
51 | ECHO "Usage: PC\$ create-lsb-image ARCH ROOTFS_IMAGE" | ||
52 | ECHO " ARCH: x86 or x86-64 or ppc32" | ||
53 | ECHO " ROOTFS_IMAGE: \ | ||
54 | Name of the rootfs image with suffix \"tar.bz2\"" | ||
55 | |||
56 | |||
57 | ECHO "" | ||
58 | ECHO "Examples:" | ||
59 | ECHO " PC\$ creat-lsb-image \ | ||
60 | x86 poky-image-lsb-qemux86-20110317030443.rootfs.tar.bz2" | ||
61 | exit 1 | ||
62 | } | ||
63 | |||
64 | #There should be two parameters to get machine type and name of image | ||
65 | if [ $# -ne 2 ]; then | ||
66 | usage | ||
67 | fi | ||
68 | |||
69 | #Get list for lsb test suite | ||
70 | case ${1} in | ||
71 | "x86") | ||
72 | T_ARCH=ia32 | ||
73 | P_ARCH=i486 | ||
74 | COM_PACKAGE_LIST="lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz" | ||
75 | ;; | ||
76 | "x86-64") | ||
77 | T_ARCH=amd64 | ||
78 | P_ARCH=x86_64 | ||
79 | MACHINE_ARCH=${MACHINE_ARCH/x86_64/x86-64} | ||
80 | COM_PACKAGE_LIST="lsb-dist-testkit-4.1.0-5.${P_ARCH}.tar.gz" | ||
81 | ;; | ||
82 | "ppc32") | ||
83 | P_ARCH=ppc | ||
84 | T_ARCH=${ARCH} | ||
85 | COM_PACKAGE_LIST="lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz" | ||
86 | ;; | ||
87 | *) | ||
88 | usage | ||
89 | ;; | ||
90 | esac | ||
91 | |||
92 | APP_PACKAGE_RPMLIST="lsb-apache-2.2.14-3.lsb4.${P_ARCH}.rpm \ | ||
93 | lsb-tcl-8.5.7-6.lsb4.${P_ARCH}.rpm \ | ||
94 | lsb-expect-5.43.0-11.lsb4.${P_ARCH}.rpm \ | ||
95 | lsb-groff-1.20.1-5.lsb4.${P_ARCH}.rpm \ | ||
96 | lsb-raptor-1.4.19-3.lsb4.${P_ARCH}.rpm \ | ||
97 | lsb-xpdf-1.01-10.lsb4.${P_ARCH}.rpm \ | ||
98 | lsb-samba-3.4.3-5.lsb4.${P_ARCH}.rpm \ | ||
99 | lsb-rsync-3.0.6-3.lsb4.${P_ARCH}.rpm" | ||
100 | |||
101 | APP_PACKAGE_SOURCELIST="expect-tests.tar \ | ||
102 | tcl-tests.tar \ | ||
103 | raptor-tests.tar \ | ||
104 | test1.pdf \ | ||
105 | test2.pdf" | ||
106 | |||
107 | PACKAGE_LIST="${COM_PACKAGE_LIST} \ | ||
108 | ${APP_PACKAGE_RPMLIST} \ | ||
109 | ${APP_PACKAGE_SOURCELIST}" | ||
110 | |||
111 | #Version for lsb test suite | ||
112 | RELEASE=released-4.1.0 | ||
113 | #Tools of download packages | ||
114 | WGET="wget -c -t 5" | ||
115 | SERVER1="\ | ||
116 | http://ftp.linuxfoundation.org/pub/lsb/bundles/${RELEASE}/dist-testkit" | ||
117 | SERVER2="\ | ||
118 | http://ftp.linux-foundation.org/pub/lsb/app-battery/${RELEASE}/${T_ARCH}" | ||
119 | SERVER3="http://ftp.linuxfoundation.org/pub/lsb/snapshots/appbat/tests" | ||
120 | |||
121 | |||
122 | #Function for downloading package from URL pointed | ||
123 | download() | ||
124 | { | ||
125 | |||
126 | for i in $@; do | ||
127 | ECHO " -->Downloading package \"${i}\"" | ||
128 | PACKAGE_NAME=${i} | ||
129 | suffix=${PACKAGE_NAME##*.} | ||
130 | if [ "$suffix" = "gz" ];then | ||
131 | ${WGET} ${SERVER1}/${i} | ||
132 | elif [ "$suffix" = "rpm" ];then | ||
133 | ${WGET} ${SERVER2}/${i} | ||
134 | else | ||
135 | ${WGET} ${SERVER3}/${i} | ||
136 | fi | ||
137 | done | ||
138 | } | ||
139 | |||
140 | #Check lsb image | ||
141 | [ ! -d $DEPLOY_DIR_IMAGE ] && ERROR "\ | ||
142 | Image directory does not exist: ${DEPLOY_DIR_IMAGE}" | ||
143 | |||
144 | ECHO "Entering directory $DEPLOY_DIR_IMAGE" | ||
145 | cd $DEPLOY_DIR_IMAGE | ||
146 | |||
147 | if [ ! -f ${2} ]; then | ||
148 | ECHO "rootfs image \"${2}\" not found in ${DEPLOY_DIR_IMAGE}" | ||
149 | ECHO "Please copy \"${2}\" to \"${DEPLOY_DIR_IMAGE}\"" | ||
150 | exit 1 | ||
151 | fi | ||
152 | |||
153 | #Umount lsbtmp | ||
154 | [ ! -d lsbtmp ] && mkdir lsbtmp | ||
155 | |||
156 | #Download lsb test suite | ||
157 | mkdir -p lsb-test-suite-${MACHINE_ARCH} || \ | ||
158 | ERROR "Couldn't find lsb test suite for ${MACHINE_ARCH}" | ||
159 | cd lsb-test-suite-${MACHINE_ARCH} | ||
160 | ECHO "Downloading lsb test suite, it would take some time..." | ||
161 | download ${PACKAGE_LIST} | ||
162 | |||
163 | cd .. | ||
164 | |||
165 | #Creat lsb image | ||
166 | if [ -f ${LSB_IMAGE} ];then | ||
167 | sudo umount lsbtmp > /dev/null 2>&1 | ||
168 | ECHO "Removing old lsb image..." | ||
169 | /bin/rm ${LSB_IMAGE} > /dev/null 2>&1 | ||
170 | fi | ||
171 | |||
172 | ECHO "Creating a 8GB file for the lsb image" | ||
173 | dd if=/dev/zero of=${LSB_IMAGE} bs=1M count=8000 > /dev/null 2>&1 | ||
174 | exit_check | ||
175 | |||
176 | ECHO "Formatting ext3 image..." | ||
177 | mkfs.ext3 -q -F ${LSB_IMAGE} > /dev/null 2>&1 | ||
178 | tune2fs -j ${LSB_IMAGE} > /dev/null 2>&1 | ||
179 | |||
180 | |||
181 | ECHO "Generating final image" | ||
182 | [ ! -d lsbtmp ] && mkdir lsbtmp | ||
183 | |||
184 | |||
185 | #Install file system and lsb test suite to lsb image | ||
186 | sudo mount -o loop ${LSB_IMAGE} lsbtmp | ||
187 | exit_check | ||
188 | |||
189 | ECHO " ->Installing rootfs..." | ||
190 | sudo tar jpxf ${2} -C lsbtmp | ||
191 | exit_check | ||
192 | |||
193 | ECHO " ->Installing lsb test suite..." | ||
194 | cd lsb-test-suite-${MACHINE_ARCH} | ||
195 | if [ "${1}" = "x86-64" ]; then | ||
196 | sudo tar zpxf lsb-dist-testkit-4.1.0-5.${P_ARCH}.tar.gz -C ../lsbtmp | ||
197 | else | ||
198 | sudo tar zpxf lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz -C ../lsbtmp | ||
199 | fi | ||
200 | exit_check | ||
201 | |||
202 | sudo mkdir ../lsbtmp/lsb-Application | ||
203 | sudo cp *.rpm *.tar *.pdf ../lsbtmp/lsb-Application | ||
204 | exit_check | ||
205 | cd .. | ||
206 | |||
207 | if [ -f modules-*-${MACHINE_ARCH}.tgz ];then | ||
208 | ECHO " ->Installing moudles of driver..." | ||
209 | sudo tar zpxf modules-*-${MACHINE_ARCH}.tgz -C lsbtmp/ | ||
210 | fi | ||
211 | |||
212 | |||
213 | #Unmount lsbtmp | ||
214 | sudo umount lsbtmp | ||
215 | exit_check | ||
216 | sudo rm -rf lsbtmp | ||
217 | |||
218 | #Change file attribute | ||
219 | sudo chown ${OWNER}:${GROUP} ${LSB_IMAGE} | ||
220 | exit_check | ||
221 | sudo chmod 755 ${LSB_IMAGE} | ||
222 | exit_check | ||
223 | |||
224 | #Set up link | ||
225 | ln -sf ${LSB_IMAGE} poky-image-lsb-${MACHINE_ARCH}.ext3 | ||
226 | |||
227 | ECHO "The LSB test environment has been setup successfully." | ||
228 | ECHO "Please run this image on platform ${MACHINE_ARCH}" | ||