Skip to content

Instantly share code, notes, and snippets.

@meshula
Created October 12, 2018 19:34
Show Gist options
  • Save meshula/845fa6cad9c1cfb8edcd141e4ccffa32 to your computer and use it in GitHub Desktop.
Save meshula/845fa6cad9c1cfb8edcd141e4ccffa32 to your computer and use it in GitHub Desktop.
from os import walk
import os, errno
import subprocess
sevenzip="7z.exe"
src="C:/Downloads/UnzippedRPMDirectory"
dir = os.getcwd()
files = []
for (dirpath, dirname, filenames) in walk(src):
files.extend(filenames)
rpms = []
for file in files:
crumbs = os.path.splitext(file)
if crumbs[-1] == ".rpm":
if not os.path.exists(crumbs[0]):
os.makedirs(crumbs[0])
os.chdir(crumbs[0])
sys = subprocess.Popen([sevenzip, "e", "-y", os.path.join(src, file)])
sys.communicate()
cpio = crumbs[0] + ".cpio"
if os.path.exists(cpio):
sys = subprocess.Popen([sevenzip, "e", "-y", cpio])
sys.communicate()
os.chdir(dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment