From e1206b0fd8cdb1c36f1e51f0c97a0074f74ea75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Sun, 13 Jun 2010 16:03:37 +0000 Subject: [PATCH] scripts: Update unpisi to extract using file objects --- scripts/unpisi | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/unpisi b/scripts/unpisi index 8c11ad5e..2744d547 100755 --- a/scripts/unpisi +++ b/scripts/unpisi @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- 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 # the terms of the GNU General Public License as published by the Free @@ -10,14 +10,13 @@ # # Please read the COPYING file. -import sys import os -import shutil -import tempfile +import sys from zipfile import BadZipfile import pisi from pisi.archive import ArchiveZip, ArchiveTar +import pisi.context as ctx import pisi.util as util def usage(errmsg): @@ -44,20 +43,14 @@ def main(): print e sys.exit(1) - # Create a temporary directory in /tmp - tempdir = tempfile.mkdtemp(prefix='unpisi') - arc.unpack_files(['files.xml', 'metadata.xml'], '.') - arc.unpack_files("install.tar.lzma", tempdir) arc.unpack_dir('comar', '.') - tar_file = util.join_path(tempdir, "install.tar.lzma") - if os.path.exists(tar_file): - tar = ArchiveTar(tar_file, 'tarlzma') + if arc.has_file(ctx.const.install_tar_lzma): + tar_file = arc.open(ctx.const.install_tar_lzma) + tar = ArchiveTar(fileobj=tar_file, arch_type='tarlzma') tar.unpack_dir('.') - os.unlink(tar_file) - shutil.rmtree(tempdir) return 0 if __name__ == "__main__":