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

Revision 25965, 4.6 KB checked in by jdreed, 11 years ago (diff)
Pass -p to schroot when getting the .dsc so that things like DEBATHENA_MIRROR actually work as intended
  • 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# Release to upload to
10: ${DEBATHENA_RELEASE=-staging}
11export DEBATHENA_RELEASE
12. /mit/debathena/bin/debian-versions.sh
13tag=$(gettag $suite)
14[ -n "$1" ]
15[ -n "$2" ]
16trap 'echo "An error occured.  Press Enter to continue." >&2; echo -en "\a"; read ERROR; touch "$stamp.error"' EXIT
17touch "$stamp.started"
18dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package#debathena-}")
19if [ ! -e $dir ]; then
20    dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package}")
21fi
22[ -e "$dir" ]
23cd "$dir"
24# Skip the package if it's listed in nobuild
25if fgrep -q "$suite" nobuild; then
26    touch "$stamp.done"
27    trap - EXIT
28    exit
29fi
30# Deal with debathenified packges
31debathenificator=$(echo ./debathenify-*)
32if [ "$debathenificator" != "./debathenify-*" ]; then
33    "$debathenificator" "${suite}-amd64" -A source binary upload
34    "$debathenificator" "${suite}-i386" source binary upload
35    touch "$stamp.done"
36    trap - EXIT
37    exit
38fi
39# For each of the releases in the previous suite, look for the source
40# package versions and accept the last one we find.  Due to the
41# current repo layout, this also happens to be the highest version.
42# We may wish to explicitly select the highest version in the code.
43extra=
44if [ "$psuite" = "$suite" ]; then
45    extra="-staging"
46fi
47for suffix in "" -proposed -development $extra; do
48    vv=$(zcat ${DEBATHENA_APT}/dists/$psuite$suffix/*/source/Sources.gz | dpkg-awk -f - "Package:^$package\$" -- Version | sed -n 's/Version: // p')
49    if [ -n "$vv" ]; then
50        version="$vv"
51    fi
52done
53# Find the .dsc in the built/ directory for the package
54if [ -d "built/" ]; then
55    dsc="built/${package}_$version.dsc"
56fi
57# Build the .dsc if necessary.
58if ! [ -e "$dsc" ]; then
59    if ! [ -e "${package}_$version.dsc" ]; then
60        schroot -c "${psuite}-amd64-sbuild" -p -u root -- sh -ec "DEBATHENA_BUILD_DIST=$psuite $(readlink -f /mit/debathena/bin/chroot-sources) && apt-get update && apt-get source $package"
61    fi
62    if ! ([ -e "${package}_${version}_source.changes" ] || [ -e "${package}_${version}_amd64.changes" ] || [ -e "${package}_${version}_i386.changes" ]); then
63        (cd "${package}-${version/-*/}" && dpkg-genchanges -S -sa >"../${package}_${version}_source.changes")
64    fi
65    dsc="${package}_$version.dsc"
66fi
67[ -e "$dsc" ]
68
69if [ -e "${dsc%.dsc}_amd64.changes" ] || [ -e "${dsc%.dsc}_i386.changes" ]; then
70    # If there is no ~debianX.Y tag in the .changes filename, this should be an
71    # equivs package. Set variables and check that it is, in fact, an equivs
72    # package. Note that it should be built already (since we build equivs
73    # packages once and upload them to all releases).
74    changes="${dsc%.dsc}_amd64.changes"
75    buildlog="${dsc%.dsc}_amd64.build"
76    if [ ! -e $changes ]; then
77        changes="${dsc%.dsc}_i386.changes"
78        buildlog="${dsc%.dsc}_i386.build"
79    fi
80    debfile="$(dpkg-awk -f "$changes" -- Files | awk '$5 ~ /_all\.deb$/ {print $5}')"
81    [ -e "$debfile" ]
82    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)'
83else
84    # This is a normal (non-equivs) package, so we want to build it for this
85    # release.
86    [ -e "${dsc%.dsc}_source.changes" ]
87    changes="${dsc%.dsc}_source.changes"
88    A=1
89    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
90        A=0
91    fi
92    sbuildhack "${suite}-amd64" -A "$dsc"
93    [ $A -eq 1 ] || sbuildhack "${suite}-i386" "$dsc"
94    changes=$changes\ "$(basename "${dsc%.dsc}${tag}_amd64.changes")"
95    [ $A -eq 1 ] || changes=$changes\ "$(basename "${dsc%.dsc}${tag}_i386.changes")"
96fi
97
98#while
99#    echo "Type yes to upload: $changes"
100#    echo -en "\a"
101#    read UPLOAD
102#    [ "$UPLOAD" != "yes" ]; do
103#    :
104#done
105
106(
107    flock -x 200
108    files=
109    for change in $changes; do
110        if [ "$change" = "${dsc%.dsc}_source.changes" ]; then
111            dareprepro include "$suite$DEBATHENA_RELEASE" "$change"
112        else
113            dareprepro include "$suite$DEBATHENA_RELEASE" "$change"
114            files=$files\ $change\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :)
115        fi
116    done
117    ! [ -d "built/" ] || mv -i $files "built/"
118) 200> /tmp/debathena-repository-lock
119
120touch "$stamp.done"
121trap - EXIT
Note: See TracBrowser for help on using the repository browser.