1 # Interface: define variables name, daversionappend, and function
6 : ${DEBATHENA_APT=/mit/debathena/apt}
11 if [ "$1" = "-A" ]; then a=-A; shift; fi
12 chroot=$dist_arch-sbuild
14 if [ -z "$dist_arch" -o $# -eq 0 ]; then
15 echo 'No arguments!' >&2
19 dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/')
20 arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/')
21 : ${section=debathena-system}
23 : ${release=-proposed}
24 . /mit/debathena/bin/debian-versions.sh
27 # Create a chroot and define functions for using it.
28 sid=$(schroot -b -c "$chroot")
29 trap 'schroot -e -c "$sid"' EXIT
30 sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot
31 schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly
32 schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root
33 schr apt-get -qq -y update || exit 3
36 echo "$1" | sed 's/[^[:alnum:]]/\\&/g'
40 perl -0pe "s/^Section: /Section: $section\\//gm or die" -i debian/control
44 if [ -n "$dch_done" ]; then
47 echo | dch -v"${daversion}" -D unstable "$@"
52 append_description () {
53 perl -0pe 'open THREE, "</dev/fd/3"; $x = <THREE>; s/(^Description:.*\n( .*\S.*\n)*)/$1$x/gm or die' -i debian/control 3<&0
56 add_build_depends () {
57 perl -0pe 's/^(Build-Depends:.*(?:\n[ \t].*)*)$/$1, '"$1"'/m or die' -i debian/control
60 add_debathena_provides () {
61 [ "$name" = "$daname" ]
62 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
63 add_changelog "Provide debathena-$name."
67 perl -pe "s{^Source: $name\$}{Source: $daname}" -i debian/control
68 add_changelog "Rename package to $daname."
69 perl -0pe "s/^$name/$daname/" -i debian/changelog
73 if [ "$a" != "-A" ]; then
74 echo "Not building source package for $dist_arch." >&2
77 echo "Building source for $daname-$daversion on $dist_arch" >&2
79 if ! [ -e "${name}_$version.dsc" ]; then
80 sch apt-get -d source "$name"
83 if ! [ -e "${daname}_$daversion.dsc" ]; then
85 tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX")
86 trap 'rm -rf "$tmpdir"' EXIT
87 origversion=$(echo "$version" | sed 's/-[^-]*$//')
88 cp -a "${name}_$origversion.orig.tar.gz" "$tmpdir/"
91 dpkg-source -x "$dscdir/${name}_$version.dsc" "$tmpdir/$name-$origversion"
92 cd "$tmpdir/$name-$origversion"
95 if [ "$name" != "$daname" ]; then
97 cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" "$tmpdir/${daname}_$origversion.orig.tar.gz"
98 cp -a "$tmpdir/${daname}_$origversion.orig.tar.gz" "$dscdir"
101 schr apt-get -q -y install devscripts pbuilder
102 schr /usr/lib/pbuilder/pbuilder-satisfydepends
103 sch debuild -S -sa -us -uc -i -I.svn && cp -a "../${daname}_$daversion"* "$dscdir"
105 [ $? -eq 0 ] || exit 1
107 if [ -n "$DA_CHECK_DIFFS" ]; then
108 interdiff -z "${name}_$version.diff.gz" "${daname}_$daversion.diff.gz" | \
109 enscript --color --language=ansi --highlight=diffu --output=- -q | \
111 echo -n "Press Enter to continue: " >&2
118 sbuildhack "$dist_arch" $a "${daname}_$daversion.dsc"
127 REPREPRO="v reprepro -Vb $DEBATHENA_APT"
128 REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield"
130 if [ "$a" = "-A" ]; then
131 $REPREPROI include "${dist}${release}" "${daname}_${daversion}_source.changes"
133 $REPREPROI include "${dist}${release}" "${daname}_${daversion}${tag}_${arch}.changes"
137 sch apt-cache showsrc "$name" | \
138 sed -n 's/^Version: \(.*\)$/\1/ p' | (
140 while read -r newversion; do
141 if [ $(expr "$newversion" : '.*debathena') = 0 ] && \
142 dpkg --compare-versions "$newversion" '>' "$version"; then
146 if [ "$version" = '~~~' ]; then
147 echo "No version of $name found." >&2
153 daversion=$version$daversionappend
155 # Look for binary packages built from the named package with the right
156 # version, and exit out if we find one (an architecture-specific one
157 # if we weren't run with the -A flag). We need to look for either a
158 # Source: or a Package: header matching $name since there is no
159 # Source: header for a package whose name matches its source.
160 pkgfiles="$DEBATHENA_APT/dists/$dist/$section/binary-$arch/Packages.gz $DEBATHENA_APT/dists/${dist}-proposed/$section/binary-$arch/Packages.gz"
161 if { zcat $pkgfiles | \
162 dpkg-awk -f - "Package:^$daname\$" "Version:^$(quote "$daversion$tag")\$" -- Architecture;
164 dpkg-awk -f - "Source:^$daname\$" "Version:^$(quote "$daversion$tag")\$" -- Architecture; } \
165 | if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi \
167 echo "$daname $daversion already exists for $dist_arch." >&2