Ejemplo n.º 1
0
def repackage_dmg(infile, output):

    if not tarfile.is_tarfile(infile):
        raise Exception("Input file %s is not a valid tarfile." % infile)

    tmpdir = tempfile.mkdtemp()
    try:
        with tarfile.open(infile) as tar:
            tar.extractall(path=tmpdir)

        # Remove the /Applications symlink. If we don't, an rsync command in
        # create_dmg() will break, and create_dmg() re-creates the symlink anyway.
        try:
            os.remove(mozpath.join(tmpdir, ' '))
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise

        volume_name = get_application_ini_value(tmpdir, 'App', 'CodeName')

        # The extra_files argument is empty [] because they are already a part
        # of the original dmg produced by the build, and they remain in the
        # tarball generated by the signing task.
        create_dmg(tmpdir, output, volume_name, [])

    finally:
        shutil.rmtree(tmpdir)
Ejemplo n.º 2
0
def repackage_dmg(infile, output):

    if not tarfile.is_tarfile(infile):
        raise Exception("Input file %s is not a valid tarfile." % infile)

    tmpdir = tempfile.mkdtemp()
    try:
        with tarfile.open(infile) as tar:
            tar.extractall(path=tmpdir)

        # Remove the /Applications symlink. If we don't, an rsync command in
        # create_dmg() will break, and create_dmg() re-creates the symlink anyway.
        try:
            os.remove(mozpath.join(tmpdir, ' '))
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise

        volume_name = get_application_ini_value(tmpdir,
                                                'App',
                                                'CodeName',
                                                fallback='Name')

        # The extra_files argument is empty [] because they are already a part
        # of the original dmg produced by the build, and they remain in the
        # tarball generated by the signing task.
        create_dmg(tmpdir, output, volume_name, [])

    finally:
        shutil.rmtree(tmpdir)
Ejemplo n.º 3
0
def repackage_mar(topsrcdir, package, mar, output):
    if not zipfile.is_zipfile(package):
        raise Exception("Package file %s is not a valid .zip file." % package)

    ensureParentDir(output)
    tmpdir = tempfile.mkdtemp()
    try:
        z = zipfile.ZipFile(package)
        z.extractall(tmpdir)
        filelist = z.namelist()
        z.close()

        # Make sure the .zip file just contains a directory like 'firefox/' at
        # the top, and find out what it is called.
        toplevel_dirs = set([mozpath.split(f)[0] for f in filelist])
        if len(toplevel_dirs) != 1:
            raise Exception("Package file is expected to have a single top-level directory (eg: 'firefox'), not: %s" % toplevel_dirs)
        ffxdir = mozpath.join(tmpdir, toplevel_dirs.pop())

        make_full_update = mozpath.join(topsrcdir, 'tools/update-packaging/make_full_update.sh')

        env = os.environ.copy()
        env['MOZ_FULL_PRODUCT_VERSION'] = get_application_ini_value(tmpdir, 'App', 'Version')
        env['MAR'] = mozpath.normpath(mar)

        cmd = [make_full_update, output, ffxdir]
        if sys.platform == 'win32':
            # make_full_update.sh is a bash script, and Windows needs to
            # explicitly call out the shell to execute the script from Python.
            cmd.insert(0, env['MOZILLABUILD'] + '/msys/bin/bash.exe')
        subprocess.check_call(cmd, env=env)

    finally:
        shutil.rmtree(tmpdir)
Ejemplo n.º 4
0
def repackage_mar(topsrcdir, package, mar, output, mar_format='lzma'):
    if not zipfile.is_zipfile(package) and not tarfile.is_tarfile(package):
        raise Exception("Package file %s is not a valid .zip or .tar file." %
                        package)

    ensureParentDir(output)
    tmpdir = tempfile.mkdtemp()
    try:
        if zipfile.is_zipfile(package):
            z = zipfile.ZipFile(package)
            z.extractall(tmpdir)
            filelist = z.namelist()
            z.close()
        else:
            z = tarfile.open(package)
            z.extractall(tmpdir)
            filelist = z.getnames()
            z.close()

        toplevel_dirs = set([mozpath.split(f)[0] for f in filelist])
        excluded_stuff = set(
            [' ', '.background', '.DS_Store', '.VolumeIcon.icns'])
        toplevel_dirs = toplevel_dirs - excluded_stuff
        # Make sure the .zip file just contains a directory like 'firefox/' at
        # the top, and find out what it is called.
        if len(toplevel_dirs) != 1:
            raise Exception(
                "Package file is expected to have a single top-level directory"
                "(eg: 'firefox'), not: %s" % toplevel_dirs)
        ffxdir = mozpath.join(tmpdir, toplevel_dirs.pop())

        make_full_update = mozpath.join(
            topsrcdir, 'tools/update-packaging/make_full_update.sh')

        env = os.environ.copy()
        env['MOZ_FULL_PRODUCT_VERSION'] = get_application_ini_value(
            tmpdir, 'App', 'Version')
        env['MAR'] = mozpath.normpath(mar)
        if mar_format == 'bz2':
            env['MAR_OLD_FORMAT'] = '1'
        # The Windows build systems have xz installed but it isn't in the path
        # like it is on Linux and Mac OS X so just use the XZ env var so the mar
        # generation scripts can find it.
        xz_path = mozpath.join(topsrcdir, 'xz/xz.exe')
        if os.path.exists(xz_path):
            env['XZ'] = mozpath.normpath(xz_path)

        cmd = [make_full_update, output, ffxdir]
        if sys.platform == 'win32':
            # make_full_update.sh is a bash script, and Windows needs to
            # explicitly call out the shell to execute the script from Python.
            cmd.insert(0, env['MOZILLABUILD'] + '/msys/bin/bash.exe')
        subprocess.check_call(cmd, env=env)

    finally:
        shutil.rmtree(tmpdir)