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