From 491d06e47261db2c6654da762b0ee6e38e14b2bb Mon Sep 17 00:00:00 2001
From: devttys0 <heffnercj@gmail.com>
Date: Thu, 2 Oct 2014 12:19:40 -0400
Subject: [PATCH] Removed firmware-mod-kit dependencies

---
 src/binwalk/config/extract.conf    | 12 ++++++------
 src/binwalk/modules/__init__.py    |  2 +-
 src/binwalk/modules/compression.py |  6 +++---
 src/binwalk/plugins/cpio.py        | 22 ++++++++++++++++++++--
 src/magic/archives                 |  1 -
 5 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/src/binwalk/config/extract.conf b/src/binwalk/config/extract.conf
index e823af2..4011729 100644
--- a/src/binwalk/config/extract.conf
+++ b/src/binwalk/config/extract.conf
@@ -25,20 +25,20 @@
 ^squashfs filesystem:squashfs:sasquatch '%e'
 ^squashfs filesystem:squashfs:unsquashfs '%e'
 
+^cramfs filesystem:cramfs:mkdir cramfs-root && mount -t cramfs '%e' cramfs-root
+^ext2 filesystem:ext2:mkdir ext2-root && mount -t ext2 '%e' ext2-root
+^romfs filesystem:romfs:mkdir romfs-root && mount -t romfs '%e' romfs-root
+
 # These assume the firmware-mod-kit is installed to /opt/firmware-mod-kit.
 # If not, change the file paths appropriately.
-^jffs2 filesystem:jffs2:/opt/firmware-mod-kit/src/jffs2/unjffs2 '%e'
-^ascii cpio archive:cpio:/opt/firmware-mod-kit/uncpio.sh '%e'
+#^jffs2 filesystem:jffs2:/opt/firmware-mod-kit/src/jffs2/unjffs2 '%e'
+#^ascii cpio archive:cpio:/opt/firmware-mod-kit/uncpio.sh '%e'
 #^squashfs filesystem:squashfs:/opt/firmware-mod-kit/unsquashfs_all.sh '%e'
 #^cramfs filesystem:cramfs:/opt/firmware-mod-kit/uncramfs_all.sh '%e'
 #^bff volume entry:bff:/opt/firmware-mod-kit/src/bff/bffxtractor.py '%e'
 #^wdk file system:wdk:/opt/firmware-mod-kit/src/firmware-tools/unwdk.py '%e'
 #^zlib compressed data:zlib:/opt/firmware-mod-kit/src/firmware-tools/unzlib.py '%e'
 
-^cramfs filesystem:cramfs:mkdir cramfs-root && mount -t cramfs '%e' cramfs-root
-^ext2 filesystem:ext2:mkdir ext2-root && mount -t ext2 '%e' ext2-root
-^romfs filesystem:romfs:mkdir romfs-root && mount -t romfs '%e' romfs-root
-
 # These will only be run if the above file paths don't exist / don't work.
 #^squashfs filesystem:squashfs:/opt/firmware-mod-kit/trunk/unsquashfs_all.sh '%e'
 #^jffs2 filesystem:jffs2:/opt/firmware-mod-kit/trunk/src/jffs2/unjffs2 '%e' # requires root
diff --git a/src/binwalk/modules/__init__.py b/src/binwalk/modules/__init__.py
index 09c662e..eb6dbe8 100644
--- a/src/binwalk/modules/__init__.py
+++ b/src/binwalk/modules/__init__.py
@@ -5,7 +5,7 @@ from binwalk.modules.hexdiff import HexDiff
 from binwalk.modules.general import General
 from binwalk.modules.extractor import Extractor
 from binwalk.modules.entropy import Entropy
-from binwalk.modules.heuristics import HeuristicCompressionAnalyzer
+#from binwalk.modules.heuristics import HeuristicCompressionAnalyzer
 from binwalk.modules.compression import RawCompression
 try:
     from binwalk.modules.disasm import Disasm
diff --git a/src/binwalk/modules/compression.py b/src/binwalk/modules/compression.py
index bd59a3e..34b06c5 100644
--- a/src/binwalk/modules/compression.py
+++ b/src/binwalk/modules/compression.py
@@ -27,12 +27,12 @@ class Deflate(object):
 
         # The tinfl library is built and installed with binwalk
         self.tinfl = binwalk.core.C.Library(self.TINFL_NAME, self.TINFL_FUNCTIONS)
-        
+
         # Add an extraction rule
         if self.module.extractor.enabled:
-            self.module.extractor.add_rule(regex='^%s' % self.DESCRIPTION.lower(), extension="deflate", cmd=self._extractor)
+            self.module.extractor.add_rule(regex='^%s' % self.DESCRIPTION.lower(), extension="deflate", cmd=self.extractor)
 
-    def _extractor(self, file_name):
+    def extractor(self, file_name):
         out_file = os.path.splitext(file_name)[0]
         self.tinfl.inflate_raw_file(file_name, out_file)
 
diff --git a/src/binwalk/plugins/cpio.py b/src/binwalk/plugins/cpio.py
index cc64601..3fdb712 100644
--- a/src/binwalk/plugins/cpio.py
+++ b/src/binwalk/plugins/cpio.py
@@ -2,11 +2,29 @@ import binwalk.core.plugin
 
 class CPIOPlugin(binwalk.core.plugin.Plugin):
     '''
-    Ensures that ASCII CPIO archive entries only get extracted once.    
+    Ensures that ASCII CPIO archive entries only get extracted once.
     '''
+#    CPIO_OUT_DIR = "cpio-root"
 
     MODULES = ['Signature']
 
+#    def init(self):
+#        if self.module.extractor.enabled:
+#            self.module.extractor.add_rule(regex="^ascii cpio archive",
+#                                           extension="cpio",
+#                                           cmd=self.extractor)
+
+#    def extractor(self, fname):
+#        out_dir = os.path.join(os.path.split(fname)[0], self.CPIO_OUT_DIR)
+
+#        try:
+#            os.mkdir(out_dir)
+#        except OSError:
+#            return
+
+#        # Lazy.
+#        os.system("cd '%s' && cpio -d -i --no-absolute-filenames < '%s' 2>&1 1>/dev/null" % (out_dir, fname))
+
     def pre_scan(self):
         # Be sure to re-set this at the beginning of every scan
         self.found_archive = False
@@ -28,7 +46,7 @@ class CPIOPlugin(binwalk.core.plugin.Plugin):
                     self.found_archive = False
                     result.extract = False
                 else:
-                    # The first entry has already been found and this is not the last entry, or the last entry 
+                    # The first entry has already been found and this is not the last entry, or the last entry
                     # has not yet been found. Don't extract.
                     result.extract = False
             else:
diff --git a/src/magic/archives b/src/magic/archives
index 6473857..3a073f4 100644
--- a/src/magic/archives
+++ b/src/magic/archives
@@ -175,7 +175,6 @@
 >54	    string		x		{jump-to-offset:0x%.8s+110+
 >94	    string		x		\b0x%.8s}
 
-
 # HP Printer Job Language
 # The header found on Win95 HP plot files is the "Silliest Thing possible" 
 # (TM)
--
libgit2 0.26.0