Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
binwalk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
binwalk
Commits
5fcb44db
Commit
5fcb44db
authored
11 years ago
by
heffnercj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup.py made python3 compliant
parent
ad9365b0
master
…
v2.3.4
v2.3.3
v2.3.2
v2.3.1
v2.3.0
v2.2.0
v2.1.1
v2.0.1
v2.0.0
v1.3.0
python27
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
17 deletions
+33
-17
setup.py
src/setup.py
+33
-17
No files found.
src/setup.py
View file @
5fcb44db
#!/usr/bin/env python
#!/usr/bin/env python
from
__future__
import
print_function
import
os
import
os
import
sys
import
sys
import
subprocess
import
subprocess
from
os
import
listdir
,
path
from
os
import
listdir
,
path
from
distutils.core
import
setup
from
distutils.core
import
setup
# Python2/3 compliance
try
:
raw_input
except
:
raw_input
=
input
# This is super hacky.
# This is super hacky.
if
"--yes"
in
sys
.
argv
:
if
"--yes"
in
sys
.
argv
:
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
"--yes"
))
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
"--yes"
))
...
@@ -20,10 +27,10 @@ def warning(lines, terminate=True, prompt=False):
...
@@ -20,10 +27,10 @@ def warning(lines, terminate=True, prompt=False):
WIDTH
=
115
WIDTH
=
115
if
not
IGNORE_WARNINGS
:
if
not
IGNORE_WARNINGS
:
print
"
\n
"
,
"*"
*
WIDTH
print
(
"
\n
"
+
"*"
*
WIDTH
)
for
line
in
lines
:
for
line
in
lines
:
print
line
print
(
line
)
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 installation anyway (Y/n)? '
)
.
lower
()
.
startswith
(
'n'
):
...
@@ -34,20 +41,19 @@ def warning(lines, terminate=True, prompt=False):
...
@@ -34,20 +41,19 @@ def warning(lines, terminate=True, prompt=False):
if
terminate
:
if
terminate
:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# Check for pre-requisite modules only if --no-prereq-checks was not specified
print
(
"checking pre-requisites"
)
print
"checking pre-requisites"
try
:
try
:
import
magic
import
magic
try
:
try
:
magic
.
MAGIC_NO_CHECK_TEXT
magic
.
MAGIC_NO_CHECK_TEXT
except
Exception
,
e
:
except
Exception
as
e
:
msg
=
[
"Pre-requisite failure:
"
,
str
(
e
),
msg
=
[
"Pre-requisite failure:
"
+
str
(
e
),
"It looks like you have an old or incompatible magic module installed."
,
"It looks like you have an old or incompatible magic module installed."
,
"Please install the official python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
"Please install the official python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
]
]
warning
(
msg
)
warning
(
msg
)
except
Exception
,
e
:
except
Exception
as
e
:
msg
=
[
"Pre-requisite failure:"
,
str
(
e
),
msg
=
[
"Pre-requisite failure:"
,
str
(
e
),
"Please install the python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
,
"Please install the python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
,
]
]
...
@@ -59,8 +65,8 @@ try:
...
@@ -59,8 +65,8 @@ try:
matplotlib
.
use
(
'Agg'
)
matplotlib
.
use
(
'Agg'
)
import
matplotlib.pyplot
import
matplotlib.pyplot
import
numpy
import
numpy
except
Exception
,
e
:
except
Exception
as
e
:
msg
=
[
"Pre-requisite check warning:
"
,
str
(
e
),
msg
=
[
"Pre-requisite check warning:
"
+
str
(
e
),
"To take advantage of this tool's entropy plotting capabilities, please install the python-matplotlib module."
,
"To take advantage of this tool's entropy plotting capabilities, please install the python-matplotlib module."
,
]
]
...
@@ -80,7 +86,7 @@ if not os.path.exists(c_lib_makefile):
...
@@ -80,7 +86,7 @@ if not os.path.exists(c_lib_makefile):
status
|=
os
.
system
(
"make"
)
status
|=
os
.
system
(
"make"
)
if
status
!=
0
:
if
status
!=
0
:
msg
=
[
"
F
ailed to build compression libraries."
,
msg
=
[
"
Build warning: f
ailed to build compression libraries."
,
"Some plugins will not work without these libraries."
"Some plugins will not work without these libraries."
]
]
...
@@ -88,7 +94,7 @@ if status != 0:
...
@@ -88,7 +94,7 @@ if status != 0:
else
:
else
:
if
"install"
in
sys
.
argv
:
if
"install"
in
sys
.
argv
:
if
os
.
system
(
"make install"
)
!=
0
:
if
os
.
system
(
"make install"
)
!=
0
:
msg
=
[
"
F
ailed to install compression libraries."
,
msg
=
[
"
Install warning: f
ailed to install compression libraries."
,
"Some plugins will not work without these libraries."
"Some plugins will not work without these libraries."
]
]
...
@@ -97,14 +103,18 @@ else:
...
@@ -97,14 +103,18 @@ else:
os
.
chdir
(
working_directory
)
os
.
chdir
(
working_directory
)
# Generate a new magic file from the files in the magic directory
# Generate a new magic file from the files in the magic directory
print
"generating binwalk magic file"
print
(
"generating binwalk magic file"
)
magic_files
=
listdir
(
"magic"
)
magic_files
=
listdir
(
"magic"
)
magic_files
.
sort
()
magic_files
.
sort
()
fd
=
open
(
"binwalk/magic/binwalk"
,
"wb"
)
fd
=
open
(
"binwalk/magic/binwalk"
,
"wb"
)
for
magic
in
magic_files
:
for
magic
in
magic_files
:
fpath
=
path
.
join
(
"magic"
,
magic
)
fpath
=
path
.
join
(
"magic"
,
magic
)
if
path
.
isfile
(
fpath
):
if
path
.
isfile
(
fpath
):
fd
.
write
(
open
(
fpath
)
.
read
())
data
=
open
(
fpath
)
.
read
()
try
:
fd
.
write
(
data
)
except
TypeError
:
fd
.
write
(
bytes
(
data
,
'UTF-8'
))
fd
.
close
()
fd
.
close
()
# The data files to install along with the binwalk module
# The data files to install along with the binwalk module
...
@@ -115,7 +125,7 @@ setup( name = "binwalk",
...
@@ -115,7 +125,7 @@ setup( name = "binwalk",
version
=
"1.2.3"
,
version
=
"1.2.3"
,
description
=
"Firmware analysis tool"
,
description
=
"Firmware analysis tool"
,
author
=
"Craig Heffner"
,
author
=
"Craig Heffner"
,
url
=
"http
://binwalk.googlecode.com
"
,
url
=
"http
s://github.com/devttys0/binwalk
"
,
requires
=
[
"magic"
,
"matplotlib.pyplot"
],
requires
=
[
"magic"
,
"matplotlib.pyplot"
],
packages
=
[
"binwalk"
],
packages
=
[
"binwalk"
],
...
@@ -137,8 +147,14 @@ if python2_path and binwalk_path:
...
@@ -137,8 +147,14 @@ if python2_path and binwalk_path:
for
line
in
open
(
binwalk_path
,
'rb'
)
.
readlines
():
for
line
in
open
(
binwalk_path
,
'rb'
)
.
readlines
():
if
i
==
0
:
if
i
==
0
:
line
=
"#!/usr/bin/env python2
\n
"
line
=
"#!/usr/bin/env python2
\n
"
data
+=
line
data
+=
str
(
line
)
i
+=
1
i
+=
1
open
(
binwalk_path
,
'wb'
)
.
write
(
data
)
fd
=
open
(
binwalk_path
,
'wb'
)
try
:
fd
.
write
(
data
)
except
TypeError
:
fd
.
write
(
bytes
(
data
,
'UTF-8'
))
fd
.
close
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment