def readChromeMetadata(self): """ Read Chrome-specific metadata from metadata file. This will also calculate extension ID from the private key. """ # Calculate extension ID from public key # (see http://supercollider.dk/2010/01/calculating-chrome-extension-id-from-your-private-key-233) import buildtools.packagerChrome as packager publicKey = packager.getPublicKey(self.config.keyFile) hash = hashlib.sha256() hash.update(publicKey) self.extensionID = hash.hexdigest()[0:32] self.extensionID = ''.join( map(lambda c: chr(97 + int(c, 16)), self.extensionID)) # Now read metadata file metadata = packager.readMetadata(self.tempdir, self.config.type) self.version = packager.getBuildVersion(self.tempdir, metadata, False, self.buildNum) self.basename = metadata.get('general', 'basename') self.compat = [] if metadata.has_section('compat') and metadata.has_option( 'compat', 'chrome'): self.compat.append({ 'id': 'chrome', 'minVersion': metadata.get('compat', 'chrome') })
def read_edge_metadata(self): """ Read Edge-specific metadata from metadata file. """ from buildtools import packager # Now read metadata file metadata = packager.readMetadata(self.tempdir, self.config.type) self.version = packager.getBuildVersion(self.tempdir, metadata, False, self.buildNum) self.basename = metadata.get('general', 'basename') self.compat = []
def readSafariMetadata(self): import sitescripts.extensions.bin.legacy.packagerSafari as packager from sitescripts.extensions.bin.legacy import xarfile metadata = packager.readMetadata(self.tempdir, self.config.type) certs = xarfile.read_certificates_and_key(self.config.keyFile)[0] self.certificateID = packager.get_developer_identifier(certs) self.version = packager.getBuildVersion(self.tempdir, metadata, False, self.buildNum) self.shortVersion = metadata.get('general', 'version') self.basename = metadata.get('general', 'basename') self.updatedFromGallery = False
def readGeckoMetadata(self): """ read Gecko-specific metadata file from a cloned repository and parse id, version, basename and the compat section out of the file """ import buildtools.packagerChrome as packager metadata = packager.readMetadata(self.tempdir, self.config.type) self.extensionID = packager.get_app_id(False, metadata) self.version = packager.getBuildVersion(self.tempdir, metadata, False, self.buildNum) self.basename = metadata.get('general', 'basename') self.min_version = metadata.get('compat', 'gecko')
def run(baseDir, sourceDir): import buildtools.packagerGecko as packagerGecko import buildtools.packagerChrome as packagerChrome sourceLocales = packagerGecko.getLocalesDir(sourceDir) if not os.path.isdir(sourceLocales): raise IOError('Directory %s not found' % sourceLocales) targetLocales = os.path.join(baseDir, '_locales') metadata = packagerChrome.readMetadata(baseDir) removed = [] if metadata.has_option('locale_sync', 'remove'): for key in re.split(r'\s+', metadata.get('locale_sync', 'remove')): removed.append(key) imported = [] for file, keys in metadata.items('locale_sync'): if file == 'remove': continue imported.append((file, re.split(r'\s+', keys))) syncLocales(sourceLocales, targetLocales, removed, imported)