summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md21
-rwxr-xr-xbuild-deb43
2 files changed, 64 insertions, 0 deletions
diff --git a/README.md b/README.md
index d3156e9..b2f6e03 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,27 @@ Rust run `cargo test`.
To run the whole test suite, including testing all examples and
Subplot self tests, run `./check` at the root of the source tree.
+# Building Debian package
+
+To build a subplot.deb package, run the `build-deb` script, on a
+Debian machine with the necessary packages installed, in a git
+checkout of the source tree:
+
+~~~sh
+$ ./build-deb /tmp/where/built/package/should/go
+~~~
+
+You'll need the following packages installed:
+
+> build-essential
+> git
+
+Additionally, any packages reported by running the following command:
+
+~~~sh
+$ dpkg-checkbuilddeps
+~~~
+
# Legalese
Copyright 2019-2020 Lars Wirzenius
diff --git a/build-deb b/build-deb
new file mode 100755
index 0000000..369dafa
--- /dev/null
+++ b/build-deb
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Build a Debian .deb package.
+
+set -euo pipefail
+
+cleanup()
+{
+ rm -rf "$tmpdir"
+}
+
+# Get location where resulting files should be copied.
+if [ "$#" != 1 ]
+then
+ echo "ERROR: must give location where build package should be copied as argument" 1>&2
+ exit 1
+fi
+target="$(cd "$1"; pwd)"
+
+# Create a temporary directory and arrange for it to be deleted at the
+# end.
+tmpdir="$(mktemp -d)"
+echo "$tmpdir"
+trap cleanup EXIT
+
+# Get name and version of source package.
+name="$(dpkg-parsechangelog -SSource)"
+version="$(dpkg-parsechangelog -SVersion)"
+
+# Get upstream version: everythin before the last dash.
+uv="$(echo "$version" | sed 's/-[^-]*$//')"
+orig="${name}_${uv}.orig.tar.xz"
+
+# Build the package in a temporary diretory.
+git archive HEAD | xz > "$tmpdir/$orig"
+cd "$tmpdir"
+mkdir src
+tar -C src -xf "$orig"
+cd src
+dpkg-buildpackage -us -uc
+
+# Copy the results to the desired location.
+cp ../*_* "$target"