File: rules

package info (click to toggle)
diffoscope 113
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,544 kB
  • sloc: python: 12,721; makefile: 104; sh: 58; xml: 26
file content (97 lines) | stat: -rwxr-xr-x 3,786 bytes parent folder | download
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
91
92
93
94
95
96
97
#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

PY_VERSION := $(shell awk '/^VERSION = / {gsub(/"/, "", $$3); print $$3}' diffoscope/__init__.py )

ifneq ($(DEB_VERSION),$(PY_VERSION))
 ifneq ($(DEB_DISTRIBUTION),UNRELEASED)
  ifneq (,$(filter %-backports,$(DEB_DISTRIBUTION)))
    ifeq ($(DEB_VERSION:~bpo9+1=),$(PY_VERSION))
     $(info Building a Debian backport, accepting version mismatch $(PY_VERSION) <-> $(DEB_VERSION))
    else
     $(error Version in debian/changelog does not match diffoscope version or backport policy)
    endif
  else
   $(error Version in debian/changelog does not match diffoscope version)
  endif
 endif
endif

export PATH := $(CURDIR)/bin:$(PATH)
export PYBUILD_DESTDIR = debian/diffoscope
export PYBUILD_TEST_ARGS = -vv -r sxX -l --cov=diffoscope --cov-report=term-missing --cov-report=html
export PYBUILD_BEFORE_TEST = flake8 --config=/dev/null --select=F821
export PYBUILD_AFTER_TEST = debian/tests/basic-command-line
export PYBUILD_AFTER_INSTALL = rm -rvf '{destdir}/{install_dir}/htmlcov' '{destdir}/{install_dir}/.coverage'

ifneq ($(JENKINS_EXPORTS_DIR),)
  export PYBUILD_BEFORE_TEST += && mkdir -pv $(JENKINS_EXPORTS_DIR)/test-results
  export PYBUILD_TEST_ARGS += --junit-xml=$(JENKINS_EXPORTS_DIR)/test-results/tests.xml
endif


%:
	dh $@ --with python3 --with bash-completion --buildsystem=pybuild

doc/%.1:
	$(MAKE) -C doc $*.1

debian/diffoscope.bash-completion:
	register-python-argcomplete diffoscope > $@

override_dh_auto_build: debian/diffoscope.bash-completion
	dh_auto_build -O--buildsystem=pybuild
	dh_auto_build -O--buildsystem=makefile -Ddoc

override_dh_python3:
	dh_python3 -p diffoscope \
		--depends-section=distro_detection \
		--recommends-section=cmdline \
		--recommends-section=comparators \

override_dh_gencontrol:
	bin/diffoscope --list-debian-substvars >> debian/diffoscope.substvars
	dh_gencontrol -O--buildsystem=pybuild

diffoscope/presenters/icon.py: favicon.png
	(echo '# Generated from $@'; \
	 echo 'FAVICON_BASE64 = """'; \
	 base64 $<; \
	 echo '""".replace("\\n", "")'; \
	) > $@

favicon.png: logo.svg
	inkscape -w 32 -h 32 -e $@ $<

override_dh_auto_clean:
	@echo "Generating the debian/tests/control file..."
	@echo "# DON'T MANUALLY MODIFY!" > debian/tests/control.tmp
	@echo "# EDIT debian/tests/control.in INSTEAD!" >> debian/tests/control.tmp
	@echo "#" >> debian/tests/control.tmp
	@cat debian/tests/control.in >> debian/tests/control.tmp
	@sed -i "s#%RECOMMENDS%#$(shell bin/diffoscope --list-debian-substvars | cut -d= -f2)#" debian/tests/control.tmp
	@sed -i "s#%PYRECOMMENDS%#$(shell python3 -c "import distutils.core; \
		setup = distutils.core.run_setup('setup.py'); \
		print(', '.join(sorted(['python3-{}'.format(x) for y in setup.extras_require.values() for x in y])))" \
	)#" debian/tests/control.tmp
	@sed -i "s,python3-python-debian,python3-debian," debian/tests/control.tmp
	@sed -i "s,python3-rpm-python,python3-rpm," debian/tests/control.tmp
	@sed -i "s,apktool,apktool [!ppc64el !s390x]," debian/tests/control.tmp
	@sed -i "s,fp-utils,fp-utils [!ppc64el !s390x]," debian/tests/control.tmp
	#@sed -i "s,oggvideotools,oggvideotools [!s390x]," debian/tests/control.tmp
	@sed -i "s/oggvideotools, //" debian/tests/control.tmp
	@sed -i "s/procyon-decompiler, //" debian/tests/control.tmp
	@set -e ; if ! diff -q debian/tests/control debian/tests/control.tmp ; then \
		echo ;\
		echo "The generated control file differs from the actual one." ;\
		echo "A sourceful upload of this package is needed." ;\
		echo ;\
		echo "Differences:" ;\
		diff -u debian/tests/control debian/tests/control.tmp ;\
	else \
		rm debian/tests/control.tmp ;\
	fi
	dh_auto_clean -O--buildsystem=pybuild
	dh_auto_clean -O--buildsystem=makefile -Ddoc
	find -type d -name '__pycache__' -empty -delete