summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/creat-lsb-image198
-rwxr-xr-xscripts/create-lsb-image228
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
19red='\E[31;40m'
20green='\E[32;40m'
21USER=`whoami`
22ARCH=$1
23MACHINE_ARCH=` bitbake -e | grep ^MACHINE_ARCH | cut -d '=' -f2 | cut -d '"' -f2`
24IMAGE_PATH=` bitbake -e | grep ^COREBASE | cut -d '=' -f2 | cut -d '"' -f2`/build/tmp/deploy/images/
25
26
27ECHO()
28{
29 echo -e "${green}$@"
30 tput sgr0
31}
32
33exit_check()
34{
35 if [ ! $? -eq 0 ]; then
36 exit $?
37 fi
38}
39
40usage()
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
49if [ $# -ne 1 ]; then
50 usage
51 exit 1
52fi
53
54#check lsb image
55if [ ! -d $IMAGE_PATH ];then
56 ECHO "${red}There isn't image directory"
57 exit 1
58fi
59ECHO "Enter directory $IMAGE_PATH"
60cd $IMAGE_PATH
61
62#get architecture
63PN=`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 ;}'`
64if [ "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
67fi
68
69if [ $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
72fi
73#set varible ARCH
74if [ ${ARCH} == x86 ];then
75 T_ARCH=ia32
76 P_ARCH=i486
77elif [ ${ARCH} == x86_64 ];then
78 T_ARCH=ia64
79 P_ARCH=ia64
80else
81 P_ARCH=ppc
82 T_ARCH=${ARCH}
83fi
84
85#umount lsbtmp
86if [ -d lsbtmp ];then
87 sudo umount lsbtmp
88fi
89
90#download lsb test suite
91mkdir -p lsb-test-suite-${MACHINE_ARCH}
92if [ -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
124else
125 ECHO "Can't find lsb test suite for ${MACHINE_ARCH}"
126fi
127cd ..
128if [ -L core-image-lsb-${MACHINE_ARCH}.ext3 ];then
129 /bin/rm core-image-lsb-${MACHINE_ARCH}.ext3
130 exit_check
131fi
132
133#creat lsb image
134if [ -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
140fi
141ECHO "creat a big ext3 file for lsb image with 5G..."
142dd if=/dev/zero of=core-image-lsb-${MACHINE_ARCH}-test.ext3 bs=1M count=5000
143exit_check
144ECHO "Format ext3 image,please input \"y\""
145mkfs.ext3 core-image-lsb-${MACHINE_ARCH}-test.ext3
146tune2fs -j core-image-lsb-${MACHINE_ARCH}-test.ext3
147
148
149ECHO "get a lsb image with lsb test suite"
150if [ ! -d lsbtmp ];then
151 mkdir lsbtmp
152fi
153
154
155#install file system and lsb test suite to lsb image
156sudo mount -o loop core-image-lsb-${MACHINE_ARCH}-test.ext3 lsbtmp
157exit_check
158
159ECHO " ->Install file system..."
160sudo tar jxf core-image-lsb-${MACHINE_ARCH}-${PN}.rootfs.tar.bz2 -C lsbtmp
161exit_check
162
163ECHO " ->Install lsb test suite..."
164cd lsb-test-suite-${MACHINE_ARCH}
165sudo tar zxf lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz -C ../lsbtmp
166exit_check
167sudo mkdir ../lsbtmp/lsb-Application
168sudo cp *.rpm ../lsbtmp/lsb-Application
169exit_check
170cd ..
171
172if [ -f modules-*-${MACHINE_ARCH}.tgz ];then
173ECHO " ->Install moules of driver..."
174 sudo tar zxf modules-*-${MACHINE_ARCH}.tgz -C lsbtmp/
175fi
176
177
178#unmount lsbtmp
179sudo umount lsbtmp
180exit_check
181sudo rm -rf lsbtmp
182
183#change file attribute
184sudo chown ${USER}:${USER} core-image-lsb-${MACHINE_ARCH}-test.ext3
185exit_check
186sudo chmod 755 core-image-lsb-${MACHINE_ARCH}-test.ext3
187exit_check
188
189#set up link
190if [ -L core-image-lsb-${MACHINE_ARCH}.ext3 ];then
191ECHO "Set up link"
192 /bin/rm core-image-lsb-${MACHINE_ARCH}.ext3
193 exit_check
194fi
195ln -s core-image-lsb-${MACHINE_ARCH}-test.ext3 core-image-lsb-${MACHINE_ARCH}.ext3
196
197ECHO "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
19red='\E[31;40m'
20green='\E[32;40m'
21
22#Get current owner
23OWNER=`whoami`
24#Get group
25GROUP=`id -gn ${USER}`
26MACHINE_ARCH=`bitbake -e | sed -n 's/^MACHINE_ARCH=\"\(.*\)\"/\1/p'`
27DEPLOY_DIR_IMAGE=`bitbake -e | sed -n 's/^DEPLOY_DIR_IMAGE=\"\(.*\)\"/\1/p'`
28#Get value of varibale MACHINE_INE and DEPLOY_DIR_IMAGE
29LSB_IMAGE=poky-image-lsb-${MACHINE_ARCH}-test.ext3
30
31ECHO()
32{
33 echo -e "${green}$@"
34 tput sgr0
35}
36
37ERROR()
38{
39 echo -e "${red}$@"
40 tput sgr0
41 exit 1
42}
43
44exit_check()
45{
46 [ $? -ne 0 ] && exit $?
47}
48
49usage()
50{
51 ECHO "Usage: PC\$ create-lsb-image ARCH ROOTFS_IMAGE"
52 ECHO " ARCH: x86 or x86-64 or ppc32"
53 ECHO " ROOTFS_IMAGE: \
54Name of the rootfs image with suffix \"tar.bz2\""
55
56
57 ECHO ""
58 ECHO "Examples:"
59 ECHO " PC\$ creat-lsb-image \
60x86 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
65if [ $# -ne 2 ]; then
66 usage
67fi
68
69#Get list for lsb test suite
70case ${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 ;;
90esac
91
92APP_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
101APP_PACKAGE_SOURCELIST="expect-tests.tar \
102 tcl-tests.tar \
103 raptor-tests.tar \
104 test1.pdf \
105 test2.pdf"
106
107PACKAGE_LIST="${COM_PACKAGE_LIST} \
108 ${APP_PACKAGE_RPMLIST} \
109 ${APP_PACKAGE_SOURCELIST}"
110
111#Version for lsb test suite
112RELEASE=released-4.1.0
113#Tools of download packages
114WGET="wget -c -t 5"
115SERVER1="\
116http://ftp.linuxfoundation.org/pub/lsb/bundles/${RELEASE}/dist-testkit"
117SERVER2="\
118http://ftp.linux-foundation.org/pub/lsb/app-battery/${RELEASE}/${T_ARCH}"
119SERVER3="http://ftp.linuxfoundation.org/pub/lsb/snapshots/appbat/tests"
120
121
122#Function for downloading package from URL pointed
123download()
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 "\
142Image directory does not exist: ${DEPLOY_DIR_IMAGE}"
143
144ECHO "Entering directory $DEPLOY_DIR_IMAGE"
145cd $DEPLOY_DIR_IMAGE
146
147if [ ! -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
151fi
152
153#Umount lsbtmp
154[ ! -d lsbtmp ] && mkdir lsbtmp
155
156#Download lsb test suite
157mkdir -p lsb-test-suite-${MACHINE_ARCH} || \
158ERROR "Couldn't find lsb test suite for ${MACHINE_ARCH}"
159cd lsb-test-suite-${MACHINE_ARCH}
160ECHO "Downloading lsb test suite, it would take some time..."
161download ${PACKAGE_LIST}
162
163cd ..
164
165#Creat lsb image
166if [ -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
170fi
171
172ECHO "Creating a 8GB file for the lsb image"
173dd if=/dev/zero of=${LSB_IMAGE} bs=1M count=8000 > /dev/null 2>&1
174exit_check
175
176ECHO "Formatting ext3 image..."
177mkfs.ext3 -q -F ${LSB_IMAGE} > /dev/null 2>&1
178tune2fs -j ${LSB_IMAGE} > /dev/null 2>&1
179
180
181ECHO "Generating final image"
182[ ! -d lsbtmp ] && mkdir lsbtmp
183
184
185#Install file system and lsb test suite to lsb image
186sudo mount -o loop ${LSB_IMAGE} lsbtmp
187exit_check
188
189ECHO " ->Installing rootfs..."
190sudo tar jpxf ${2} -C lsbtmp
191exit_check
192
193ECHO " ->Installing lsb test suite..."
194cd lsb-test-suite-${MACHINE_ARCH}
195if [ "${1}" = "x86-64" ]; then
196 sudo tar zpxf lsb-dist-testkit-4.1.0-5.${P_ARCH}.tar.gz -C ../lsbtmp
197else
198 sudo tar zpxf lsb-dist-testkit-4.1.0-5.${T_ARCH}.tar.gz -C ../lsbtmp
199fi
200exit_check
201
202sudo mkdir ../lsbtmp/lsb-Application
203sudo cp *.rpm *.tar *.pdf ../lsbtmp/lsb-Application
204exit_check
205cd ..
206
207if [ -f modules-*-${MACHINE_ARCH}.tgz ];then
208ECHO " ->Installing moudles of driver..."
209 sudo tar zpxf modules-*-${MACHINE_ARCH}.tgz -C lsbtmp/
210fi
211
212
213#Unmount lsbtmp
214sudo umount lsbtmp
215exit_check
216sudo rm -rf lsbtmp
217
218#Change file attribute
219sudo chown ${OWNER}:${GROUP} ${LSB_IMAGE}
220exit_check
221sudo chmod 755 ${LSB_IMAGE}
222exit_check
223
224#Set up link
225ln -sf ${LSB_IMAGE} poky-image-lsb-${MACHINE_ARCH}.ext3
226
227ECHO "The LSB test environment has been setup successfully."
228ECHO "Please run this image on platform ${MACHINE_ARCH}"