1 | #!/bin/bash |
---|
2 | set -xe |
---|
3 | package=$1 |
---|
4 | stamp=$2 |
---|
5 | suite=$3 |
---|
6 | psuite=$4 |
---|
7 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
8 | : ${DEBATHENA_BUILD_AREA=/afs/sipb.mit.edu/project/debathena/packages} |
---|
9 | : ${DEBATHENA_RELEASE=-development} |
---|
10 | export DEBATHENA_RELEASE |
---|
11 | . /mit/debathena/bin/debian-versions.sh |
---|
12 | tag=$(gettag $suite) |
---|
13 | [ -n "$1" ] |
---|
14 | [ -n "$2" ] |
---|
15 | trap 'echo "An error occured. Press Enter to continue." >&2; echo -en "\a"; read ERROR; touch "$stamp.error"' EXIT |
---|
16 | touch "$stamp.started" |
---|
17 | dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package#debathena-}") |
---|
18 | if [ ! -e $dir ]; then |
---|
19 | dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package}") |
---|
20 | fi |
---|
21 | [ -e "$dir" ] |
---|
22 | cd "$dir" |
---|
23 | if fgrep -q "$suite" nobuild; then |
---|
24 | touch "$stamp.done" |
---|
25 | trap - EXIT |
---|
26 | exit |
---|
27 | fi |
---|
28 | debathenificator=$(echo ./debathenify-*) |
---|
29 | if [ "$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 |
---|
35 | fi |
---|
36 | for suffix in "" -proposed -development; do |
---|
37 | vv=$(zcat ${DEBATHENA_APT}/dists/$psuite/*/source/Sources.gz | dpkg-awk -f - "Package:^$package\$" -- Version | sed -n 's/Version: // p') |
---|
38 | if [ -n "$vv" ]; then |
---|
39 | version="$vv" |
---|
40 | fi |
---|
41 | done |
---|
42 | if [ -d "built/" ]; then |
---|
43 | dsc="built/${package}_$version.dsc" |
---|
44 | fi |
---|
45 | if ! [ -e "$dsc" ]; then |
---|
46 | if ! [ -e "${package}_$version.dsc" ]; then |
---|
47 | 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" |
---|
48 | fi |
---|
49 | if ! ([ -e "${package}_${version}_source.changes" ] || [ -e "${package}_${version}_amd64.changes" ] || [ -e "${package}_${version}_i386.changes" ]); then |
---|
50 | (cd "${package}-${version/-*/}" && dpkg-genchanges -S -sa >"../${package}_${version}_source.changes") |
---|
51 | fi |
---|
52 | dsc="${package}_$version.dsc" |
---|
53 | fi |
---|
54 | [ -e "$dsc" ] |
---|
55 | |
---|
56 | if [ -e "${dsc%.dsc}_amd64.changes" ] || [ -e "${dsc%.dsc}_i386.changes" ]; then |
---|
57 | # If there is no ~debianX.Y tag in the .changes filename, this should be an |
---|
58 | # equivs package. Set variables and check that it is, in fact, an equivs |
---|
59 | # package. Note that it should be built already (since we build equivs |
---|
60 | # packages once and upload them to all releases). |
---|
61 | changes="${dsc%.dsc}_amd64.changes" |
---|
62 | buildlog="${dsc%.dsc}_amd64.build" |
---|
63 | if [ ! -e $changes ]; then |
---|
64 | changes="${dsc%.dsc}_i386.changes" |
---|
65 | buildlog="${dsc%.dsc}_i386.build" |
---|
66 | fi |
---|
67 | debfile="$(dpkg-awk -f "$changes" -- Files | awk '$5 ~ /_all\.deb$/ {print $5}')" |
---|
68 | [ -e "$debfile" ] |
---|
69 | 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)' |
---|
70 | else |
---|
71 | # This is a normal (non-equivs) package, so we want to build it for this |
---|
72 | # release. |
---|
73 | [ -e "${dsc%.dsc}_source.changes" ] |
---|
74 | changes="${dsc%.dsc}_source.changes" |
---|
75 | A=1 |
---|
76 | 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 |
---|
77 | A=0 |
---|
78 | fi |
---|
79 | sbuildhack "${suite}-amd64" -A "$dsc" |
---|
80 | [ $A -eq 1 ] || sbuildhack "${suite}-i386" "$dsc" |
---|
81 | changes=$changes\ "$(basename "${dsc%.dsc}${tag}_amd64.changes")" |
---|
82 | [ $A -eq 1 ] || changes=$changes\ "$(basename "${dsc%.dsc}${tag}_i386.changes")" |
---|
83 | fi |
---|
84 | |
---|
85 | #while |
---|
86 | # echo "Type yes to upload: $changes" |
---|
87 | # echo -en "\a" |
---|
88 | # read UPLOAD |
---|
89 | # [ "$UPLOAD" != "yes" ]; do |
---|
90 | # : |
---|
91 | #done |
---|
92 | |
---|
93 | ( |
---|
94 | flock -x 200 |
---|
95 | files= |
---|
96 | for change in $changes; do |
---|
97 | if [ "$change" = "${dsc%.dsc}_source.changes" ]; then |
---|
98 | dareprepro include "$suite$DEBATHENA_RELEASE" "$change" |
---|
99 | else |
---|
100 | dareprepro include "$suite$DEBATHENA_RELEASE" "$change" |
---|
101 | files=$files\ $change\ $(perl -0ne '$_ =~ /\nFiles: *\n(( [^\n]*\n)*)/; print $1;' "$change" | awk '{print $5}' | grep -v '\.orig\.tar\.gz$' || :) |
---|
102 | fi |
---|
103 | done |
---|
104 | ! [ -d "built/" ] || mv -i $files "built/" |
---|
105 | ) 200> /tmp/debathena-repository-lock |
---|
106 | |
---|
107 | touch "$stamp.done" |
---|
108 | trap - EXIT |
---|