]> git.pld-linux.org Git - projects/cleanbuild.git/blobdiff - cleanbuild
run findbr inside container
[projects/cleanbuild.git] / cleanbuild
index 2255866becd78908f2257e907d6f9b9456cb926e..e7da70a158ea725fe5793fc3d5f339b8051c089b 100755 (executable)
@@ -8,11 +8,13 @@ CACHEDIR="$PWD/poldekcache"
 RPMMACROS=""
 BUILDERRC=""
 IGNORE=""
+CHROOTSIZE="4G"
 ignore() { IGNORE="$IGNORE $*"; }
 NODEBUG=true
 CLEANAFTER=false
 FORCE_UMOUNT=false
 NOREBUILDDB=true
+MULTILIB=false
 # Whatever you set here as value, consider that it may not be shorter than
 # /usr/lib/debug (or /usr/src/debug) for debuginfo to work.
 # You get "Only dest dir longer than base dir not supported" error otherwise.
@@ -21,7 +23,7 @@ BUILDDIR=/usr/src/BUILD
 [ -r .cleanbuildrc ] && . ./.cleanbuildrc
 
 [ -z "$USER" ] && echo "USER not defined" && exit 1
-[ "$USER" == "root" ] && echo "USER must not be root" && exit 1
+[ "$USER" = "root" ] && echo "USER must not be root" && exit 1
 
 export LC_ALL=C
 unset LANGUAGE
@@ -41,6 +43,7 @@ usage() {
        echo " --cleanafter | -ca  - clean after build"
        echo " --forceumount | -fu - force umount tmpfs"
        echo " --debug             - enable debug"
+       echo " --network           - allow build to use networking"
        echo " -a, -b, -c, -d, -e  - select alternative chroot directory"
        exit 1
 }
@@ -49,6 +52,7 @@ FETCH=false
 CLEAN=false
 CREATE=false
 BUILD=false
+NETWORK=false
 INSTALL=false
 
 case "$0" in
@@ -114,12 +118,18 @@ while [ $# -gt 0 ]; do
                        DEST="$V"
                        SRC="-n $V-ready"
                        ;;
+               -[1-9]G | -[1-9][0-9]G )
+                       CHROOTSIZE="$V"
+                       ;;
                --cleanafter | -ca)
                        CLEANAFTER=true
                        ;;
                --debug)
                        NODEBUG=false
                        ;;
+               --network)
+                       NETWORK=true
+                       ;;
                --forceumount | -fu)
                        FORCE_UMOUNT=true
                        ;;
@@ -212,19 +222,37 @@ for D in installed buildlogs $CACHEDIR; do
 done
 
 ignore \
-       vserver-packages \
        upstart\* \
+       upstart \
+       compat-\* \
+       systemd-init \
+       hhvm \
+       vserver-packages \
        xorg-driver-video-fglrx\* xorg-driver-video-nvidia\* xorg-xserver-xgl-libGL \
+       xorg-driver-video-vboxvideo \
        xorg-data-xbitmaps \
        compat-gcc\* \
        libpng1\* \
+       libjpeg libjpeg-devel \
        freetype1-devel-* \
        anacron fcron hc-cron \
        masqmail msmtp-sendmail omta postfix sendmail ssmtp nail-mail nullmailer \
        ghostscript-esp \
-       \*-multilib-\* \
+       perl-Scalar-List-Utils \
+       perl-ExtUtils-Install \
+       phonon-backend-mplayer phonon-backend-vlc \
+       libgcj libgcj-devel \
+       icedtea6-jre icedtea6-jdk \
+       icedtea7-jre icedtea7-jdk \
+       java-sun-jre java-sun-jdk \
+       java5-sun-jre java5-sun-jdk \
+       oracle-java7-jre oracle-java7-jdk \
+       gnome-menus \
        gnome-speech-driver-festival gnome-speech-driver-speech-dispatcher
 
+if ! $MULTILIB; then
+       ignore '*-multilib-*'
+fi
 
 rebuilddb()
 {
@@ -275,12 +303,20 @@ build_prepare_root()
        set -e
        $NODEBUG || set -x
        mkdir $CHDIR
-       mount -t tmpfs -o size=8G,relatime /dev/null $CHDIR
+       mount -t tmpfs -o size=$CHROOTSIZE,relatime /dev/null $CHDIR
        echo $$ > $CHDIR/.pid
 
-       rpm --root=$CHDIR --initdb 
+       rpmversion=$(rpm -E '%(v=%{_rpmversion}; IFS=.; set -- $v; echo $1)')
+       rpmversion=${rpmversion:-4}
+
+       if [ "$rpmversion" -ge 5 ]; then
+               rpm --root=$CHDIR -qa
+       else
+               rpm --root=$CHDIR --initdb
+       fi
        poldek --up || :
-       poldek -O "ignore=$IGNORE" -u rpm-build pwdutils coreutils
+       poldek -O "ignore=$IGNORE" -u rpm-build pwdutils coreutils time util-linux git-core gawk
+       echo Poldek exit: $?
 
        for DIR in dev proc sys; do
                # We need to create these directories manually, because they are marked
@@ -289,7 +325,9 @@ build_prepare_root()
                mount -o bind /$DIR $CHDIR/$DIR
        done
 
-       chroot $CHDIR useradd -m $USER -u$(id $USER -u)
+       # group 'users' may already exist, so ignore errors
+       chroot $CHDIR groupadd $(id $USER -gn) -g$(id $USER -g) || :
+       chroot $CHDIR useradd -m $USER -u$(id $USER -u) -g $(id $USER -gn)
 
        # replicate files which already belong to $USER
        # so they will have correct owner and permissions
@@ -320,8 +358,10 @@ build_mount_home()
 {
        $NODEBUG || set -x
        mount -o bind $HOME/rpm $CHDIR/$CHHOME/rpm
-}
 
+       # ensure RPMS dir is available
+       chroot $CHDIR su $USER -c 'mkdir -p $(rpm -E %_rpmdir)'
+}
 
 print_installed()
 {
@@ -362,7 +402,7 @@ builddie()
 LAST_INSTALL=""
 poldek_install()
 {
-       I="$1";
+       local I="$1" ret
        # Nothing to install
        [ -n "$I" ] || return 1
        # Installing same packets second time
@@ -385,7 +425,9 @@ poldek_install()
        [ -n "$ret" ] && return $ret
 
        # try harder
+       info "Poldek install failed, retry without ignore"
        poldek -u $I && return 0
+       info "Poldek install failed, retry once more without ignore"
        poldek -u $I && return 0
        warn "Poldek:" "Could not install" $I
        return 1
@@ -396,9 +438,9 @@ maybe_call()
        local cond="$1"; shift
        local func="$1"; shift
 
-       [ $cond == "false" ] && return
-       $func "$@"
-       [ $cond == "exit_after" ] && exit
+       [ $cond = "false" ] && return
+       "$func" "$@"
+       [ $cond = "exit_after" ] && exit
 }
 
 fetch()
@@ -423,6 +465,9 @@ create()
 }
 
 
+info "Configured Poldek sources"
+poldek -l
+
 maybe_call $FETCH fetch
 
 check_running
@@ -435,6 +480,8 @@ echo $$ > $CHDIR/.pid
 
 maybe_call $INSTALL poldek_install "$*"
 
+maybe_call $NETWORK cp -bf /etc/resolv.conf $CHDIR/etc/
+
 $BUILD || exit
 
 if [ -p /tmp/fixfreq ]; then
@@ -445,7 +492,7 @@ while true; do
        info "Building $build_pkg in $CHNAME"
        rebuilddb
        find $CHDIR/usr/lib{,64} -name "*.la" -print0 | \
-               xargs -0 -r sed -i -e "s@dependency_libs=.*@dependency_libs=' '@" || :
+               xargs -0 -r sed -i -e "s@dependency_libs=.*@dependency_libs=' '@"
        buildlog="buildlogs/$build_pkg"
        if [ -r $buildlog ]; then
                i=1
@@ -457,10 +504,8 @@ while true; do
        fi
        ./findunusedbr -c $CHDIR $HOME/rpm/packages/$build_pkg/$build_pkg.spec
        title "building"
-       { chroot $CHDIR su $USER -c "$CHHOME/rpm/packages/builder -nn -bb $build_pkg $builder_options" < /dev/null 2>&1; echo $? > ecode; } | tee $buildlog
-
-       ECODE=$(< ecode)
-       rm -f ecode
+       ./teeboth $buildlog chroot $CHDIR su $USER -c "$CHHOME/rpm/packages/builder -nn --define '_enable_debug_packages 0' -bb $build_pkg $builder_options"
+       ECODE=$?
 
        if grep -q "error: Failed build dependencies:" $buildlog; then
                SEARCH=$(cat $buildlog | awk '/^Error:/ { p = 0 }; { if ( p ) { f="p"; if ( $1 ~ /^\// ) f="f"; printf "search -%c %s; ", f, $1; } }; /error: Failed build dependencies:/ { p = 1 }')
This page took 0.080236 seconds and 4 git commands to generate.