Ticket #617: haikuporter-7z-support-with-attribution.diff
| File haikuporter-7z-support-with-attribution.diff, 2.5 KB (added by richienyhus, 2 years ago) |
|---|
-
trunk/haikuporter
6 6 # copyright 2009 Alexander Deynichenko 7 7 # copyright 2009 HaikuBot (aka RISC) 8 8 # copyright 2010-2011 Jack Laxson (Jrabbit) 9 # copyright 2012 Sam Toyer (qxcv) 9 10 10 11 info = {} 11 12 info['version'] = 'r' + '$Rev$'[6:-2] … … 27 28 from subprocess import check_call, Popen, CalledProcessError 28 29 from optparse import OptionParser 29 30 31 try: 32 import py7zlib 33 except ImportError: 34 py7zlib = None 35 30 36 # -- HaikuPorts options ------------------------------------------------------- 31 37 32 38 # location of haikuports.conf … … 685 691 # unpack source archive 686 692 print 'Unpacking ' + self.src_local 687 693 archiveFullPath = self.downloadDir + '/' + self.src_local 694 extension = archiveFullPath.split('/')[-1].split('.')[-1] 688 695 if tarfile.is_tarfile(archiveFullPath): 689 696 tf = tarfile.open(self.downloadDir + '/' + self.src_local, 690 697 'r') … … 695 702 + self.src_local, 'r') 696 703 zf.extractall(self.workDir) 697 704 zf.close() 698 elif archiveFullPath.split('/')[-1].split('.')[-1]== 'xz':705 elif extension == 'xz': 699 706 xz = 0 700 707 try: 701 708 xz = Popen(['xz', '-d', '-k', archiveFullPath]) … … 711 718 tf = tarfile.open(tar, 'r') 712 719 tf.extractall(self.workDir) 713 720 tf.close() 721 elif extension == '7z': 722 fp = open(archiveFullPath) 723 if py7zlib is None: 724 if not self.prompt_installer('pylzma'): 725 sys.exit() 726 archive = __import__('py7zlib').Archive7z(fp) 727 else: 728 archive = py7zlib.Archive7z(fp) 729 for item in archive.files: 730 out_filename = os.path.join(self.workDir, item.filename) 731 out_fp = open(out_filename, 'w') 732 out_fp.write(item.read()) 733 out_fp.close() 734 fp.close() 714 735 else: 715 736 sys.exit('Error: Unrecognized archive type.') 716 737 … … 957 978 'hg': 'mercurial', 958 979 'cvs': 'cvs', 959 980 'bzr': 'bazaar', 981 'pylzma': 'pylzma', 960 982 } 961 983 if self.options.yes: 962 984 check_call('installoptionalpackage' + ' '
