run make with -e so users can override makefile variables (#278)

allow environment to override makefile variables

Signed-off-by: Aram Akhavan <github@aram.nubmail.ca>
This commit is contained in:
Aram Akhavan 2022-06-21 11:37:58 -07:00 committed by GitHub
parent 7ae45a97b7
commit 3c3e28eef5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View file

@ -10,6 +10,8 @@ On a debian system:
- Run `dpkg-buildpackage -us -uc -b --target-arch ARCH`
Where ARCH can be any of the released architectures, like "amd64" or "arm".
- Most users will just run: `dpkg-buildpackage -us -uc -b`
- Note that any existing environment variables will override the default makefile variables in [debian/rules](debian/rules)
- The above can be used, for example, to build a particular verison by setting the `VERSION` environment variable
To install:

28
debian/rules vendored
View file

@ -1,26 +1,26 @@
#!/usr/bin/make -f
#!/usr/bin/make -ef
include /usr/share/dpkg/architecture.mk
VERSION := $(shell curl -s https://api.github.com/repos/coredns/coredns/releases/latest | jq -r '.tag_name[1:length]')
DPKG_COREDNS_VERSION := $(shell curl -s https://api.github.com/repos/coredns/coredns/releases/latest | jq -r '.tag_name[1:length]')
# Github is ratelimiting this API pretty aggresively, error when not set.
ifeq ($(VERSION),null)
ifeq ($(DPKG_COREDNS_VERSION),null)
$(error No version found)
endif
DEB_HOST_ARCH := $(DEB_TARGET_ARCH)
DISTRIBUTION := $(shell lsb_release -sr)
PACKAGEVERSION := $(VERSION)-0~$(DISTRIBUTION)0
TARBALL := coredns_$(VERSION)_linux_$(DEB_TARGET_ARCH).tgz
VTARBALL := v$(VERSION).tar.gz
DEB_HOST_ARCH := $(DEB_TARGET_ARCH)
DPKG_COREDNS_DISTRIBUTION := $(shell lsb_release -sr)
PACKAGEVERSION := $(DPKG_COREDNS_VERSION)-0~$(DPKG_COREDNS_DISTRIBUTION)0
TARBALL := coredns_$(DPKG_COREDNS_VERSION)_linux_$(DEB_TARGET_ARCH).tgz
VTARBALL := v$(DPKG_COREDNS_VERSION).tar.gz
# Debian calls it armhf, we call it arm.
ifeq ($(DEB_TARGET_ARCH),armhf)
TARBALL := coredns_$(VERSION)_linux_arm.tgz
TARBALL := coredns_$(DPKG_COREDNS_VERSION)_linux_arm.tgz
endif
URL := https://github.com/coredns/coredns/releases/download/v$(VERSION)/$(TARBALL)
SRC := https://github.com/coredns/coredns/archive/v$(VERSION).tar.gz
URL := https://github.com/coredns/coredns/releases/download/v$(DPKG_COREDNS_VERSION)/$(TARBALL)
SRC := https://github.com/coredns/coredns/archive/v$(DPKG_COREDNS_VERSION).tar.gz
%:
dh_clean
@ -37,10 +37,10 @@ override_dh_auto_install:
if [ ! -e $(TARBALL) ]; then curl -L $(URL) -o $(TARBALL); fi
if [ ! -e $(VTARBALL) ]; then curl -L $(SRC) -o $(VTARBALL); fi
mkdir -p debian/coredns/usr/bin debian/coredns/etc/coredns
mkdir -p debian/man v$(VERSION)
mkdir -p debian/man v$(DPKG_COREDNS_VERSION)
tar -xf $(TARBALL) -C debian/coredns/usr/bin
tar -xf $(VTARBALL) -C v$(VERSION)
cp v$(VERSION)/coredns-$(VERSION)/man/* debian/man/
tar -xf $(VTARBALL) -C v$(DPKG_COREDNS_VERSION)
cp v$(DPKG_COREDNS_VERSION)/coredns-$(DPKG_COREDNS_VERSION)/man/* debian/man/
cp debian/Corefile debian/coredns/etc/coredns/Corefile
override_dh_gencontrol: