| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # |
| 3 | # rebuild - builds every package in a clean cowbuilder environment |
| 4 | # Usage: rebuild list |
| 5 | # |
| 6 | # Copyright (C) 2007 Bastian Venthur |
| 7 | # |
| 8 | # License: GPL 2 |
| 9 | # |
| 10 | # Version: 2007-06-06 |
| 11 | # * Included many patches from Gregor Herrmann |
| 12 | # Version: 2007-02-21 |
| 13 | # * Initial release |
| 14 | |
| 15 | |
| 16 | LIST=$1 |
| 17 | DIST=${2:-testing} |
| 18 | MIRROR=http://ftp.at.debian.org |
| 19 | |
| 20 | LOGDIR=$(pwdscip-shell system . . pwd.)/"logs" |
| 21 | BUILDDIR=$(pwdscip-shell system . . pwd.)/"build" |
| 22 | BASEPATH="/var/cache/pbuilder/testing-base.cowscip-shell filesystem . . `/var/cache/pbuilder/testing-base.cow`." |
| 23 | |
| 24 | # source lsb-functions for nice log messages |
| 25 | . /lib/lsb/init-functionsscip-shell source . . `/lib/lsb/init-functions`. |
| 26 | |
| 27 | function buildscip-shell shell shell-project 0.0.0 build(). { |
| 28 | PACKAGE=$1 |
| 29 | |
| 30 | mkdirscip-shell system . . mkdir. -p $BUILDDIR/$PACKAGE |
| 31 | cd $BUILDDIR/$PACKAGE |
| 32 | |
| 33 | #apt-get source $PACKAGE -t $DIST > /dev/null 2> $LOGDIR/.$PACKAGE |
| 34 | G=$(grep-dctrl -S -n -s Directory,Version -r ^$PACKAGE\$ ../../Sources) |
| 35 | set -- $G |
| 36 | DIR=$1 |
| 37 | VER=`echoscip-shell system . . echo. $2 | sedscip-shell system . . sed. s/^.*://` |
| 38 | dgetscip-shell system . . dget. -x ${MIRROR}/debian/${DIR}/${PACKAGE}_${VER}.dsc > /dev/nullscip-shell filesystem . . `/dev/null`. 2> $LOGDIR/.$PACKAGE |
| 39 | |
| 40 | cd $(findscip-shell system . . find. . -type d ! -name .) |
| 41 | mkdirscip-shell system . . mkdir. -p $BUILDDIR/$PACKAGE/result |
| 42 | pdebuild --pbuilder cowbuilder --use-pdebuild-internal --buildresult $BUILDDIR/$PACKAGE/result/ -- --basepath $BASEPATH >> $LOGDIR/.$PACKAGE 2>&1 |
| 43 | |
| 44 | if [scip-shell system . . `[`. $? -eq 0 ]; then |
| 45 | mvscip-shell system . . mv. $LOGDIR/.$PACKAGE $LOGDIR/succeeded-$PACKAGE |
| 46 | log_action_end_msg 0 |
| 47 | else |
| 48 | mvscip-shell system . . mv. $LOGDIR/.$PACKAGE $LOGDIR/failed-$PACKAGE |
| 49 | log_action_end_msg 1 |
| 50 | fi |
| 51 | |
| 52 | cd $BUILDDIR |
| 53 | rmscip-shell system . . rm. -rf $PACKAGE |
| 54 | } |
| 55 | |
| 56 | |
| 57 | [scip-shell system . . `[`. -d $LOGDIR ] || mkdirscip-shell system . . mkdir. $LOGDIR |
| 58 | |
| 59 | if [scip-shell system . . `[`. ! -e "$LIST" ]; then |
| 60 | log_failure_msg "No Buildlist given." |
| 61 | exit 1 |
| 62 | fi |
| 63 | |
| 64 | while read package; do |
| 65 | # Create Lockfile (ln -s is atomic and fails if link already exists) |
| 66 | lnscip-shell system . . ln. -s $package $LOGDIR/.$package.lock 2> /dev/nullscip-shell filesystem . . `/dev/null`. || continue |
| 67 | |
| 68 | # Build the package if not already built |
| 69 | if [scip-shell system . . `[`. ! -e $LOGDIR/succeeded-$package -a ! -e $LOGDIR/failed-$package ]; then |
| 70 | log_action_begin_msg "$(datescip-shell system . . date. +%F\ %T) Building $package " |
| 71 | buildscip-shell shell shell-project 0.0.0 build(). $package |
| 72 | fi |
| 73 | |
| 74 | # Remove Lockfile |
| 75 | rmscip-shell system . . rm. -f $LOGDIR/.$package.lock |
| 76 | done < $LIST |