def run(baseDir, version, keyFile, downloadsRepo):
  # Replace version number in metadata file "manually", ConfigParser will mess
  # up the order of lines.
  handle = open(packager.getMetadataPath(baseDir), 'rb')
  rawMetadata = handle.read()
  handle.close()
  versionRegExp = re.compile(r'^(\s*version\s*=\s*).*', re.I | re.M)
  rawMetadata = re.sub(versionRegExp, r'\g<1>%s' % version, rawMetadata)
  handle = open(packager.getMetadataPath(baseDir), 'wb')
  handle.write(rawMetadata)
  handle.close()

  # Read extension name and branch name
  locales = packager.readLocaleMetadata(baseDir, [packager.defaultLocale])
  extensionName = locales[packager.defaultLocale]['name']

  metadata = packager.readMetadata(baseDir)

  # Now commit the change and tag it
  subprocess.Popen(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)]).communicate()
  subprocess.Popen(['hg', 'tag', '-R', baseDir, '-f', version]).communicate()

  # Create a release build
  buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version))
  packager.createBuild(baseDir, outFile=buildPath, releaseBuild=True, keyFile=keyFile)

  # Create source archive
  archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'

  archiveHandle = open(archivePath, 'wb')
  archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePath), mode='w:gz')
  (data, dummy) = subprocess.Popen(['hg', 'archive', '-R', baseDir, '-t', 'tar', '-S', '-'], stdout=subprocess.PIPE).communicate()
  repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
  for fileInfo in repoArchive:
    if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
      continue
    fileData = repoArchive.extractfile(fileInfo)
    fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
    archive.addfile(fileInfo, fileData)
  repoArchive.close()
  archive.close()
  archiveHandle.close()

  # Now add the downloads and commit
  subprocess.Popen(['hg', 'add', '-R', downloadsRepo, buildPath, archivePath]).communicate()
  subprocess.Popen(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)]).communicate()

  # Push all changes
  subprocess.Popen(['hg', 'push', '-R', baseDir]).communicate()
  subprocess.Popen(['hg', 'push', '-R', downloadsRepo]).communicate()
def run(baseDir, type, version, keyFile, downloadsRepo):
    if type == "gecko":
        import buildtools.packagerGecko as packager
    elif type == "chrome":
        import buildtools.packagerChrome as packager

    # Replace version number in metadata file "manually", ConfigParser will mess
    # up the order of lines.
    handle = open(packager.getMetadataPath(baseDir, type), 'rb')
    rawMetadata = handle.read()
    handle.close()
    versionRegExp = re.compile(r'^(\s*version\s*=\s*).*', re.I | re.M)
    rawMetadata = re.sub(versionRegExp, r'\g<1>%s' % version, rawMetadata)
    handle = open(packager.getMetadataPath(baseDir, type), 'wb')
    handle.write(rawMetadata)
    handle.close()

    # Read extension name from locale data
    import buildtools.packagerGecko as packagerGecko
    if type == "gecko":
        locales_base = baseDir
    else:
        # This is somewhat of a hack but reading out locale import config here would be too much
        locales_base = os.path.join(baseDir, "adblockplus")

    locales = packagerGecko.readLocaleMetadata(locales_base,
                                               [packagerGecko.defaultLocale])
    extensionName = locales[packagerGecko.defaultLocale]['name']

    # Now commit the change and tag it
    subprocess.check_call([
        'hg', 'commit', '-R', baseDir, '-m',
        'Releasing %s %s' % (extensionName, version)
    ])
    subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version])

    # Create a release build
    downloads = []
    if type == "gecko":
        metadata = packager.readMetadata(baseDir, type)
        buildPath = os.path.join(
            downloadsRepo,
            packager.getDefaultFileName(baseDir, metadata, version, 'xpi'))
        packager.createBuild(baseDir,
                             type=type,
                             outFile=buildPath,
                             releaseBuild=True,
                             keyFile=keyFile)
        downloads.append(buildPath)
    elif type == "chrome":
        # We actually have to create three different builds for Chrome: signed a unsigned Chrome builds
        # (the latter for Chrome Web Store) and a signed Opera build.
        metadata = packager.readMetadata(baseDir, type)
        buildPath = os.path.join(
            downloadsRepo,
            packager.getDefaultFileName(baseDir, metadata, version, 'crx'))
        packager.createBuild(baseDir,
                             type=type,
                             outFile=buildPath,
                             releaseBuild=True,
                             keyFile=keyFile)
        downloads.append(buildPath)

        buildPathUnsigned = os.path.join(
            baseDir,
            packager.getDefaultFileName(baseDir, metadata, version, 'zip'))
        packager.createBuild(baseDir,
                             type=type,
                             outFile=buildPathUnsigned,
                             releaseBuild=True,
                             keyFile=None)

        metadataOpera = packager.readMetadata(baseDir, "opera")
        buildPathOpera = os.path.join(
            downloadsRepo,
            packager.getDefaultFileName(baseDir, metadataOpera, version,
                                        'crx'))
        packager.createBuild(baseDir,
                             type="opera",
                             outFile=buildPathOpera,
                             releaseBuild=True,
                             keyFile=keyFile)
        downloads.append(buildPathOpera)

    # Create source archive
    archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'

    archiveHandle = open(archivePath, 'wb')
    archive = tarfile.open(fileobj=archiveHandle,
                           name=os.path.basename(archivePath),
                           mode='w:gz')
    data = subprocess.check_output(
        ['hg', 'archive', '-R', baseDir, '-t', 'tar', '-S', '-'])
    repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
    for fileInfo in repoArchive:
        if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
            continue
        fileData = repoArchive.extractfile(fileInfo)
        fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
        archive.addfile(fileInfo, fileData)
    repoArchive.close()
    archive.close()
    archiveHandle.close()
    downloads.append(archivePath)

    # Now add the downloads and commit
    subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
    subprocess.check_call([
        'hg', 'commit', '-R', downloadsRepo, '-m',
        'Releasing %s %s' % (extensionName, version)
    ])

    # Push all changes
    subprocess.check_call(['hg', 'push', '-R', baseDir])
    subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
def run(baseDir, type, version, keyFiles, downloadsRepo):
  if type == "gecko":
    import buildtools.packagerGecko as packager
  elif type == "chrome":
    import buildtools.packagerChrome as packager

  # Replace version number in metadata file "manually", ConfigParser will mess
  # up the order of lines.
  metadata = packager.readMetadata(baseDir, type)
  with open(metadata.option_source("general", "version"), 'r+b') as file:
    rawMetadata = file.read()
    rawMetadata = re.sub(
      r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
      rawMetadata, flags=re.I | re.M
    )

    file.seek(0)
    file.write(rawMetadata)
    file.truncate()

  # Read extension name from locale data
  import buildtools.packagerGecko as packagerGecko
  if type == "gecko":
    locales_base = baseDir
  else:
    # This is somewhat of a hack but reading out locale import config here would be too much
    locales_base = os.path.join(baseDir, "adblockcash")

  locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaultLocale])
  extensionName = locales[packagerGecko.defaultLocale]['name']

  # Now commit the change and tag it
  subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)])
  subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version])

  # Create a release build
  downloads = []
  if type == "gecko":
    keyFile = keyFiles[0] if keyFiles else None
    metadata = packager.readMetadata(baseDir, type)
    buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'xpi'))
    packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFile)
    downloads.append(buildPath)
  elif type == "chrome":
    # We actually have to create four different builds for Chrome: signed a unsigned Chrome builds
    # (the latter for Chrome Web Store), a signed Opera build and a signed Safari build.
    metadata = packager.readMetadata(baseDir, type)
    buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'crx'))
    packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFiles[0])
    downloads.append(buildPath)

    buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(baseDir, metadata, version, 'zip'))
    packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, releaseBuild=True, keyFile=None)

    metadataOpera = packager.readMetadata(baseDir, "opera")
    buildPathOpera = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadataOpera, version, 'crx'))
    packager.createBuild(baseDir, type="opera", outFile=buildPathOpera, releaseBuild=True, keyFile=keyFiles[0])
    downloads.append(buildPathOpera)

    import buildtools.packagerSafari as packagerSafari
    metadataSafari = packagerSafari.readMetadata(baseDir, "safari")
    buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileName(baseDir, metadataSafari, version, 'safariextz'))
    packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1])
    downloads.append(buildPathSafari)

  # Create source archive
  archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
  create_sourcearchive(baseDir, archivePath)
  downloads.append(archivePath)

  # Now add the downloads and commit
  subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
  subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)])

  # Push all changes
  subprocess.check_call(['hg', 'push', '-R', baseDir])
  subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
def run(baseDir, version, keyFile, downloadsRepo):
    # Replace version number in metadata file "manually", ConfigParser will mess
    # up the order of lines.
    handle = open(packager.getMetadataPath(baseDir), 'rb')
    rawMetadata = handle.read()
    handle.close()
    versionRegExp = re.compile(r'^(\s*version\s*=\s*).*', re.I | re.M)
    rawMetadata = re.sub(versionRegExp, r'\g<1>%s' % version, rawMetadata)
    handle = open(packager.getMetadataPath(baseDir), 'wb')
    handle.write(rawMetadata)
    handle.close()

    # Read extension name and branch name
    locales = packager.readLocaleMetadata(baseDir, [packager.defaultLocale])
    extensionName = locales[packager.defaultLocale]['name']

    metadata = packager.readMetadata(baseDir)

    # Now commit the change and tag it
    subprocess.Popen([
        'hg', 'commit', '-R', baseDir, '-m',
        'Releasing %s %s' % (extensionName, version)
    ]).communicate()
    subprocess.Popen(['hg', 'tag', '-R', baseDir, '-f', version]).communicate()

    # Create a release build
    buildPath = os.path.join(
        downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version))
    packager.createBuild(baseDir,
                         outFile=buildPath,
                         releaseBuild=True,
                         keyFile=keyFile)

    # Create source archive
    archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'

    archiveHandle = open(archivePath, 'wb')
    archive = tarfile.open(fileobj=archiveHandle,
                           name=os.path.basename(archivePath),
                           mode='w:gz')
    (data, dummy) = subprocess.Popen(
        ['hg', 'archive', '-R', baseDir, '-t', 'tar', '-S', '-'],
        stdout=subprocess.PIPE).communicate()
    repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
    for fileInfo in repoArchive:
        if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
            continue
        fileData = repoArchive.extractfile(fileInfo)
        fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
        archive.addfile(fileInfo, fileData)
    repoArchive.close()
    archive.close()
    archiveHandle.close()

    # Now add the downloads and commit
    subprocess.Popen(
        ['hg', 'add', '-R', downloadsRepo, buildPath,
         archivePath]).communicate()
    subprocess.Popen([
        'hg', 'commit', '-R', downloadsRepo, '-m',
        'Releasing %s %s' % (extensionName, version)
    ]).communicate()

    # Push all changes
    subprocess.Popen(['hg', 'push', '-R', baseDir]).communicate()
    subprocess.Popen(['hg', 'push', '-R', downloadsRepo]).communicate()
def run(baseDir, type, version, keyFiles, downloadsRepo):
    if type == "gecko":
        import buildtools.packagerGecko as packager
    elif type == "chrome":
        import buildtools.packagerChrome as packager

    # Replace version number in metadata file "manually", ConfigParser will mess
    # up the order of lines.
    metadata = packager.readMetadata(baseDir, type)
    with open(metadata.option_source("general", "version"), 'r+b') as file:
        rawMetadata = file.read()
        rawMetadata = re.sub(
            r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
            rawMetadata, flags=re.I | re.M
        )

        file.seek(0)
        file.write(rawMetadata)
        file.truncate()

    # Read extension name from locale data
    import buildtools.packagerGecko as packagerGecko
    if type == "gecko":
        locales_base = baseDir
    else:
        # This is somewhat of a hack but reading out locale import config here would be too much
        locales_base = os.path.join(baseDir, "adblockplus")

    locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaultLocale])
    extensionName = locales[packagerGecko.defaultLocale]['name']

    # Now commit the change and tag it
    subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)])
    subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version])

    # Create a release build
    downloads = []
    if type == "gecko":
        keyFile = keyFiles[0] if keyFiles else None
        metadata = packager.readMetadata(baseDir, type)
        buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(metadata, version, 'xpi'))
        packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFile)
        downloads.append(buildPath)
    elif type == "chrome":
        # We actually have to create three different builds: signed and unsigned
        # Chrome builds (the latter for Chrome Web Store), and a signed Safari build.
        metadata = packager.readMetadata(baseDir, type)
        buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(metadata, version, 'crx'))
        packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFiles[0])
        downloads.append(buildPath)

        buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(metadata, version, 'zip'))
        packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, releaseBuild=True, keyFile=None)

        import buildtools.packagerSafari as packagerSafari
        metadataSafari = packagerSafari.readMetadata(baseDir, "safari")
        buildPathSafari = os.path.join(downloadsRepo, packagerSafari.getDefaultFileName(metadataSafari, version, 'safariextz'))
        packagerSafari.createBuild(baseDir, type="safari", outFile=buildPathSafari, releaseBuild=True, keyFile=keyFiles[1])
        downloads.append(buildPathSafari)

    # Create source archive
    archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'
    create_sourcearchive(baseDir, archivePath)
    downloads.append(archivePath)

    # Now add the downloads and commit
    subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
    subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)])

    # Push all changes
    subprocess.check_call(['hg', 'push', '-R', baseDir])
    subprocess.check_call(['hg', 'push', '-R', downloadsRepo])
Ejemplo n.º 6
0
def run(baseDir, type, version, keyFile, downloadsRepo):
  if type == "gecko":
    import buildtools.packagerGecko as packager
  elif type == "chrome":
    import buildtools.packagerChrome as packager

  # Replace version number in metadata file "manually", ConfigParser will mess
  # up the order of lines.
  metadata = packager.readMetadata(baseDir, type)
  with open(metadata.option_source("general", "version"), 'r+b') as file:
    rawMetadata = file.read()
    rawMetadata = re.sub(
      r'^(\s*version\s*=\s*).*', r'\g<1>%s' % version,
      rawMetadata, flags=re.I | re.M
    )

    file.seek(0)
    file.write(rawMetadata)
    file.truncate()

  # Read extension name from locale data
  import buildtools.packagerGecko as packagerGecko
  if type == "gecko":
    locales_base = baseDir
  else:
    # This is somewhat of a hack but reading out locale import config here would be too much
    locales_base = os.path.join(baseDir, "adblockplus")

  locales = packagerGecko.readLocaleMetadata(locales_base, [packagerGecko.defaultLocale])
  extensionName = locales[packagerGecko.defaultLocale]['name']

  # Now commit the change and tag it
  subprocess.check_call(['hg', 'commit', '-R', baseDir, '-m', 'Releasing %s %s' % (extensionName, version)])
  subprocess.check_call(['hg', 'tag', '-R', baseDir, '-f', version])

  # Create a release build
  downloads = []
  if type == "gecko":
    metadata = packager.readMetadata(baseDir, type)
    buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'xpi'))
    packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFile)
    downloads.append(buildPath)
  elif type == "chrome":
    # We actually have to create three different builds for Chrome: signed a unsigned Chrome builds
    # (the latter for Chrome Web Store) and a signed Opera build.
    metadata = packager.readMetadata(baseDir, type)
    buildPath = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadata, version, 'crx'))
    packager.createBuild(baseDir, type=type, outFile=buildPath, releaseBuild=True, keyFile=keyFile)
    downloads.append(buildPath)

    buildPathUnsigned = os.path.join(baseDir, packager.getDefaultFileName(baseDir, metadata, version, 'zip'))
    packager.createBuild(baseDir, type=type, outFile=buildPathUnsigned, releaseBuild=True, keyFile=None)

    metadataOpera = packager.readMetadata(baseDir, "opera")
    buildPathOpera = os.path.join(downloadsRepo, packager.getDefaultFileName(baseDir, metadataOpera, version, 'crx'))
    packager.createBuild(baseDir, type="opera", outFile=buildPathOpera, releaseBuild=True, keyFile=keyFile)
    downloads.append(buildPathOpera)

  # Create source archive
  archivePath = os.path.splitext(buildPath)[0] + '-source.tgz'

  archiveHandle = open(archivePath, 'wb')
  archive = tarfile.open(fileobj=archiveHandle, name=os.path.basename(archivePath), mode='w:gz')
  data = subprocess.check_output(['hg', 'archive', '-R', baseDir, '-t', 'tar', '-S', '-'])
  repoArchive = tarfile.open(fileobj=StringIO(data), mode='r:')
  for fileInfo in repoArchive:
    if os.path.basename(fileInfo.name) in ('.hgtags', '.hgignore'):
      continue
    fileData = repoArchive.extractfile(fileInfo)
    fileInfo.name = re.sub(r'^[^/]+/', '', fileInfo.name)
    archive.addfile(fileInfo, fileData)
  repoArchive.close()
  archive.close()
  archiveHandle.close()
  downloads.append(archivePath)

  # Now add the downloads and commit
  subprocess.check_call(['hg', 'add', '-R', downloadsRepo] + downloads)
  subprocess.check_call(['hg', 'commit', '-R', downloadsRepo, '-m', 'Releasing %s %s' % (extensionName, version)])

  # Push all changes
  subprocess.check_call(['hg', 'push', '-R', baseDir])
  subprocess.check_call(['hg', 'push', '-R', downloadsRepo])