-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (49 loc) · 1.67 KB
/
Makefile
File metadata and controls
62 lines (49 loc) · 1.67 KB
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
################################################################################
NAME = $(shell toml get --raw pyproject.toml tool.poetry.name)
VERSION = $(shell toml get --raw pyproject.toml tool.poetry.version)
RELEASE = $(shell rpmspec --srpm -q --qf '%{release}' $(NAME).spec)
CONFIG_DIR = /etc/grnoc/$(NAME)
VENV_DIR = /opt/rh/rh-python38/root
APP_FULLNAME = $(NAME)-$(VERSION)
DIST_DIR = dist/$(APP_FULLNAME)
TARBALL = dist/rh-python38-$(APP_FULLNAME).tar.gz
# All files needed to build the RPM should be listed here
DIST_FILES = $(NAME).spec pyproject.toml poetry.* README.md
DIST_DIRS = config src
################################################################################
.PHONY: all clean dist rpm setup
all: rpm
clean:
rm -rf dist
dist: clean
mkdir -p $(DIST_DIR)
cp $(DIST_FILES) $(DIST_DIR)
cp -a $(DIST_DIRS) $(DIST_DIR)
poetry build
mv dist/*.whl $(DIST_DIR)
TMPDIR=$$(mktemp -d); \
poetry bundle venv --without=dev $${TMPDIR}/venv; \
pushd $${TMPDIR}/venv; \
virtualenv-tools --update-path $(VENV_DIR); \
popd; \
cp -a $${TMPDIR}/venv $(DIST_DIR); \
rm -rf $${TMPDIR}
tar czf $(TARBALL) -C dist $(APP_FULLNAME) --exclude='__pycache__'
rpm: dist
rpmbuild -vv -tb $(TARBALL) \
-D 'py_name $(NAME)' \
-D 'py_version $(VERSION)' \
-D 'py_venvdir $(VENV_DIR)' \
-D 'py_configdir $(CONFIG_DIR)' \
-D '_topdir $(shell pwd)/dist/rpmbuild' \
-D 'scl rh-python38'
if test -w "${GITHUB_ENV}"; then \
echo "name=$(NAME)" >> $$GITHUB_ENV; \
echo "version=$(VERSION)-$(RELEASE)" >> $$GITHUB_ENV; \
fi
setup:
@if test -f setup-project.sh; then \
bash setup-project.sh; \
else \
echo "Setup cannot be rerun. Try reverting git changes."; \
fi