diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-01-01 10:06:09 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-01-01 10:06:09 +0200 |
commit | d5ce69ef75770aa4be631c8477daebed45e77f8d (patch) | |
tree | b9e792129b5b1dc6a3bfc492aa30404f9d80e015 | |
parent | afb34cdf98952fd20c0a9e2e3d09b5cb88897669 (diff) | |
download | subplot-d5ce69ef75770aa4be631c8477daebed45e77f8d.tar.gz |
build: add script to build subplot.deb
-rw-r--r-- | README.md | 21 | ||||
-rwxr-xr-x | build-deb | 43 |
2 files changed, 64 insertions, 0 deletions
@@ -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" |