Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 275 lines (269 sloc) 10.117 kB
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
1 #!/bin/bash
2 run_kiwi()
3 {
4 imagetype=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE imagetype)
5 imagename=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE filename)
6 imageversion=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE version)
7 # prepare rpms as source and createrepo on the repositories
6c5a993 @adrianschroeter * fix repo creation in --noinit case
adrianschroeter authored
8 ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos
9 cd $BUILD_ROOT/$TOPDIR/SOURCES/repos
10 for r in */* ; do
11 test -L $r && continue
12 test -d $r || continue
13 repo="$TOPDIR/SOURCES/repos/$r/"
14 # create compatibility link for old kiwi versions
15 rc="${r//:/:/}"
16 if test "$rc" != "$r" ; then
17 rl="${rc//[^\/]}"
18 rl="${rl//?/../}"
19 mkdir -p "${rc%/*}"
20 ln -s $rl$r "${rc%/*}/${rc##*/}"
21 repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/"
22 fi
7aa8a7f @adrianschroeter - do not run createrepo on --no-init
adrianschroeter authored
23 if test "$imagetype" != product -a "$DO_INIT" != "false" ; then
5edc095 @mlschroe - run createrepo with --simple-md-filenames if possible
mlschroe authored
24 echo "creating repodata for $repo"
25 if chroot $BUILD_ROOT createrepo --simple-md-filenames --help >/dev/null 2>&1 ; then
26 chroot $BUILD_ROOT createrepo --simple-md-filenames "$repo"
27 else
28 chroot $BUILD_ROOT createrepo "$repo"
29 fi
6c5a993 @adrianschroeter * fix repo creation in --noinit case
adrianschroeter authored
30 fi
31 done
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
32 # unpack root tar
33 for t in $BUILD_ROOT/$TOPDIR/SOURCES/root.tar* ; do
34 test -f $t || continue
35 mkdir -p $BUILD_ROOT/$TOPDIR/SOURCES/root
36 chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/root -xf "$TOPDIR/SOURCES/${t##*/}"
37 done
38 # fix script permissions
39 chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/*.sh 2>/dev/null
40 # unpack tar files in image directories
41 if test -d $BUILD_ROOT/$TOPDIR/SOURCES/images ; then
42 (
43 cd $BUILD_ROOT/$TOPDIR/SOURCES/images
44 for r in */* ; do
45 test -L $r && continue
46 test -d $r || continue
47 for t in $r/root.tar* ; do
48 test -f $t || continue
49 mkdir -p $r/root
50 chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/images/$r/root -xf "$TOPDIR/SOURCES/images/$r/${t##*/}"
51 done
52 # fix script permissions
53 chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/images/$r/*.sh 2>/dev/null
54 # create compatibility link for old kiwi versions
55 rc="${r//:/:/}"
56 if test "$rc" != "$r" ; then
57 rl="${rc//[^\/]}"
58 rl="${rl//?/../}"
59 mkdir -p "${rc%/*}"
60 ln -s $rl$r "${rc%/*}/${rc##*/}"
61 fi
62 done
63 )
64 fi
65 rm -f $BUILD_ROOT/$TOPDIR/SOURCES/config.xml
66 ln -s $SPECFILE $BUILD_ROOT/$TOPDIR/SOURCES/config.xml
67 if test "$imagetype" = product ; then
68 echo "running kiwi --create-instsource..."
69 # runs always as abuild user
70 mkdir -p "$BUILD_ROOT/$TOPDIR/KIWIROOT"
71 chroot "$BUILD_ROOT" chown -R abuild.abuild "$TOPDIR"
75e96df @adrianschroeter - handle past and current kiwi versions correctly during product buil…
adrianschroeter authored
72 ver=`chroot "$BUILD_ROOT" su -c "/usr/sbin/kiwi --version | sed -n 's,.*kiwi version v\(.*\),\1,p'"`
73 if [ ${ver:0:1} == "3" ]; then
74 # old style kiwi 3 builds
75 chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/sbin/kiwi --root $TOPDIR/KIWIROOT -v --logfile terminal -p $TOPDIR/SOURCES --instsource-local --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true
76 if [ ${ver:2:2} == "01" ]; then
77 ## This block is obsolete with current kiwi versions, only needed for kiwi 3.01 version
78 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
79 test -d "$i" || continue
80 n="${i##*/}"
81 test "$n" = scripts && continue
82 test "$n" != "${n%0}" && continue
83 chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER
84 done
85 fi
86 else
59ad51c @bugfinder fix kiwi verbosity again, version number detection back to 4.90
bugfinder authored
87 if [ ${ver:0:1} == "4" -a ${ver:2:2} -lt 90 ]; then
b037032 @adrianschroeter - handle broken kiwi from openSUSE 11.4 correctly and increase runlev…
adrianschroeter authored
88 # broken kiwi version, not accepting verbose level
59ad51c @bugfinder fix kiwi verbosity again, version number detection back to 4.90
bugfinder authored
89 chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/sbin/kiwi --root $TOPDIR/KIWIROOT -v -v --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true
b037032 @adrianschroeter - handle broken kiwi from openSUSE 11.4 correctly and increase runlev…
adrianschroeter authored
90 else
91 # current default
92 chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/sbin/kiwi --root $TOPDIR/KIWIROOT -v 2 --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true
93 fi
75e96df @adrianschroeter - handle past and current kiwi versions correctly during product buil…
adrianschroeter authored
94 fi
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
95
96 # move created product to correct destination
97 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
98 test -e "$i" || continue
99 f=${i##*/}
100 case $f in
101 *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
102 scripts) ;;
103 *0) ;;
104 *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
105 esac
106 done
107 else
108 BUILD_SUCCEEDED=true
109 if [ -z "$RUNNING_IN_VM" ]; then
110 # NOTE: this must be done with the outer system, because it loads the dm-mod kernel modules, which needs to fit to the kernel.
111 echo "starting device mapper for kiwi..."
112 [ -x /etc/init.d/boot.device-mapper ] && /etc/init.d/boot.device-mapper start
113 fi
114 for imgtype in $imagetype ; do
115 echo "running kiwi --prepare for $imgtype..."
116 # Do not use $BUILD_USER here, since we always need root permissions
7aa8a7f @adrianschroeter - do not run createrepo on --no-init
adrianschroeter authored
117 if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
118 echo "running kiwi --create for $imgtype..."
119 mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
7aa8a7f @adrianschroeter - do not run createrepo on --no-init
adrianschroeter authored
120 chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --create $TOPDIR/KIWIROOT-$imgtype --logfile terminal --type $imgtype -d $TOPDIR/KIWI-$imgtype" - root < /dev/null || cleanup_and_exit 1
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
121 else
122 cleanup_and_exit 1
123 fi
124 done
125
126 # create tar.gz of images, in case it makes sense
127 imagearch=`uname -m`
128 buildnum=""
129 if test -n "$RELEASE"; then
130 buildnum="-Build$RELEASE"
131 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
132 imageout="$imagename.$imagearch-$imageversion"
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
133 for imgtype in $imagetype ; do
134 case "$imgtype" in
135 oem)
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
136 cat > $BUILD_ROOT/kiwi_post.sh << EOF
137 echo "compressing oem images... "
138 cd /$TOPDIR/KIWI-oem
139 if [ -e "$imageout.iso" ]; then
140 echo "take iso file and create sha256..."
141 mv "$imageout.iso" "/$TOPDIR/KIWI/$imageout$buildnum.iso"
e30617e @adrianschroeter fix bzip2 and sha1sum also in oem case
adrianschroeter authored
142 pushd /$TOPDIR/KIWI
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
143 if [ -x /usr/bin/sha256sum ]; then
144 /usr/bin/sha256sum "$imageout$buildnum.iso" > "$imageout$buildnum.iso.sha256"
145 fi
e30617e @adrianschroeter fix bzip2 and sha1sum also in oem case
adrianschroeter authored
146 popd
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
147 fi
148 if [ -e "$imageout.raw" ]; then
471ff33 @adrianschroeter - use xz as compression tool for oem-kiwi images if possible (as it s…
adrianschroeter authored
149 compress_tool="bzip2"
150 compress_suffix="bz2"
151 if [ -x /usr/bin/xz ]; then
152 # take xz to get support for sparse files
153 compress_tool="xz -2"
154 compress_suffix="xz"
155 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
156 mv "$imageout.raw" "/$TOPDIR/KIWI/$imageout$buildnum.raw"
e30617e @adrianschroeter fix bzip2 and sha1sum also in oem case
adrianschroeter authored
157 pushd /$TOPDIR/KIWI
471ff33 @adrianschroeter - use xz as compression tool for oem-kiwi images if possible (as it s…
adrianschroeter authored
158 echo "\$compress_tool raw file..."
159 \$compress_tool "$imageout$buildnum.raw"
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
160 if [ -x /usr/bin/sha256sum ]; then
161 echo "Create sha256 file..."
471ff33 @adrianschroeter - use xz as compression tool for oem-kiwi images if possible (as it s…
adrianschroeter authored
162 /usr/bin/sha256sum "$imageout$buildnum.raw.\${compress_suffix}" > "$imageout$buildnum.raw.\${compress_suffix}.sha256"
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
163 fi
e30617e @adrianschroeter fix bzip2 and sha1sum also in oem case
adrianschroeter authored
164 popd
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
165 fi
e30617e @adrianschroeter fix bzip2 and sha1sum also in oem case
adrianschroeter authored
166
8b623cd @adrianschroeter fix exporting iso and raw files in oem mode
adrianschroeter authored
167 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-raw.tar.bz2" \
168 --exclude="$imageout.iso" --exclude="$imageout.raw" *
169 cd /$TOPDIR/KIWI
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
170 if [ -x /usr/bin/sha256sum ]; then
171 /usr/bin/sha256sum "$imageout$buildnum-raw.tar.bz2" > "$imageout$buildnum-raw.tar.bz2.sha256"
172 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
173 EOF
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
174 ;;
175 vmx)
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
176 cat > $BUILD_ROOT/kiwi_post.sh << EOF
177 echo "compressing vmx images... "
178 cd /$TOPDIR/KIWI-vmx
179 # This option has a number of format parameters
8efdb79 @adrianschroeter * tar vmx kind images into logical groups.
adrianschroeter authored
180 VMXFILES=""
181 SHAFILES=""
f4273d6 @adrianschroeter The ovf file is useless alone, package it as part of the vmdk/vmx tar…
adrianschroeter authored
182 for i in "$imageout.vmx" "$imageout.vmdk" "$imageout-disk*.vmdk" "$imageout.ovf"; do
8efdb79 @adrianschroeter * tar vmx kind images into logical groups.
adrianschroeter authored
183 ls \$i >& /dev/null && VMXFILES="\$VMXFILES \$i"
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
184 done
5a04634 @adrianschroeter - take .raw files as fallback build result if nothing else exists
adrianschroeter authored
185 # take raw files as fallback
186 if [ -z "\$VMXFILES" ]; then
6c793a6 @adrianschroeter - fix syntax error when compressing vmx kiwi build images
adrianschroeter authored
187 ls "$imageout.raw" >& /dev/null && VMXFILES="$imageout.raw"
5a04634 @adrianschroeter - take .raw files as fallback build result if nothing else exists
adrianschroeter authored
188 fi
8efdb79 @adrianschroeter * tar vmx kind images into logical groups.
adrianschroeter authored
189 if [ -n "\$VMXFILES" ]; then
190 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" \$VMXFILES
191 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
192 fi
193
194 if [ -e "$imageout.xenconfig" ]; then
33bf7d0 @adrianschroeter xen images need the initrd files packaged
adrianschroeter authored
195 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" $imageout.xenconfig $imageout.raw initrd-*
8efdb79 @adrianschroeter * tar vmx kind images into logical groups.
adrianschroeter authored
196 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
197 fi
198 # FIXME: do we need a single .raw file in any case ?
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
199
200 cd /$TOPDIR/KIWI
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
201 if [ -n "\$SHAFILES" -a -x /usr/bin/sha256sum ]; then
8efdb79 @adrianschroeter * tar vmx kind images into logical groups.
adrianschroeter authored
202 for i in \$SHAFILES; do
203 echo "Create sha256 file..."
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
204 /usr/bin/sha256sum "\$i" > "\$i.sha256"
8efdb79 @adrianschroeter * tar vmx kind images into logical groups.
adrianschroeter authored
205 done
206 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
207 EOF
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
208 ;;
209 xen)
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
210 cat > $BUILD_ROOT/kiwi_post.sh << EOF
211 echo "compressing xen images... "
212 cd /$TOPDIR/KIWI-xen
213 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-xen.tar.bz2" \
214 `grep ^kernel $imageout.xenconfig | cut -d'"' -f2` \
215 `grep ^ramdisk $imageout.xenconfig | cut -d'"' -f2` \
ddcb056 @adrianschroeter also xen guest images need the initrd files
adrianschroeter authored
216 initrd-* \
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
217 "$imageout.xenconfig" \
218 "$imageout"
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
219 if [ -x /usr/bin/sha256sum ]; then
220 echo "Create sha256 file..."
221 cd $TOPDIR/KIWI
222 /usr/bin/sha256sum "$imageout$buildnum-xen.tar.bz2" > "$imageout$buildnum-xen.tar.bz2.sha256"
223 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
224 EOF
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
225 ;;
226 pxe)
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
227 cat > $BUILD_ROOT/kiwi_post.sh << EOF
228 echo "compressing pxe images... "
229 cd /$TOPDIR/KIWI-pxe
1c9a49e @adrianschroeter fix syntax error
adrianschroeter authored
230 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-pxe.tar.bz2" ${imageout}* initrd-*
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
231 if [ -x /usr/bin/sha256sum ]; then
232 echo "Create sha256 file..."
233 cd $TOPDIR/KIWI
234 /usr/bin/sha256sum "$imageout$buildnum-pxe.tar.bz2" > "$imageout$buildnum-pxe.tar.bz2.sha256"
235 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
236 EOF
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
237 ;;
238 iso)
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
239 cat > $BUILD_ROOT/kiwi_post.sh << EOF
240 cd /$TOPDIR/KIWI-iso
241 for i in *.iso; do
242 mv "\$i" "/$TOPDIR/KIWI/\${i%.iso}$buildnum.iso"
243 done
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
244 if [ -x /usr/bin/sha256sum ]; then
245 echo "creating sha256 sum for iso images... "
246 cd $TOPDIR/KIWI
247 for i in *.iso; do
248 /usr/bin/sha256sum "\$i" > "\$i.sha256"
249 done
250 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
251 EOF
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
252 ;;
253 *)
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
254 cat > $BUILD_ROOT/kiwi_post.sh << EOF
255 echo "compressing unkown images... "
256 cd /$TOPDIR/KIWI-$imgtype
257 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-$imgtype.tar.bz2" *
9796f16 @adrianschroeter make sha256sum run optional, old systems like SLE 10 based don't have…
adrianschroeter authored
258 if [ -x /usr/bin/sha256sum ]; then
259 echo "Create sha256 file..."
260 cd /$TOPDIR/KIWI
261 /usr/bin/sha256sum "$imageout$buildnum-$imgtype.tar.bz2" > "$imageout$buildnum-$imgtype.tar.bz2.sha256"
262 fi
0c47e12 cleanup build_kiwi.sh (step 2 from ro)
Ruediger Oertel authored
263 EOF
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
264 ;;
265 esac
471ff33 @adrianschroeter - use xz as compression tool for oem-kiwi images if possible (as it s…
adrianschroeter authored
266 chroot $BUILD_ROOT su -c "sh -e /kiwi_post.sh" || cleanup_and_exit 1
e1ec400 cleanup build_kiwi.sh (step 3)
Ruediger Oertel authored
267 rm -f $BUILD_ROOT/kiwi_post.sh
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
268 done
269 fi
ac44f4b @adrianschroeter - add hook to run QA tests esp for post product builds
adrianschroeter authored
270 # Hook for running post kiwi build scripts like QA scripts if installed
e03027c @adrianschroeter - fix test for existens kiwi qa script
adrianschroeter authored
271 if [ -x $BUILD_ROOT/usr/lib/build/kiwi_post_run ]; then
ac44f4b @adrianschroeter - add hook to run QA tests esp for post product builds
adrianschroeter authored
272 chroot $BUILD_ROOT su -c /usr/lib/build/kiwi_post_run || cleanup_and_exit 1
273 fi
db96d9d @lnussel move huge block of kiwi code to separate file
lnussel authored
274 }
Something went wrong with that request. Please try again.