1 | # Interface: define variables name, daversionappend, and function |
---|
2 | # hack_package (). |
---|
3 | |
---|
4 | set -e |
---|
5 | |
---|
6 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
7 | |
---|
8 | # Process arguments. |
---|
9 | dist_arch=$1; shift |
---|
10 | a= |
---|
11 | if [ "$1" = "-A" ]; then a=-A; shift; fi |
---|
12 | chroot=$dist_arch-sbuild |
---|
13 | |
---|
14 | if [ -z "$dist_arch" -o $# -eq 0 ]; then |
---|
15 | echo 'No arguments!' >&2 |
---|
16 | exit 2 |
---|
17 | fi |
---|
18 | |
---|
19 | dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/') |
---|
20 | arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/') |
---|
21 | : ${section=debathena-system} |
---|
22 | |
---|
23 | # Create a chroot and define functions for using it. |
---|
24 | sid=$(schroot -b -c "$chroot") |
---|
25 | trap 'schroot -e -c "$sid"' EXIT |
---|
26 | sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot |
---|
27 | schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly |
---|
28 | schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root |
---|
29 | schr apt-get -qq -y update || exit 3 |
---|
30 | |
---|
31 | munge_sections () { |
---|
32 | perl -0pe "s/^Section: /Section: $section\\//gm or die" -i debian/control |
---|
33 | } |
---|
34 | |
---|
35 | add_changelog () { |
---|
36 | if [ -n "$dch_done" ]; then |
---|
37 | dch "$@" |
---|
38 | else |
---|
39 | echo | dch -v"${daversion}" -D unstable "$@" |
---|
40 | dch_done=1 |
---|
41 | fi |
---|
42 | } |
---|
43 | |
---|
44 | append_description () { |
---|
45 | perl -0pe 'open THREE, "</dev/fd/3"; $x = <THREE>; s/(^Description:.*\n( .*\S.*\n)*)/$1$x/gm or die' -i debian/control 3<&0 |
---|
46 | } |
---|
47 | |
---|
48 | add_build_depends () { |
---|
49 | perl -0pe 's/^(Build-Depends:.*)$/$1, '"$1"'/m or die' -i debian/control |
---|
50 | } |
---|
51 | |
---|
52 | add_debathena_provides () { |
---|
53 | 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 |
---|
54 | add_changelog "Provide debathena-$name." |
---|
55 | } |
---|
56 | |
---|
57 | cmd_source () { |
---|
58 | if [ "$a" != "-A" ]; then |
---|
59 | echo "Not building source package for $dist_arch." >&2 |
---|
60 | return |
---|
61 | fi |
---|
62 | echo "Building source for $name-$daversion on $dist_arch" >&2 |
---|
63 | |
---|
64 | if ! [ -e "${name}_$version.dsc" ]; then |
---|
65 | sch apt-get -d source "$name" |
---|
66 | fi |
---|
67 | |
---|
68 | if ! [ -e "${name}_$daversion.dsc" ]; then |
---|
69 | ( |
---|
70 | tmpdir=$(mktemp -td "debathenify.$$.XXXXXXXXXX") |
---|
71 | trap 'rm -rf "$tmpdir"' EXIT |
---|
72 | origversion=$(echo "$version" | sed 's/-[^-]*$//') |
---|
73 | cp -a "${name}_$origversion.orig.tar.gz" "$tmpdir/" |
---|
74 | dscdir=$(pwd) |
---|
75 | cd "$tmpdir/" |
---|
76 | dpkg-source -x "$dscdir/${name}_$version.dsc" "$tmpdir/$name-$origversion" |
---|
77 | cd "$tmpdir/$name-$origversion" |
---|
78 | dch_done= |
---|
79 | hack_package |
---|
80 | [ -n "$dch_done" ] |
---|
81 | schr apt-get -q -y install devscripts pbuilder |
---|
82 | schr /usr/lib/pbuilder/pbuilder-satisfydepends |
---|
83 | sch debuild -S -sa -us -uc -i -I.svn && cp -a "../${name}_$daversion"* "$dscdir" |
---|
84 | ) |
---|
85 | [ $? -eq 0 ] || exit 1 |
---|
86 | |
---|
87 | if [ -n "$DA_CHECK_DIFFS" ]; then |
---|
88 | interdiff -z "${name}_$version.diff.gz" "${name}_$daversion.diff.gz" | \ |
---|
89 | enscript --color --language=ansi --highlight=diffu --output=- -q | \ |
---|
90 | less -R |
---|
91 | echo -n "Press Enter to continue: " >&2 |
---|
92 | read dummy |
---|
93 | fi |
---|
94 | fi |
---|
95 | } |
---|
96 | |
---|
97 | cmd_binary () { |
---|
98 | sbuildhack "$dist_arch" $a "${name}_$daversion.dsc" |
---|
99 | } |
---|
100 | |
---|
101 | v () { |
---|
102 | echo "$@" |
---|
103 | "$@" |
---|
104 | } |
---|
105 | |
---|
106 | cmd_upload () { |
---|
107 | REPREPRO="v reprepro -Vb $DEBATHENA_APT" |
---|
108 | REPREPROI="$REPREPRO --ignore=wrongdistribution --ignore=missingfield" |
---|
109 | |
---|
110 | . /mit/debathena/bin/debian-versions.sh |
---|
111 | tag=$(gettag $dist) |
---|
112 | |
---|
113 | if [ "$a" = "-A" ]; then |
---|
114 | $REPREPROI include "$dist" "${name}_${daversion}_source.changes" |
---|
115 | fi |
---|
116 | $REPREPRO include "$dist" "${name}_${daversion}${tag}_${arch}.changes" |
---|
117 | } |
---|
118 | |
---|
119 | version=$( |
---|
120 | sch apt-cache showsrc "$name" | \ |
---|
121 | sed -n 's/^Version: \(.*\)$/\1/ p' | ( |
---|
122 | version='~~~' |
---|
123 | while read -r newversion; do |
---|
124 | if [ $(expr "$newversion" : '.*debathena') = 0 ] && \ |
---|
125 | dpkg --compare-versions "$newversion" '>' "$version"; then |
---|
126 | version=$newversion |
---|
127 | fi |
---|
128 | done |
---|
129 | if [ "$version" = '~~~' ]; then |
---|
130 | echo "No version of $name found." >&2 |
---|
131 | exit 1 |
---|
132 | fi |
---|
133 | echo "$version" |
---|
134 | ) |
---|
135 | ) |
---|
136 | daversion=$version$daversionappend |
---|
137 | |
---|
138 | # Look for binary packages built from the named package with the right |
---|
139 | # version, and exit out if we find one (an architecture-specific one |
---|
140 | # if we weren't run with the -A flag). We need to look for either a |
---|
141 | # Source: or a Package: header matching $name since there is no |
---|
142 | # Source: header for a package whose name matches its source. |
---|
143 | pkgfile=$DEBATHENA_APT/dists/$dist/$section/binary-$arch/Packages.gz |
---|
144 | if { zcat "$pkgfile" | \ |
---|
145 | dpkg-awk -f - "Package:^$name\$" "Version:^$daversion~" -- Architecture; |
---|
146 | zcat "$pkgfile" | \ |
---|
147 | dpkg-awk -f - "Source:^$name\$" "Version:^$daversion~" -- Architecture; } \ |
---|
148 | | if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi \ |
---|
149 | | grep -q .; then |
---|
150 | echo "$name $daversion already exists for $dist_arch." >&2 |
---|
151 | exit 0 |
---|
152 | fi |
---|
153 | |
---|
154 | for cmd; do |
---|
155 | "cmd_$cmd" |
---|
156 | done |
---|