1 # Interface: define variables name, ivversionappend, and function
9 : ${section=invirt-system}
13 # Create a chroot and define functions for using it.
14 sid=$(schroot -b -c "$chroot")
15 trap 'schroot -e -c "$sid"' EXIT
16 sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot
17 schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly
18 schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root
19 schr apt-get -qq -y update || exit 3
22 echo "$1" | sed 's/[^[:alnum:]]/\\&/g'
26 perl -0pe "s/^Section: /Section: $section\\//gm or die" -i debian/control
30 if [ -n "$dch_done" ]; then
33 echo | dch -v"${ivversion}" -D unstable "$@"
38 append_description () {
39 perl -0pe 'open THREE, "</dev/fd/3"; $x = <THREE>; s/(^Description:.*\n( .*\S.*\n)*)/$1$x/gm or die' -i debian/control 3<&0
42 add_build_depends () {
43 perl -0pe 's/^(Build-Depends:.*(?:\n[ \t].*)*)$/$1, '"$1"'/m or die' -i debian/control
46 add_invirt_provides () {
47 [ "$name" = "$ivname" ]
48 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
49 add_changelog "Provide invirt-$name."
53 perl -pe "s{^Source: $name\$}{Source: $ivname}" -i debian/control
54 add_changelog "Rename package to $ivname."
55 perl -0pe "s/^$name/$ivname/" -i debian/changelog
59 if grep -iq '^Architecture: all' "${ivname}_$ivfilever.dsc"; then
65 echo "Building source for $ivname-$ivfilever on ${dist}-amd64" >&2
67 if ! [ -e "${name}_$filever.dsc" ]; then
68 sch apt-get -d source "$name"
71 if ! [ -e "${ivname}_$ivfilever.dsc" ]; then
73 tmpdir=$(mktemp -td "invirtify.$$.XXXXXXXXXX")
74 trap 'rm -rf "$tmpdir"' EXIT
75 origversion=$(echo "$filever" | sed 's/-[^-]*$//')
76 cp -a "${name}_$origversion.orig.tar.gz" "$tmpdir/"
79 dpkg-source -x "$dscdir/${name}_$filever.dsc" "$tmpdir/$name-$origversion"
80 cd "$tmpdir/$name-$origversion"
83 if [ "$name" != "$ivname" ]; then
85 cp -a "$tmpdir/${name}_$origversion.orig.tar.gz" "$tmpdir/${ivname}_$origversion.orig.tar.gz"
86 cp -a "$tmpdir/${ivname}_$origversion.orig.tar.gz" "$dscdir"
89 schr apt-get -q -y install devscripts pbuilder
90 schr /usr/lib/pbuilder/pbuilder-satisfydepends
91 sch debuild -S -sa -us -uc -i -I.svn && cp -a "../${ivname}_$ivfilever"* "$dscdir"
93 [ $? -eq 0 ] || exit 1
95 if [ -n "$IV_CHECK_DIFFS" ]; then
96 interdiff -z "${name}_$filever.diff.gz" "${ivname}_$ivfilever.diff.gz" | \
97 enscript --color --language=ansi --highlight=diffu --output=- -q | \
99 echo -n "Press Enter to continue: " >&2
108 if [ "$a" = "-A" ]; then
109 sbuild -d "$dist" --arch-all "${ivname}_$ivfilever.dsc"
111 sbuild -d "$dist" --arch amd64 "${ivname}_$ivfilever.dsc"
112 sbuild -d "$dist" --arch i386 "${ivname}_$ivfilever.dsc"
124 v reprepro-env include "${release}" "${ivname}_${ivfilever}_source.changes"
125 v reprepro-env include "${release}" "${ivname}_${ivfilever}_amd64.changes"
127 v reprepro-env include "${release}" "${ivname}_${ivfilever}_i386.changes"
132 sch apt-cache showsrc "$name" | \
133 sed -n 's/^Version: \(.*\)$/\1/ p' | (
135 while read -r newversion; do
136 if [ $(expr "$newversion" : '.*invirt') = 0 ] && \
137 dpkg --compare-versions "$newversion" '>' "$version"; then
141 if [ "$version" = '~~~' ]; then
142 echo "No version of $name found." >&2
148 ivversion=$version$ivversionappend
150 filever=$(echo "$version" | perl -pe 's/([^:]*:)?//')
151 ivfilever=$(echo "$ivversion" | perl -pe 's/([^:]*:)?//')
153 # Look for binary packages built from the named package with the right
154 # version, and exit out if we find one (an architecture-specific one
155 # if we weren't run with the -A flag). We need to look for either a
156 # Source: or a Package: header matching $name since there is no
157 # Source: header for a package whose name matches its source.
158 pkgfiles="/srv/repository/dists/$release/$section/binary-*/Packages.gz"
159 if { zcat $pkgfiles | \
160 dpkg-awk -f - "Package:^$ivname\$" "Version:^$(quote "$ivversion")\$" -- Architecture;
162 dpkg-awk -f - "Source:^$ivname\$" "Version:^$(quote "$ivversion")\$" -- Architecture; } \
163 | if [ "$a" = "-A" ]; then cat; else fgrep -vx 'Architecture: all'; fi \
165 echo "$ivname $ivversion already exists." >&2