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-gitdep
binwalk
Commits
d3a03b2d
Commit
d3a03b2d
authored
Dec 22, 2013
by
devttys0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated setup.py
parent
43c8dd8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
109 deletions
+116
-109
setup.py
setup.py
+116
-109
No files found.
setup.py
View file @
d3a03b2d
...
@@ -2,41 +2,45 @@
...
@@ -2,41 +2,45 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
os
import
os
import
sys
import
sys
from
distutils.core
import
setup
import
tempfile
import
subprocess
from
distutils.core
import
setup
,
Command
from
distutils.dir_util
import
remove_tree
from
distutils.dir_util
import
remove_tree
MODULE_NAME
=
"binwalk"
# Python2/3 compliance
# Python2/3 compliance
try
:
try
:
raw_input
raw_input
except
NameError
:
except
NameError
:
raw_input
=
input
raw_input
=
input
def
cleanup_build_directory
():
# This is super hacky.
# Requires to chdir into the src directory first
if
"--yes"
in
sys
.
argv
:
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
"--yes"
))
IGNORE_WARNINGS
=
True
else
:
IGNORE_WARNINGS
=
False
# cd into the src directory, no matter where setup.py was invoked from
os
.
chdir
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"src"
))
def
which
(
command
):
# /usr/local/bin is usually the default install path, though it may not be in $PATH
usr_local_bin
=
os
.
path
.
sep
.
join
([
os
.
path
.
sep
,
'usr'
,
'local'
,
'bin'
,
command
])
try
:
try
:
remove_tree
(
"build"
)
location
=
subprocess
.
Popen
([
"which"
,
command
],
shell
=
False
,
stdout
=
subprocess
.
PIPE
)
.
communicate
()[
0
]
.
strip
(
)
except
KeyboardInterrupt
as
e
:
except
KeyboardInterrupt
as
e
:
raise
e
raise
e
except
Exception
:
except
Exception
as
e
:
pass
pass
def
cleanup_module_directory
():
if
not
location
and
os
.
path
.
exists
(
usr_local_bin
):
# Installing doesn't remove old files that may have been deleted from the module.
location
=
usr_local_bin
if
"install"
in
sys
.
argv
:
try
:
import
binwalk
for
path
in
binwalk
.
__path__
:
try
:
remove_tree
(
path
+
os
.
path
.
sep
+
"*"
)
except
OSError
as
e
:
pass
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
pass
return
location
# Change to the binwalk src directory
def
warning
(
lines
,
terminate
=
True
,
prompt
=
True
):
def
warning
(
lines
,
terminate
=
True
,
prompt
=
True
):
WIDTH
=
115
WIDTH
=
115
...
@@ -54,103 +58,106 @@ def warning(lines, terminate=True, prompt=True):
...
@@ -54,103 +58,106 @@ def warning(lines, terminate=True, prompt=True):
if
terminate
:
if
terminate
:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
# This is super hacky.
if
"--yes"
in
sys
.
argv
:
sys
.
argv
.
pop
(
sys
.
argv
.
index
(
"--yes"
))
IGNORE_WARNINGS
=
True
else
:
IGNORE_WARNINGS
=
False
# cd into the src directory, no matter where setup.py was invoked from
class
UninstallCommand
(
Command
):
os
.
chdir
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"src"
))
description
=
"Uninstalls the Python module"
user_options
=
[]
print
(
"checking pre-requisites"
)
def
initialize_options
(
self
):
try
:
pass
import
magic
def
finalize_options
(
self
):
pass
def
run
(
self
):
try
:
import
binwalk
for
path
in
binwalk
.
__path__
:
try
:
remove_tree
(
path
)
except
OSError
as
e
:
pass
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
as
e
:
pass
script_path
=
which
(
MODULE_NAME
)
if
script_path
:
try
:
print
(
"removing '
%
s'"
%
script_path
)
os
.
unlink
(
script_path
)
except
KeyboardInterrupt
as
e
:
pass
except
Exception
as
e
:
pass
class
CleanCommand
(
Command
):
description
=
"Clean Python build directories"
user_options
=
[]
def
initialize_options
(
self
):
pass
def
finalize_options
(
self
):
pass
def
run
(
self
):
try
:
remove_tree
(
"build"
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
pass
try
:
remove_tree
(
"dist"
)
except
KeyboardInterrupt
as
e
:
raise
e
except
Exception
:
pass
# Check pre-requisite Python modules during an install
if
"install"
in
sys
.
argv
:
print
(
"checking pre-requisites"
)
try
:
try
:
magic
.
MAGIC_NO_CHECK_TEXT
import
pyqtgraph
except
AttributeError
as
e
:
import
QtPyWhatever
msg
=
[
"Pre-requisite failure: "
+
str
(
e
),
except
ImportError
as
e
:
"It looks like you have an old or incompatible magic module installed."
,
msg
=
[
"Pre-requisite check warning: "
+
str
(
e
)
,
"Please install the official python-magic module, or download and install it from source: ftp://ftp.astron.com/pub/file/"
"To take advantage of this
%
s's graphing capabilities, please install this module."
%
MODULE_NAME
,
]
]
warning
(
msg
)
except
ImportError
as
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/"
,
]
warning
(
msg
)
try
:
import
pyqtgraph
except
ImportError
as
e
:
msg
=
[
"Pre-requisite check warning: "
+
str
(
e
),
"To take advantage of this tool's graphing capabilities, please install the pyqtgraph module."
,
]
warning
(
msg
,
prompt
=
True
)
# Build / install C compression libraries
c_lib_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"C"
)
c_lib_makefile
=
os
.
path
.
join
(
c_lib_dir
,
"Makefile"
)
working_directory
=
os
.
getcwd
()
os
.
chdir
(
c_lib_dir
)
status
=
0
if
not
os
.
path
.
exists
(
c_lib_makefile
):
status
|=
os
.
system
(
"./configure"
)
status
|=
os
.
system
(
"make"
)
if
status
!=
0
:
msg
=
[
"Build warning: failed to build C libraries."
,
"Some features will not work without these libraries."
]
warning
(
msg
,
prompt
=
True
)
elif
"install"
in
sys
.
argv
:
if
os
.
system
(
"make install"
)
!=
0
:
msg
=
[
"Install warning: failed to install C libraries."
,
"Some features will not work without these libraries."
]
warning
(
msg
,
prompt
=
True
)
warning
(
msg
,
prompt
=
True
)
os
.
system
(
"make distclean"
)
# Re-build the magic file during a build/install
if
"install"
in
sys
.
argv
or
"build"
in
sys
.
argv
:
os
.
chdir
(
working_directory
)
# Generate a new magic file from the files in the magic directory
print
(
"creating
%
s magic file"
%
MODULE_NAME
)
cleanup_build_directory
()
magic_files
=
os
.
listdir
(
"magic"
)
cleanup_module_directory
()
magic_files
.
sort
()
fd
=
open
(
"
%
s/magic/
%
s"
%
(
MODULE_NAME
,
MODULE_NAME
),
"wb"
)
# Generate a new magic file from the files in the magic directory
for
magic
in
magic_files
:
print
(
"creating binwalk magic file"
)
fpath
=
os
.
path
.
join
(
"magic"
,
magic
)
magic_files
=
os
.
listdir
(
"magic"
)
if
os
.
path
.
isfile
(
fpath
):
magic_files
.
sort
()
fd
.
write
(
open
(
fpath
,
"rb"
)
.
read
())
fd
=
open
(
"binwalk/magic/binwalk"
,
"wb"
)
fd
.
close
()
for
magic
in
magic_files
:
fpath
=
os
.
path
.
join
(
"magic"
,
magic
)
# The data files to install along with the module
if
os
.
path
.
isfile
(
fpath
):
fd
.
write
(
open
(
fpath
,
"rb"
)
.
read
())
fd
.
close
()
# The data files to install along with the binwalk module
install_data_files
=
[
"magic/*"
,
"config/*"
,
"plugins/*"
,
"modules/*"
,
"core/*"
]
install_data_files
=
[
"magic/*"
,
"config/*"
,
"plugins/*"
,
"modules/*"
,
"core/*"
]
# Install the binwalk module, script and support files
# Install the module, script, and support files
setup
(
name
=
"binwalk"
,
setup
(
name
=
MODULE_NAME
,
version
=
"2.0.0 beta"
,
version
=
"2.0.0 beta"
,
description
=
"Firmware analysis tool"
,
description
=
"Firmware analysis tool"
,
author
=
"Craig Heffner"
,
author
=
"Craig Heffner"
,
url
=
"https://github.com/devttys0/binwalk"
,
url
=
"https://github.com/devttys0/
%
s"
%
MODULE_NAME
,
requires
=
[
"magic"
,
"pyqtgraph"
],
packages
=
[
"binwalk"
],
package_data
=
{
"binwalk"
:
install_data_files
},
scripts
=
[
"scripts/binwalk"
],
)
cleanup_build_directory
()
requires
=
[
"magic"
,
"pyqtgraph"
],
packages
=
[
MODULE_NAME
],
package_data
=
{
MODULE_NAME
:
install_data_files
},
scripts
=
[
os
.
path
.
join
(
"scripts"
,
MODULE_NAME
)],
cmdclass
=
{
'clean'
:
CleanCommand
,
'uninstall'
:
UninstallCommand
}
)
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