Example #1
0
#!/usr/bin/env python3

import tarfile
import zipfile
import subprocess
import os
from jarmanifest import log
from jarmanifest.configuration import config

logger = log.getLogger('util.archives')

ignore_no_ext = False
ignore_ext_list = []
if config.has_option('archives', 'ignore_no_ext'):
    ignore_no_ext = eval(config.get('archives', 'ignore_no_ext'))
if config.has_option('archives', 'ignore_ext_list'):
    ignore_ext_list = config.get('archives', 'ignore_ext_list').split(',')


# handler class for tars with invalid headers
# Some .tgz patchs eg: JBPAPP-8049.zip/JBPAPP-8049-signed.tgz tend
# to have things like '\x81' in its headers, raiseing a
# UnicodeDecodeError
# We fake the tarfile module using the sytems 'tar' binary
class custom_tarfile:
    def __init__(self, filename):
        self.command = 'tar'
        self.filename = os.path.abspath(filename)
        self.filelist = self.get_filelist()
        self.extracted = False
"""
Module to handle jar manifest files
"""
from jarmanifest import log, archives

logger = log.getLogger('util.manifest')
manifestkeys = None

def getManifestkeys():
	global manifestkeys
	if manifestkeys is None:
		logger.debug('Generating manifest keys')
		manifestkeys = list(map(str.lower, [
		'Name','Specification-Title','Specification-Vendor',
		'Specification-Version','Implementation-Title',
		'Implementation-Version','Implementation-Vendor',
		'Implementation-URL', 'Extension-Name', 'Comment']))
		manifestkeys = [i.replace('-','') for i in manifestkeys]
	return manifestkeys

# From: http://docs.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#Notes on Manifest and Signature Files
# No line may be longer than 72 bytes (not characters), in its
# UTF8-encoded form. If a value would make the initial line longer
# than this, it should be continued on extra lines
# (each starting with a single SPACE).
def getAttributes(manifestFile):
	logger.debug('Parsing attributes from %s'%(manifestFile))
	manifestkeys = getManifestkeys()
	mf = open(manifestFile,'r',encoding='utf8')
	manifest = []
	current = {}
Example #3
0
"""
Module to handle jar manifest files
"""
from jarmanifest import log, archives

logger = log.getLogger('util.manifest')
manifestkeys = None


def getManifestkeys():
    global manifestkeys
    if manifestkeys is None:
        logger.debug('Generating manifest keys')
        manifestkeys = list(
            map(str.lower, [
                'Name', 'Specification-Title', 'Specification-Vendor',
                'Specification-Version', 'Implementation-Title',
                'Implementation-Version', 'Implementation-Vendor',
                'Implementation-URL', 'Extension-Name', 'Comment'
            ]))
        manifestkeys = [i.replace('-', '') for i in manifestkeys]
    return manifestkeys


# From: http://docs.oracle.com/javase/1.4.2/docs/guide/jar/jar.html#Notes on Manifest and Signature Files
# No line may be longer than 72 bytes (not characters), in its
# UTF8-encoded form. If a value would make the initial line longer
# than this, it should be continued on extra lines
# (each starting with a single SPACE).
def getAttributes(manifestFile):
    logger.debug('Parsing attributes from %s' % (manifestFile))
#!/usr/bin/env python3

import tarfile
import zipfile
import subprocess
import os
from jarmanifest import log
from jarmanifest.configuration import config

logger = log.getLogger('util.archives')

ignore_no_ext = False
ignore_ext_list = []
if config.has_option('archives','ignore_no_ext'):
	ignore_no_ext = eval(config.get('archives','ignore_no_ext'))
if config.has_option('archives','ignore_ext_list'):
	ignore_ext_list = config.get('archives','ignore_ext_list').split(',')

# handler class for tars with invalid headers
# Some .tgz patchs eg: JBPAPP-8049.zip/JBPAPP-8049-signed.tgz tend
# to have things like '\x81' in its headers, raiseing a
# UnicodeDecodeError
# We fake the tarfile module using the sytems 'tar' binary
class custom_tarfile:
	def __init__(self,filename):
		self.command = 'tar'
		self.filename = os.path.abspath(filename)
		self.filelist = self.get_filelist()
		self.extracted = False

	def get_filelist(self):