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 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 ver=`chroot "$BUILD_ROOT" su -c "/usr/sbin/kiwi --version | sed -n 's,.*kiwi version v\(.*\),\1,p'"`
74 if [ ${ver:0:1} == "3" ]; then
75 # old style kiwi 3 builds
76 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
77 if [ ${ver:2:2} == "01" ]; then
78 ## This block is obsolete with current kiwi versions, only needed for kiwi 3.01 version
79 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
80 test -d "$i" || continue
82 test "$n" = scripts && continue
83 test "$n" != "${n%0}" && continue
84 chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER
89 chroot "$BUILD_ROOT" su -c "APPID=- LANG=POSIX /usr/sbin/kiwi --root $TOPDIR/KIWIROOT -v --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - abuild < /dev/null && BUILD_SUCCEEDED=true
92 # move created product to correct destination
93 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
94 test -e "$i" || continue
97 *.iso) mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
100 *) test -d $i && mv $i $BUILD_ROOT/$TOPDIR/KIWI/. ;;
105 if [ -z "$RUNNING_IN_VM" ]; then
106 # NOTE: this must be done with the outer system, because it loads the dm-mod kernel modules, which needs to fit to the kernel.
107 echo "starting device mapper for kiwi..."
108 [ -x /etc/init.d/boot.device-mapper ] && /etc/init.d/boot.device-mapper start
110 for imgtype in $imagetype ; do
111 echo "running kiwi --prepare for $imgtype..."
112 # Do not use $BUILD_USER here, since we always need root permissions
113 if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imgtype" - root < /dev/null ; then
114 echo "running kiwi --create for $imgtype..."
115 mkdir -p $BUILD_ROOT/$TOPDIR/KIWI-$imgtype
116 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
122 # create tar.gz of images, in case it makes sense
125 if test -n "$RELEASE"; then
126 buildnum="-Build$RELEASE"
128 imageout="$imagename.$imagearch-$imageversion"
129 for imgtype in $imagetype ; do
132 cat > $BUILD_ROOT/kiwi_post.sh << EOF
133 echo "compressing oem images... "
135 if [ -e "$imageout.iso" ]; then
136 echo "take iso file and create sha256..."
137 mv "$imageout.iso" "/$TOPDIR/KIWI/$imageout$buildnum.iso"
139 if [ -x /usr/bin/sha256sum ]; then
140 /usr/bin/sha256sum "$imageout$buildnum.iso" > "$imageout$buildnum.iso.sha256"
144 if [ -e "$imageout.raw" ]; then
145 mv "$imageout.raw" "/$TOPDIR/KIWI/$imageout$buildnum.raw"
147 echo "bzip2 raw file..."
148 bzip2 "$imageout$buildnum.raw"
149 if [ -x /usr/bin/sha256sum ]; then
150 echo "Create sha256 file..."
151 /usr/bin/sha256sum "$imageout$buildnum.raw.bz2" > "$imageout$buildnum.raw.bz2.sha256"
156 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-raw.tar.bz2" \
157 --exclude="$imageout.iso" --exclude="$imageout.raw" *
159 if [ -x /usr/bin/sha256sum ]; then
160 /usr/bin/sha256sum "$imageout$buildnum-raw.tar.bz2" > "$imageout$buildnum-raw.tar.bz2.sha256"
165 cat > $BUILD_ROOT/kiwi_post.sh << EOF
166 echo "compressing vmx images... "
168 # This option has a number of format parameters
171 for i in "$imageout.vmx" "$imageout.vmdk" "$imageout-disk*.vmdk" "$imageout.ovf"; do
172 ls \$i >& /dev/null && VMXFILES="\$VMXFILES \$i"
174 if [ -n "\$VMXFILES" ]; then
175 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" \$VMXFILES
176 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
179 if [ -e "$imageout.xenconfig" ]; then
180 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-vmx.tar.bz2" $imageout.xenconfig $imageout.raw initrd-*
181 SHAFILES="\$SHAFILES $imageout$buildnum-vmx.tar.bz2"
183 # FIXME: do we need a single .raw file in any case ?
186 if [ -n "\$SHAFILES" -a -x /usr/bin/sha256sum ]; then
187 for i in \$SHAFILES; do
188 echo "Create sha256 file..."
189 /usr/bin/sha256sum "\$i" > "\$i.sha256"
195 cat > $BUILD_ROOT/kiwi_post.sh << EOF
196 echo "compressing xen images... "
198 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-xen.tar.bz2" \
199 `grep ^kernel $imageout.xenconfig | cut -d'"' -f2` \
200 `grep ^ramdisk $imageout.xenconfig | cut -d'"' -f2` \
202 "$imageout.xenconfig" \
204 if [ -x /usr/bin/sha256sum ]; then
205 echo "Create sha256 file..."
207 /usr/bin/sha256sum "$imageout$buildnum-xen.tar.bz2" > "$imageout$buildnum-xen.tar.bz2.sha256"
212 cat > $BUILD_ROOT/kiwi_post.sh << EOF
213 echo "compressing pxe images... "
215 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-pxe.tar.bz2" ${imageout}* initrd-*
216 if [ -x /usr/bin/sha256sum ]; then
217 echo "Create sha256 file..."
219 /usr/bin/sha256sum "$imageout$buildnum-pxe.tar.bz2" > "$imageout$buildnum-pxe.tar.bz2.sha256"
224 cat > $BUILD_ROOT/kiwi_post.sh << EOF
227 mv "\$i" "/$TOPDIR/KIWI/\${i%.iso}$buildnum.iso"
229 if [ -x /usr/bin/sha256sum ]; then
230 echo "creating sha256 sum for iso images... "
233 /usr/bin/sha256sum "\$i" > "\$i.sha256"
239 cat > $BUILD_ROOT/kiwi_post.sh << EOF
240 echo "compressing unkown images... "
241 cd /$TOPDIR/KIWI-$imgtype
242 tar cvjfS "/$TOPDIR/KIWI/$imageout$buildnum-$imgtype.tar.bz2" *
243 if [ -x /usr/bin/sha256sum ]; then
244 echo "Create sha256 file..."
246 /usr/bin/sha256sum "$imageout$buildnum-$imgtype.tar.bz2" > "$imageout$buildnum-$imgtype.tar.bz2.sha256"
251 chroot $BUILD_ROOT su -c "sh -x -e /kiwi_post.sh" || cleanup_and_exit 1
252 rm -f $BUILD_ROOT/kiwi_post.sh