# Distributed under the terms of the GNU General Public License v2 or any # later version # # Latest version of this file can be downloaded from: # http://www.emdebian.org/repos/current/emdebian/trunk/buildcross/trunk/ # but it might need some fix for you to work. # ---------------------------------------------------------------------- # Copyright 2010 Hector Oron #---------------------------------------------------------------------- # Useful shell functions #---------------------------------------------------------------------- # check build-deps checkinstalled () { while [ -n "$1" ]; do dpkg -l "$1" |grep -q "^ii" || { echo "$1 is not installed." ${ROOTCMD} apt-get -y --force-yes install $1 ${ROOTCMD} apt-get clean } shift done } #---------------------------------------------------------------------- # Update system update_sys () { ${ROOTCMD} apt-get -f -y --force-yes install ${ROOTCMD} apt-get -f -y --force-yes update ${ROOTCMD} apt-get -f -y --force-yes dist-upgrade } #---------------------------------------------------------------------- # sanity check build environment sanitycheck () { echo "Sanity check..." checkinstalled dpkg-cross # checkinstalled wget #checkinstalled dctrl-tools checkinstalled grep-dctrl checkinstalled sudo checkinstalled fakeroot checkinstalled dpatch checkinstalled time checkinstalled patchutils checkinstalled tar checkinstalled bzip2 checkinstalled lsb-release checkinstalled autoconf checkinstalled autoconf2.13 checkinstalled automake1.9 checkinstalled libtool checkinstalled autogen checkinstalled gawk checkinstalled bison checkinstalled flex checkinstalled realpath checkinstalled texinfo checkinstalled devscripts checkinstalled reprepro checkinstalled less checkinstalled coreutils checkinstalled automake1.4 checkinstalled automake1.7 checkinstalled dh-make checkinstalled debhelper checkinstalled apt-cross checkinstalled emdebian-tools # Following lines are gdb dependencies checkinstalled texinfo checkinstalled libncurses5-dev checkinstalled libreadline5-dev #checkinstalled gcj checkinstalled gobjc checkinstalled cdbs checkinstalled quilt checkinstalled type-handling checkinstalled build-essential checkinstalled gcc-multilib checkinstalled libc6-dev-i386 checkinstalled lib32gcc1 checkinstalled dejagnu checkinstalled gperf checkinstalled libmpfr-dev checkinstalled sharutils checkinstalled pbuilder checkinstalled chrpath echo "Sanity check passed." } #---------------------------------------------------------------------- # find full version string: version # XXX: What about epochs? version () { # Fails on sh4 if [ x"${ARCH}" != x"sh4" ] ; then rmadison -a ${ARCH} ${1} | grep -w ${SUITE} | cut -d'|' -f2 | tr -d ' ' | cut -d'+' -f1 |sed 's/1://'|tail -n 1 else rmadison ${1} | grep -w ${SUITE} | cut -d'|' -f2 | tr -d ' ' | cut -d'+' -f1 |sed 's/1://'|tail -n 1 fi } #---------------------------------------------------------------------- # source version: srcver srcver () { local x=$(apt-cache showsrc $1 |grep ^Version: |sed 's/^Version: //' |sort -bru |head -1) echo $(echo $x |sed 's/\(.*\)\(-[0-9]*$\)/\1/' |sed 's/1://') } #---------------------------------------------------------------------- # find upstream version string: upstreamversion upstreamversion () { echo $(version $1 |sed 's/\(.*\)\(-[0-9]*$\)/\1/') } #---------------------------------------------------------------------- # find debian revision string: debianrevision debianrevision () { echo $(version $1 |sed 's/\(.*-\)\([0-9]*$\)/\2/') } #---------------------------------------------------------------------- # find sourcepackage: sourcepackage sourcepackage () { local x=$(grep-status -PX $1 -s Source: -n) local y=$1 echo ${x:=$y} } #---------------------------------------------------------------------- # find source directory: sourcedir sourcedir () { echo $1-$(srcver $1) } #---------------------------------------------------------------------- # find source directory: sourcedir_v sourcedir_v () { local _a=`sourcedir $(srcver $1)` local _b=`echo ${_a} | cut -d'-' -f1` echo $1-${_b} } #---------------------------------------------------------------------- # checks if the packages has already been built is_new_package () { # Find Debian version # Emdebian repository check # Fylesystem check # Return yes echo 0 } #---------------------------------------------------------------------- # make cross ${ARCH} package: make-cross-package make-cross-package () { local _version=$(version $1) # XXX Need to check if works fine now # ${ROOTCMD} apt-cross -v -v -a ${ARCH} -S ${SUITE} -m ${MIRROR} -x libc-bin -x libc-dev-bin -f -b $1 ${ROOTCMD} apt-cross -v -v -a ${ARCH} -S ${SUITE} -m ${MIRROR} -x libc-bin -x libc-dev-bin -x debconf-2.0 -x debconf -f -i $1 ${ROOTCMD} apt-cross -v -v -a ${ARCH} -S ${SUITE} -m ${MIRROR} -x libc-bin -x libc-dev-bin -x debconf-2.0 -x debconf -f -b $1 } #---------------------------------------------------------------------- # build and install libraries needed to build the cross toolchain build-libs () { # Lets get kernel info; linux kernel headers make-cross-package linux-libc-dev make-cross-package gcc-4.4-base make-cross-package libgcc1 make-cross-package libmpfr make-cross-package libmpfr-dev if [ ${ARCH} = "hppa" ]; then make-cross-package libgcc4 fi if [ ${ARCH} = "m68k" ] ; then make-cross-package libgcc2 fi # Added lib32gcc1 for testing - not sure if this is needed if [ ${ARCH} = "amd64" ] ; then make-cross-package lib32gcc1 fi if [ ${ARCH} = "ia64" ] ; then make-cross-package lib32gcc1 fi make-cross-package zlib1g make-cross-package zlib1g-dev make-cross-package libgmp3-dev make-cross-package libgmp3c2 make-cross-package libgmpxx4ldbl make-cross-package libmpfr-dev make-cross-package libmpfr1ldbl make-cross-package libstdc++6 # Lets get glibc if [ ${ARCH} = "alpha" ] || [ ${ARCH} = "ia64" ] ; then make-cross-package libc6.1 make-cross-package libc6.1-dev else make-cross-package libc6 make-cross-package libc6-dev fi # Build dependencies if [ ${ARCH} = "ia64" ] ; then make-cross-package libatomic-ops-dev make-cross-package libunwind7 make-cross-package libunwind7-dev fi if [ ${ARCH} = "powerpc" ]; then make-cross-package libc6-ppc64 make-cross-package libc6-dev-ppc64 fi if [ ${ARCH} = "i386" ]; then make-cross-package libc6-amd64 make-cross-package lib64gcc1 make-cross-package libc6-dev-amd64 fi if [ ${ARCH} = "sparc" ]; then make-cross-package libc6-sparc64 make-cross-package libc6-dev-sparc64 fi if [ ${ARCH} = "s390" ]; then make-cross-package libc6-s390x make-cross-package libc6-dev-s390x fi if [ ${ARCH} = "mips" ] || [ ${ARCH} = "mipsel" ]; then make-cross-package libc6-mipsn32 make-cross-package libc6-mips64 make-cross-package libc6-dev-mips64 make-cross-package libc6-dev-mipsn32 make-cross-package libn32gcc1 make-cross-package libn32z1 make-cross-package libn32z1-dev fi # make-cross-package uclibc-toolchain # make-cross-package libuclibc0 # make-cross-package libuclibc-dev # make-cross-arch-package gdb # Final work: Install libraries and do clean up # XXX Now apt-cross does -i then -b to keep _all.ded ${ROOTCMD} dpkg -i *all.deb ${ROOTCMD} chown $USER.$GROUP *.deb # rm -rf *${ARCH}.deb } #---------------------------------------------------------------------- # applies patches apply_patch () { local aux=`cat /usr/share/buildcross/patches/series-${1}` for patchfile in $aux; do echo "===> Applying $patchfile patch <===" patch -p1 < /usr/share/buildcross/patches/$patchfile done } #---------------------------------------------------------------------- # build and install cross gdb build-gdb () { local _upver=$(upstreamversion gdb) local _version=$(version gdb) local _dir=$(sourcedir gdb) local _debarch=${ARCH} if [ ! -d gdb-${_version} ]; then rm -rf $_dir apt-get source gdb mv $_dir gdb-${_version} fi cd gdb-${_version} ${ROOTCMD} /usr/lib/pbuilder/pbuilder-satisfydepends-classic GDB_TARGET=${ARCH} dpkg-buildpackage -rfakeroot -uc -us cd .. # $ROOTCMD dpkg -i gdb-${_debarch}-linux-gnu_${_version}_${HOSTARCH}.deb >> dpkg.log #// Do clean up # rm -rf *.gz *.bz2 *.dsc *.changes *.tgz *.tar gdb-${_version}/ if [ x"${CLEANDIRS}" = x"yes" ] ; then rm -rf gdb-${_version}/ fi } #---------------------------------------------------------------------- # build and install cross binutils build-binutils () { local _upver=$(upstreamversion binutils) local _version=$(version binutils) local _dir=$(sourcedir binutils) local _debarch=${ARCH} if [ ! -d binutils-${_version} ]; then rm -rf $_dir apt-get source binutils cd $_dir echo "${ARCH}" > debian/target #// Workarround patches apply_patch binutils cd .. mv $_dir binutils-${_version} fi cd binutils-${_version} ${ROOTCMD} /usr/lib/pbuilder/pbuilder-satisfydepends-classic TARGET=${ARCH} fakeroot debian/rules binary-cross #dpkg-genchanges > binutils_${_version}_${debarch}.changes cd .. $ROOTCMD dpkg -i --force-overwrite binutils-*-linux-gnu*.deb >> dpkg.log #// Do clean up # rm -rf *.gz *.bz2 *.tgz *.dsc *.changes *.tar binutils-${_version}/ if [ x"${CLEANDIRS}" = x"yes" ] ; then rm -rf binutils-${_version}/ fi } #---------------------------------------------------------------------- # build cross gcc versions: build-gcc build-gcc () { local _upver=$(upstreamversion gcc-$1) local _version=$(version gcc-$1) local _dir=$(sourcedir gcc-$1) local _vers=$(sourcedir_v gcc-$1) if [ ! -d gcc-$1-${_version} ]; then rm -rf $_dir apt-get source gcc-$1 cd $_vers ## XX Needs fix: add apply_patch gcc-4.4 # Workaround for GCC4.2 if [ ${1} = "4.1" ] || [ ${1} = "4.2" ]; then apply_patch gcc-4.1-4.2-cross-powerpc.patch # apply_patch fixes-cross-naming-4.3b.patch # apply_patch reverse_cross_fix.patch # apply_patch gcc42-amd64-i386.patch # apply_patch gcc-4.2-4.2.2-cross.patch fi # Patch gcc-3.3 #if [ ${GCCVER} = "3.3" ]; then # cp ../../patches/gcc-3.3.6-emdebian-cross.dpatch debian/patches # apply_patch gcc-3.3.patch # Disables multi-arch # apply_patch gcc-3.3.6.patch #fi # if [ ${1} = "4.3" ]; then # #apply_patch omit-base.diff # apply_patch s390-cross-no-biarch.dpatch # fi if [ ${1} = "4.4" ]; then # apply_patch gcc-4.4-update-cross-fixes.patch apply_patch gcc-4.4 fi ${ROOTCMD} /usr/lib/pbuilder/pbuilder-satisfydepends-classic GCC_TARGET=${ARCH} DEB_CROSS=yes fakeroot debian/rules control cd .. mv $_vers gcc-$1-${_version} fi cd gcc-$1-${_version} ${ROOTCMD} /usr/lib/pbuilder/pbuilder-satisfydepends-classic DEB_CROSS_NO_BIARCH=yes DH_VERBOSE=1 \ GCC_TARGET=${ARCH} DEB_CROSS=yes dpkg-buildpackage -us -uc -rfakeroot cd .. } #---------------------------------------------------------------------- # install cross gcc versions: install-gcc install-gcc () { local _version=$(version gcc-$1) local _versionrepo=$(echo gcc-$1 | sed -e 's/-//' | sed -e 's/\.//') # $ROOTCMD dpkg -i *gcc*4.4*.deb >> dpkg.log #// Do clean up # rm -rf *.gz *.bz2 *.tgz *.tar gcc-$1-${_version}/ *.changes *.dsc if [ x"${CLEANDIRS}" = x"yes" ] ; then rm -rf gcc-$1-${_version}/ fi } #---------------------------------------------------------------------- # build cross gcc-snapshot build-gcc-snapshot () { # Hack, hack. cd /usr/lib $ROOTCMD ln -sf /usr gcc-snapshot cd .. build-gcc snapshot # install-gcc snapshot } #---------------------------------------------------------------------- # Finally, do the work. em_cross () { # unset with_sysroot # with_sysroot=/usr/s390-linux-gnu/ PKG=$1 ARCH=$2 CURDIR=`pwd` if [ ! -d $LOGPATH ]; then mkdir -p $LOGPATH fi # Sets build as failed echo 1 > $LOGPATH/$HOST-$ARCH-$PKG.log sanitycheck # dpkg-cross version check if [[ "2.4.0" < $(dpkg-cross --help 2>&1 |awk '{print $3; exit;}') ]]; then echo "dpkg-cross is too old." ${ROOTCMD} apt-get install -f dpkg-cross fi # Clean dir ? # em_clean [ -d ${ARCH} ] || mkdir ${ARCH} cd ${ARCH} echo "Updating apt-cross cache" if [ ${ARCH} == "sh4" ]; then unset MIRROR MIRROR=${MIRROR:="http://ftp.debian-ports.org/debian"} fi ${ROOTCMD} apt-cross -a ${ARCH} -S ${SUITE} -m ${MIRROR} -u echo "Building for ARCH::${ARCH}" case ${1} in libs) build-libs > ../$LOGPATH/$HOST-$ARCH-$PKG.log 2>&1 ;; binutils) build-binutils > ../$LOGPATH/$HOST-$ARCH-$PKG.log 2>&1 ;; gdb) build-gdb > ../$LOGPATH/$HOST-$ARCH-$PKG.log 2>&1 ;; snapshot) build-gcc-snapshot > ../$LOGPATH/$HOST-$ARCH-$PKG.log 2>&1;; 3.3|3.4|4.1|4.2|4.3|4.4|4.5) GCCVER=${1} checkinstalled gcc-${GCCVER} build-gcc ${GCCVER} > ../$LOGPATH/$HOST-$ARCH-$PKG.log 2>&1 install-gcc ${GCCVER} ;; test) echo "TEST DONE: buildcross should now run" ; mkdir test; cd test; apply_patch binutils; cd .. ;; esac cd ${CURDIR} echo `pwd` # FIXME: REPLACE: This quite does not work TEST="`cat ./$LOGPATH/$HOST-$ARCH-$PKG.log | grep *.deb | sort -n | uniq |head -n 1`" if [ -n ${TEST} ] ; then echo 1 >> ./$LOGPATH/$HOST-$ARCH-$PKG.log else echo 0 >> ./$LOGPATH/$HOST-$ARCH-$PKG.log fi } #---------------------------------------------------------------------- # clean directories and installed bins em_clean () { for ARCH in $ARCHLIST; do [ "x$ARCH" = "x" ] && continue ${ROOTCMD} apt-get remove -y --force-yes `dpkg -l | grep $ARCH | cut -d' ' -f3` done ${ROOTCMD} apt-get remove -y --force-yes `dpkg -l | grep gnueabi | cut -d' ' -f3` # FIXME: Maybe it is better clean conf_vars arches? rm -rf powerpc arm armel mips mipsel i386 sparc s390 amd64 \ sh4 m68k hppa alpha ia64 logs logs.html dpkg.log } #---------------------------------------------------------------------- # Get a tarball with the tools #// Buggy em_tgz () { filepath=`pwd` files=`ls -1 *.deb` filename=`basename $filepath` mkdir $filename-toolchain for i in $files; do dpkg -x $i $filename-toolchain done pushd $filename-toolchain tar zcf ../$filename-toolchain.tgz . popd } #---------------------------------------------------------------------- # Do build via em_cross funct, kept for historical reasons em_build () { PKG=$1 ARCH=$2 em_cross $PKG $ARCH em_log $PKG $ARCH } #---------------------------------------------------------------------- # Keep logs in the webpage generated by em_wrap em_log () { PKG=$1 ARCH=$2 # Check logs - Need to be improved, it does not work fine. VAR=`tail -n 1 $LOGPATH/$HOST-$ARCH-$PKG.log` # Maybe show logfile on the html if [ x"${VAR}" = x"0" ] ; then echo "Build succesful" echo "   $HOST : $ARCH : $SUITE : $PKG : LOGFILE : Build succesful
" >> $LOGHTMLPATH/$LOGHTML else echo "Build maybe failed unless it is `libs` build" echo "   $HOST : $ARCH : $SUITE : $PKG : LOGFILE : Build maybe failed
" >> $LOGHTMLPATH/$LOGHTML fi } #---------------------------------------------------------------------- # Wrapper HTML to display results em_wrap () { echo $LOGPATH echo $LOGHTML cat << 'EOF' > $LOGHTML Buildcross results: Emdebian vs Debian (unstable)
emdebian logo
news emdebian projects support development

Emdebian buildcross toolchain updates: unstable

This page is generated automatically by buildcross infrastructure to check latest status in Emdebian toolchain unstable repository against upstream Debian unstable.


You can check buildcross complete log

BUILD-HOST : ARCH : SUITE : PKG : LOGFILE : STATUS
EOF for ARCH in $ARCHLIST; do for PKG in $PKGLIST; do em_build $PKG $ARCH done done cat << 'EOF' >> $LOGHTML
EOF }