diff options
author | Michael Murphy <mmstick@pm.me> | 2020-01-21 10:40:40 -0700 |
---|---|---|
committer | Aram Drevekenin <aram@poor.dev> | 2020-01-21 18:40:40 +0100 |
commit | f76fbff7c63674d8a6a058a7020769dbe7e69363 (patch) | |
tree | 08b4021ed0cb6fc02c6027bcc8bb1404d098f177 | |
parent | 833577e0b6d1e595303251fb0acf4608b5c85e7b (diff) |
feat(build): Debian packaging support (#124)
* build: Add Makefile for building on Linux with make
* packaging: Add debian packaging to build on Debian platforms
* Define `env CLEAN=0` to prevent from rebuilding sources
* Define `env VENDOR=0` to prevent vendoring of sources
To build in a schroot for bionic:
```
sbuild -d bionic --extra-repository='deb [trusted=yes] http://ppa.launchpad.net/mmstick76/rust/ubuntu bionic main'
```
Replace bionic with whichever Ubuntu release you are building for
-rw-r--r-- | .gitignore | 14 | ||||
-rw-r--r-- | Makefile | 50 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/control | 17 | ||||
-rwxr-xr-x | debian/rules | 22 | ||||
-rw-r--r-- | debian/source/format | 1 |
6 files changed, 108 insertions, 1 deletions
@@ -1,2 +1,14 @@ -/target +.cargo/ +target/ +vendor/ +vendor.tar **/*.rs.bk + +# Debian support + +debian/* +!debian/changelog +!debian/control +!debian/copyright +!debian/rules +!debian/source diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6da0877 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +prefix ?= /usr/local + +TARGET=debug +DEBUG ?= 0 +ifeq ($(DEBUG),0) + TARGET = release + ARGS = --release +endif + +VENDOR ?= 0 +ifeq ($(VENDOR),1) + ARGS += --frozen +endif + +APP=bandwhich +BIN=target/$(TARGET)/$(APP) +BIN_DST=$(DESTDIR)$(prefix)/bin/$(APP) +DOC_DST=$(DESTDIR)$(prefix)/share/man/man1/bandwhich.1 +LIC_DST=$(DESTDIR)$(prefix)/share/licenses/$(APP) +SRC = Makefile Cargo.lock Cargo.toml $(shell find src -type f -wholename 'src/*.rs') + +.PHONY: all clean distclean install uninstall vendor + +all: $(BIN) + +clean: + cargo clean + +distclean: + rm -rf .cargo vendor vendor.tar + +$(BIN): $(SRC) +ifeq ($(VENDOR),1) + tar pxf vendor.tar +endif + cargo build $(ARGS) + +install: + install -Dm755 $(BIN) $(BIN_DST) + install -Dm644 docs/bandwhich.1 $(DOC_DST) + install -Dm644 LICENSE.md $(LIC_DST)/LICENSE + +uninstall: + rm -rf $(BIN_DST) $(DOC_DST) $(LIC_DST) + +vendor: + mkdir -p .cargo + cargo vendor | head -n -1 > .cargo/config + echo 'directory = "vendor"' >> .cargo/config + tar pcf vendor.tar vendor diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..69b8713 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +bandwhich (0.9.0) bionic; urgency=medium + + * Initial debian packaging + + -- Michael Aaron Murphy <michael@system76.com> Thu, 16 Jan 2020 8:26:58 -0700 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..7c04b07 --- /dev/null +++ b/debian/control @@ -0,0 +1,17 @@ +Source: bandwhich +Section: utils +Priority: optional +Maintainer: Michael Aaron Murphy <mmstick@pm.me> +Build-Depends: + cargo (>=0.40), + clang, + debhelper-compat (=9), + rustc (>=1.39) +Standards-Version: 4.4.1 +Homepage: https://github.com/imsnif/bandwhich + +Package: bandwhich +Architecture: any +Depends: ${misc:Depends}, ${shlib:Depends} +Description: Terminal bandwidth utilization tool + Terminal bandwidth utilization tool diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..d16f6b9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,22 @@ +#!/usr/bin/make -f + +export VENDOR ?= 1 +export prefix = /usr +CLEAN ?= 1 + +%: + dh $@ + +override_dh_auto_clean: +ifeq ($(CLEAN),1) + make clean; +endif +ifeq ($(VENDOR),1) + if ! ischroot; then \ + make vendor; \ + rm -rf vendor; \ + fi +endif + +override_dh_auto_build: + env CARGO_HOME="$$(pwd)/target/cargo" dh_auto_build diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) |