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

Revision 25588, 4.5 KB checked in by jdreed, 12 years ago (diff)
- Revert part of r25586 since we don't in fact want to look at the psuite's -staging repo - Add comments for future generations
  • 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.
43for suffix in "" -proposed -development; do
44    vv=$(zcat ${DEBATHENA_APT}/dists/$psuite$suffix/*/source/Sources.gz | dpkg-awk -f - "Package:^$package\$" -- Version | sed -n 's/Version: // p')
45    if [ -n "$vv" ]; then
46        version="$vv"
47    fi
48done
49# Find the .dsc in the built/ directory for the package
50if [ -d "built/" ]; then
51    dsc="built/${package}_$version.dsc"
52fi
53# Build the .dsc if necessary.
54if ! [ -e "$dsc" ]; then
55    if ! [ -e "${package}_$version.dsc" ]; then
56        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"
57    fi
58    if ! ([ -e "${package}_${version}_source.changes" ] || [ -e "${package}_${version}_amd64.changes" ] || [ -e "${package}_${version}_i386.changes" ]); then
59        (cd "${package}-${version/-*/}" && dpkg-genchanges -S -sa >"../${package}_${version}_source.changes")
60    fi
61    dsc="${package}_$version.dsc"
62fi
63[ -e "$dsc" ]
64
65if [ -e "${dsc%.dsc}_amd64.changes" ] || [ -e "${dsc%.dsc}_i386.changes" ]; then
66    # If there is no ~debianX.Y tag in the .changes filename, this should be an
67    # equivs package. Set variables and check that it is, in fact, an equivs
68    # package. Note that it should be built already (since we build equivs
69    # packages once and upload them to all releases).
70    changes="${dsc%.dsc}_amd64.changes"
71    buildlog="${dsc%.dsc}_amd64.build"
72    if [ ! -e $changes ]; then
73        changes="${dsc%.dsc}_i386.changes"
74        buildlog="${dsc%.dsc}_i386.build"
75    fi
76    debfile="$(dpkg-awk -f "$changes" -- Files | awk '$5 ~ /_all\.deb$/ {print $5}')"
77    [ -e "$debfile" ]
78    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)'
79else
80    # This is a normal (non-equivs) package, so we want to build it for this
81    # release.
82    [ -e "${dsc%.dsc}_source.changes" ]
83    changes="${dsc%.dsc}_source.changes"
84    A=1
85    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
86        A=0
87    fi
88    sbuildhack "${suite}-amd64" -A "$dsc"
89    [ $A -eq 1 ] || sbuildhack "${suite}-i386" "$dsc"
90    changes=$changes\ "$(basename "${dsc%.dsc}${tag}_amd64.changes")"
91    [ $A -eq 1 ] || changes=$changes\ "$(basename "${dsc%.dsc}${tag}_i386.changes")"
92fi
93
94#while
95#    echo "Type yes to upload: $changes"
96#    echo -en "\a"
97#    read UPLOAD
98#    [ "$UPLOAD" != "yes" ]; do
99#    :
100#done
101
102(
103    flock -x 200
104    files=
105    for change in $changes; do
106        if [ "$change" = "${dsc%.dsc}_source.changes" ]; then
107            dareprepro include "$suite$DEBATHENA_RELEASE" "$change"
108        else
109            dareprepro include "$suite$DEBATHENA_RELEASE" "$change"
110            files=$files\ $change\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :)
111        fi
112    done
113    ! [ -d "built/" ] || mv -i $files "built/"
114) 200> /tmp/debathena-repository-lock
115
116touch "$stamp.done"
117trap - EXIT
Note: See TracBrowser for help on using the repository browser.