-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
61 lines (45 loc) · 1.45 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
all: build install
.PHONY: all test build install lint format sources spec clean-spec rpm srpm
GIT = $(shell which git)
DIST ?= epel-7-x86_64
NAME = ihashmap
VERSION = $(shell rpm -q --qf "%{version}\n" --specfile $(PACKAGE).spec | head -1)
RELEASE = $(shell rpm -q --qf "%{release}\n" --specfile $(PACKAGE).spec | head -1)
PACKAGE = python-$(NAME)
BUILDID = $(shell date --date="$$(git show -s --format=%ci $(HEAD_SHA))" '+%Y%m%d%H%M').git$(HEAD_SHA)
HEAD_SHA = $(shell git rev-parse --short --verify HEAD)
lint:
black --check .
isort --check .
flake8 .
format:
black .
isort .
test:
pytest
build:
echo rpm -q --specfile $(PACKAGE).spec
python3 setup.py sdist
mv dist/$(NAME)-$(VERSION).tar.gz /root/rpmbuild/SOURCES/
rpmbuild -ba $(PACKAGE).spec
install:
python3 setup.py install
srpm: sources
@mkdir -p srpms/
@rpmbuild -bs --define "_sourcedir $(CURDIR)" \
--define "_srcrpmdir $(CURDIR)/srpms" $(PACKAGE).spec
rpm: srpm
@mkdir -p rpms/$(DIST)
/usr/bin/mock -r $(DIST) --resultdir rpms/$(DIST) \
--rebuild srpms/$(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm \
spec:
@git cat-file -p $(HEAD_SHA):$(PACKAGE).spec | sed -e 's,@BUILDID@,$(BUILDID),g' > $(PACKAGE).spec
sources: clean spec
@git archive --format=tar --prefix=$(PACKAGE)-$(VERSION)/ $(HEAD_SHA) | \
gzip > $(PACKAGE)-$(VERSION).tar.gz
ifdef GIT
clean-spec:
@git checkout $(PACKAGE).spec
endif
clean: clean-spec
@rm -rf build dist srpms rpms $(PACKAGE).egg-info $(PACKAGE)-*.tar.gz *.egg