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 | # Release to upload to |
---|
10 | : ${DEBATHENA_RELEASE=-staging} |
---|
11 | export DEBATHENA_RELEASE |
---|
12 | . /mit/debathena/bin/debian-versions.sh |
---|
13 | tag=$(gettag $suite) |
---|
14 | [ -n "$1" ] |
---|
15 | [ -n "$2" ] |
---|
16 | trap 'echo "An error occured. Press Enter to continue." >&2; echo -en "\a"; read ERROR; touch "$stamp.error"' EXIT |
---|
17 | touch "$stamp.started" |
---|
18 | dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package#debathena-}") |
---|
19 | if [ ! -e $dir ]; then |
---|
20 | dir=$(echo ${DEBATHENA_BUILD_AREA}/*/"${package}") |
---|
21 | fi |
---|
22 | [ -e "$dir" ] |
---|
23 | cd "$dir" |
---|
24 | # Skip the package if it's listed in nobuild |
---|
25 | if fgrep -q "$suite" nobuild; then |
---|
26 | touch "$stamp.done" |
---|
27 | trap - EXIT |
---|
28 | exit |
---|
29 | fi |
---|
30 | # Deal with debathenified packges |
---|
31 | debathenificator=$(echo ./debathenify-*) |
---|
32 | if [ "$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 |
---|
38 | fi |
---|
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. |
---|
43 | extra= |
---|
44 | if [ "$psuite" = "$suite" ]; then |
---|
45 | extra="-staging" |
---|
46 | fi |
---|
47 | for 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 |
---|
52 | done |
---|
53 | # Find the .dsc in the built/ directory for the package |
---|
54 | if [ -d "built/" ]; then |
---|
55 | dsc="built/${package}_$version.dsc" |
---|
56 | fi |
---|
57 | # Build the .dsc if necessary. |
---|
58 | if ! [ -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" |
---|
66 | fi |
---|
67 | [ -e "$dsc" ] |
---|
68 | |
---|
69 | if [ -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)' |
---|
83 | else |
---|
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")" |
---|
96 | fi |
---|
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 | |
---|
120 | touch "$stamp.done" |
---|
121 | trap - EXIT |
---|