Exemplo n.º 1
0
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)
Exemplo n.º 2
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('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)
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)
Exemplo n.º 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("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:
        from buildtools import xarfile

        certs, key = xarfile.read_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:
        from buildtools import xarfile

        xarfile.create(outFile, files, keyFile)
    else:
        files.zip(outFile)
Exemplo n.º 5
0
def createBuild(baseDir, type='edge', outFile=None,  # noqa: preserve API.
                buildNum=None, releaseBuild=False, keyFile=None,
                devenv=False):

    metadata = packager.readMetadata(baseDir, type)
    version = packager.getBuildVersion(baseDir, metadata, releaseBuild,
                                       buildNum)

    outfile = outFile or packager.getDefaultFileName(metadata, version, 'appx')

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

    files = packager.Files(packagerChrome.getPackageFiles(params),
                           packagerChrome.getIgnoredFiles(params))

    if metadata.has_section('mapping'):
        mapped = metadata.items('mapping')
        files.readMappedFiles(mapped)
        files.read(baseDir, skip=[filename for filename, _ in mapped])
    else:
        files.read(baseDir)

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

    if metadata.has_section('preprocess'):
        files.preprocess(metadata.options('preprocess'), {'needsExt': True})

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

    files['manifest.json'] = packagerChrome.createManifest(params, files)

    move_files_to_extension(files)

    if metadata.has_section('appx_assets'):
        for name, path in metadata.items('appx_assets'):
            path = os.path.join(baseDir, path)
            files.read(path, '{}/{}'.format(ASSETS_DIR, name))

    files[MANIFEST] = create_appx_manifest(params, files, releaseBuild)
    files[BLOCKMAP] = create_appx_blockmap(files)
    files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP])

    files.zip(outfile, compression=zipfile.ZIP_STORED)
Exemplo n.º 6
0
def createBuild(baseDir, type='edge', outFile=None,  # noqa: preserve API.
                buildNum=None, releaseBuild=False, keyFile=None,
                devenv=False):

    metadata = packager.readMetadata(baseDir, type)
    version = packager.getBuildVersion(baseDir, metadata, releaseBuild,
                                       buildNum)

    outfile = outFile or packager.getDefaultFileName(metadata, version, 'appx')

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

    files = packager.Files(packagerChrome.getPackageFiles(params),
                           packagerChrome.getIgnoredFiles(params))

    if metadata.has_section('mapping'):
        mapped = metadata.items('mapping')
        files.readMappedFiles(mapped)
        files.read(baseDir, skip=[filename for filename, _ in mapped])
    else:
        files.read(baseDir)

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

    if metadata.has_section('preprocess'):
        files.preprocess(metadata.options('preprocess'), {'needsExt': True})

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

    files['manifest.json'] = packagerChrome.createManifest(params, files)

    move_files_to_extension(files)

    if metadata.has_section('appx_assets'):
        for name, path in metadata.items('appx_assets'):
            path = os.path.join(baseDir, path)
            files.read(path, '{}/{}'.format(ASSETS_DIR, name))

    files[MANIFEST] = create_appx_manifest(params, files, releaseBuild)
    files[BLOCKMAP] = create_appx_blockmap(files)
    files[CONTENT_TYPES] = create_content_types_map(files.keys() + [BLOCKMAP])

    files.zip(outfile, compression=zipfile.ZIP_STORED)
Exemplo n.º 7
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('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:
        from buildtools import xarfile
        certs, key = xarfile.read_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)

    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:
        from buildtools import xarfile
        xarfile.create(outFile, files, keyFile)
    else:
        files.zip(outFile)