unpisi: Use pisi.package module instead of duplicating extraction code
This commit is contained in:
+5
-20
@@ -14,10 +14,7 @@ import os
|
||||
import sys
|
||||
from zipfile import BadZipfile
|
||||
|
||||
import pisi
|
||||
from pisi.archive import ArchiveZip, ArchiveTar
|
||||
import pisi.context as ctx
|
||||
import pisi.util as util
|
||||
from pisi.package import Package
|
||||
|
||||
def usage(errmsg):
|
||||
print """
|
||||
@@ -38,26 +35,14 @@ def main():
|
||||
usage("File %s not found" % sys.argv[1])
|
||||
|
||||
try:
|
||||
arc = ArchiveZip(sys.argv[1], 'zip', 'r')
|
||||
package = Package(sys.argv[1])
|
||||
except BadZipfile, e:
|
||||
print e
|
||||
sys.exit(1)
|
||||
|
||||
arc.unpack_files(['files.xml', 'metadata.xml'], '.')
|
||||
arc.unpack_dir('comar', '.')
|
||||
|
||||
archive_name = None
|
||||
if arc.has_file(ctx.const.install_tar_xz):
|
||||
archive_name = ctx.const.install_tar_xz
|
||||
archive_format = "tarxz"
|
||||
elif arc.has_file(ctx.const.install_tar_lzma):
|
||||
archive_name = ctx.const.install_tar_lzma
|
||||
archive_format = "tarlzma"
|
||||
|
||||
if archive_name:
|
||||
tar_file = arc.open(archive_name)
|
||||
tar = ArchiveTar(fileobj=tar_file, arch_type=archive_format)
|
||||
tar.unpack_dir('.')
|
||||
package.extract_pisi_files(".")
|
||||
package.extract_dir("comar", ".")
|
||||
package.extract_install(".")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user