summaryrefslogtreecommitdiff
path: root/build-deb
blob: 369dafa53c16926c03ca8cd0b799d5d13bf08d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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"