Commit 34665477 by devttys0

Added prefix support to make uninstall

parent 8fd98939
......@@ -18,7 +18,6 @@ ifeq ($(strip $(prefix)),)
else
PREFIX="--prefix=$(prefix)"
endif
START_SCRIPT="binwalk-start"
.PHONY: all install build deps clean uninstall
......@@ -35,13 +34,12 @@ build:
$(PYTHON) ./setup.py build
start-script:
echo '#!/bin/sh' > $(START_SCRIPT)
echo "PREFIX=\"$(prefix)\"" >> $(START_SCRIPT)
echo 'PYVERSION=`python --version 2>&1 | cut -d' ' -f2 | cut -d'.' -f1,2`' >> $(START_SCRIPT)
echo 'export PYTHONPATH="\$PREFIX/lib/python$PYVERSION/site-packages"' >> $(START_SCRIPT)
echo '\$PREFIX/bin/binwalk "\$@"' >> $(START_SCRIPT)
chmod +x $(START_SCRIPT)
echo '#\!/bin/sh' > $@
echo "PREFIX=\"$(prefix)\"" >> $@
echo 'PYVERSION=`python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1,2`' >> $@
echo 'export PYTHONPATH="$$PREFIX/lib/python$$PYVERSION/site-packages"' >> $@
echo '$$PREFIX/bin/binwalk "$$@"' >> $@
chmod +x $@
clean:
if [ "$(BUILD_C_LIBS)" -eq "1" ]; then make -C $(SRC_C_DIR) clean; fi
......@@ -49,9 +47,9 @@ clean:
distclean: clean
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:
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():
return paths
def remove_binwalk_module():
for path in find_binwalk_module_paths():
def remove_binwalk_module(pydir=None, pybin=None):
if pydir:
module_paths = [pydir]
else:
module_paths = find_binwalk_module_paths()
for path in module_paths:
try:
remove_tree(path)
except OSError as e:
pass
script_path = which(MODULE_NAME)
if script_path:
if not pybin:
pybin = which(MODULE_NAME)
if pybin:
try:
print("removing '%s'" % script_path)
os.unlink(script_path)
print("removing '%s'" % pybin)
os.unlink(pybin)
except KeyboardInterrupt as e:
pass
except Exception as e:
......@@ -66,16 +73,20 @@ def remove_binwalk_module():
class UninstallCommand(Command):
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):
pass
self.pydir = None
self.pybin = None
def finalize_options(self):
pass
def run(self):
remove_binwalk_module()
remove_binwalk_module(self.pydir, self.pybin)
class CleanCommand(Command):
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