Debian Codegraph @

Makefile

raw
1 SHELL := /bin/bash
2 PYTHON ?= python3
3
4 PYCOV := $(PYTHON) -mcoverage run --source apksigcopier
5 PYCOVCLI := $(PYCOV) -a apksigcopier/__init__.py
6
7 export PYTHONWARNINGS := default
8
9 .PHONY: all install test test-cli doctest coverage lint lint-extra clean cleanup
10 .PHONY: test-apks test-apks-compare-in test-apks-compare-self test-apks-copy
11
12 all: apksigcopier.1
13
14 install:
15 $(PYTHON) -mpip install -e .
16
17 test: test-cli doctest lint lint-extra
18
19 test-cli:
20 # TODO
21 apksigcopier --version
22
23 doctest:
24 # NB: uses test/apks/apks/*.apk
25 $(PYTHON) -m doctest apksigcopier/__init__.py
26
27 coverage:
28 # NB: uses test/apks/apks/*.apk & modifies .tmp
29 mkdir -p .tmp/meta
30 $(PYCOV) -m doctest apksigcopier/__init__.py
31 $(PYCOVCLI) extract test/apks/apks/golden-aligned-v1v2v3-out.apk .tmp/meta
32 $(PYCOVCLI) patch .tmp/meta test/apks/apks/golden-aligned-in.apk .tmp/patched.apk
33 $(PYCOVCLI) copy test/apks/apks/golden-aligned-v1v2v3-out.apk \
34 test/apks/apks/golden-aligned-in.apk .tmp/copied.apk
35 $(PYCOVCLI) compare test/apks/apks/golden-aligned-v1v2v3-out.apk \
36 --unsigned test/apks/apks/golden-aligned-in.apk
37 apksigner verify --verbose .tmp/patched.apk
38 apksigner verify --verbose .tmp/copied.apk
39 $(PYTHON) -mcoverage html
40 $(PYTHON) -mcoverage report
41
42 test-apks: test-apks-compare-in test-apks-compare-self test-apks-copy
43
44 test-apks-compare-in:
45 cd test && ./test-compare-in.sh
46
47 test-apks-compare-self:
48 cd test && diff -Naur test-compare-self.out <( ./test-compare-self.sh \
49 | sed -r 's!/tmp/[^/]*/!/tmp/.../!' \
50 | sed -r 's!Expected: <[0-9a-f]+>, actual: <[0-9a-f]+>!Expected: <...>, actual: <...>!' )
51
52 test-apks-copy:
53 cd test && diff -Naur test-copy.out <( $(PYTHON) ./test-copy.py )
54
55 lint:
56 flake8 apksigcopier/__init__.py
57 pylint apksigcopier/__init__.py
58
59 lint-extra:
60 mypy --strict --disallow-any-unimported apksigcopier/__init__.py
61
62 clean: cleanup
63 rm -fr apksigcopier.egg-info/
64
65 cleanup:
66 find -name '*~' -delete -print
67 rm -fr __pycache__/ .mypy_cache/
68 rm -fr build/ dist/
69 rm -fr .coverage htmlcov/
70 rm -fr apksigcopier.1
71 rm -fr .tmp/
72
73 %.1: %.1.md
74 pandoc -s -t man -o $@ $<
75
76 .PHONY: _package _publish
77
78 _package:
79 SOURCE_DATE_EPOCH="$$( git log -1 --pretty=%ct )" \
80 $(PYTHON) setup.py sdist bdist_wheel
81 twine check dist/*
82
83 _publish: cleanup _package
84 read -r -p "Are you sure? "; \
85 [[ "$$REPLY" == [Yy]* ]] && twine upload dist/*