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