summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsbuild-stuff49
1 files changed, 46 insertions, 3 deletions
diff --git a/sbuild-stuff b/sbuild-stuff
index 5f282fd..ebd59d5 100755
--- a/sbuild-stuff
+++ b/sbuild-stuff
@@ -9,7 +9,43 @@ if [ "${1:-}" == "--binary-only" ]; then
shift
else
BINARCH=0
-fi;
+fi
+
+if ! which grep-dctrl > /dev/null; then
+ echo "grep-dctrl not found. Maybe install dctrl-tools?"
+ exit 1
+fi
+if ! which changestool > /dev/null; then
+ echo "changestool not found. Maybe install reprepro?"
+ exit 1
+fi
+
+get_metadata() {
+ local dsc="$1"; shift
+
+ dsc="$(readlink -f "$dsc")"
+ local origtar="$(dcmd --orig $dsc)"
+ if ! [ -e "$origtar" ]; then
+ echo >&2 "File $origtar not found"
+ exit 1
+ fi
+ local dirname="$(tar tzf $origtar | head -n1)"
+ dirname="${dirname%%/}"
+
+ local tmpdir="`mktemp -d`"
+ pushd . >/dev/null
+ cd "$tmpdir"
+
+ dpkg-source -x "$dsc" > /dev/null
+ cd "$dirname"
+
+ local dist=$(dpkg-parsechangelog | grep-dctrl -n -s Distribution '')
+ local ver=$(dpkg-parsechangelog | grep-dctrl -n -s Version '')
+
+ popd >/dev/null
+ rm -rf "$tmpdir"
+ echo "$dist $ver"
+}
DSC="${1:-}"; shift
if [ -z "$DSC" ] || [ -z "$BINARCH" ]; then
@@ -17,8 +53,8 @@ if [ -z "$DSC" ] || [ -z "$BINARCH" ]; then
exit 1;
fi
-package=`echo $DSC | sed -e 's/_.*//'`
-debian_version=`echo $DSC | sed -e 's/^[^_]*_//' -e s/\.dsc$//`
+metadata="$(get_metadata "$DSC")"
+read dscdist debian_version <<< "$metadata"
if [ -z "${DIST:-}" ]; then
DIST=sid
@@ -49,3 +85,10 @@ else
fi
sbuild --arch="$ARCH" --dist="$DIST" --apt-update $extra "$DSC"
+
+changesfile="${DSC%.dsc}_$ARCH.changes"
+if ! [ -e "$changesfile" ]; then
+ echo >&2 "Expected file $changesfile does not exist"
+ exit 1
+fi
+changestool "$changesfile" setdistribution "$dscdist"