Commit c04728f6 by devttys0

Fixed python3 & install bugs.

parent b62f15f9
...@@ -7,16 +7,16 @@ export exec_prefix=@exec_prefix@ ...@@ -7,16 +7,16 @@ export exec_prefix=@exec_prefix@
export LIBDIR=@libdir@ export LIBDIR=@libdir@
export INSTALL_OPTIONS=@INSTALL_OPTIONS@ export INSTALL_OPTIONS=@INSTALL_OPTIONS@
PYTHON=python PYTHON=python3
SRC_C_DIR="./src/C" SRC_C_DIR="./src/C"
.PHONY: all install build deps clean uninstall .PHONY: all install build deps clean uninstall
all: build all: build
install: build install:
make -C $(SRC_C_DIR) install make -C $(SRC_C_DIR) install
$(PYTHON) ./setup.py install $(PYTHON) ./setup.py install --yes
ldconfig || true ldconfig || true
build: build:
......
...@@ -51,7 +51,7 @@ def warning(lines, terminate=True, prompt=True): ...@@ -51,7 +51,7 @@ def warning(lines, terminate=True, prompt=True):
print("*" * WIDTH, "\n") print("*" * WIDTH, "\n")
if prompt: if prompt:
if raw_input('Continue installation anyway (Y/n)? ').lower().startswith('n'): if raw_input('Continue anyway (Y/n)? ').lower().startswith('n'):
terminate = True terminate = True
else: else:
terminate = False terminate = False
......
...@@ -15,13 +15,18 @@ if has_key(__builtins__, 'BLOCK_FILE_PARENT_CLASS'): ...@@ -15,13 +15,18 @@ if has_key(__builtins__, 'BLOCK_FILE_PARENT_CLASS'):
else: else:
BLOCK_FILE_PARENT_CLASS = io.FileIO BLOCK_FILE_PARENT_CLASS = io.FileIO
# The __debug__ value is a bit backwards; by default it is set to True, but
# then set to False if the Python interpreter is run with the -O option.
if not __debug__:
DEBUG = True
else:
DEBUG = False
def debug(msg): def debug(msg):
''' '''
Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag. Displays debug messages to stderr only if the Python interpreter was invoked with the -O flag.
''' '''
# The __debug__ value is a bit backwards; by default it is set to True, but if DEBUG:
# then set to False if the Python interpreter is run with the -O option.
if not __debug__:
sys.stderr.write("DEBUG: " + msg + "\n") sys.stderr.write("DEBUG: " + msg + "\n")
sys.stderr.flush() sys.stderr.flush()
......
...@@ -70,7 +70,7 @@ class Settings: ...@@ -70,7 +70,7 @@ class Settings:
Returns the path, if it exists; returns None otherwise. Returns the path, if it exists; returns None otherwise.
''' '''
if self.paths.has_key(usersys) and has_key(self.paths[usersys], fname) and self.paths[usersys][fname]: if has_key(self.paths, usersys) and has_key(self.paths[usersys], fname) and self.paths[usersys][fname]:
return self.paths[usersys][fname] return self.paths[usersys][fname]
return None return None
......
...@@ -274,7 +274,7 @@ class Extractor(Module): ...@@ -274,7 +274,7 @@ class Extractor(Module):
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
raise e raise e
except Exception as e: except Exception as e:
if self.config.verbose: if binwalk.core.common.DEBUG:
raise Exception("Extractor.load_defaults failed to load file '%s': %s" % (extract_file, str(e))) raise Exception("Extractor.load_defaults failed to load file '%s': %s" % (extract_file, str(e)))
def build_output_directory(self, path): def build_output_directory(self, path):
...@@ -547,8 +547,8 @@ class Extractor(Module): ...@@ -547,8 +547,8 @@ class Extractor(Module):
except Exception as e: except Exception as e:
binwalk.core.common.warning("Extractor.execute failed to run internal extractor '%s': %s" % (str(cmd), str(e))) binwalk.core.common.warning("Extractor.execute failed to run internal extractor '%s': %s" % (str(cmd), str(e)))
else: else:
# If not in verbose mode, create a temporary file to redirect stdout and stderr to # If not in debug mode, create a temporary file to redirect stdout and stderr to
if not self.config.verbose: if not binwalk.core.common.DEBUG:
tmp = tempfile.TemporaryFile() tmp = tempfile.TemporaryFile()
# Replace all instances of FILE_NAME_PLACEHOLDER in the command with fname # Replace all instances of FILE_NAME_PLACEHOLDER in the command with fname
...@@ -568,7 +568,7 @@ class Extractor(Module): ...@@ -568,7 +568,7 @@ class Extractor(Module):
# Silently ignore no such file or directory errors. Why? Because these will inevitably be raised when # Silently ignore no such file or directory errors. Why? Because these will inevitably be raised when
# making the switch to the new firmware mod kit directory structure. We handle this elsewhere, but it's # making the switch to the new firmware mod kit directory structure. We handle this elsewhere, but it's
# annoying to see this spammed out to the console every time. # annoying to see this spammed out to the console every time.
if self.config.verbose or (not hasattr(e, 'errno') or e.errno != 2): if binwalk.core.common.DEBUG or (not hasattr(e, 'errno') or e.errno != 2):
binwalk.core.common.warning("Extractor.execute failed to run external extrator '%s': %s" % (str(cmd), str(e))) binwalk.core.common.warning("Extractor.execute failed to run external extrator '%s': %s" % (str(cmd), str(e)))
retval = None retval = None
......
...@@ -25,13 +25,13 @@ class TarPlugin(binwalk.core.plugin.Plugin): ...@@ -25,13 +25,13 @@ class TarPlugin(binwalk.core.plugin.Plugin):
""" """
# There are two possible encodings for a number field, see # There are two possible encodings for a number field, see
# itn() below. # itn() below.
if s[0] != chr(0200): if s[0] != chr(0x80):
try: try:
n = int(self.nts(s) or "0", 8) n = int(self.nts(s) or "0", 8)
except ValueError: except ValueError:
raise ValueError("invalid tar header") raise ValueError("invalid tar header")
else: else:
n = 0L n = 0
for i in xrange(len(s) - 1): for i in xrange(len(s) - 1):
n <<= 8 n <<= 8
n += ord(s[i + 1]) n += ord(s[i + 1])
......
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