2 # Script to build a package. It uses init_buildsystem to setup a chroot
3 # building tree. This script needs a directory as parameter. This directory
4 # has to include sources and a spec file.
6 # BUILD_ROOT here the packages will be built
8 # (c) 1997-2008 SuSE GmbH Nuernberg, Germany
10 test -z "$BUILD_DIR" && BUILD_DIR=/usr/lib/build
11 test -z "$BUILD_ROOT" && BUILD_ROOT=/var/tmp/build-root
13 export BUILD_ARCH BUILD_ROOT BUILD_RPMS BUILD_DIR
20 # mkreiserfs only works with qemu/uml if it is able to create a file
21 # system that is owned by the calling user (bnc#369006)
22 #xen_img_mkfs='mkreiserfs -q -f'
23 #xen_img_mkfs='mkfs.ext2 -m 0 -q -F'
24 xen_img_mkfs='mkfs.ext3 -m 0 -q -F'
25 qemu_kernel=/boot/vmlinuz
26 qemu_initrd=/boot/initrd
27 qemu_bin=/usr/bin/qemu
28 uml_kernel=/boot/vmlinux-um
29 uml_initrd=/boot/initrd-um
31 kvm_kernel=/boot/vmlinuz
32 kvm_initrd=/boot/initrd
33 kvm_bin=/usr/bin/qemu-kvm
34 mkinitrd_virtio_cmd=(env rootfstype=ext2 mkinitrd -d /dev/null -m "virtio_pci virtio_blk" -k $kvm_kernel -i $kvm_initrd-virtio)
35 # whether we have virtio support
65 export PATH=$BUILD_DIR:$PATH
68 export YAST_IS_RUNNING=instsys
78 Some comments for build
79 -----------------------
81 With build you can create rpm packages. They will be built in a chroot
82 system. This chroot system will be setup automatically. Normally you can
83 simply call build with a spec file as parameter - nothing else has to be
86 If you want to set the directory were the chroot system will be setup
87 (at the moment it uses $BUILD_ROOT),
88 simply set the the environment variable BUILD_ROOT.
92 export BUILD_ROOT=/var/tmp/mybuildroot
95 Normally build builds the complete package including src.rpm (rpmbuild -ba).
96 If you want let build only make the binary package, simply set
98 export BUILD_RPM_BUILD_STAGE=-bb
100 (or -bc, -bp, -bi, ... see "Maximum RPM" for more details [*]).
102 When the build command succeeds, the rpm files can be found under
103 $BUILD_ROOT/usr/src/packages/RPMS/
108 --help You already got it :)
110 --clean Delete old build root before initializing it
112 --no-init Skip initialization of build root and start with build
115 --no-checks Do not run post-build checks
117 --rpms path1:path2:...
118 Specify path where to find the RPMs for the build system
120 --arch arch1:arch2:...
121 Specify what architectures to select from the RPMs
124 Do not expand dependencies but search the specfile for
127 --verify Run verify when initializing the build root
130 Also install package 'pack'
133 Use 'rootdir' to setup chroot environment
135 --baselibs Create -32bit/-64bit/-x86 rpms for other architectures
138 List rpms that would be used to create a fresh build root.
139 Does not create the build root or perform a build.
142 enable feature X for build
145 disable feature X for build
148 define macro X with value Y
151 use ccache to speed up rebuilds
154 use N parallel build jobs with icecream
157 enable creation of a debuginfo package
159 Remember to have fun!
161 [*] Maximum RPM: http://www.rpm.org/max-rpm/
165 echo "Usage: `basename $0` [--no-init|--clean|--rpms path|--verify|--help] [dir-to-build|spec-to-build]"
172 cleanup_and_exit () {
174 test -z "$1" && set 0
175 if test -n "$RUNNING_IN_VM" ; then
177 if test -n "$VM_SWAP" -a -e "$VM_SWAP" ; then
178 swapoff "$VM_SWAP" 2>/dev/null
179 echo -n "BUILDSTATUS$1" >"$VM_SWAP"
181 exec >&0 2>&0 # so that the logging tee finishes
182 sleep 1 # wait till tee terminates
183 kill -9 -1 # goodbye cruel world
184 exec /bin/bash -c 'mount -n -o remount,ro / ; halt -f -p'
187 umount -n $BUILD_ROOT/proc 2>/dev/null || true
188 umount -n $BUILD_ROOT/dev/pts 2>/dev/null || true
189 test "$VM_IMAGE" = 1 && VM_IMAGE=
190 [ -n "$VM_IMAGE" ] && umount $BUILD_ROOT 2>/dev/null || true
211 # create a shell script from command line. Used for preserving arguments
223 if [ "$ccache" = 1 ]; then
224 if mkdir -p $BUILD_ROOT/var/lib/build/ccache/bin; then
225 for i in gcc g++ cc c++; do
226 # ln -sf /usr/bin/ccache $BUILD_ROOT/var/lib/build/ccache/bin/$i
227 rm -f $BUILD_ROOT/var/lib/build/ccache/bin/$i
228 test -e $BUILD_ROOT/usr/bin/$i || continue
229 echo '#! /bin/sh' > $BUILD_ROOT/var/lib/build/ccache/bin/$i
230 echo "test -e /usr/bin/$i || exit 1" > $BUILD_ROOT/var/lib/build/ccache/bin/$i
231 echo 'export PATH=/opt/icecream/bin:/usr/bin:$PATH' >> $BUILD_ROOT/var/lib/build/ccache/bin/$i
232 echo "ccache $i \"\$@\"" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i
233 chmod 755 $BUILD_ROOT/var/lib/build/ccache/bin/$i
234 echo "Installed ccache wrapper as $BUILD_ROOT/var/lib/build/ccache/bin/$i"
237 mkdir -p "$BUILD_ROOT"/.ccache
238 chroot "$BUILD_ROOT" chown -R "$BUILD_USER" "/.ccache"
239 echo "export CCACHE_DIR=/.ccache" > "$BUILD_ROOT"/etc/profile.d/build_ccache.sh
240 echo 'export PATH=/var/lib/build/ccache/bin:$PATH' >> "$BUILD_ROOT"/etc/profile.d/build_ccache.sh
242 rm -f "$BUILD_ROOT$builduserhome"/bin/{gcc,g++,cc,c++}
243 rm -f "$BUILD_ROOT"/var/lib/build/ccache/bin/{gcc,g++,cc,c++}
249 if [ "$icecream" -eq 0 ]; then
250 rm -rf "$BUILD_ROOT"/var/run/icecream
251 rm -f "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
255 if ! chroot "$BUILD_ROOT" rpm -q icecream >/dev/null 2>/dev/null; then
256 echo "*** icecream package not installed ***"
261 echo "using icecream with $icecream jobs"
263 if [ "$ccache" -ne 1 ]; then
264 echo 'export PATH=/opt/icecream/bin:$PATH' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
266 echo 'export CCACHE_PATH=/opt/icecream/bin' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
269 local icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/var/run/icecream/*.tar.{bz2,gz}`)
270 icecc_vers=${icecc_vers//$BUILD_ROOT/}
272 # XXX use changelog like autobuild does instead?
273 # only run create-env if compiler or glibc changed
274 if [ -z "$icecc_vers" \
275 -o ! -e "$BUILD_ROOT/$icecc_vers" \
276 -o "$BUILD_ROOT/usr/bin/gcc" -nt "$BUILD_ROOT/$icecc_vers" \
277 -o "$BUILD_ROOT/usr/bin/g++" -nt "$BUILD_ROOT/$icecc_vers" \
278 -o "$BUILD_ROOT/usr/bin/as" -nt "$BUILD_ROOT/$icecc_vers" \
279 -o "$BUILD_ROOT/lib/libc.so.6" -nt "$BUILD_ROOT/$icecc_vers" ]
281 rm -rf $BUILD_ROOT/var/run/icecream
282 mkdir -p $BUILD_ROOT/var/run/icecream
283 if [ -e "$BUILD_ROOT"/usr/bin/create-env ]; then
284 createenv=/usr/bin/create-env
285 elif [ -e "$BUILD_ROOT"/usr/lib/icecc/icecc-create-env ]; then
286 createenv="/usr/lib/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX
288 echo "create-env not found"
292 chroot $BUILD_ROOT bash -c "cd /var/run/icecream; $createenv"
293 icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/var/run/icecream/*.tar.{bz2,gz}`)
294 icecc_vers=${icecc_vers//$BUILD_ROOT/}
296 echo "reusing existing icecream environment $icecc_vers"
298 if [ -n "$icecc_vers" ]; then
299 echo "export ICECC_VERSION=$icecc_vers" >> "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
305 if [ -n "$VM_IMAGE" -o -n "$RUNNING_IN_VM" ]; then
313 eval "mem=\$(($2/3*4))"
315 echo "Memory limit set to ${mem}KB"
319 done < <(cat /proc/meminfo) # cat for proc stuff
322 function create_baselibs {
323 echo "... creating baselibs"
325 for RPM in $BUILD_ROOT$TOPDIR/RPMS/*/*.rpm ; do
326 BRPMS="$BRPMS ${RPM#$BUILD_ROOT}"
329 if test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs.conf ; then
330 BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs.conf"
332 if test -f $BUILD_ROOT/usr/lib/build/mkbaselibs ; then
333 if test -z "$BASELIBS_CFG" -a -e $BUILD_ROOT/usr/lib/build/baselibs.conf ; then
334 BASELIBS_CFG="-c /usr/lib/build/baselibs.conf"
336 chroot $BUILD_ROOT /usr/lib/build/mkbaselibs -c /usr/lib/build/baselibs_global.conf $BASELIBS_CFG $BRPMS || cleanup_and_exit 1
338 # use external version
339 rm -rf $BUILD_ROOT/.mkbaselibs
340 mkdir -p $BUILD_ROOT/.mkbaselibs
341 cp -f $BUILD_DIR/mkbaselibs $BUILD_ROOT/.mkbaselibs
342 cp -f $BUILD_DIR/baselibs_global.conf $BUILD_ROOT/.mkbaselibs
343 if test -z "$BASELIBS_CFG" -a -e $BUILD_DIR/baselibs.conf ; then
344 cp -f $BUILD_DIR/baselibs.conf $BUILD_ROOT/.mkbaselibs/baselibs.conf
345 BASELIBS_CFG="-c /.mkbaselibs/baselibs.conf"
347 chroot $BUILD_ROOT /.mkbaselibs/mkbaselibs -c /.mkbaselibs/baselibs_global.conf $BASELIBS_CFG $BRPMS || cleanup_and_exit 1
348 rm -rf $BUILD_ROOT/.mkbaselibs
352 detect_vm_2nd_stage()
354 if ! test "$0" = "/.build/build" ; then
357 echo "2nd stage started in virtual machine"
360 . $BUILD_DIR/build.data
361 echo "machine type: `uname -m`"
362 if test "$PERSONALITY" != 0 -a -z "$PERSONALITY_SET" ; then
363 export PERSONALITY_SET=true
364 echo "switching personality to $PERSONALITY..."
365 # this is 32bit perl/glibc, thus the 32bit syscall number
366 exec perl -e 'syscall(136, '$PERSONALITY') == -1 && warn("personality: $!\n");exec "/.build/build" || die("/.build/build: $!\n")'
368 PATH=$BUILD_DIR:$PATH
370 mount -orw -n -tproc none /proc
371 mount -n -o remount,rw /
372 if test -n "$VM_SWAP" ; then
373 for i in 1 2 3 4 5 6 7 8 9 10 ; do
374 test -e "$VM_SWAP" && break
375 test $i = 1 && echo "waiting for $VM_SWAP to appear"
380 # recreate the swap device manually if it didn't exist for some
381 # reason, hardcoded to hda2 atm
382 if ! test -b "$VM_SWAP" ; then
385 mknod "$VM_SWAP" b 3 2
388 swapon -v "$VM_SWAP" || exit 1
397 if [ -z "$BUILD_ARCH" ]; then
398 BUILD_ARCH=`uname -m`
399 test i686 = "$BUILD_ARCH" && BUILD_ARCH=i586 # XXX: why?
403 i686) BUILD_ARCH="i686:i586:i486:i386" ;;
404 i586) BUILD_ARCH="i586:i486:i386" ;;
405 i486) BUILD_ARCH="i486:i386" ;;
406 x86_64) BUILD_ARCH="x86_64:i686:i586:i486:i386" ;;
408 if test "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
409 cpuflags=`grep ^flags /proc/cpuinfo`
410 cpuflags="$cpuflags "
411 test "$cpuflags" = "${cpuflags/ cx8 /}" -o "$cpuflags" = "${cpuflags/ cmov /}" && {
412 echo "Your cpu doesn't support i686 rpms. Exit."
421 if [ -z "$SPECFILES" ]; then
424 set -- "${SPECFILES[@]}"
428 if [ "$spec" = "${spec#/}" ]; then
432 if [ -d "$spec" ]; then
433 specs=("$spec"/*.spec)
434 if [ -n "$specs" ]; then
435 SPECFILES=("${SPECFILES[@]}" "${specs[@]}")
437 specs=("$spec"/*.spec)
438 if [ -n "$specs" ]; then
439 SPECFILES=("${SPECFILES[@]}" "${specs[@]}")
443 SPECFILES[${#SPECFILES[@]}]="$spec";
447 if test -z "$SPECFILES"; then
448 echo no spec files or src rpms found in $@. exit...
453 become_root_or_fail()
455 if [ ! -w /root ]; then
456 echo "You have to be root to use $0" >&2
464 if [ -d "$BUILD_ROOT" ]; then
465 # check if it is owned by root
466 if [ -z "$RUNNING_IN_VM" -a \! -O "$BUILD_ROOT" -a "`stat -c %u $BUILD_ROOT`" -ne 0 ]; then
467 echo "BUILD_ROOT=$BUILD_ROOT must be owned by $USER. Exit..."
471 test "$BUILD_ROOT" != "${BUILD_ROOT%/*}" && mkdir -p "${BUILD_ROOT%/*}"
472 if ! mkdir $BUILD_ROOT; then
473 echo "can not create BUILD_ROOT=$BUILD_ROOT. Exit..."
478 rm -rf "$BUILD_ROOT"/.build.packages
483 perl -e 'syscall('$PERSONALITY_SYSCALL', 0); exec(@ARGV) || die("$ARGV[0]: $!\n")' "$@"
490 case `perl -V:archname` in
491 *x86_64*) PERSONALITY_SYSCALL=135 ;;
492 *i?86*) PERSONALITY_SYSCALL=136 ;;
497 if detect_vm_2nd_stage ; then
498 set "/.build-srcdir/$SPECFILE"
502 while test -n "$1"; do
510 set -- "----noarg=$PARAM" "$@"
524 CLEAN_BUILD='--clean'
531 if [ -z "$BUILD_RPMS" ] ; then
542 export VERIFY_BUILD_SYSTEM=true
545 ABUILD_TARGET_ARCH="$ARG"
553 BUILD_EXTRA_PACKS="$BUILD_EXTRA_PACKS $ARG"
563 CREATE_BASELIBS=internal
574 *-xen|*-kvm|--uml|--qemu)
576 if [ -n "$ARG" -a "$ARG" = "${ARG#-}" ]; then
587 *-xenmemory|*-memory)
592 RPMLIST="--rpmlist $ARG"
612 BUILD_RPM_BUILD_STAGE="$ARG"
616 USEUSEDFORBUILD="--useusedforbuild"
621 --define|--with|--without)
622 definesnstuff[${#definesnstuff[@]}]="$PARAM";
623 definesnstuff[${#definesnstuff[@]}]="$ARG";
627 if [ -z "$ARG" ] ; then
631 repos[${#repos[@]}]="$PARAM";
632 repos[${#repos[@]}]="$ARG";
636 if [ -z "$ARG" ] ; then
637 echo "--icecream needs an argument" >&2
660 echo "$ARG does not take an argument"
667 echo Unknown Option "$PARAM". Exit.
671 SPECFILES[${#SPECFILES[@]}]="$PARAM";
676 # XXX: doesn't kill vm if in prepare stage (because there is none)
677 if test -n "$KILL" ; then
678 test -z "$SRCDIR" || usage
679 if test -z "$VM_IMAGE" ; then
680 if ! $BUILD_DIR/killchroot -s 9 $BUILD_ROOT ; then
681 echo "could not kill build in $BUILD_ROOT"
684 elif test "$VM_TYPE" = 'xen'; then
685 XENID="${VM_IMAGE%/root}"
687 if xm list "build:$XENID" >/dev/null 2>&1 ; then
688 if ! xm destroy "build:$XENID" ; then
689 echo "could not kill xen build $XENID"
693 elif test -n "$VM_TYPE"; then
694 if ! fuser -k -TERM "$VM_IMAGE"; then
695 echo "could not kill build in $VM_IMAGE"
699 echo "don't know how to kill this build job"
705 if [ "$VM_TYPE" = 'kvm' ]; then
706 if [ ! -r /dev/kvm -o ! -x "$qemu_bin"-kvm ]; then
710 qemu_kernel="$kvm_kernel"
711 qemu_initrd="$kvm_initrd"
712 if [ ! -e $qemu_initrd-virtio -o $qemu_kernel -nt $qemu_initrd-virtio ]; then
713 if [ ! -w /root ]; then
714 echo "No initrd that provides virtio support found. virtio accelleration disabled."
715 echo "Run the following command as root to enable virtio:"
716 shellquote "${mkinitrd_virtio_cmd[@]}"
718 elif /sbin/modinfo virtio_pci >/dev/null 2>&1; then
719 echo "creating $qemu_initrd-virtio"
720 "${mkinitrd_virtio_cmd[@]}" || cleanup_and_exit 1
727 if [ "$kvm_virtio" = 1 ]; then
728 qemu_initrd="$qemu_initrd-virtio"
730 qemu_rootdev=/dev/vda
733 qemu_rootdev=/dev/sda
737 if [ "$VM_TYPE" = 'qemu' ]; then
739 qemu_rootdev=/dev/sda
742 if [ -z "$RPMLIST" ]; then
743 if [ -z "$repos" -a -z "$BUILD_RPMS" ]; then
744 BUILD_RPMS="/media/dvd/suse"
752 if [ -n "$CLEAN_BUILD" ]; then
758 if test -n "$LIST_STATE" ; then
759 BUILD_ROOT=`mktemp -d /var/tmp/build-list-state-XXXXXX`
760 test -d "$BUILD_ROOT" || cleanup_and_exit 1
761 SPECFILE=$SPECFILES # only one specified anyways
762 if test "$SPECFILE" != "${SPECFILE%.src.rpm}" ; then
763 rm -rf $BUILD_ROOT/usr/src/packages
764 mkdir -p $BUILD_ROOT/usr/src/packages/SOURCES $BUILD_ROOT/usr/src/packages/SPECS
765 rpm -i --nodigest --nosignature --root $BUILD_ROOT $SPECFILE || {
766 echo "could not install $SPECFILE." 2>&1
770 for SPECFILE in $BUILD_ROOT/usr/src/packages/SPECS/*.spec ; do : ; done
772 init_buildsystem --list-state "${definesnstuff[@]}" "${repos[@]}" $USEUSEDFORBUILD $SPECFILE $BUILD_EXTRA_PACKS
775 cleanup_and_exit $ERR
778 if test -z "$RUNNING_IN_VM" ; then
779 if test -n "$VM_IMAGE" ; then
780 if test "$VM_IMAGE" = 1 ; then
781 VM_IMAGE="$BUILD_ROOT.img"
783 if test ! -e "$VM_IMAGE" ; then
784 echo "you need to create a file system on $VM_IMAGE first"
788 if test -n "$VM_IMAGE" ; then
789 if test -n "$CLEAN_BUILD" ; then
790 echo "Creating filesystem on $VM_IMAGE"
791 $xen_img_mkfs $VM_IMAGE || become_root_or_fail
794 if [ -w /root ]; then
795 mount -o loop $VM_IMAGE $BUILD_ROOT || cleanup_and_exit 1
797 mount $BUILD_ROOT || become_root_or_fail
800 test -w /root || become_root_or_fail
802 if test -n "$VM_SWAP" ; then
803 dd if=/dev/zero of="$VM_SWAP" bs=12 count=1 conv=notrunc 2>/dev/null
810 rm -f $BUILD_ROOT/exit
812 if [ -w /root ]; then
813 mkdir -p $BUILD_ROOT/proc
814 mkdir -p $BUILD_ROOT/dev/pts
815 mount -n -tproc none $BUILD_ROOT/proc || true
816 mount -n -tdevpts none $BUILD_ROOT/dev/pts
819 if test -z "$VM_IMAGE" -a -z "$LOGFILE"; then
820 LOGFILE="$BUILD_ROOT/.build.log"
823 if test -n "$LOGFILE" ; then
824 echo logging output to $LOGFILE...
827 if test -n "$VM_IMAGE" ; then
828 exec 1> >(exec -a 'build logging tee' perl -e 'open(F,">>",$ARGV[0])||die("$ARGV[0]: $!\n");$|=1;select(F);$|=1;while(<STDIN>){print STDOUT;s/^\r//s;s/\r\n/\n/gs;print F}' $LOGFILE) 2>&1
830 exec 1> >(exec -a 'build logging tee' tee -a $LOGFILE) 2>&1
839 test -z "$HOST" && HOST=`hostname`
841 if [ -z "$RUNNING_IN_VM" ]; then
842 echo Using BUILD_ROOT=$BUILD_ROOT
843 test -n "$BUILD_RPMS" && echo Using BUILD_RPMS=$BUILD_RPMS
844 echo Using BUILD_ARCH=$BUILD_ARCH
845 test -n "$VM_TYPE" && echo "Doing $VM_TYPE build in $VM_IMAGE"
849 test "$BUILD_ARCH" = all && BUILD_ARCH=
850 BUILD_USER_ABUILD_USED=
852 for SPECFILE in "${SPECFILES[@]}" ; do
854 SRCDIR="${SPECFILE%/*}"
855 SPECFILE="${SPECFILE##*/}"
859 *.spec|*.src.rpm) BUILDTYPE=spec ;;
860 *.dsc) BUILDTYPE=dsc ;;
861 *.kiwi) BUILDTYPE=kiwi ;;
863 if test -z "$BUILDTYPE" ; then
864 echo "don't know how to build $SPECFILE"
870 if [ -z "$RUNNING_IN_VM" ]; then
872 echo "$HOST started \"build $SPECFILE\" at `date`."
874 test -n "$REASON" && echo "$REASON"
879 # first setup building directory...
881 test -s "$SPECFILE" || {
882 echo "$SPECFILE" is empty. This should not happen...
886 if test "$SPECFILE" != "${SPECFILE%.src.rpm}" ; then
887 echo processing src rpm `pwd`/$SPECFILE...
888 TOPDIR=`rpm --eval '%_topdir'`
889 rm -rf $BUILD_ROOT$TOPDIR
890 mkdir -p $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SPECS
891 rpm -i --nodigest --nosignature --root $BUILD_ROOT $SPECFILE || {
892 echo "could not install $SPECFILE."
895 rm -rf $BUILD_ROOT/.build-srcdir
896 mkdir -p $BUILD_ROOT/.build-srcdir
897 mv $BUILD_ROOT$TOPDIR/SOURCES/* $BUILD_ROOT/.build-srcdir
898 mv $BUILD_ROOT$TOPDIR/SPECS/* $BUILD_ROOT/.build-srcdir
899 MYSRCDIR=$BUILD_ROOT/.build-srcdir
900 cd $MYSRCDIR || cleanup_and_exit 1
901 for SPECFILE in *.spec ; do : ; done
903 echo processing specfile `pwd`/$SPECFILE...
908 test -n "$BUILD_EXTRA_PACKS" && ADDITIONAL_PACKS="$ADDITIONAL_PACKS $BUILD_EXTRA_PACKS"
909 test -n "$CREATE_BASELIBS" && ADDITIONAL_PACKS="$ADDITIONAL_PACKS build"
910 test "$ccache" = '1' && ADDITIONAL_PACKS="$ADDITIONAL_PACKS ccache"
911 test "$icecream" -gt 1 && ADDITIONAL_PACKS="$ADDITIONAL_PACKS icecream gcc-c++"
912 test -n "$DO_LINT" && ADDITIONAL_PACKS="$ADDITIONAL_PACKS rpmlint-Factory"
914 if test -n "$CHANGELOG" -a -z "$RUNNING_IN_VM" ; then
915 rm -f $BUILD_ROOT/.build-changelog
917 *.dsc) CFFORMAT=debian ;;
920 echo "running changelog2spec --target $CFFORMAT --file $MYSRCDIR/$SPECFILE"
921 if ! $BUILD_DIR/changelog2spec --target $CFFORMAT --file "$MYSRCDIR/$SPECFILE" > $BUILD_ROOT/.build-changelog ; then
922 rm -f $BUILD_ROOT/.build-changelog
926 if test -n "$VM_TYPE"; then
927 rm -rf $BUILD_ROOT/.build
928 mkdir -p $BUILD_ROOT/.build
929 if test "$DO_INIT" = true ; then
930 # do fist stage of init_buildsystem
931 rm -f $BUILD_ROOT/.build.success
932 set -- init_buildsystem --prepare "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USEUSEDFORBUILD $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS
934 "$@" || cleanup_and_exit 1
935 if [ ! -w /root ]; then
936 # remove setuid bit if files belong to user to make e.g. mount work
937 find $BUILD_ROOT/{bin,sbin,usr/bin,usr/sbin} -type f -uid $UID -perm +4000 -print0 | xargs -0 --no-run-if-empty chmod -s
940 # start up xen, rerun ourself
941 cp -a $BUILD_DIR/. $BUILD_ROOT/.build
942 if ! test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
943 rm -rf $BUILD_ROOT/.build-srcdir
944 mkdir $BUILD_ROOT/.build-srcdir
945 if test "$BUILDTYPE" = kiwi ; then
946 cp -pRL "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir
948 cp -p "$MYSRCDIR"/* $BUILD_ROOT/.build-srcdir
950 MYSRCDIR=$BUILD_ROOT/.build-srcdir
953 echo "SPECFILE='${SPECFILE//"'"/$Q}'" > $BUILD_ROOT/.build/build.data
954 echo "BUILD_JOBS='${BUILD_JOBS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
955 echo "BUILD_ARCH='${BUILD_ARCH//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
956 echo "BUILD_RPMS='${BUILD_RPMS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
959 cp $BUILD_DIST $BUILD_ROOT/.build/build.dist
960 BUILD_DIST=/.build/build.dist
963 echo "BUILD_DIST='${BUILD_DIST//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
964 echo "RELEASE='${RELEASE//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
965 echo "BUILD_DEBUG='${BUILD_DEBUG//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
966 echo "DO_LINT='${DO_LINT//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
967 echo "DO_CHECKS='${DO_CHECKS//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
968 echo "NOROOTFORBUILD='${NOROOTFORBUILD//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
969 echo "CREATE_BASELIBS='$CREATE_BASELIBS'" >> $BUILD_ROOT/.build/build.data
970 echo "REASON='${REASON//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
971 echo "CHANGELOG='${CHANGELOG//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
972 echo "INCARNATION='${INCARNATION//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
973 echo "DISTURL='${DISTURL//"'"/$Q}'" >> $BUILD_ROOT/.build/build.data
974 # FIXME: this depends on the kernel and vm.
975 # could be hda2, sda2 for xen or hdb/sdb for qemu
976 test -n "$VM_SWAP" && echo "VM_SWAP='${VM_SWAPDEV:-/dev/hda2}'" >> $BUILD_ROOT/.build/build.data
978 test -n "$PERSONALITY_SYSCALL" && PERSONALITY=`perl -e 'print syscall('$PERSONALITY_SYSCALL', 0)."\n"'`
979 echo "PERSONALITY='$PERSONALITY'" >> $BUILD_ROOT/.build/build.data
980 echo "MYHOSTNAME='`hostname`'" >> $BUILD_ROOT/.build/build.data
981 echo -n "definesnstuff=(" >> $BUILD_ROOT/.build/build.data
982 shellquote "${definesnstuff[@]}" >> $BUILD_ROOT/.build/build.data
983 echo ")" >> $BUILD_ROOT/.build/build.data
984 echo -n "repos=(" >> $BUILD_ROOT/.build/build.data
985 shellquote "${repos[@]}" >> $BUILD_ROOT/.build/build.data
986 echo ")" >> $BUILD_ROOT/.build/build.data
987 umount -n $BUILD_ROOT/proc 2> /dev/null || true
988 umount -n $BUILD_ROOT/dev/pts 2> /dev/null || true
989 umount -n $BUILD_ROOT/mnt 2> /dev/null || true
992 if [ "$VM_TYPE" = 'xen' ]; then
993 XMROOT=file:$VM_IMAGE
994 XMROOT=${XMROOT/#file:\/dev/phy:/dev}
995 XMROOT="disk=$XMROOT,hda1,w"
997 if test -n "$VM_SWAP" ; then
999 XMSWAP=${XMSWAP/#file:\/dev/phy:/dev}
1000 XMSWAP="disk=$XMSWAP,hda2,w"
1002 XENID="${VM_IMAGE%/root}"
1003 XENID="${XENID##*/}"
1004 echo "booting XEN kernel ..."
1005 set -- xm create -c $BUILD_DIR/xen.conf name="build:$XENID" ${MEMSIZE:+memory=$MEMSIZE} $XMROOT $XMSWAP extra="quiet init=/.build/build panic=1 console=ttyS0"
1006 if test "$PERSONALITY" != 0 ; then
1007 # have to switch back to PER_LINUX to make xm work
1011 "$@" || true # somehow this is always false
1012 elif [ "$VM_TYPE" = 'uml' ]; then
1013 echo "booting UML kernel ..."
1014 set -- $uml_kernel initrd=$uml_initrd root=/ubda init=/.build/build panic=1 quiet ubd0=$VM_IMAGE ${MEMSIZE:+mem=$MEMSIZE}
1017 elif [ "$VM_TYPE" = 'qemu' -o "$VM_TYPE" = 'kvm' ]; then
1018 echo "booting QEMU ..."
1019 if [ "$kvm_virtio" = 1 ]; then
1020 qemu_disks=(-drive file="$VM_IMAGE",if=virtio -hda /dev/null)
1021 if [ -n "$VM_SWAP" ]; then
1022 qemu_disks[${#qemu_disks[@]}]="-drive"
1023 qemu_disks[${#qemu_disks[@]}]="file=$VM_SWAP,if=virtio"
1026 qemu_disks=(-hda "$VM_IMAGE")
1027 if [ -n "$VM_SWAP" ]; then
1028 qemu_disks[${#qemu_disks[@]}]="-hdb"
1029 qemu_disks[${#qemu_disks[@]}]="$VM_SWAP"
1032 set -- $qemu_bin -no-reboot -nographic -net none -serial stdio \
1033 -kernel $qemu_kernel \
1034 -initrd $qemu_initrd \
1035 -append "root=$qemu_rootdev panic=1 quiet rw console=ttyS0,115200 init=/.build/build" \
1036 ${MEMSIZE:+-m $MEMSIZE} \
1039 if test "$PERSONALITY" != 0 ; then
1040 # have to switch back to PER_LINUX to make qemu work
1046 if test -n "$VM_SWAP" ; then
1047 BUILDSTATUS=`dd if="$VM_SWAP" bs=12 count=1 2>/dev/null`
1048 case $BUILDSTATUS in
1050 mkdir -p $BUILD_ROOT/.build.packages
1051 cd $BUILD_ROOT/.build.packages || cleanup_and_exit 1
1052 echo "extracting built packages..."
1053 dd if=$VM_SWAP bs=512 skip=1 | cpio --extract --no-absolute-filenames -v
1057 cleanup_and_exit ${BUILDSTATUS#BUILDSTATUS}
1065 if test "$DO_INIT" = true ; then
1067 # create legacy .buildenv file
1069 test -z "$INCARNATION" && INCARNATION=0
1070 echo "BUILD_INCARNATION=$INCARNATION" > $BUILD_ROOT/.buildenv
1072 CREATE_BUILD_BINARIES=
1073 egrep '^#[ ]*needsbinariesforbuild[ ]*$' >/dev/null <$MYSRCDIR/$SPECFILE && CREATE_BUILD_BINARIES=--create-build-binaries
1074 set -- init_buildsystem "${definesnstuff[@]}" "${repos[@]}" $CLEAN_BUILD $USEUSEDFORBUILD $CREATE_BUILD_BINARIES $RPMLIST "$MYSRCDIR/$SPECFILE" $ADDITIONAL_PACKS
1076 "$@" || cleanup_and_exit 1
1077 mount -n -tproc none $BUILD_ROOT/proc || true
1078 mount -n -tdevpts none $BUILD_ROOT/dev/pts
1081 if test -z "$BUILD_DIST" -a -e "$BUILD_ROOT/.guessed_dist" ; then
1082 BUILD_DIST=`cat $BUILD_ROOT/.guessed_dist`
1083 echo "assuming dist $BUILD_DIST"
1087 # fix rpmrc if we are compiling for i686
1089 test -f $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 && mv $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 $BUILD_ROOT/usr/lib/rpm/rpmrc
1090 if test -e $BUILD_ROOT/usr/lib/rpm/rpmrc -a "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then
1091 mv $BUILD_ROOT/usr/lib/rpm/rpmrc $BUILD_ROOT/usr/lib/rpm/rpmrc_i586
1092 sed -e 's/^buildarchtranslate: athlon.*/buildarchtranslate: athlon: i686/' -e 's/^buildarchtranslate: i686.*/buildarchtranslate: i686: i686/' < $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 > $BUILD_ROOT/usr/lib/rpm/rpmrc
1096 # check if we want to build with the abuild user
1099 if test -x $BUILD_ROOT/bin/rpm ; then
1100 SUSE_VERSION=`chroot $BUILD_ROOT /bin/rpm --eval '%{?suse_version}' 2>/dev/null`
1101 if test -n "$SUSE_VERSION" && test "$SUSE_VERSION" -le 1020 ; then
1105 if test "$BUILD_USER" = abuild ; then
1106 egrep '^#[ ]*needsrootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=root
1108 egrep '^#[ ]*norootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=abuild
1110 test -n "$NOROOTFORBUILD" && BUILD_USER=abuild
1111 test "$BUILDTYPE" = kiwi && BUILD_USER=root
1113 if test $BUILD_USER = abuild ; then
1114 if ! egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then
1115 echo 'abuild::399:399:Autobuild:/home/abuild:/bin/bash' >>$BUILD_ROOT/etc/passwd
1116 echo 'abuild:*:::::::' >>$BUILD_ROOT/etc/shadow # This is needed on Mandriva 2009
1117 echo 'abuild::399:' >>$BUILD_ROOT/etc/group
1118 mkdir -p $BUILD_ROOT/home/abuild
1119 chown 399:399 $BUILD_ROOT/home/abuild
1121 if test -f $BUILD_ROOT/etc/shadow ; then
1122 sed -e "s@^root::@root:*:@" < $BUILD_ROOT/etc/shadow > $BUILD_ROOT/etc/shadow.t && mv $BUILD_ROOT/etc/shadow.t $BUILD_ROOT/etc/shadow
1124 BUILD_USER_ABUILD_USED=true
1126 if egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then
1127 egrep -v '^abuild:' <$BUILD_ROOT/etc/passwd >$BUILD_ROOT/etc/passwd.new
1128 mv $BUILD_ROOT/etc/passwd.new $BUILD_ROOT/etc/passwd
1129 egrep -v '^abuild:' <$BUILD_ROOT/etc/shadow >$BUILD_ROOT/etc/shadow.new
1130 mv $BUILD_ROOT/etc/shadow.new $BUILD_ROOT/etc/shadow
1131 egrep -v '^abuild:' <$BUILD_ROOT/etc/group >$BUILD_ROOT/etc/group.new
1132 mv $BUILD_ROOT/etc/group.new $BUILD_ROOT/etc/group
1133 rm -rf $BUILD_ROOT/home/abuild
1137 if test "$BUILDTYPE" = spec ; then
1138 TOPDIR=`chroot $BUILD_ROOT su -c "rpm --eval '%_topdir'" - $BUILD_USER`
1140 TOPDIR=/usr/src/packages
1141 mkdir -p $BUILD_ROOT$TOPDIR
1144 rm -f $BUILD_ROOT/.build.packages
1145 ln -s ${TOPDIR#/} $BUILD_ROOT/.build.packages
1147 mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
1148 mount -n -tdevpts none $BUILD_ROOT/dev/pts 2> /dev/null
1154 # nasty hack to prevent rpath on known paths
1155 # FIXME: do this only for suse
1156 if test -d "$BUILD_ROOT/etc/profile.d" ; then
1157 echo "export SUSE_IGNORED_RPATHS=/etc/ld.so.conf" > "$BUILD_ROOT/etc/profile.d/buildsystem.sh"
1161 # now clean up RPM building directories
1163 rm -rf $BUILD_ROOT$TOPDIR
1164 for i in BUILD RPMS/`uname -m` RPMS/i386 RPMS/noarch SOURCES SPECS SRPMS BUILDROOT; do
1165 mkdir -p $BUILD_ROOT$TOPDIR/$i
1166 test $BUILD_USER = abuild && chown 399:399 $BUILD_ROOT$TOPDIR/$i
1168 test -e $BUILD_ROOT/exit && cleanup_and_exit
1170 mkdir -p $BUILD_ROOT$TOPDIR/SOURCES
1171 if test "$BUILDTYPE" = kiwi ; then
1172 mkdir -p $BUILD_ROOT$TOPDIR/KIWI
1173 if test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir ; then
1174 mv "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
1176 cp -dLR "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
1179 cp -p "$MYSRCDIR"/* $BUILD_ROOT$TOPDIR/SOURCES/
1181 test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir && rm -rf "$MYSRCDIR"
1184 test -n "$CHANGELOG" -a -f "$BUILD_ROOT/.build-changelog" && CHANGELOGARGS="--changelog $BUILD_ROOT/.build-changelog"
1186 if test "$BUILDTYPE" = spec ; then
1187 # do buildrequires/release substitution
1189 if test -n "$RELEASE"; then
1190 args=(--release "$RELEASE")
1192 substitutedeps "${args[@]}" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1
1193 # extract macros from configuration
1194 getmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" > $BUILD_ROOT/root/.rpmmacros
1195 if test -n "$BUILD_DEBUG" ; then
1197 %prep %?_suse_insert_debug_package%%prep
1198 %package %?_suse_insert_debug_package%%package
1199 %suse_insert_debug_package \
1200 %global _suse_insert_debug_package \\\
1201 %%undefine _suse_insert_debug_package \\\
1204 ' >> $BUILD_ROOT/root/.rpmmacros
1206 test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros
1207 # extract optflags from configuration
1208 getoptflags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ${BUILD_DEBUG:+--debug} > $BUILD_ROOT/root/.rpmrc
1209 test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc
1211 if test -f $BUILD_ROOT/.spec.new ; then
1212 if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT/.spec.new ; then
1213 echo -----------------------------------------------------------------
1214 echo I have the following modifications for $SPECFILE:
1215 diff $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT/.spec.new
1216 mv $BUILD_ROOT/.spec.new $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE
1218 rm -f $BUILD_ROOT/.spec.new
1222 if test "$BUILDTYPE" = dsc ; then
1223 rm -rf $BUILD_ROOT$TOPDIR/BUILD
1224 test $BUILD_USER = abuild && chown 399:399 $BUILD_ROOT$TOPDIR
1226 DEB_SOURCEDIR=$TOPDIR/SOURCES
1227 DEB_DSCFILE=$SPECFILE
1228 for f in $BUILD_ROOT$TOPDIR/SOURCES/debian.* ; do
1229 test -f $f && DEB_TRANSFORM=true
1231 if test -n "$DEB_TRANSFORM" ; then
1232 echo "running debian transformer..."
1233 mkdir -p $BUILD_ROOT$TOPDIR/SOURCES.DEB
1234 if ! debtransform $CHANGELOGARGS $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT$TOPDIR/SOURCES.DEB ; then
1235 echo "debian transforming failed."
1238 DEB_SOURCEDIR=$TOPDIR/SOURCES.DEB
1239 for DEB_DSCFILE in $BUILD_ROOT/$DEB_SOURCEDIR/*.dsc ; do : ; done
1240 DEB_DSCFILE="${DEB_DSCFILE##*/}"
1242 chroot $BUILD_ROOT su -c "dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD" - $BUILD_USER
1245 if test $BUILD_USER = abuild ; then
1246 chown -R 399:399 $BUILD_ROOT$TOPDIR/*
1248 chown -R root:root $BUILD_ROOT$TOPDIR/*
1250 cd $BUILD_ROOT$TOPDIR/SOURCES || cleanup_and_exit 1
1252 echo -----------------------------------------------------------------
1253 if test "$BUILD_USER" = root ; then
1254 echo ----- building $SPECFILE
1256 echo ----- building $SPECFILE "(user $BUILD_USER)"
1258 echo -----------------------------------------------------------------
1259 echo -----------------------------------------------------------------
1260 test -n "$RUNNING_IN_VM" && ifconfig lo 127.0.0.1 up
1261 test -n "$RUNNING_IN_VM" -a -n "$MYHOSTNAME" && hostname "$MYHOSTNAME"
1263 BUILD_SUCCEEDED=false
1265 if test "$BUILDTYPE" = spec ; then
1266 test -z "$BUILD_RPM_BUILD_STAGE" && BUILD_RPM_BUILD_STAGE=-ba
1268 # XXX: move _srcdefattr to macro file?
1269 rpmbopts=("$BUILD_RPM_BUILD_STAGE" "--define" "_srcdefattr (-,root,root)")
1270 if [ -n "$ABUILD_TARGET_ARCH" ]; then
1271 rpmbopts[${#rpmbopts[@]}]="--target=$ABUILD_TARGET_ARCH"
1273 if [ -n "$BUILD_JOBS" ]; then
1274 rpmbopts[${#rpmbopts[@]}]='--define'
1275 rpmbopts[${#rpmbopts[@]}]="jobs $BUILD_JOBS"
1277 if [ -n "$DISTURL" ]; then
1278 rpmbopts[${#rpmbopts[@]}]='--define'
1279 rpmbopts[${#rpmbopts[@]}]="disturl $DISTURL"
1281 if test -s "$BUILD_ROOT/usr/lib/rpm/mandriva/macros" ; then
1282 rpmbopts[${#rpmbopts[@]}]='--eval'
1283 rpmbopts[${#rpmbopts[@]}]="%undefine _enable_debug_packages"
1285 if [ -n "$BUILD_DEBUG" ]; then
1286 rpmbopts[${#rpmbopts[@]}]='--eval'
1287 rpmbopts[${#rpmbopts[@]}]="%suse_insert_debug_package"
1291 test -x $BUILD_ROOT/usr/bin/rpmbuild || rpmbuild=rpm
1292 # su involves a shell which would require even more
1293 # complicated quoting to bypass than this
1294 toshellscript $rpmbuild \
1295 "${definesnstuff[@]}" \
1297 "$TOPDIR/SOURCES/$SPECFILE" \
1298 > $BUILD_ROOT/.build.command
1299 chmod 755 $BUILD_ROOT/.build.command
1300 chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true
1303 if test "$BUILDTYPE" = dsc ; then
1304 chroot $BUILD_ROOT su -c "cd $TOPDIR/BUILD && dpkg-buildpackage -us -uc -rfakeroot-tcp" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true
1305 mkdir -p $BUILD_ROOT/$TOPDIR/DEBS
1306 for DEB in $BUILD_ROOT/$TOPDIR/*.deb ; do
1307 test -e "$DEB" && mv "$DEB" "$BUILD_ROOT/$TOPDIR/DEBS"
1310 ln $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE $BUILD_ROOT/$TOPDIR/DEBS/
1312 ln $BUILD_ROOT/$DEB_SOURCEDIR/$f $BUILD_ROOT/$TOPDIR/DEBS/
1313 done < <(sed -ne '/^Files:/,$s/^ ................................ [0-9][0-9]* //p' < $BUILD_ROOT/$DEB_SOURCEDIR/$DEB_DSCFILE)
1316 if test "$BUILDTYPE" = kiwi ; then
1317 # run createrepo on the repositories
1318 if test -d $BUILD_ROOT/$TOPDIR/SOURCES/repos ; then
1320 cd $BUILD_ROOT/$TOPDIR/SOURCES/repos
1322 test -L $r && continue
1323 test -d $r || continue
1324 repo="$TOPDIR/SOURCES/repos/$r/"
1325 # create compatibility link
1327 if test "$rc" != "$r" ; then
1332 ln -s $rl$r "${rc%/*}/${rc##*/}"
1333 repo="$TOPDIR/SOURCES/repos/${rc%/*}/${rc##*/}/"
1335 echo "creating repodata for $repo"
1336 chroot $BUILD_ROOT createrepo "$repo"
1340 # unpack tar files in image directories
1341 if test -d $BUILD_ROOT/$TOPDIR/SOURCES/images ; then
1343 cd $BUILD_ROOT/$TOPDIR/SOURCES/images
1345 test -L $r && continue
1346 test -d $r || continue
1347 for t in $r/root.tar* ; do
1348 test -f $t || continue
1350 chroot $BUILD_ROOT tar -C $TOPDIR/SOURCES/images/$r/root -xf "$TOPDIR/SOURCES/images/$r/$t{##*/}"
1352 # create compatibility link
1354 if test "$rc" != "$r" ; then
1358 ln -s $rl$r "${rc%/*}/${rc##*/}"
1363 rm -f $BUILD_ROOT/$TOPDIR/SOURCES/config.xml
1364 ln -s $SPECFILE $BUILD_ROOT/$TOPDIR/SOURCES/config.xml
1365 imagetype=$(perl -I$BUILD_DIR -MBuild::Kiwi -e Build::Kiwi::show $BUILD_ROOT/$TOPDIR/SOURCES/$SPECFILE imagetype)
1366 chroot $BUILD_ROOT su -c "kiwi --version" -
1367 if test "$imagetype" = product ; then
1368 echo "running kiwi --create-instsource..."
1369 chroot $BUILD_ROOT su -c "kiwi --root $TOPDIR/KIWIROOT -v -v --instsource-local --logfile terminal -p $TOPDIR/SOURCES --create-instsource $TOPDIR/SOURCES" - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true
1370 for i in $BUILD_ROOT/$TOPDIR/KIWIROOT/main/* ; do
1371 test -d "$i" || continue
1373 test "$n" = scripts && continue
1374 test "$n" != "${n%0}" && continue
1375 chroot $BUILD_ROOT su -c "suse-isolinux $TOPDIR/KIWIROOT/main/$n $TOPDIR/KIWI/$n.iso" - $BUILD_USER
1378 BUILD_SUCCEEDED=true
1379 for imagetype in $imagetype ; do
1380 echo "running kiwi --prepare for $imagetype..."
1381 if chroot $BUILD_ROOT su -c "cd $TOPDIR/SOURCES && kiwi --prepare $TOPDIR/SOURCES --logfile terminal --root $TOPDIR/KIWIROOT-$imagetype" - $BUILD_USER < /dev/null ; then
1382 echo "running kiwi --create for $imagetype..."
1383 chroot $BUILD_ROOT su -c "kiwi --create $TOPDIR/KIWIROOT-$imagetype --logfile terminal --type $imagetype -d $TOPDIR/KIWI" - $BUILD_USER < /dev/null || BUILD_SUCCEEDED=
1387 test -z "$BUILD_SUCCEEDED" && break
1392 test "$BUILD_SUCCEEDED" = true || cleanup_and_exit 1
1393 test -d "$SRCDIR" && cd "$SRCDIR"
1396 RPMS=`find $BUILD_ROOT/$TOPDIR/RPMS -type f -name "*.rpm"`
1398 if test -n "$RPMS" -a -n "$BUILD_USER_ABUILD_USED" ; then
1399 echo "... checking for files with abuild user/group"
1401 while read un gn fn ; do
1402 if test "$un" = abuild -o "$gn" = abuild -o "$un" = 399 -o "$gn" = 399 ; then
1406 done < <(rpm -qp --qf '[%{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]' $RPMS)
1407 if test -n "$BADFILE" ; then
1408 echo "please fix your filelist (e.g. add defattr)"
1413 if test -n "$RPMS" -a -d "$BUILD_ROOT/usr/lib/build/checks" ; then
1414 mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
1416 export DO_RPM_REMOVE=true
1417 for SRPM in $BUILD_ROOT/$TOPDIR/SRPMS/*src.rpm ; do
1418 test -f "$SRPM" && PNAME=`rpm --nodigest --nosignature -qp --qf "%{NAME}" $SRPM`
1420 for CHECKSCRIPT in $BUILD_ROOT/usr/lib/build/checks/* ; do
1421 echo "... running `basename $CHECKSCRIPT`"
1422 $CHECKSCRIPT || cleanup_and_exit 1
1424 umount -n $BUILD_ROOT/proc 2> /dev/null
1427 if test -n "$RPMS" -a "$DO_CHECKS" != "false" -a -x "$BUILD_ROOT/opt/testing/bin/rpmlint" -a -d "$BUILD_ROOT/$TOPDIR/RPMS" ; then
1428 LINT_RPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/RPMS \
1429 \( -name "*-debuginfo-*" -o -name "*-debugsource-*" \
1430 -o -name "*-32bit-*" -o -name "*-64bit-*" \
1431 -o -name "*-x86-*" -o -name "*-ia32-*" \) -prune \
1432 -o -type f -name '*.rpm' -print))
1433 SRPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/SRPMS -type f -name "*.rpm"))
1435 echo "RPMLINT report:"
1436 echo "==============="
1437 chroot $BUILD_ROOT /opt/testing/bin/rpmlint --info ${LINT_RPM_FILE_LIST[*]#$BUILD_ROOT} ${SRPM_FILE_LIST[*]#$BUILD_ROOT} || cleanup_and_exit 1
1440 if test -n "$RPMS" -a -n "$CREATE_BASELIBS" -a -d "$BUILD_ROOT/$TOPDIR/RPMS" ; then
1441 if test -f $BUILD_ROOT/usr/lib/build/mkbaselibs -o "$CREATE_BASELIBS" != internal ; then
1442 mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
1444 umount -n $BUILD_ROOT/proc 2> /dev/null
1448 if test -n "$RUNNING_IN_VM" -a -n "$VM_SWAP"; then
1449 echo "... saving built packages"
1451 $BUILD_DIR/extractbuild "$VM_SWAP" || cleanup_and_exit 1
1454 echo "... build is finished"