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 chroot $BUILD_ROOT createrepo "$repo"
29 for t in $BUILD_ROOT/$TOPDIR/SOURCES/root.tar* ; do
30 test -f $t || continue
31 mkdir -p $BUILD_ROOT/$TOPDIR/SOURCES/root
32 chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/root -xf "$TOPDIR/SOURCES/${t##*/}"
34 # fix script permissions
35 chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/*.sh 2>/dev/null
36 # unpack tar files in image directories
37 if test -d $BUILD_ROOT/$TOPDIR/SOURCES/images ; then
39 cd $BUILD_ROOT/$TOPDIR/SOURCES/images
41 test -L $r && continue
42 test -d $r || continue
43 for t in $r/root.tar* ; do
44 test -f $t || continue
46 chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/images/$r/root -xf "$TOPDIR/SOURCES/images/$r/${t##*/}"
48 # fix script permissions
49 chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/images/$r/*.sh 2>/dev/null
50 # create compatibility link for old kiwi versions
52 if test "$rc" != "$r" ; then
56 ln -s $rl$r "${rc%/*}/${rc##*/}"
61 rm -f $BUILD_ROOT/$TOPDIR/SOURCES/config.xml
62 ln -s $SPECFILE $BUILD_ROOT/$TOPDIR/SOURCES/config.xml
63 chroot $BUILD_ROOT su -c "kiwi --version" -
64 if test "$imagetype" = product ; then
65 echo "running kiwi --create-instsource..."
66 # runs always as abuild user
67 mkdir -p "$BUILD_ROOT/$TOPDIR/KIWIROOT"
68 chroot "$BUILD_ROOT" chown -R abuild.abuild "$TOPDIR"
69 # --instsource-local is only needed for openSUSE 11.1 and SLE 11 SP0 kiwi.
70 chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/sbin/kiwi --root $TOPDIR/KIWIROOT -v -v --logfile terminal -p $TOPDIR/SOURCES --instsource-local --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true
71 ### This block is obsolete with current kiwi versions, only needed for kiwi 3.01 version
72 # for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
73 # test -d "$i" || continue
75 # test "$n" = scripts && continue
76 # test "$n" != "${n%0}" && continue
77 # chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER
80 # move created product to correct destination
81 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
82 test -e "$i" || continue
85 *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
88 *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
93 if [ -z "$RUNNING_IN_VM" ]; then
94 # NOTE: this must be done with the outer system, because it loads the dm-mod kernel modules, which needs to fit to the kernel.
95 echo "starting device mapper for kiwi..."
96 [ -x /etc/init.d/boot.device-mapper ] && /etc/init.d/boot.device-mapper start
98 for imgtype in $imagetype ; do
99 echo "running kiwi --prepare for $imgtype..."
100 # Do not use $BUILD_USER here, since we always need root permissions
101 if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then
102 echo "running kiwi --create for $imgtype..."
103 mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
104 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
110 # create tar.gz of images, in case it makes sense
113 if test -n "$RELEASE"; then
114 buildnum="-Build$RELEASE"
116 imageout="$imagename.$imagearch-$imageversion"
117 for imgtype in $imagetype ; do
120 cat > $BUILD_ROOT/kiwi_post.sh << EOF
121 echo "compressing oem images... "
123 if [ -e "$imageout.iso" ]; then
124 echo "take iso file and create sha256..."
125 mv "$imageout.iso" "/$TOPDIR/KIWI/$imageout$buildnum.iso"
127 if [ -x /usr/bin/sha256sum ]; then
128 /usr/bin/sha256sum "$imageout$buildnum.iso" > "$imageout$buildnum.iso.sha256"
132 if [ -e "$imageout.raw" ]; then
133 mv "$imageout.raw" "/$TOPDIR/KIWI/$imageout$buildnum.raw"
135 echo "bzip2 raw file..."
136 bzip2 "$imageout$buildnum.raw"
137 if [ -x /usr/bin/sha256sum ]; then
138 echo "Create sha256 file..."
139 /usr/bin/sha256sum "$imageout$buildnum.raw.bz2" > "$imageout$buildnum.raw.bz2.sha256"
144 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-raw.tar.bz2" \
145 --exclude="$imageout.iso" --exclude="$imageout.raw" *
147 if [ -x /usr/bin/sha256sum ]; then
148 /usr/bin/sha256sum "$imageout$buildnum-raw.tar.bz2" > "$imageout$buildnum-raw.tar.bz2.sha256"
153 cat > $BUILD_ROOT/kiwi_post.sh << EOF
154 echo "compressing vmx images... "
156 # This option has a number of format parameters
159 for i in "$imageout.vmx" "$imageout.vmdk" "$imageout-disk*.vmdk" "$imageout.ovf"; do
160 ls \$i >& /dev/null && VMXFILES="\$VMXFILES \$i"
162 if [ -n "\$VMXFILES" ]; then
163 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" \$VMXFILES
164 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
167 if [ -e "$imageout.xenconfig" ]; then
168 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" $imageout.xenconfig $imageout.raw initrd-*
169 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
171 # FIXME: do we need a single .raw file in any case ?
174 if [ -n "\$SHAFILES" -a -x /usr/bin/sha256sum ]; then
175 for i in \$SHAFILES; do
176 echo "Create sha256 file..."
177 /usr/bin/sha256sum "\$i" > "\$i.sha256"
183 cat > $BUILD_ROOT/kiwi_post.sh << EOF
184 echo "compressing xen images... "
186 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-xen.tar.bz2" \
187 `grep ^kernel $imageout.xenconfig | cut -d'"' -f2` \
188 `grep ^ramdisk $imageout.xenconfig | cut -d'"' -f2` \
190 "$imageout.xenconfig" \
192 if [ -x /usr/bin/sha256sum ]; then
193 echo "Create sha256 file..."
195 /usr/bin/sha256sum "$imageout$buildnum-xen.tar.bz2" > "$imageout$buildnum-xen.tar.bz2.sha256"
200 cat > $BUILD_ROOT/kiwi_post.sh << EOF
201 echo "compressing pxe images... "
203 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-pxe.tar.bz2" ${imageout}* initrd-*
204 if [ -x /usr/bin/sha256sum ]; then
205 echo "Create sha256 file..."
207 /usr/bin/sha256sum "$imageout$buildnum-pxe.tar.bz2" > "$imageout$buildnum-pxe.tar.bz2.sha256"
212 cat > $BUILD_ROOT/kiwi_post.sh << EOF
215 mv "\$i" "/$TOPDIR/KIWI/\${i%.iso}$buildnum.iso"
217 if [ -x /usr/bin/sha256sum ]; then
218 echo "creating sha256 sum for iso images... "
221 /usr/bin/sha256sum "\$i" > "\$i.sha256"
227 cat > $BUILD_ROOT/kiwi_post.sh << EOF
228 echo "compressing unkown images... "
229 cd /$TOPDIR/KIWI-$imgtype
230 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-$imgtype.tar.bz2" *
231 if [ -x /usr/bin/sha256sum ]; then
232 echo "Create sha256 file..."
234 /usr/bin/sha256sum "$imageout$buildnum-$imgtype.tar.bz2" > "$imageout$buildnum-$imgtype.tar.bz2.sha256"
239 chroot $BUILD_ROOT su -c "sh -x -e /kiwi_post.sh" || cleanup_and_exit 1
240 rm -f $BUILD_ROOT/kiwi_post.sh