scripts: Update unpisi to extract using file objects

This commit is contained in:
Fatih Aşıcı
2010-06-13 16:03:37 +00:00
parent 727ba7964b
commit e1206b0fd8
+6 -13
View File
@@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (C) 2006, TUBITAK/UEKAE # Copyright (C) 2006-2010, TUBITAK/UEKAE
# #
# This program is free software; you can redistribute it and/or modify it under # This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free # the terms of the GNU General Public License as published by the Free
@@ -10,14 +10,13 @@
# #
# Please read the COPYING file. # Please read the COPYING file.
import sys
import os import os
import shutil import sys
import tempfile
from zipfile import BadZipfile from zipfile import BadZipfile
import pisi import pisi
from pisi.archive import ArchiveZip, ArchiveTar from pisi.archive import ArchiveZip, ArchiveTar
import pisi.context as ctx
import pisi.util as util import pisi.util as util
def usage(errmsg): def usage(errmsg):
@@ -44,20 +43,14 @@ def main():
print e print e
sys.exit(1) sys.exit(1)
# Create a temporary directory in /tmp
tempdir = tempfile.mkdtemp(prefix='unpisi')
arc.unpack_files(['files.xml', 'metadata.xml'], '.') arc.unpack_files(['files.xml', 'metadata.xml'], '.')
arc.unpack_files("install.tar.lzma", tempdir)
arc.unpack_dir('comar', '.') arc.unpack_dir('comar', '.')
tar_file = util.join_path(tempdir, "install.tar.lzma") if arc.has_file(ctx.const.install_tar_lzma):
if os.path.exists(tar_file): tar_file = arc.open(ctx.const.install_tar_lzma)
tar = ArchiveTar(tar_file, 'tarlzma') tar = ArchiveTar(fileobj=tar_file, arch_type='tarlzma')
tar.unpack_dir('.') tar.unpack_dir('.')
os.unlink(tar_file)
shutil.rmtree(tempdir)
return 0 return 0
if __name__ == "__main__": if __name__ == "__main__":