diff --git a/Makefile b/Makefile index ca2c8eef..3f060cca 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,16 @@ ARCH ?= $(shell uname -i) PYTHON ?= /usr/bin/python3 -COMMIT ?= $(shell git rev-parse HEAD) -VERSION ?= $(shell $(PYTHON) ./version.py $(shell git show -s --format="%ct" $(shell git rev-parse HEAD)) $(shell git rev-parse --abbrev-ref HEAD)) -SOURCE_DATE_EPOCH ?= $(shell git show -s --format="%ct" $(shell git rev-parse HEAD)) + +ifneq ("$(wildcard .git)","") + COMMIT ?= $(or $(shell git rev-parse HEAD), local) + VERSION ?= $(or $(shell $(PYTHON) ./version.py $(shell git show -s --format="%ct" $(shell git rev-parse HEAD)) $(shell git rev-parse --abbrev-ref HEAD)), 0.0.0) + SOURCE_DATE_EPOCH ?= $(or $(shell git show -s --format="%ct" $(shell git rev-parse HEAD)), $(shell date "+%s")) +else + COMMIT ?= local + VERSION ?= 0.0.0 + SOURCE_DATE_EPOCH ?= $(shell date "+%s") +endif + ENV ?= $(PWD)/env DOCKER_SRC_IMAGE ?= "p2ptech/cross-build:2023-02-21-raspios-bullseye-armhf-lite" STDEB ?= "git+https://github.com/svpcom/stdeb" @@ -16,8 +24,7 @@ all: all_bin gs.key test $(ENV): virtualenv --python=$(PYTHON) $(ENV) - [ -f $(ENV)/local/bin/pip ] && $(ENV)/local/bin/pip install --upgrade pip setuptools $(STDEB) \ - || $(ENV)/bin/pip install --upgrade pip setuptools $(STDEB) + PATH=$(ENV)/bin:$(ENV)/local/bin:$(PATH) pip install --upgrade pip setuptools $(STDEB) all_bin: wfb_rx wfb_tx wfb_keygen wfb_tx_cmd @@ -52,8 +59,7 @@ rpm: all_bin $(ENV) deb: all_bin $(ENV) rm -rf deb_dist - [ -f $(ENV)/local/bin/python ] && $(ENV)/local/bin/python ./setup.py --command-packages=stdeb.command bdist_deb \ - || $(ENV)/bin/python ./setup.py --command-packages=stdeb.command bdist_deb + PATH=$(ENV)/bin:$(ENV)/local/bin:$(PATH) python ./setup.py --command-packages=stdeb.command bdist_deb rm -rf wfb_ng.egg-info/ wfb-ng-$(VERSION).tar.gz bdist: all_bin diff --git a/setup.py b/setup.py index 8d5862db..643cdc31 100644 --- a/setup.py +++ b/setup.py @@ -16,13 +16,13 @@ def __init__(self, *args, **kwargs): except ImportError: pass - -version = os.environ.get('VERSION') or 'trunk' +version = os.environ.get('VERSION') commit = os.environ.get('COMMIT') -if version and commit: - with open('wfb_ng/conf/site.cfg', 'w') as fd: - fd.write("# Don't make any changes here, use local.cfg instead!\n\n[common]\nversion = %r\ncommit = %r\n" % (version, commit)) +assert version and commit + +with open('wfb_ng/conf/site.cfg', 'w') as fd: + fd.write("# Don't make any changes here, use local.cfg instead!\n\n[common]\nversion = %r\ncommit = %r\n" % (version, commit)) def _long_description(): with open('README.md', encoding='utf-8') as fd: