Skip to content

extract: improve .deb extraction #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions cve_bin_tool/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Extraction of archives
'''
import os
import glob
import shutil
import tempfile
import itertools
Expand Down Expand Up @@ -67,17 +68,12 @@ def extract_file_rpm(cls, filename, extraction_path):
@classmethod
def extract_file_deb(cls, filename, extraction_path):
""" Extract debian packages """
if subprocess.call(["ar", "x", filename], cwd=extraction_path) != 0:
return 1
for filename in os.listdir(extraction_path):
if '.tar' in filename:
result = subprocess.call(
["tar", "-C", extraction_path, "-zxf",
os.path.join(extraction_path, filename)])
os.unlink(os.path.join(extraction_path, filename))
if result != 0:
return result
return 0
result = subprocess.call(["ar", "x", filename], cwd=extraction_path)
if result != 0:
return result
datafile = glob.glob(os.path.join(extraction_path, "data.tar.*"))[0]
result = subprocess.call(["tar", "-C", extraction_path, "-axf", datafile])
return result

@classmethod
def extract_file_cab(cls, filename, extraction_path):
Expand Down