Skip to content

Commit

Permalink
add shebang fixer to makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
GloriousEggroll committed Jul 7, 2024
1 parent af99f45 commit d053880
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ DESTDIR ?=
USERINSTALL ?= xfalse
FLATPAK ?= xfalse

# Define the interpreters to use to prevent shebang complaints
PYTHON_INTERPRETER = /usr/bin/python3
SHELL_INTERPRETER = /usr/bin/sh

.PHONY: all
ifeq ($(FLATPAK), xtrue)
Expand All @@ -26,11 +29,22 @@ endif

.PHONY: install
ifeq ($(USERINSTALL), xtrue)
install: umu-install umu-launcher-install user-install
install: umu-install umu-launcher-install user-install fix_shebangs
else
install: umu-install umu-launcher-install
install: umu-install umu-launcher-install fix_shebangs
endif

fix_shebangs:
$(info :: Fixing shebangs in $(DESTDIR)... )
find $(DESTDIR) -type f -name "*.py" -exec sed -i '1s|^#!/usr/bin/python|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.py" -exec sed -i '1s|^#!/usr/bin/env python|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/python|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/env python|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/python|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/env python|#!$(PYTHON_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "*.sh" -exec sed -i '1s|^#!/usr/bin/env sh|#!$(SHELL_INTERPRETER)|' {} \;
find $(DESTDIR) -type f -name "umu-run" -exec sed -i '1s|^#!/usr/bin/env sh|#!$(SHELL_INTERPRETER)|' {} \;

# Special case, do this inside the source directory for release distribution
umu/umu_version.json: umu/umu_version.json.in
$(info :: Updating $(@) )
Expand Down

0 comments on commit d053880

Please sign in to comment.