def createBuild(baseDir, type, outFile=None, buildNum=None, releaseBuild=False, keyFile=None):
  metadata = readMetadata(baseDir, type)
  version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)

  if not outFile:
    outFile = getDefaultFileName(baseDir, metadata, version, 'safariextz' if keyFile else 'zip')

  params = {
    'type': type,
    'baseDir': baseDir,
    'releaseBuild': releaseBuild,
    'version': version,
    'devenv': False,
    'metadata': metadata,
  }

  requiredAssets = ()
  requiredAssetsPath = None
  if metadata.has_section('buildConfig'):
    requiredAssets = re.split(r'\s+', metadata.get('buildConfig', 'requiredAssets'))
    requiredAssetsPath = metadata.get('buildConfig', 'requiredAssetsPath')

  files = Files(getPackageFiles(params), getIgnoredFiles(params),
                requiredAssets=requiredAssets, requiredAssetsPath=requiredAssetsPath,
                process=lambda path, data: processFile(path, data, params))
  if metadata.has_section('mapping'):
    files.readMappedFiles(metadata.items('mapping'))
  files.read(baseDir)

  if metadata.has_section('convert_js'):
    convertJS(params, files)

  if metadata.has_section('convert_img'):
    from imageConversion import convertImages
    convertImages(params, files)

  if metadata.has_section('preprocess'):
    files.preprocess(
      [f for f, _ in metadata.items('preprocess')],
      {'needsExt': True}
    )

  if metadata.has_section('import_locales'):
    importGeckoLocales(params, files)

  files['lib/info.js'] = createInfoModule(params)
  files['background.html'] = createBackgroundPage(params)
  files['Info.plist'] = createManifest(params, files)

  fixAbsoluteUrls(files)

  dirname = metadata.get('general', 'basename') + '.safariextension'
  for filename in files.keys():
    files[os.path.join(dirname, filename)] = files.pop(filename)

  if keyFile:
    createSignedXarArchive(outFile, files, keyFile)
  else:
    files.zip(outFile)
def createBuild(baseDir,
                type,
                outFile=None,
                buildNum=None,
                releaseBuild=False,
                keyFile=None):
    metadata = readMetadata(baseDir, type)
    version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)

    if not outFile:
        outFile = getDefaultFileName(baseDir, metadata, version,
                                     'safariextz' if keyFile else 'zip')

    params = {
        'type': type,
        'baseDir': baseDir,
        'releaseBuild': releaseBuild,
        'version': version,
        'devenv': False,
        'metadata': metadata,
    }

    files = Files(getPackageFiles(params),
                  getIgnoredFiles(params),
                  process=lambda path, data: processFile(path, data, params))
    if metadata.has_section('mapping'):
        files.readMappedFiles(metadata.items('mapping'))
    files.read(baseDir)

    if metadata.has_section('convert_js'):
        convertJS(params, files)

    if metadata.has_section('convert_img'):
        from imageConversion import convertImages
        convertImages(params, files)

    if metadata.has_section('preprocess'):
        files.preprocess([f for f, _ in metadata.items('preprocess')],
                         {'needsExt': True})

    if metadata.has_section('import_locales'):
        importGeckoLocales(params, files)

    files['lib/info.js'] = createInfoModule(params)
    files['background.html'] = createBackgroundPage(params)
    files['Info.plist'] = createManifest(params, files)

    fixAbsoluteUrls(files)

    dirname = metadata.get('general', 'basename') + '.safariextension'
    for filename in files.keys():
        files[os.path.join(dirname, filename)] = files.pop(filename)

    if keyFile:
        createSignedXarArchive(outFile, files, keyFile)
    else:
        files.zip(outFile)
Beispiel #3
0
def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuild=False, keyFile=None, experimentalAPI=False, devenv=False):
  metadata = readMetadata(baseDir, type)
  version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)

  if outFile == None:
    outFile = getDefaultFileName(baseDir, metadata, version, 'crx' if keyFile else 'zip')

  params = {
    'type': type,
    'baseDir': baseDir,
    'releaseBuild': releaseBuild,
    'version': version,
    'experimentalAPI': experimentalAPI,
    'devenv': devenv,
    'metadata': metadata,
  }

  files = Files(getPackageFiles(params), getIgnoredFiles(params),
                process=lambda path, data: processFile(path, data, params))
  files['manifest.json'] = createManifest(params)
  if metadata.has_section('mapping'):
    files.readMappedFiles(metadata.items('mapping'))
  files.read(baseDir)

  if metadata.has_section('convert_js'):
    convertJS(params, files)

  if metadata.has_section('convert_img'):
    from imageConversion import convertImages
    convertImages(params, files)

  if metadata.has_section('preprocess'):
    files.preprocess(
      [f for f, _ in metadata.items('preprocess')],
      {'needsExt': True}
    )

  if metadata.has_section('import_locales'):
    importGeckoLocales(params, files)

  if devenv:
    files['devenvPoller__.js'] = createPoller(params)

  if (metadata.has_option('general', 'backgroundScripts') and
      'lib/info.js' in re.split(r'\s+', metadata.get('general', 'backgroundScripts')) and
      'lib/info.js' not in files):
    files['lib/info.js'] = createInfoModule(params)

  zipdata = files.zipToString()
  signature = None
  pubkey = None
  if keyFile != None:
    signature = signBinary(zipdata, keyFile)
    pubkey = getPublicKey(keyFile)
  writePackage(outFile, pubkey, signature, zipdata)
Beispiel #4
0
def createBuild(baseDir, type, outFile=None, buildNum=None, releaseBuild=False, keyFile=None, devenv=False):
  metadata = readMetadata(baseDir, type)
  version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)

  if not outFile:
    outFile = getDefaultFileName(metadata, version, 'safariextz' if keyFile else 'zip')

  params = {
    'type': type,
    'baseDir': baseDir,
    'releaseBuild': releaseBuild,
    'version': version,
    'devenv': devenv,
    'metadata': metadata,
  }

  mapped = metadata.items('mapping') if metadata.has_section('mapping') else []
  files = Files(getPackageFiles(params), getIgnoredFiles(params),
                process=lambda path, data: processFile(path, data, params))
  files.readMappedFiles(mapped)
  files.read(baseDir, skip=[opt for opt, _ in mapped])

  if metadata.has_section('convert_js'):
    convertJS(params, files)

  if metadata.has_section('convert_img'):
    from imageConversion import convertImages
    convertImages(params, files)

  if metadata.has_section('preprocess'):
    files.preprocess(
      [f for f, _ in metadata.items('preprocess')],
      {'needsExt': True}
    )

  if metadata.has_section('import_locales'):
    importGeckoLocales(params, files)

  if metadata.has_option('general', 'testScripts'):
    files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl',
                                                 ('general', 'testScripts'))

  if keyFile:
    certs, key = get_certificates_and_key(keyFile)
    params['developerIdentifier'] = get_developer_identifier(certs)

  files['lib/info.js'] = createInfoModule(params)
  files['background.html'] = createScriptPage(params, 'background.html.tmpl',
                                              ('general', 'backgroundScripts'))
  files['Info.plist'] = createManifest(params, files)

  fixAbsoluteUrls(files)

  dirname = metadata.get('general', 'basename') + '.safariextension'
  for filename in files.keys():
    files[os.path.join(dirname, filename)] = files.pop(filename)

  if not devenv and keyFile:
    createSignedXarArchive(outFile, files, certs, key)
  else:
    files.zip(outFile)
Beispiel #5
0
def createBuild(baseDir,
                type='chrome',
                outFile=None,
                buildNum=None,
                releaseBuild=False,
                keyFile=None,
                experimentalAPI=False,
                devenv=False):
    metadata = readMetadata(baseDir, type)
    version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)

    if outFile == None:
        outFile = getDefaultFileName(metadata, version,
                                     'crx' if keyFile else 'zip')

    params = {
        'type': type,
        'baseDir': baseDir,
        'releaseBuild': releaseBuild,
        'version': version,
        'experimentalAPI': experimentalAPI,
        'devenv': devenv,
        'metadata': metadata,
    }

    files = Files(getPackageFiles(params),
                  getIgnoredFiles(params),
                  process=lambda path, data: processFile(path, data, params))

    if metadata.has_section('mapping'):
        files.readMappedFiles(metadata.items('mapping'))
    files.read(baseDir)

    if metadata.has_section('convert_js'):
        convertJS(params, files)

    if metadata.has_section('convert_img'):
        from imageConversion import convertImages
        convertImages(params, files)

    if metadata.has_section('preprocess'):
        files.preprocess([f for f, _ in metadata.items('preprocess')],
                         {'needsExt': True})

    if metadata.has_section('import_locales'):
        importGeckoLocales(params, files)

    files['manifest.json'] = createManifest(params, files)
    if type == 'chrome':
        fixTranslationsForCWS(files)

    if devenv:
        import buildtools
        import random
        files.read(os.path.join(buildtools.__path__[0],
                                'chromeDevenvPoller__.js'),
                   relpath='devenvPoller__.js')
        files['devenvVersion__'] = str(random.random())

    if (metadata.has_option('general', 'backgroundScripts')
            and 'lib/info.js' in re.split(
                r'\s+', metadata.get('general', 'backgroundScripts'))
            and 'lib/info.js' not in files):
        files['lib/info.js'] = createInfoModule(params)

    zipdata = files.zipToString()
    signature = None
    pubkey = None
    if keyFile != None:
        signature = signBinary(zipdata, keyFile)
        pubkey = getPublicKey(keyFile)
    writePackage(outFile, pubkey, signature, zipdata)
Beispiel #6
0
def createBuild(baseDir, type='chrome', outFile=None, buildNum=None, releaseBuild=False, keyFile=None, experimentalAPI=False, devenv=False):
  metadata = readMetadata(baseDir, type)
  version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)

  if outFile == None:
    outFile = getDefaultFileName(metadata, version, 'crx' if keyFile else 'zip')

  params = {
    'type': type,
    'baseDir': baseDir,
    'releaseBuild': releaseBuild,
    'version': version,
    'experimentalAPI': experimentalAPI,
    'devenv': devenv,
    'metadata': metadata,
  }

  mapped = metadata.items('mapping') if metadata.has_section('mapping') else []
  files = Files(getPackageFiles(params), getIgnoredFiles(params),
                process=lambda path, data: processFile(path, data, params))

  files.readMappedFiles(mapped)
  files.read(baseDir, skip=[opt for opt, _ in mapped])

  if metadata.has_section('convert_js'):
    convertJS(params, files)

  if metadata.has_section('convert_img'):
    from imageConversion import convertImages
    convertImages(params, files)

  if metadata.has_section('preprocess'):
    files.preprocess(
      [f for f, _ in metadata.items('preprocess')],
      {'needsExt': True}
    )

  if metadata.has_section('import_locales'):
    importGeckoLocales(params, files)

  files['manifest.json'] = createManifest(params, files)
  if type == 'chrome':
    fixTranslationsForCWS(files)

  if devenv:
    import buildtools
    import random
    files.read(os.path.join(buildtools.__path__[0], 'chromeDevenvPoller__.js'), relpath='devenvPoller__.js')
    files['devenvVersion__'] = str(random.random())

  if (metadata.has_option('general', 'backgroundScripts') and
      'lib/info.js' in metadata.get('general', 'backgroundScripts').split() and
      'lib/info.js' not in files):
    files['lib/info.js'] = createInfoModule(params)

  if metadata.has_option('general', 'testScripts'):
    files['qunit/index.html'] = createScriptPage(params, 'testIndex.html.tmpl',
                                                 ('general', 'testScripts'))

  zipdata = files.zipToString()
  signature = None
  pubkey = None
  if keyFile != None:
    signature = signBinary(zipdata, keyFile)
    pubkey = getPublicKey(keyFile)
  writePackage(outFile, pubkey, signature, zipdata)