Commit 4989aba0 by heffnercj

update.py now fetches updates from github.

parent feb152b3
......@@ -390,9 +390,11 @@ def main():
elif opt in ("-u", "--update"):
try:
sys.stdout.write("Updating signatures...")
if verbose:
sys.stdout.write("\n")
sys.stdout.flush()
binwalk.Update().update()
binwalk.Update(verbose).update()
sys.stdout.write("done.\n")
sys.exit(0)
......
......@@ -48,6 +48,8 @@ class Config:
BINWALK_MAGIC_FILE = "binwalk"
BINCAST_MAGIC_FILE = "bincast"
BINARCH_MAGIC_FILE = "binarch"
ZLIB_MAGIC_FILE = "zlib"
COMPRESSD_MAGIC_FILE = "compressd"
def __init__(self):
'''
......@@ -75,6 +77,8 @@ class Config:
self.paths['system'][self.BINWALK_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.BINWALK_MAGIC_FILE)
self.paths['system'][self.BINCAST_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.BINCAST_MAGIC_FILE)
self.paths['system'][self.BINARCH_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.BINARCH_MAGIC_FILE)
self.paths['system'][self.ZLIB_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.ZLIB_MAGIC_FILE)
self.paths['system'][self.COMPRESSD_MAGIC_FILE] = self._system_path(self.BINWALK_MAGIC_DIR, self.COMPRESSD_MAGIC_FILE)
self.paths['system'][self.EXTRACT_FILE] = self._system_path(self.BINWALK_CONFIG_DIR, self.EXTRACT_FILE)
self.paths['system'][self.PLUGINS] = self._system_path(self.BINWALK_PLUGINS_DIR)
......
......@@ -12,14 +12,19 @@ class Update:
Update().update()
'''
BASE_URL = "http://binwalk.googlecode.com/svn/trunk/src/binwalk/"
BASE_URL = "https://raw.github.com/devttys0/binwalk/master/src/binwalk/"
MAGIC_PREFIX = "magic/"
CONFIG_PREFIX = "config/"
def __init__(self):
def __init__(self, verbose=False):
'''
Class constructor.
@verbose - Verbose flag.
Returns None.
'''
self.verbose = verbose
self.config = Config()
def update(self):
......@@ -33,6 +38,7 @@ class Update:
self.update_binarch()
self.update_extract()
self.update_zlib()
self.update_compressd()
def _do_update_from_svn(self, prefix, fname):
'''
......@@ -54,6 +60,9 @@ class Update:
url = self.BASE_URL + prefix + fname
try:
if self.verbose:
print "Fetching %s..." % url
data = urllib2.urlopen(url).read()
open(self.config.paths['system'][fname], "wb").write(data)
except Exception, e:
......@@ -91,6 +100,14 @@ class Update:
'''
self._do_update_from_svn(self.MAGIC_PREFIX, self.config.ZLIB_MAGIC_FILE)
def update_compressd(self):
'''
Updates the compress'd signature file.
Returns None.
'''
self._do_update_from_svn(self.MAGIC_PREFIX, self.config.COMPRESSD_MAGIC_FILE)
def update_extract(self):
'''
Updates the extract.conf file.
......
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