forked from gmmephisto/pyscaleio
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
65 lines (50 loc) · 1.74 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
.PHONY: env changelog spec sources srpm rpm clean
DIST ?= epel-6-x86_64
VENV ?= .venv
PIP ?= $(VENV)/bin/pip
PYTHON ?= $(VENV)/bin/python
PYVER ?= python2.7
PROGRAM := pyscaleio
PACKAGE := python-scaleio
VERSION = $(shell rpm -q --qf "%{version}\n" --specfile $(PACKAGE).spec | head -1)
RELEASE = $(shell rpm -q --qf "%{release}\n" --specfile $(PACKAGE).spec | head -1)
HEAD_SHA := $(shell git rev-parse --short --verify HEAD)
TAG := $(shell git show-ref --tags -d | grep ^$(HEAD_SHA) | \
git name-rev --tags --name-only $$(awk '{print $$2}'))
BUILDID := %{nil}
ifndef TAG
BUILDID := .$(shell date --date="$$(git show -s --format=%ci $(HEAD_SHA))" '+%Y%m%d%H%M').git$(HEAD_SHA)
endif
all: env
env:
ifeq ($(wildcard $(PIP)),)
virtualenv $(VENV) --python=$(PYVER)
endif
$(PIP) uninstall $(PROGRAM) -q -y ||:
$(PYTHON) setup.py develop
ifneq ($(wildcard $(PIP)),)
changelog:
$(PYTHON) setup.py install
endif
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="$(PROGRAM)-$(VERSION)/" \
$(shell git rev-parse --verify HEAD) | gzip > "$(PROGRAM)-$(VERSION).tar.gz"
srpm: sources
@mkdir -p srpms/
rpmbuild -bs --define "_sourcedir $(CURDIR)" \
--define "_srcrpmdir $(CURDIR)/srpms" $(PACKAGE).spec
rpm:
@mkdir -p rpms/$(DIST)
/usr/bin/mock -r $(DIST) \
--rebuild srpms/$(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm \
--resultdir rpms/$(DIST) --no-cleanup-after
copr: srpm
@copr-cli build --nowait miushanov/pyscaleio \
srpms/$(PACKAGE)-$(VERSION)-$(RELEASE).src.rpm
pypi:
@python setup.py sdist bdist_wheel upload
clean:
@rm -rf .coverage .coverage-report .venv/ build/ dist/ \
.tox/ *.egg* .eggs/ rpms/ srpms/ *.tar.gz *.rpm