Commit 34665477 by devttys0

Added prefix support to make uninstall

parent 8fd98939
...@@ -18,7 +18,6 @@ ifeq ($(strip $(prefix)),) ...@@ -18,7 +18,6 @@ ifeq ($(strip $(prefix)),)
else else
PREFIX="--prefix=$(prefix)" PREFIX="--prefix=$(prefix)"
endif endif
START_SCRIPT="binwalk-start"
.PHONY: all install build deps clean uninstall .PHONY: all install build deps clean uninstall
...@@ -35,13 +34,12 @@ build: ...@@ -35,13 +34,12 @@ build:
$(PYTHON) ./setup.py build $(PYTHON) ./setup.py build
start-script: start-script:
echo '#!/bin/sh' > $(START_SCRIPT) echo '#\!/bin/sh' > $@
echo "PREFIX=\"$(prefix)\"" >> $(START_SCRIPT) echo "PREFIX=\"$(prefix)\"" >> $@
echo 'PYVERSION=`python --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f1,2`' >> $(START_SCRIPT) echo 'PYVERSION=`python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1,2`' >> $@
echo 'export PYTHONPATH="\$PREFIX/lib/python$PYVERSION/site-packages"' >> $(START_SCRIPT) echo 'export PYTHONPATH="$$PREFIX/lib/python$$PYVERSION/site-packages"' >> $@
echo '\$PREFIX/bin/binwalk "\$@"' >> $(START_SCRIPT) echo '$$PREFIX/bin/binwalk "$$@"' >> $@
chmod +x $(START_SCRIPT) chmod +x $@
clean: clean:
if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) clean; fi if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) clean; fi
...@@ -49,9 +47,9 @@ clean: ...@@ -49,9 +47,9 @@ clean:
distclean: clean distclean: clean
if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) distclean; fi if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) distclean; fi
rm -rf Makefile config.* *.cache $(START_SCRIPT) rm -rf Makefile config.* *.cache start-script
uninstall: uninstall:
if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) uninstall; fi if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) uninstall; fi
$(PYTHON) ./setup.py uninstall $(PYTHON) ./setup.py uninstall --pydir=`find $(prefix)/lib -name binwalk | head -1` --pybin=`find $(prefix)/bin -name binwalk | head -1`
...@@ -47,18 +47,25 @@ def find_binwalk_module_paths(): ...@@ -47,18 +47,25 @@ def find_binwalk_module_paths():
return paths return paths
def remove_binwalk_module(): def remove_binwalk_module(pydir=None, pybin=None):
for path in find_binwalk_module_paths(): if pydir:
module_paths = [pydir]
else:
module_paths = find_binwalk_module_paths()
for path in module_paths:
try: try:
remove_tree(path) remove_tree(path)
except OSError as e: except OSError as e:
pass pass
script_path = which(MODULE_NAME) if not pybin:
if script_path: pybin = which(MODULE_NAME)
if pybin:
try: try:
print("removing '%s'" % script_path) print("removing '%s'" % pybin)
os.unlink(script_path) os.unlink(pybin)
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
pass pass
except Exception as e: except Exception as e:
...@@ -66,16 +73,20 @@ def remove_binwalk_module(): ...@@ -66,16 +73,20 @@ def remove_binwalk_module():
class UninstallCommand(Command): class UninstallCommand(Command):
description = "Uninstalls the Python module" description = "Uninstalls the Python module"
user_options = [] user_options = [
('pydir=', None, 'Specify the path to the binwalk python module to be removed.'),
('pybin=', None, 'Specify the path to the binwalk executable to be removed.'),
]
def initialize_options(self): def initialize_options(self):
pass self.pydir = None
self.pybin = None
def finalize_options(self): def finalize_options(self):
pass pass
def run(self): def run(self):
remove_binwalk_module() remove_binwalk_module(self.pydir, self.pybin)
class CleanCommand(Command): class CleanCommand(Command):
description = "Clean Python build directories" description = "Clean Python build directories"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment