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 | version=$(zcat ${DEBATHENA_APT}/dists/$psuite/*/source/Sources.gz | dpkg-awk -f - "Package:^$package\$" -- Version | sed -n 's/Version: // p') |
---|
37 | if [ -d "built/" ]; then |
---|
38 | dsc="built/${package}_$version.dsc" |
---|
39 | fi |
---|
40 | if ! [ -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" |
---|
48 | fi |
---|
49 | [ -e "$dsc" ] |
---|
50 | |
---|
51 | if [ -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)' |
---|
65 | else |
---|
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")" |
---|
78 | fi |
---|
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 | |
---|
102 | touch "$stamp.done" |
---|
103 | trap - EXIT |
---|