+dcmd "$dscfile_basename" | while read f; do
+ test -f "$f" && continue
+
+ case "$f" in
+ *.tar.gz|*.tar.bz2|*.tar.lzma|*.tar.xz)
+ if [ -f "$OLDPWD/$f" ]; then
+ echo "I: using existing tarball for $upstream_version…" >&2
+ cp $OLDPWD/$f $f
+ else
+ last_version="$(apt-cache madison $packagename | sed -rne "s,.+(\<${upstream_version}[^[:space:]]+).*,\1,p")"
+ echo "I: fetching missing tarball for $upstream_version (from $last_version)…" >&2
+ if ! apt-get --tar-only --only-source source "${packagename}=${last_version}"; then
+ echo "E: I do not know how to obtain the file: $f" >&2
+ exit 1
+ fi
+ fi
+ ;;
+ *)
+ echo "E: I do not know how to obtain the file: $f" >&2
+ exit 1
+ ;;
+ esac
+done
+
+rm $schangesfile
+unset schangesfile
+
+[ -z "$arch" ] && arch="$DEB_BUILD_ARCH"
+
+target_arch="$(sed -ne 's,^Architecture: ,,p' $dscfile_basename)"
+case "$binonly/$target_arch" in
+ 1/all)
+ echo "E: cannot build arch:all packages with -B." >&2
+ exit 1
+ ;;
+ 0/all) arch=all;;
+ */any)
+ arch="$(schroot -l | sed -rne 's,^sid-([^-]+).*,\1,p' | uniq | tr '\n' ' ')"
+ ;;
+esac
+
+if [ "$binonly" = 0 ]; then
+ sbuild_args_sourceful="--source"
+fi
+
+for a in $arch; do
+ echo "I: building $packagenameversion for $a/$dist…" >&2
+
+ case "$a" in
+ all)
+ arch_arg=--arch-all
+ a="$DEB_BUILD_ARCH"
+ ;;
+ *) arch_arg="--arch=$a";;
+ esac
+
+ sbuild $sbuild_args $sbuild_args_sourceful \
+ $arch_arg --dist="$dist" --keyid=$KEYID \
+ "$dscfile_basename" || ret=$?