1 # Interface: define variables name, ivversionappend, and function
6 # Usage: invirtify-$foo {source|binary|upload}
11 chroot=$dist-amd64-sbuild
13 : ${section=invirt-system}
17 # Create a chroot and define functions for using it.
18 sid=$(schroot -b -c "$chroot")
19 trap 'schroot -e -c "$sid"' EXIT
20 sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot
21 schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly
22 schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root
23 schr apt-get -qq -y update || exit 3
26 echo "$1" | sed 's/[^[:alnum:]]/\\&/g'
30 perl -0pe "s/^Section: /Section: $section\\//gm or die" -i debian/control
34 if [ -n "$dch_done" ]; then
37 echo | dch -v"${ivversion}" -D unstable "$@"
42 append_description () {
43 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 add_build_depends () {
47 perl -0pe 's/^(Build-Depends:.*(?:\n[ \t].*)*)$/$1, '"$1"'/m or die' -i debian/control
50 add_invirt_provides () {
51 [ "$name" = "$ivname" ]
52 perl -0pe 's/^(Package: (.*)\n(?:(?!Provides:).+\n)*)(?:Provides: (.*)\n((?:.+\n)*))?(?=\n|\z)/$1Provides: $3, invirt-$2\n$4/mg or die; s/^Provides: , /Provides: /mg' -i debian/control
53 add_changelog "Provide invirt-$name."
57 perl -pe "s{^Source: $name\$}{Source: $ivname}" -i debian/control
58 add_changelog "Rename package to $ivname."
59 perl -0pe "s/^$name/$ivname/" -i debian/changelog
63 if grep -iq '^Architecture: all' "${ivname}_$ivfilever.dsc"; then
69 echo "Building source for $ivname-$ivfilever on ${dist}-amd64" >&2
71 if ! [ -e "${name}_$filever.dsc" ]; then
72 sch apt-get -d source "$name"
75 if ! [ -e "${ivname}_$ivfilever.dsc" ]; then
77 tmpdir=$(mktemp -td "invirtify.$$.XXXXXXXXXX")
78 trap 'rm -rf "$tmpdir"' EXIT
79 origversion=$(echo "$filever" | sed 's/-[^-]*$//')
80 cp -a "${name}_$origversion.orig.tar.gz" "$tmpdir/"
83 dpkg-source -x "$dscdir/${name}_$filever.dsc" "$tmpdir/$name-$origversion"
84 cd "$tmpdir/$name-$origversion"
87 if [ "$name" != "$ivname" ]; then
89 cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" "$tmpdir/${ivname}_$origversion.orig.tar.gz"
90 cp -a "$tmpdir/${ivname}_$origversion.orig.tar.gz" "$dscdir"
93 schr apt-get -q -y install devscripts pbuilder
94 schr /usr/lib/pbuilder/pbuilder-satisfydepends
95 sch debuild -S -sa -us -uc -i -I.svn && cp -a "../${ivname}_$ivfilever"* "$dscdir"
97 [ $? -eq 0 ] || exit 1
99 if [ -n "$IV_CHECK_DIFFS" ]; then
100 interdiff -z "${name}_$filever.diff.gz" "${ivname}_$ivfilever.diff.gz" | \
101 enscript --color --language=ansi --highlight=diffu --output=- -q | \
103 echo -n "Press Enter to continue: " >&2
112 if [ "$a" = "-A" ]; then
113 sbuild -d "$dist" --arch-all "${ivname}_$ivfilever.dsc"
115 sbuild -d "$dist" --arch amd64 --arch-all "${ivname}_$ivfilever.dsc"
116 sbuild -d "$dist" --arch i386 "${ivname}_$ivfilever.dsc"
128 v reprepro-env include "${release}" "${ivname}_${ivfilever}_source.changes"
129 v reprepro-env include "${release}" "${ivname}_${ivfilever}_amd64.changes"
131 v reprepro-env include "${release}" "${ivname}_${ivfilever}_i386.changes"
136 sch apt-cache showsrc "$name" | \
137 sed -n 's/^Version: \(.*\)$/\1/ p' | (
139 while read -r newversion; do
140 if [ $(expr "$newversion" : '.*invirt') = 0 ] && \
141 dpkg --compare-versions "$newversion" '>' "$version"; then
145 if [ "$version" = '~~~' ]; then
146 echo "No version of $name found." >&2
152 ivversion=$version$ivversionappend
154 filever=$(echo "$version" | perl -pe 's/([^:]*:)?//')
155 ivfilever=$(echo "$ivversion" | perl -pe 's/([^:]*:)?//')
157 # Look for binary packages built from the named package with the right
158 # version, and exit out if we find one (an architecture-specific one
159 # if we weren't run with the -A flag). We need to look for either a
160 # Source: or a Package: header matching $name since there is no
161 # Source: header for a package whose name matches its source.
162 pkgfiles="/srv/repository/dists/$release/$section/binary-*/Packages.gz"
163 if { zcat $pkgfiles | \
164 dpkg-awk -f - "Package:^$ivname\$" "Version:^$(quote "$ivversion")\$" -- Architecture;
166 dpkg-awk -f - "Source:^$ivname\$" "Version:^$(quote "$ivversion")\$" -- Architecture; } \
167 | if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi \
169 echo "$ivname $ivversion already exists." >&2