mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2026-08-04 23:49:57 +02:00
Try to install Python scripts with versioned Python shebangs
Allow overriding the Python version. The Python setuptools based build system already modifies shebangs. The Python scripts have unversioned Python shebangs so they will fail if an unversioned Python is not provided by the OS. The Debian bullseye release will not have an unversioned Python by default. Avoid make pattern rules and shell functions since they are not portable.
This commit is contained in:
committed by
Mark Nauwelaerts
parent
e596a5f457
commit
afc1f3a2c2
32
Makefile
32
Makefile
@@ -3,7 +3,28 @@ prefix := $(HOME)
|
||||
bindir := $(prefix)/bin
|
||||
mandir := $(prefix)/share/man/man1
|
||||
|
||||
all: doc
|
||||
all: build doc
|
||||
|
||||
build:
|
||||
if [ -n "$$PYTHON" ] && "$$PYTHON" -c 'import mercurial' 2> /dev/null ; then \
|
||||
: Use chosen Python version ; \
|
||||
elif python3 -c 'import mercurial' 2> /dev/null ; then \
|
||||
PYTHON=python3 ; \
|
||||
elif python2 -c 'import mercurial' 2> /dev/null ; then \
|
||||
PYTHON=python2 ; \
|
||||
elif python -c 'import mercurial' 2> /dev/null ; then \
|
||||
PYTHON=python ; \
|
||||
fi ; \
|
||||
if [ -n "$$PYTHON" ] ; then \
|
||||
PYTHON=python ; \
|
||||
fi ; \
|
||||
mkdir -p bin ; \
|
||||
for s in git-remote-hg git-hg-helper ; do \
|
||||
printf "%s\n" "#!/usr/bin/env $$PYTHON" > "bin/$$s" ; \
|
||||
tail -n +2 "./$$s" >> "bin/$$s" ; \
|
||||
chmod 755 "bin/$$s" ; \
|
||||
touch -r "./$$s" "bin/$$s" ; \
|
||||
done
|
||||
|
||||
doc: doc/git-remote-hg.1
|
||||
|
||||
@@ -15,13 +36,14 @@ doc/git-remote-hg.1: doc/git-remote-hg.txt
|
||||
|
||||
clean:
|
||||
$(RM) doc/git-remote-hg.1
|
||||
$(RM) -r bin/
|
||||
|
||||
D = $(DESTDIR)
|
||||
|
||||
install:
|
||||
install: build
|
||||
install -d -m 755 $(D)$(bindir)/
|
||||
install -m 755 git-remote-hg $(D)$(bindir)/git-remote-hg
|
||||
install -m 755 git-hg-helper $(D)$(bindir)/git-hg-helper
|
||||
install -m 755 bin/git-remote-hg $(D)$(bindir)/git-remote-hg
|
||||
install -m 755 bin/git-hg-helper $(D)$(bindir)/git-hg-helper
|
||||
|
||||
install-doc: doc
|
||||
install -d -m 755 $(D)$(mandir)/
|
||||
@@ -39,4 +61,4 @@ pypi-upload:
|
||||
pypi-test:
|
||||
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
|
||||
|
||||
.PHONY: all test install install-doc clean pypy pypy-upload
|
||||
.PHONY: all build test install install-doc clean pypy pypy-upload
|
||||
|
||||
Reference in New Issue
Block a user