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
8 ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos
9 cd $BUILD_ROOT/$TOPDIR/SOURCES/repos
11 test -L $r && continue
12 test -d $r || continue
13 repo="$TOPDIR/SOURCES/repos/$r/"
14 # create compatibility link for old kiwi versions
16 if test "$rc" != "$r" ; then
20 ln -s $rl$r "${rc%/*}/${rc##*/}"
21 repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/"
23 if test "$imagetype" != product ; then
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"
28 chroot $BUILD_ROOT createrepo "$repo"
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##*/}"
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
43 cd $BUILD_ROOT/$TOPDIR/SOURCES/images
45 test -L $r && continue
46 test -d $r || continue
47 for t in $r/root.tar* ; do
48 test -f $t || continue
50 chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/images/$r/root -xf "$TOPDIR/SOURCES/images/$r/${t##*/}"
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
56 if test "$rc" != "$r" ; then
60 ln -s $rl$r "${rc%/*}/${rc##*/}"
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"
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
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
87 if [ ${ver:0:1} == "4" -a ${ver:2:2} -lt 90 ]; then
88 # broken kiwi version, not accepting verbose level
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
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
96 # move created product to correct destination
97 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
98 test -e "$i" || continue
101 *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
104 *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
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
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
117 if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then
118 echo "running kiwi --create for $imgtype..."
119 mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
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
126 # create tar.gz of images, in case it makes sense
129 if test -n "$RELEASE"; then
130 buildnum="-Build$RELEASE"
132 imageout="$imagename.$imagearch-$imageversion"
133 for imgtype in $imagetype ; do
136 cat > $BUILD_ROOT/kiwi_post.sh << EOF
137 echo "compressing oem images... "
139 if [ -e "$imageout.iso" ]; then
140 echo "take iso file and create sha256..."
141 mv "$imageout.iso" "/$TOPDIR/KIWI/$imageout$buildnum.iso"
143 if [ -x /usr/bin/sha256sum ]; then
144 /usr/bin/sha256sum "$imageout$buildnum.iso" > "$imageout$buildnum.iso.sha256"
148 if [ -e "$imageout.raw" ]; then
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"
156 mv "$imageout.raw" "/$TOPDIR/KIWI/$imageout$buildnum.raw"
158 echo "\$compress_tool raw file..."
159 \$compress_tool "$imageout$buildnum.raw"
160 if [ -x /usr/bin/sha256sum ]; then
161 echo "Create sha256 file..."
162 /usr/bin/sha256sum "$imageout$buildnum.raw.\${compress_suffix}" > "$imageout$buildnum.raw.\${compress_suffix}.sha256"
167 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-raw.tar.bz2" \
168 --exclude="$imageout.iso" --exclude="$imageout.raw" *
170 if [ -x /usr/bin/sha256sum ]; then
171 /usr/bin/sha256sum "$imageout$buildnum-raw.tar.bz2" > "$imageout$buildnum-raw.tar.bz2.sha256"
176 cat > $BUILD_ROOT/kiwi_post.sh << EOF
177 echo "compressing vmx images... "
179 # This option has a number of format parameters
182 for i in "$imageout.vmx" "$imageout.vmdk" "$imageout-disk*.vmdk" "$imageout.ovf"; do
183 ls \$i >& /dev/null && VMXFILES="\$VMXFILES \$i"
185 if [ -n "\$VMXFILES" ]; then
186 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" \$VMXFILES
187 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
190 if [ -e "$imageout.xenconfig" ]; then
191 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" $imageout.xenconfig $imageout.raw initrd-*
192 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
194 # FIXME: do we need a single .raw file in any case ?
197 if [ -n "\$SHAFILES" -a -x /usr/bin/sha256sum ]; then
198 for i in \$SHAFILES; do
199 echo "Create sha256 file..."
200 /usr/bin/sha256sum "\$i" > "\$i.sha256"
206 cat > $BUILD_ROOT/kiwi_post.sh << EOF
207 echo "compressing xen images... "
209 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-xen.tar.bz2" \
210 `grep ^kernel $imageout.xenconfig | cut -d'"' -f2` \
211 `grep ^ramdisk $imageout.xenconfig | cut -d'"' -f2` \
213 "$imageout.xenconfig" \
215 if [ -x /usr/bin/sha256sum ]; then
216 echo "Create sha256 file..."
218 /usr/bin/sha256sum "$imageout$buildnum-xen.tar.bz2" > "$imageout$buildnum-xen.tar.bz2.sha256"
223 cat > $BUILD_ROOT/kiwi_post.sh << EOF
224 echo "compressing pxe images... "
226 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-pxe.tar.bz2" ${imageout}* initrd-*
227 if [ -x /usr/bin/sha256sum ]; then
228 echo "Create sha256 file..."
230 /usr/bin/sha256sum "$imageout$buildnum-pxe.tar.bz2" > "$imageout$buildnum-pxe.tar.bz2.sha256"
235 cat > $BUILD_ROOT/kiwi_post.sh << EOF
238 mv "\$i" "/$TOPDIR/KIWI/\${i%.iso}$buildnum.iso"
240 if [ -x /usr/bin/sha256sum ]; then
241 echo "creating sha256 sum for iso images... "
244 /usr/bin/sha256sum "\$i" > "\$i.sha256"
250 cat > $BUILD_ROOT/kiwi_post.sh << EOF
251 echo "compressing unkown images... "
252 cd /$TOPDIR/KIWI-$imgtype
253 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-$imgtype.tar.bz2" *
254 if [ -x /usr/bin/sha256sum ]; then
255 echo "Create sha256 file..."
257 /usr/bin/sha256sum "$imageout$buildnum-$imgtype.tar.bz2" > "$imageout$buildnum-$imgtype.tar.bz2.sha256"
262 chroot $BUILD_ROOT su -c "sh -e /kiwi_post.sh" || cleanup_and_exit 1
263 rm -f $BUILD_ROOT/kiwi_post.sh
266 # Hook for running post kiwi build scripts like QA scripts if installed
267 if [ -x /usr/lib/build/kiwi_post_run ]; then
268 chroot $BUILD_ROOT su -c /usr/lib/build/kiwi_post_run || cleanup_and_exit 1