HaikuPorts
  • Login
  • Preferences
  • Help/Guide
  • Wiki
  • Timeline
  • Roadmap
  • View Tickets
  • Search
  • Port Log
  • Blog

Context Navigation

  • Back to Ticket #617

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

     
    66# copyright 2009 Alexander Deynichenko 
    77# copyright 2009 HaikuBot (aka RISC) 
    88# copyright 2010-2011 Jack Laxson (Jrabbit) 
     9# copyright 2012 Sam Toyer (qxcv) 
    910 
    1011info = {} 
    1112info['version'] = 'r' + '$Rev$'[6:-2] 
    … …  
    2728from subprocess import check_call, Popen, CalledProcessError 
    2829from optparse import OptionParser 
    2930 
     31try: 
     32    import py7zlib 
     33except ImportError: 
     34    py7zlib = None 
     35 
    3036# -- HaikuPorts options ------------------------------------------------------- 
    3137 
    3238# location of haikuports.conf 
    … …  
    685691        # unpack source archive 
    686692        print 'Unpacking ' + self.src_local 
    687693        archiveFullPath = self.downloadDir + '/' + self.src_local 
     694        extension = archiveFullPath.split('/')[-1].split('.')[-1] 
    688695        if tarfile.is_tarfile(archiveFullPath): 
    689696            tf = tarfile.open(self.downloadDir + '/' + self.src_local, 
    690697                              'r') 
    … …  
    695702                                  + self.src_local, 'r') 
    696703            zf.extractall(self.workDir) 
    697704            zf.close() 
    698         elif archiveFullPath.split('/')[-1].split('.')[-1] == 'xz': 
     705        elif extension == 'xz': 
    699706            xz = 0 
    700707            try: 
    701708                xz = Popen(['xz', '-d', '-k', archiveFullPath]) 
    … …  
    711718                tf = tarfile.open(tar, 'r') 
    712719                tf.extractall(self.workDir) 
    713720                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() 
    714735        else: 
    715736            sys.exit('Error: Unrecognized archive type.') 
    716737 
    … …  
    957978            'hg': 'mercurial', 
    958979            'cvs': 'cvs', 
    959980            'bzr': 'bazaar', 
     981            'pylzma': 'pylzma', 
    960982            } 
    961983        if self.options.yes: 
    962984            check_call('installoptionalpackage' + ' ' 

Download in other formats:

  • Original Format

Trac Powered

Powered by Trac 0.13dev-r10686
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/