hy. here are my auto compiling script. there is a bit more management in it, and i seperated the whole thing in two scripts (the basic idea was, that they could run on seperated machine, or the build script could run in a chroot environment for security...).
i only tried to compile my own packages (i don't have a debian source mirror here, and also no access to a pc with such a mirror). i started the scripts with : cd /home/devel if [ -f builder.pid ] then kill `cat builder.pid` rm builder.pid fi if [ -f manager.pid ] then kill `cat manager.pid` rm manager.pid fi bin/builder -W/home/devel/Work > debug.builder 2>&1 & bin/manager -I/home/devel/Incoming -O/home/devel/Done -W/home/devel/Work \ -F/home/devel/Failed -L/home/devel/Logs > debug.manager 2>&1 & regards, andreas
#!/bin/bash set -e version="0.1" progname="`basename \"$0\"`" pidfile="${progname}.pid" workdir="" arch="`dpkg --print-architecture`" clean="" target="binary" targetparam="" makeflags=--silent usageversion () { cat >&2 <<END Debian GNU/Linux builder ${version}. Copyright (C) 1996,97 Ian Jackson, Lars Wirzenius, Andreas Jellinghaus. This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO warranty. Usage: ${progname} [options] Options: -B binary-only, no arch-indep files -p<pidfile> pidfile (default ${pidfile}) -W<workdir> work directory -a<arch> architectute used in file names (default ${arch}) -c also log cleanup -v verbose, don't set MAKEFLAGS to --silent -d debug mode (set -x) -h print this message END } while [ $# != 0 ] do value="`echo x\"$1\" | sed -e 's/^x-.//'`" case "$1" in -h) usageversion; exit 0 ;; -B) target="binary-arch"; targetparam="-B" ;; -p*) pidfile="${value}" ;; -W*) workdir="${value}" ;; -a*) arch="${value}" ;; -v) makeflags="" ;; -c) clean="true" ;; -d) set -x ;; *) echo >&2 "${progname}: unknown option or argument $1" usageversion; exit 2 ;; esac shift done if [ -z "${workdir}" ]; then echo "you must specify a workdir with -W" >&2 exit 1 fi if ! [ -d ${workdir} ]; then echo "no such directory : ${workdir}" >&2 exit 1 fi if [ -e "${pidfile}" ]; then echo "pidfile already exists : ${pidfile}" >&2 exit 1 fi trap "rm -f ${pidfile}" 1 2 3 15 echo $$ > ${pidfile} if [ -n "${makeflags}" ]; then export MAKEFLAGS="${makeflags}"; fi cd ${workdir} while true do while ! test -e todo do sleep 10 done file="`cat todo`" fdir="`dirname ${file}`" file="`basename ${file}`" package="`echo ${file} |cut -d_ -f1`" suffix="`echo ${file} |cut -d_ -f2`" version="`basename ${suffix} .dsc`" dirver="`echo ${version}|cut -d- -f1`" dir="${package}-${dirver}" changes="${package}_${version}_${arch}.changes" orig="${package}_${dirver}.orig.tar.gz" logfile="${package}_${version}_${arch}.buildlog" cleanlog="/dev/null" rm todo if [ -n "${clean}" ]; then cleanlog="${logfile}" ; fi rm -rf * echo "BUILD : extracting ${package} ${version}" >> ${logfile} if ! dpkg-source -x ${fdir}/${file} 2>&1 >> ${logfile} then rm -rf ${dir} echo "BUILD : Couldn't extract ${file}" >> ${logfile} echo "BUILD : failed ${package} ${version}" >> ${logfile} echo "failed" > result continue fi rm ${orig} echo "BUILD : building ${package} ${version}" >> ${logfile} cd ${dir} if ! debian/rules build 2>> ../${logfile} >> ../${logfile} then build clean 2>> ../${cleanlog} >> ../${cleanlog} cd .. rm -rf $DIR echo "BUILD : Couldn't compile ${file}" >> ${logfile} echo "BUILD : failed ${package} ${version}" >> ${logfile} echo "failed" > result continue fi echo "BUILD : packaging ${package} ${version}" >> ../${logfile} if ! build $target 2>> ../${logfile} >> ../${logfile} then build clean 2>> ../${cleanlog} >> ../${cleanlog} cd .. rm -rf ${dir} echo "BUILD : Couldn't package ${file}" >> ${logfile} echo "BUILD : failed ${package} ${version}" >> ${logfile} echo "failed" > result continue fi echo "BUILD : changes file ${package} ${version}" >> ../${logfile} if ! dpkg-genchanges -b ${targetparam} > ../${changes} 2>> ../${logfile} then build clean 2>> ../${cleanlog} >> ../${cleanlog} cd .. rm -rf $DIR ${changes} echo "BUILD : Couldn't generate changes ${file}" >> ${logfile} echo "BUILD : failed ${package} ${version}" >> ${logfile} echo "failed" > result continue fi build clean 2>> ../${logfile} >> ../${logfile} cd .. rm -rf ${dir} echo "BUILD : files builded ${package} ${version}" >> ${logfile} ls >> ${logfile} echo "BUILD : ok ${package} ${version}" >> ${logfile} echo "ok" > result done
#!/bin/bash set -e version="0.1" progname="`basename \"$0\"`" pidfile="${progname}.pid" logfile="${progname}.log" pkgfile="${progname}.dat" pgpring=/usr/doc/dpkg/developer-keys.pgp pgpfile=.pgp/phrase arch="`dpkg --print-architecture`" incoming="" outgoing="" workdir="" usageversion () { cat >&2 <<END Debian GNU/Linux builder ${version}. Copyright (C) 1996,97 Ian Jackson, Lars Wirzenius, Andreas Jellinghaus. This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO warranty. Usage: ${progname} [options] Options: -p<pidfile> pidfile (default ${pidfile}) -l<logfile> logfile (default ${logfile}) -R<pgpring> pgp ring of valid developers (default ${pgpring}) -P<passphrase> file with pgp phrase (default ${pgpfile}) -a<arch> set architecure (default ${arch}) -D<pkgfile> list of packages processed (default ${pkgfile}) -I<incoming> directory with source packages -O<outgoing> directory for new packages -W<workdir> directory where the builder works -F<faileddir> directory with logfiles if build failed -L<logdir> directory with logfiles if build succeded -d debug mode (set -x) -h print this message END } while [ $# != 0 ] do value="`echo x\"$1\" | sed -e 's/^x-.//'`" case "$1" in -h) usageversion; exit 0 ;; -p*) pidfile="${value}" ;; -l*) logfile="${value}" ;; -R*) pgpring="${value}" ;; -P*) pgpfile="${value}" ;; -a*) arch="${value}" ;; -d) set -x ;; -D*) pkgfile="${value}" ;; -I*) incoming="${value}" ;; -O*) outgoing="${value}" ;; -W*) workdir="${value}" ;; -F*) faileddir="${value}" ;; -L*) logdir="${value}" ;; *) echo >&2 "${progname}: unknown option or argument $1" usageversion; exit 2 ;; esac shift done if [ -z "${incoming}" ]; then echo "you must specify a source dir with -I" >&2 exit 1 fi if ! [ -d "${incoming}" ]; then echo "directory ${incoming} does not exist" >&2 exit 1 fi if [ -z "${outgoing}" ]; then echo "you must specify a package dir with -O" >&2 exit 1 fi if ! [ -d "${outgoing}" ]; then echo "directory ${outgoing} does not exist" >&2 exit 1 fi if [ -z "${workdir}" ]; then echo "you must specify a workdir with -W" >&2 exit 1 fi if ! [ -d "${workdir}" ]; then echo "directory ${workdir} does not exist" >&2 exit 1 fi if [ -n "${pgpfile}" ]; then export PGPPASS="`cat ${pgpfile}`" fi if [ -e "${pidfile}" ]; then echo "pidfile already exixts : ${pidfile}" >&2 exit 1 fi trap "rm -f ${pidfile}" 1 2 3 15 echo $$ > ${pidfile} log () { echo $@ >> ${logfile} } addfile () { echo [EMAIL PROTECTED] >> ${pkgfile} log "marked as proceded : $@" } while true do for file in `ls ${incoming}/*.dsc` do file="`basename ${file}`" if grep -q "${file}.${arch}" ${pkgfile} then continue fi if ! grep -q "BEGIN PGP SIGNED MESSAGE" ${incoming}/${file} then log "No pgp signature found in : ${file}" addfile ${file} continue fi if ! pgp +batchmode < ${incoming}/${file} > /dev/null then log "PGP signature invalid : ${file}" addfile ${file} continue fi echo ${incoming}/${file} > ${workdir}/todo addfile ${file} while ! test -e ${workdir}/result do sleep 10 done echo "geschaft !" if ! test "`cat ${workdir}/result`" == "ok" ; then rm ${workdir}/result mv ${workdir}/*buildlog ${failed} log "failed to build : ${file}" continue fi echo "Ok" rm ${workdir}/result changes=`ls ${workdir}/*changes` if test -z "${changes}" then mv ${workdir}/*buildlog ${failed} log "no changes file found : ${file}" continue fi if ! pgp -sat ${changes} then rm ${changes}.asc ${changes} mv ${workdir}/*buildlog ${failed} mv ${workdir}/*buildlog ${failed} log "pgp signing failed : ${file}" continue fi mv ${changes}.asc ${changes} mv ${workdir}/* ${outgoing} done done