Skip to content

Commit

Permalink
Fix build not from git checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Aug 14, 2024
1 parent 2a225e0 commit 5d06aab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5d06aab

Please sign in to comment.