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 if test -d $BUILD_ROOT/$TOPDIR/SOURCES/repos -a "$DO_INIT" != false ; then
10 ln -sf $TOPDIR/SOURCES/repos $BUILD_ROOT/repos
11 cd $BUILD_ROOT/$TOPDIR/SOURCES/repos
13 test -L $r && continue
14 test -d $r || continue
15 repo="$TOPDIR/SOURCES/repos/$r/"
16 # create compatibility link for old kiwi versions
18 if test "$rc" != "$r" ; then
22 ln -s $rl$r "${rc%/*}/${rc##*/}"
23 repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/"
25 if test "$imagetype" != product ; then
26 echo "creating repodata for $repo"
27 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 chroot $BUILD_ROOT su -c "kiwi --version" -
68 if test "$imagetype" = product ; then
69 echo "running kiwi --create-instsource..."
70 # runs always as abuild user
71 mkdir -p "$BUILD_ROOT/$TOPDIR/KIWIROOT"
72 chroot "$BUILD_ROOT" chown -R abuild.abuild "$TOPDIR"
73 # --instsource-local is only needed for openSUSE 11.1 and SLE 11 SP0 kiwi.
74 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
75 ### This block is obsolete with current kiwi versions, only needed for kiwi 3.01 version
76 # for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
77 # test -d "$i" || continue
79 # test "$n" = scripts && continue
80 # test "$n" != "${n%0}" && continue
81 # chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER
84 # move created product to correct destination
85 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
86 test -e "$i" || continue
89 *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
92 *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
97 if [ -z "$RUNNING_IN_VM" ]; then
98 # NOTE: this must be done with the outer system, because it loads the dm-mod kernel modules, which needs to fit to the kernel.
99 echo "starting device mapper for kiwi..."
100 [ -x /etc/init.d/boot.device-mapper ] && /etc/init.d/boot.device-mapper start
102 for imgtype in $imagetype ; do
103 echo "running kiwi --prepare for $imgtype..."
104 # Do not use $BUILD_USER here, since we always need root permissions
105 if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then
106 echo "running kiwi --create for $imgtype..."
107 mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
108 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
114 # create tar.gz of images, in case it makes sense
117 if test -n "$RELEASE"; then
118 buildnum="-Build$RELEASE"
120 for imgtype in $imagetype ; do
123 pushd $BUILD_ROOT/$TOPDIR/KIWI-oem > /dev/null
124 echo "compressing oem images... "
125 tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-raw.tar.bz2 \
126 --exclude=$imagename.$imagearch-$imageversion.iso \
127 --exclude=$imagename.$imagearch-$imageversion.raw \
128 * || cleanup_and_exit 1
129 sha256sum $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-raw.tar.bz2 \
130 > "$BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-raw.tar.bz2.sha256" || cleanup_and_exit 1
131 if [ -e $imagename.$imagearch-$imageversion.iso ]; then
132 echo "take iso file and create sha256..."
133 mv $imagename.$imagearch-$imageversion.iso \
134 $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum.iso || cleanup_and_exit 1
135 pushd $BUILD_ROOT/$TOPDIR/KIWI > /dev/null
136 sha256sum $imagename.$imagearch-$imageversion$buildnum.iso \
137 > "$imagename.$imagearch-$imageversion$buildnum.iso.sha256" || cleanup_and_exit 1
140 if [ -e $imagename.$imagearch-$imageversion.raw ]; then
141 mv $imagename.$imagearch-$imageversion.raw \
142 $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum.raw || cleanup_and_exit 1
143 pushd $BUILD_ROOT/$TOPDIR/KIWI > /dev/null
144 echo "bzip2 raw file..."
145 bzip2 $imagename.$imagearch-$imageversion$buildnum.raw && \
146 echo "Create sha256 file..." && \
147 sha256sum $imagename.$imagearch-$imageversion$buildnum.raw.bz2 \
148 > "$imagename.$imagearch-$imageversion$buildnum.raw.bz2.sha256" || cleanup_and_exit 1
154 pushd $BUILD_ROOT/$TOPDIR/KIWI-vmx > /dev/null
155 echo "compressing vmx images... "
156 # This option has a number of format parameters
158 for i in $imagename.$imagearch-$imageversion.vmx $imagename.$imagearch-$imageversion.vmdk $imagename.$imagearch-$imageversion.ovf \
159 $imagename.$imagearch-$imageversion-disk*.vmdk $imagename.$imagearch-$imageversion.xenconfig; do
160 ls $i >& /dev/null && FILES="$FILES $i"
162 # kiwi is not removing the .rar file, if a different output format is defined. Do not include it by default.
163 [ -z "$FILES" ] && FILES="$imagename.$imagearch-$imageversion.raw"
164 tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-vmx.tar.bz2 \
165 $FILES || cleanup_and_exit 1
166 echo "Create sha256 file..."
167 sha256sum $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-vmx.tar.bz2 \
168 > "$BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-vmx.tar.bz2.sha256" || cleanup_and_exit 1
172 pushd $BUILD_ROOT/$TOPDIR/KIWI-xen > /dev/null
173 echo "compressing xen images... "
174 tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-xen.tar.bz2 \
175 `grep ^kernel $imagename.$imagearch-$imageversion.xenconfig | cut -d'"' -f2` \
176 `grep ^ramdisk $imagename.$imagearch-$imageversion.xenconfig | cut -d'"' -f2` \
177 $imagename.$imagearch-$imageversion.xenconfig \
178 $imagename.$imagearch-$imageversion || cleanup_and_exit 1
180 echo "Create sha256 file..."
181 sha256sum $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-xen.tar.bz2 \
182 > "$BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-xen.tar.bz2.sha256" || cleanup_and_exit 1
185 pushd $BUILD_ROOT/$TOPDIR/KIWI-pxe > /dev/null
186 echo "compressing pxe images... "
187 tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-pxe.tar.bz2 \
188 $imagename.$imagearch-$imageversion* \
189 initrd-* || cleanup_and_exit 1
191 echo "Create sha256 file..."
192 sha256sum $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-pxe.tar.bz2 \
193 > "$BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-pxe.tar.bz2.sha256" || cleanup_and_exit 1
196 pushd $BUILD_ROOT/$TOPDIR/KIWI-iso > /dev/null
197 echo "creating sha256 sum for iso images... "
199 pushd $BUILD_ROOT/$TOPDIR/KIWI/ > /dev/null
200 mv $BUILD_ROOT/$TOPDIR/KIWI-iso/$i ${i%.iso}$buildnum.iso || cleanup_and_exit 1
201 sha256sum ${i%.iso}$buildnum.iso > ${i%.iso}$buildnum.iso.sha256 || cleanup_and_exit 1
207 pushd $BUILD_ROOT/$TOPDIR/KIWI-$imgtype > /dev/null
208 echo "compressing unkown images... "
209 tar cvjfS $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-$imgtype.tar.bz2 \
210 * || cleanup_and_exit 1
211 echo "Create sha256 file..."
212 sha256sum $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-$imgtype.tar.bz2 \
213 > $BUILD_ROOT/$TOPDIR/KIWI/$imagename.$imagearch-$imageversion$buildnum-$imgtype.tar.bz2.sha256 || cleanup_and_exit 1