diff --git a/src/plugins/unpacking/deb/__init__.py b/src/plugins/unpacking/deb/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/plugins/unpacking/deb/code/__init__.py b/src/plugins/unpacking/deb/code/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/plugins/unpacking/deb/code/deb.py b/src/plugins/unpacking/deb/code/deb.py new file mode 100644 index 000000000..ad0b06171 --- /dev/null +++ b/src/plugins/unpacking/deb/code/deb.py @@ -0,0 +1,18 @@ +''' +This plugin unpacks debian packages +''' +from common_helper_process import execute_shell_command + +name = 'Deb' +mime_patterns = ['application/vnd.debian.binary-package'] +version = '0.1' + + +def unpack_function(file_path, tmp_dir): + return {'output': execute_shell_command('fakeroot dpkg-deb -v -x {} {}'.format(file_path, tmp_dir))} + + +# ----> Do not edit below this line <---- +def setup(unpack_tool): + for item in mime_patterns: + unpack_tool.register_plugin(item, (unpack_function, name, version)) diff --git a/src/plugins/unpacking/deb/test/__init__.py b/src/plugins/unpacking/deb/test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/plugins/unpacking/deb/test/data/test.deb b/src/plugins/unpacking/deb/test/data/test.deb new file mode 100644 index 000000000..e33f1c81a Binary files /dev/null and b/src/plugins/unpacking/deb/test/data/test.deb differ diff --git a/src/plugins/unpacking/deb/test/test_deb.py b/src/plugins/unpacking/deb/test/test_deb.py new file mode 100644 index 000000000..7b4f54bdd --- /dev/null +++ b/src/plugins/unpacking/deb/test/test_deb.py @@ -0,0 +1,17 @@ +import os +from test.unit.unpacker.test_unpacker import TestUnpackerBase + + +TEST_DATA_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data') + + +class TestDebUnpacker(TestUnpackerBase): + + def test_unpacker_selection_generic(self): + self.check_unpacker_selection('application/vnd.debian.binary-package', 'Deb') + + def test_extraction(self): + files, meta_data = self.unpacker.extract_files_from_file(os.path.join(TEST_DATA_DIR, 'test.deb'), self.tmp_dir.name) + + self.assertEqual(len(files), 3, 'file number incorrect') + self.assertIn('./usr/bin/test_elf_sfx', meta_data['output'])