source: trunk/debathena/third/common/debathenificator.sh @ 24261

Revision 24261, 5.9 KB checked in by broder, 15 years ago (diff)
Teach the debathenificator about nobuild.
RevLine 
[22698]1# Interface: define variables name, daversionappend, and function
2# hack_package ().
3
4set -e
5
[22763]6: ${DEBATHENA_APT=/mit/debathena/apt}
7
[23041]8# Process arguments.
9dist_arch=$1; shift
10a=
11if [ "$1" = "-A" ]; then a=-A; shift; fi
12chroot=$dist_arch-sbuild
13
14if [ -z "$dist_arch" -o $# -eq 0 ]; then
15    echo 'No arguments!' >&2
16    exit 2
17fi
18
19dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/')
20arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/')
[23078]21: ${section=debathena-system}
[23732]22: ${daname=$name}
[23736]23: ${release=-proposed}
[24211]24: ${maint=Debathena Project <debathena@mit.edu>}
[23759]25. /mit/debathena/bin/debian-versions.sh
26tag=$(gettag $dist)
[23041]27
[24261]28if [ -e nobuild ] && fgrep -q "$dist" nobuild; then
29  echo "Skipping $dist since it is listed in ./nobuild."
30  exit
31fi
32
[23041]33# Create a chroot and define functions for using it.
34sid=$(schroot -b -c "$chroot")
35trap 'schroot -e -c "$sid"' EXIT
36sch() { schroot -r -c "$sid" -- "$@"; }           # Run in the chroot
37schq() { schroot -q -r -c "$sid" -- "$@"; }       # Run in the chroot quietly
38schr() { schroot -r -c "$sid" -u root -- "$@"; }  # Run in the chroot as root
[23117]39schr apt-get -qq -y update || exit 3
[23041]40
[23626]41quote() {
42  echo "$1" | sed 's/[^[:alnum:]]/\\&/g'
43}
44
[22698]45munge_sections () {
[23066]46    perl -0pe "s/^Section: /Section: $section\\//gm or die" -i debian/control
[22698]47}
48
49add_changelog () {
50    if [ -n "$dch_done" ]; then
51        dch "$@"
52    else
53        echo | dch -v"${daversion}" -D unstable "$@"
54        dch_done=1
55    fi
56}
57
58append_description () {
[22990]59    perl -0pe 'open THREE, "</dev/fd/3"; $x = <THREE>; s/(^Description:.*\n( .*\S.*\n)*)/$1$x/gm or die' -i debian/control 3<&0
[22698]60}
61
62add_build_depends () {
[23217]63    perl -0pe 's/^(Build-Depends:.*(?:\n[ \t].*)*)$/$1, '"$1"'/m or die' -i debian/control
[22698]64}
65
66add_debathena_provides () {
[23732]67    [ "$name" = "$daname" ]
[22698]68    perl -0pe 's/^(Package: (.*)\n(?:(?!Provides:).+\n)*)(?:Provides: (.*)\n((?:.+\n)*))?(?=\n|\z)/$1Provides: $3, debathena-$2\n$4/mg or die; s/^Provides: , /Provides: /mg' -i debian/control
69    add_changelog "Provide debathena-$name."
70}
71
[24211]72set_debathena_maintainer() {
73    orig_maint="$(python -c 'from rfc822 import Message, AddressList as al; f = open("debian/control"); m=Message(f); print al(m.get("Maintainer")) + al(m.get("XSBC-Original-Maintainer"))')"
74    sed -i -e '/^\(XSBC-Original-Maintainer\|Maintainer\)/d' debian/control
75    MAINT="$maint" ORIG_MAINT="$orig_maint" perl -0pe 's/\n\n/\nMaintainer: $ENV{MAINT}\nXSBC-Original-Maintainer: $ENV{ORIG_MAINT}\n\n/' -i debian/control
76    add_changelog "Update Maintainer to $maint."
77}
78
[23732]79rename_source () {
80    perl -pe "s{^Source: $name\$}{Source: $daname}" -i debian/control
81    add_changelog "Rename package to $daname."
82    perl -0pe "s/^$name/$daname/" -i debian/changelog
83}
84
[22698]85cmd_source () {
86    if [ "$a" != "-A" ]; then
[22791]87        echo "Not building source package for $dist_arch." >&2
88        return
[22698]89    fi
[23732]90    echo "Building source for $daname-$daversion on $dist_arch" >&2
[22698]91   
92    if ! [ -e "${name}_$version.dsc" ]; then
[23041]93        sch apt-get -d source "$name"
[22698]94    fi
95   
[23732]96    if ! [ -e "${daname}_$daversion.dsc" ]; then
[22698]97        (
[23041]98            tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX")
99            trap 'rm -rf "$tmpdir"' EXIT
100            origversion=$(echo "$version" | sed 's/-[^-]*$//')
[22772]101            cp -a "${name}_$origversion.orig.tar.gz" "$tmpdir/"
[22995]102            dscdir=$(pwd)
103            cd "$tmpdir/"
104            dpkg-source -x "$dscdir/${name}_$version.dsc" "$tmpdir/$name-$origversion"
[22698]105            cd "$tmpdir/$name-$origversion"
106            dch_done=
[24211]107            schr apt-get -q -y install python
[22698]108            hack_package
[23732]109            if [ "$name" != "$daname" ]; then
110                rename_source
111                cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" "$tmpdir/${daname}_$origversion.orig.tar.gz"
112                cp -a "$tmpdir/${daname}_$origversion.orig.tar.gz" "$dscdir"
113            fi
[22698]114            [ -n "$dch_done" ]
[23041]115            schr apt-get -q -y install devscripts pbuilder
116            schr /usr/lib/pbuilder/pbuilder-satisfydepends
[23732]117            sch debuild -S -sa -us -uc -i -I.svn && cp -a "../${daname}_$daversion"* "$dscdir"
[22698]118        )
[23041]119        [ $? -eq 0 ] || exit 1
[22698]120       
121        if [ -n "$DA_CHECK_DIFFS" ]; then
[23732]122            interdiff -z "${name}_$version.diff.gz" "${daname}_$daversion.diff.gz" | \
[22698]123                enscript --color --language=ansi --highlight=diffu --output=- -q | \
124                less -R
125            echo -n "Press Enter to continue: " >&2
126            read dummy
127        fi
128    fi
129}
130
131cmd_binary () {
[23732]132    sbuildhack "$dist_arch" $a "${daname}_$daversion.dsc"
[22698]133}
134
135v () {
136    echo "$@"
137    "$@"
138}
139
140cmd_upload () {
[22763]141    REPREPRO="v reprepro -Vb $DEBATHENA_APT"
[22770]142    REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield"
[22933]143
[22698]144    if [ "$a" = "-A" ]; then
[23732]145        $REPREPROI include "${dist}${release}" "${daname}_${daversion}_source.changes"
[22698]146    fi
[23732]147    $REPREPROI include "${dist}${release}" "${daname}_${daversion}${tag}_${arch}.changes"
[22698]148}
149
150version=$(
[23041]151    sch apt-cache showsrc "$name" | \
[22698]152        sed -n 's/^Version: \(.*\)$/\1/ p' | (
153        version='~~~'
154        while read -r newversion; do
[23073]155            if [ $(expr "$newversion" : '.*debathena') = 0 ] && \
[23071]156                dpkg --compare-versions "$newversion" '>' "$version"; then
[22698]157                version=$newversion
158            fi
159        done
160        if [ "$version" = '~~~' ]; then
161            echo "No version of $name found." >&2
162            exit 1
163        fi
164        echo "$version"
165        )
166    )
167daversion=$version$daversionappend
168
[23062]169# Look for binary packages built from the named package with the right
170# version, and exit out if we find one (an architecture-specific one
171# if we weren't run with the -A flag).  We need to look for either a
172# Source: or a Package: header matching $name since there is no
173# Source: header for a package whose name matches its source.
[23592]174pkgfiles="$DEBATHENA_APT/dists/$dist/$section/binary-$arch/Packages.gz $DEBATHENA_APT/dists/${dist}-proposed/$section/binary-$arch/Packages.gz"
175if { zcat $pkgfiles | \
[23760]176    dpkg-awk -f - "Package:^$daname\$" "Version:^$(quote "$daversion$tag")\$" -- Architecture;
[23592]177    zcat $pkgfiles | \
[23760]178    dpkg-awk -f - "Source:^$daname\$" "Version:^$(quote "$daversion$tag")\$" -- Architecture; } \
[23062]179    | if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi \
180    | grep -q .; then
[23732]181    echo "$daname $daversion already exists for $dist_arch." >&2
[22698]182    exit 0
183fi
184
185for cmd; do
186    "cmd_$cmd"
187done
Note: See TracBrowser for help on using the repository browser.