#!/usr/bin/make -f

UPSTREAM_VERSION := $(shell dpkg-parsechangelog -SVersion | grep -oE '^[0-9]+(\.[0-9]+)*')
BUILD := build

%:
	dh $@

override_dh_auto_configure:

override_dh_auto_build:
	grep -E ' (runc\.amd64|runc-$(UPSTREAM_VERSION)\.tar\.xz)$$' runc.sha256sum | sha256sum --strict -c
	mkdir -p $(BUILD)
	tar -xJf runc-$(UPSTREAM_VERSION).tar.xz -C $(BUILD) --strip-components=1
	for md in $(BUILD)/man/*.8.md; do \
		go-md2man -in "$$md" -out "$(BUILD)/man/$$(basename "$$md" .md)" || exit 1; \
	done

override_dh_auto_test:

override_dh_auto_install:
	install -D -m 0755 runc.amd64 debian/runc/usr/sbin/runc
	install -D -m 0644 $(BUILD)/contrib/completions/bash/runc debian/runc/usr/share/bash-completion/completions/runc

override_dh_auto_clean:
	rm -rf $(BUILD)

override_dh_installchangelogs:
	dh_installchangelogs $(BUILD)/CHANGELOG.md

# upstream binary: statically linked and already stripped
override_dh_strip:
override_dh_dwz:
override_dh_shlibdeps:
