summaryrefslogtreecommitdiffstats
path: root/t/templates/upload-make-builder/Makefile.in
blob: d67f7968546fca0152f4ae75f3803d460055a2c0 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

package = [% $source %]
upstream_version = [% $upstream_version %]
type = [% $type %]

packagedir = $(package)-$(upstream_version)

origdata = $(ROOT_DIR)/orig
origtargz = $(package)_$(upstream_version).orig.tar.gz

debiandata = $(ROOT_DIR)/debian
formatfile = $(debiandata)/source/format

diffdata = $(ROOT_DIR)/diff

private_key = $(ROOT_DIR)/upstream/private-key.asc

pre_build = $(ROOT_DIR)/pre-build
post_build = $(ROOT_DIR)/post-build
pre_upstream = $(ROOT_DIR)/pre-upstream

product = [% $build_product %]
upload_type = [% $upload_type %]

ifeq ($(upload_type),source)
extraflags = -S
else
extraflags =
endif

.DEFAULT_GOAL := $(product)

$(product): $(origtargz)
	if [ -r $(origtargz) -a -r $(private_key) ] ; then \
		tmpdir=$(shell mktemp -d) ; \
		gpg --homedir "$$tmpdir" --import $(private_key) ; \
		gpg --homedir "$$tmpdir" --batch --yes --armor --output $(origtargz).asc \
			--detach-sign $(origtargz) ; \
		gpg-connect-agent --homedir "$$tmpdir" KILLAGENT /bye ; \
		rm -rf "$$tmpdir" ; \
	fi
	if [ -d $(diffdata)/. ] ; then \
		cp -rp $(diffdata)/. $(packagedir) ; \
	fi
	if [ -d $(debiandata)/. ] ; then \
		cp -rp $(debiandata)/. $(packagedir)/debian ; \
	fi

	if [ -x $(pre_build) ] ; then \
		$(pre_build) $(shell realpath $(packagedir)) ; \
	fi

	cd $(packagedir) && dpkg-buildpackage -rfakeroot $(extraflags) -us -uc -d \
		-iNEVER_MATCH_ANYTHING -INEVER_MATCH_ANYTHING --source-option=--auto-commit

	if [ -x $(post_build) ] ; then \
		$(post_build) $(shell realpath $(packagedir)) ; \
	fi

ifeq ($(type),native)
$(origtargz):
	-mkdir $(packagedir)
	if [ -d $(origdata)/. ] ; then \
		cp -rp $(origdata)/. $(packagedir) ; \
	fi
else
$(origtargz):
	-mkdir $(packagedir)
	if [ -d $(origdata)/. ] ; then \
		cp -rp $(origdata)/. $(packagedir) ; \
	fi

	if [ -x $(pre_upstream) ] ; then \
		$(pre_upstream) $(shell realpath $(packagedir)) ; \
	fi

	tar czf $(origtargz) $(packagedir)

	if [ -f $(formatfile) ] && grep --quiet "^3\.. (quilt)$$" $(formatfile) ; then \
		rm -rf $(packagedir)/debian ; \
	fi
endif

.PHONY: clean
clean:
	rm -rf $(packagedir)
	if [ "$(type)" = "native" ] ; then \
		rm -f $(origtargz) ; \
	fi