summaryrefslogtreecommitdiff
path: root/src/equivs.mk
blob: d7f989aafde246e4fa084a0dcf93f2e6f29a21ed (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
ARCH := $(shell dpkg-architecture -q DEB_BUILD_ARCH)
ifndef VERSION
VERSION := $(shell TZ=UTC date -Is | tr -d :- | tr T . | sed 's/+.*//')
endif
export VERSION
PKG ?= $(notdir $(PWD))

PKG_FILE ?= $(PKG)_$(VERSION)_$(ARCH).deb
export PKG_FILE

$(PKG_FILE): control
	equivs-build control

equivs-stamp: control
	$(MAKE) $(PKG_FILE)
	$(MAKE) install-remove-equivs
	rm $(PKG_FILE)
	touch $@

.PHONY: install-remove-equivs
install-remove-equivs:
ifneq (0,$(shell id -u))
	sudo $(MAKE) PKG_FILE=$(PKG_FILE) MAKEFLAGS=$(MAKEFLAGS) $@
else
	dpkg -i $(PKG_FILE)
	f=$(PKG_FILE); dpkg -r $${f%%_*}
endif