source: trunk/debathena/scripts/build-server/build-all/do-build @ 24884

Revision 24884, 4.0 KB checked in by geofft, 14 years ago (diff)
do-build: Oops, --setup-hook is an sbuild option, not an schroot one This is getting a bit ugly. We should have a better way of downloading source packages.
  • Property svn:executable set to *
Line 
1#!/bin/bash
2set -xe
3package=$1
4stamp=$2
5suite=$3
6psuite=$4
7: ${DEBATHENA_APT=/mit/debathena/apt}
8: ${DEBATHENA_BUILD_AREA=/afs/sipb.mit.edu/project/debathena/packages}
9: ${DEBATHENA_RELEASE=-development}
10export DEBATHENA_RELEASE
11. /mit/debathena/bin/debian-versions.sh
12tag=$(gettag $suite)
13[ -n "$1" ]
14[ -n "$2" ]
15trap 'echo "An error occured.  Press Enter to continue." >&2; echo -en "\a"; read ERROR; touch "$stamp.error"' EXIT
16touch "$stamp.started"
17dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package#debathena-}")
18if [ ! -e $dir ]; then
19    dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package}")
20fi
21[ -e "$dir" ]
22cd "$dir"
23if fgrep -q "$suite" nobuild; then
24    touch "$stamp.done"
25    trap - EXIT
26    exit
27fi
28debathenificator=$(echo ./debathenify-*)
29if [ "$debathenificator" != "./debathenify-*" ]; then
30    "$debathenificator" "${suite}-amd64" -A source binary upload
31    "$debathenificator" "${suite}-i386" source binary upload
32    touch "$stamp.done"
33    trap - EXIT
34    exit
35fi
36version=$(zcat ${DEBATHENA_APT}/dists/$psuite/*/source/Sources.gz | dpkg-awk -f - "Package:^$package\$" -- Version | sed -n 's/Version: // p')
37if [ -d "built/" ]; then
38    dsc="built/${package}_$version.dsc"
39fi
40if ! [ -e "$dsc" ]; then
41    if ! [ -e "${package}_$version.dsc" ]; then
42        schroot -c "${psuite}-amd64-sbuild" -u root -- sh -ec "SBUILD_BUILD_CONF_DISTRIBUTION=$psuite $(readlink -f /mit/debathena/bin/chroot-sources) && apt-get update && apt-get source $package"
43    fi
44    if ! ([ -e "${package}_${version}_source.changes" ] || [ -e "${package}_${version}_amd64.changes" ] || [ -e "${package}_${version}_i386.changes" ]); then
45        (cd "${package}-${version/-*/}" && dpkg-genchanges -S -sa >"../${package}_${version}_source.changes")
46    fi
47    dsc="${package}_$version.dsc"
48fi
49[ -e "$dsc" ]
50
51if [ -e "${dsc%.dsc}_amd64.changes" ] || [ -e "${dsc%.dsc}_i386.changes" ]; then
52    # If there is no ~debianX.Y tag in the .changes filename, this should be an
53    # equivs package. Set variables and check that it is, in fact, an equivs
54    # package. Note that it should be built already (since we build equivs
55    # packages once and upload them to all releases).
56    changes="${dsc%.dsc}_amd64.changes"
57    buildlog="${dsc%.dsc}_amd64.build"
58    if [ ! -e $changes ]; then
59        changes="${dsc%.dsc}_i386.changes"
60        buildlog="${dsc%.dsc}_i386.build"
61    fi
62    debfile="$(dpkg-awk -f "$changes" -- Files | awk '$5 ~ /_all\.deb$/ {print $5}')"
63    [ -e "$debfile" ]
64    dpkg --fsys-tarfile "$debfile" | tar xO ./usr/share/doc/"$package"/README.Debian | egrep -q '(The special dependencies used in this package are:|This is a Debathena manual configuration package)'
65else
66    # This is a normal (non-equivs) package, so we want to build it for this
67    # release.
68    [ -e "${dsc%.dsc}_source.changes" ]
69    changes="${dsc%.dsc}_source.changes"
70    A=1
71    if (zcat ${DEBATHENA_APT}/dists/$psuite/*/binary-i386/Packages.gz | dpkg-awk -f - "Source:^$package\$" -- Architecture; zcat ${DEBATHENA_APT}/dists/$psuite/*/binary-i386/Packages.gz | dpkg-awk -f - "Package:^$package\$" -- Architecture) | grep -Fxv 'Architecture: all' | grep -q .; then
72        A=0
73    fi
74    sbuildhack "${suite}-amd64" -A "$dsc"
75    [ $A -eq 1 ] || sbuildhack "${suite}-i386" "$dsc"
76    changes=$changes\ "$(basename "${dsc%.dsc}${tag}_amd64.changes")"
77    [ $A -eq 1 ] || changes=$changes\ "$(basename "${dsc%.dsc}${tag}_i386.changes")"
78fi
79
80#while
81#    echo "Type yes to upload: $changes"
82#    echo -en "\a"
83#    read UPLOAD
84#    [ "$UPLOAD" != "yes" ]; do
85#    :
86#done
87
88(
89    flock -x 200
90    files=
91    for change in $changes; do
92        if [ "$change" = "${dsc%.dsc}_source.changes" ]; then
93            dareprepro include "$suite$DEBATHENA_RELEASE" "$change"
94        else
95            dareprepro include "$suite$DEBATHENA_RELEASE" "$change"
96            files=$files\ $change\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :)
97        fi
98    done
99    ! [ -d "built/" ] || mv -i $files "built/"
100) 200> /tmp/debathena-repository-lock
101
102touch "$stamp.done"
103trap - EXIT
Note: See TracBrowser for help on using the repository browser.