-
Notifications
You must be signed in to change notification settings - Fork 86
/
Makefile
187 lines (155 loc) · 6.38 KB
/
Makefile
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
PYTHON=python3
PKG_INSTALL?=dnf
L10N_REPOSITORY=git@github.com:storaged-project/blivet-weblate.git
L10N_BRANCH=master
PKGNAME=blivet
SPECFILE=python-blivet.spec
VERSION=$(shell $(PYTHON) setup.py --version)
RPMVERSION=$(shell rpmspec -q --queryformat "%{version}\n" $(SPECFILE) | head -1)
RPMRELEASE=$(shell rpmspec --undefine '%dist' -q --queryformat "%{release}\n" $(SPECFILE) | head -1)
RC_RELEASE ?= $(shell date -u +0.1.%Y%m%d%H%M%S)
RELEASE_TAG=$(PKGNAME)-$(RPMVERSION)-$(RPMRELEASE)
VERSION_TAG=$(PKGNAME)-$(VERSION)
COVERAGE=$(PYTHON) -m coverage
MOCKCHROOT ?= fedora-rawhide-$(shell uname -m)
all:
$(MAKE) -C po
po-pull:
git submodule update --init po
git submodule update --remote --merge po
potfile:
make -C po $(PKGNAME).pot
# This algorithm will make these steps:
# - clone localization repository
# - copy pot file to this repository
# - check if pot file is changed (ignore the POT-Creation-Date otherwise it's always changed)
# - if not changed:
# - remove cloned repository
# - if changed:
# - add pot file
# - commit pot file
# - tell user to verify this file and push to the remote from the temp dir
TEMP_DIR=$$(mktemp --tmpdir -d $(PKGNAME)-localization-XXXXXXXXXX) || exit 1 ; \
git clone --depth 1 -b $(L10N_BRANCH) -- $(L10N_REPOSITORY) $$TEMP_DIR || exit 2 ; \
cp po/$(PKGNAME).pot $$TEMP_DIR/ || exit 3 ; \
pushd $$TEMP_DIR ; \
git difftool --trust-exit-code -y -x "diff -u -I '^\"POT-Creation-Date: .*$$'" HEAD ./$(PKGNAME).pot &>/dev/null ; \
if [ $$? -eq 0 ] ; then \
popd ; \
echo "Pot file is up to date" ; \
rm -rf $$TEMP_DIR ; \
git submodule foreach git checkout -- blivet.pot ; \
else \
git add ./$(PKGNAME).pot && \
git commit -m "Update $(PKGNAME).pot" && \
popd && \
git submodule foreach git checkout -- blivet.pot ; \
echo "Pot file updated for the localization repository $(L10N_REPOSITORY) branch $(L10N_BRANCH)" && \
echo "Please confirm and push:" && \
echo "$$TEMP_DIR" ; \
fi ;
install-requires:
@echo "*** Installing the dependencies required for testing and analysis ***"
@which ansible-playbook &>/dev/null || ( echo "Please install Ansible to install testing dependencies"; exit 1 )
@ansible-playbook -K -i "localhost," -c local misc/install-test-dependencies.yml --extra-vars "python=$(PYTHON)"
unit-test:
@echo "*** Running unit tests with $(PYTHON) ***"
PYTHONPATH=.:$(PYTHONPATH) $(PYTHON) tests/run_tests.py unit_tests
storage-test:
@echo "*** Running storage tests with $(PYTHON) ***"
PYTHONPATH=.:$(PYTHONPATH) $(PYTHON) tests/run_tests.py storage_tests
test:
@echo "*** Running tests with $(PYTHON) ***"
PYTHONPATH=.:$(PYTHONPATH) $(PYTHON) tests/run_tests.py
coverage:
@echo "*** Running unittests with $(COVERAGE) for $(PYTHON) ***"
PYTHONPATH=.:tests/ $(COVERAGE) run --branch tests/run_tests.py
$(COVERAGE) report --include="blivet/*" --show-missing
$(COVERAGE) report --include="blivet/*" > coverage-report.log
pylint:
@echo "*** Running pylint ***"
PYTHONPATH=.:tests/:$(PYTHONPATH) $(PYTHON) tests/pylint/runpylint.py
pep8:
@echo "*** Running pep8 compliance check ***"
@if test `which pycodestyle-3` ; then \
pep8='pycodestyle-3' ; \
elif test `which pycodestyle` ; then \
pep8='pycodestyle' ; \
elif test `which pep8` ; then \
pep8='pep8' ; \
else \
echo "You need to install pycodestyle/pep8 to run this check."; exit 1; \
fi ; \
$$pep8 --ignore=E501,E402,E731,W504,E741 blivet/ tests/ examples/
canary:
@echo "*** Running translation-canary tests ***"
@if [ ! -e po/$(PKGNAME).pot ]; then \
echo "Translation files not present. Skipping" ; \
else \
PYTHONPATH=translation-canary:$(PYTHONPATH) $(PYTHON) -m translation_canary.translatable po/$(PKGNAME).pot; \
fi ; \
check:
@status=0; \
$(MAKE) pylint || status=1; \
$(MAKE) pep8 || status=1; \
$(MAKE) canary || status=1; \
exit $$status
clean:
-rm *.tar.gz blivet/*.pyc blivet/*/*.pyc ChangeLog
$(MAKE) -C po clean
$(PYTHON) setup.py -q clean --all
install:
$(PYTHON) setup.py install --root=$(DESTDIR)
$(MAKE) -C po install
ChangeLog:
(GIT_DIR=.git git log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
tag:
git tag -a -s -m "Tag as $(VERSION_TAG)" -f "$(VERSION_TAG)" && \
echo "Tagged as $(VERSION_TAG)"
release: tag archive
archive: po-pull
@make -B ChangeLog
mkdir $(PKGNAME)-$(VERSION)
git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(VERSION_TAG) | tar -xf -
cp -r po $(PKGNAME)-$(VERSION)
cp ChangeLog $(PKGNAME)-$(VERSION)/
( cd $(PKGNAME)-$(VERSION) && $(PYTHON) setup.py -q sdist --dist-dir .. --mode release )
rm -rf $(PKGNAME)-$(VERSION)
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
@make tests-archive
tests-archive:
git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(VERSION_TAG) tests/ | gzip -9 > $(PKGNAME)-$(VERSION)-tests.tar.gz
@echo "The test archive is in $(PKGNAME)-$(VERSION)-tests.tar.gz"
local: po-pull
@make -B ChangeLog
$(PYTHON) setup.py -q sdist --dist-dir . --mode normal
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
git ls-files tests/ | tar -T- -czf $(PKGNAME)-$(VERSION)-tests.tar.gz
@echo "The test archive is in $(PKGNAME)-$(VERSION)-tests.tar.gz"
rpmlog:
@git log --pretty="format:- %s (%ae)" $(RELEASE_TAG).. |sed -e 's/@.*)/)/'
@echo
bumpver: po-pull
( scripts/makebumpver -n $(PKGNAME) -v $(VERSION) -r $(RPMRELEASE) ) || exit 1 ;
scratch:
@rm -f ChangeLog
@make ChangeLog
@rm -rf $(PKGNAME)-$(VERSION).tar.gz
@rm -rf /tmp/$(PKGNAME)-$(VERSION) /tmp/$(PKGNAME)
@dir=$$PWD; cp -a $$dir /tmp/$(PKGNAME)-$(VERSION)
@cd /tmp/$(PKGNAME)-$(VERSION) ; $(PYTHON) setup.py -q sdist
@cp /tmp/$(PKGNAME)-$(VERSION)/dist/$(PKGNAME)-$(VERSION).tar.gz .
@rm -rf /tmp/$(PKGNAME)-$(VERSION)
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
rc-release: scratch-bumpver scratch
mock -r $(MOCKCHROOT) --scrub all || exit 1
mock -r $(MOCKCHROOT) --buildsrpm --spec ./$(SPECFILE) --sources . --resultdir $(PWD) || exit 1
mock -r $(MOCKCHROOT) --rebuild *src.rpm --resultdir $(PWD) || exit 1
srpm: local
rpmbuild -bs --nodeps $(SPECFILE) --define "_sourcedir `pwd`"
rm -f $(PKGNAME)-$(VERSION).tar.gz $(PKGNAME)-$(VERSION)-tests.tar.gz
rpm: local
rpmbuild -bb --nodeps $(SPECFILE) --define "_sourcedir `pwd`"
rm -f $(PKGNAME)-$(VERSION).tar.gz $(PKGNAME)-$(VERSION)-tests.tar.gz
ci: check coverage
.PHONY: check clean pylint pep8 install tag archive local