Пример #1
0
def mk_source_cdrom(components, codename,
                    init_codename, target,
                    cdrom_size=CDROM_SIZE, xml=None,
                    mirror='http://ftp.de.debian.org/debian'):

    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-branches

    hostfs.mkdir_p('/var/cache/elbe/sources')

    forbiddenPackages = []
    if xml is not None and xml.has('target/pkg-list'):
        for i in xml.node('target/pkg-list'):
            try:
                if i.tag == 'pkg' and i.et.attrib['on_src_cd'] == 'False':
                    forbiddenPackages.append(i.text('.').strip())
            except KeyError:
                pass

    repos = {}

    for component in components.keys():
        rfs, cache, pkg_lst = components[component]
        logging.info("Adding %s component", component)
        rfs.mkdir_p("/var/cache/elbe/sources")
        repo = CdromSrcRepo(codename, init_codename,
                            os.path.join(target, "srcrepo-%s" % component),
                            cdrom_size, mirror)
        repos[component] = repo
        for pkg, version in pkg_lst:
            add_source_pkg(repo, component,
                           cache, pkg, version,
                           forbiddenPackages)

    # elbe fetch_initvm_pkgs has downloaded all sources to
    # /var/cache/elbe/sources
    # use walk_files to scan it, and add all dsc files.
    #
    # we can not just copy the source repo, like we do
    # with the bin repo, because the src cdrom can be split
    # into multiple cdroms

    initvm_repo = Filesystem('/var/cache/elbe/sources')

    for _ , dsc_real in initvm_repo.walk_files():
        if not dsc_real.endswith('.dsc'):
            continue

        repos["main"].include_init_dsc(dsc_real, "initvm")

    for repo in repos.values():
        repo.finalize()

    if xml is not None:
        options = get_iso_options(xml)

        for arch_vol in xml.all('src-cdrom/archive'):
            volume_attr = arch_vol.et.get('volume')

            for repo in repos.values():

                if volume_attr == 'all':
                    volume_list = repo.volume_indexes
                else:
                    volume_list = [int(v) for v in volume_attr.split(",")]
                for volume_number in volume_list:
                    with archive_tmpfile(arch_vol.text(".")) as fp:
                        if volume_number in repo.volume_indexes:
                            do('tar xvfj "%s" -h -C "%s"' % (fp.name,
                                                             repo.get_volume_fs(volume_number).path))
                        else:
                            logging.warning("The src-cdrom archive's volume value "
                                            "is not contained in the actual volumes")
    else:
        options = ""

    return [(repo.buildiso(os.path.join(target, "src-cdrom-%s.iso" % component),
            options=options)) for component, repo in repos.items()]
Пример #2
0
def mk_source_cdrom(rfs, arch, codename, init_codename, target,
                    cdrom_size=CDROM_SIZE, xml=None):

    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-branches

    hostfs.mkdir_p('/var/cache/elbe/sources')
    rfs.mkdir_p('/var/cache/elbe/sources')

    if xml is not None:
        mirror = xml.get_primary_mirror(rfs.fname("cdrom"))
    else:
        mirror = 'http://ftp.de.debian.org/debian'

    repo = CdromSrcRepo(codename, init_codename,
                        os.path.join(target, "srcrepo"),
                        cdrom_size,
                        mirror)

    cache = get_rpcaptcache(rfs, arch)
    cache.update()
    pkglist = cache.get_installed_pkgs()

    forbiddenPackages = []
    if xml is not None and xml.has('target/pkg-list'):
        for i in xml.node('target/pkg-list'):
            try:
                if i.tag == 'pkg' and i.et.attrib['on_src_cd'] == 'False':
                    forbiddenPackages.append(i.text('.').strip())

            except KeyError:
                pass

    for pkg in pkglist:
        # Do not include forbidden packages in src cdrom
        if pkg.name in forbiddenPackages:
            continue
        pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
        try:
            dsc = cache.download_source(pkg.name, '/var/cache/elbe/sources')
            repo.includedsc(dsc, force=True)
        except ValueError:
            logging.error("No sources for package '%s'", pkg_id)
        except FetchError:
            logging.error("Source for package '%s' could not be downloaded", pkg_id)

    # elbe fetch_initvm_pkgs has downloaded all sources to
    # /var/cache/elbe/sources
    # use walk_files to scan it, and add all dsc files.
    #
    # we can not just copy the source repo, like we do
    # with the bin repo, because the src cdrom can be split
    # into multiple cdroms

    initvm_repo = Filesystem('/var/cache/elbe/sources')

    for _ , dsc_real in initvm_repo.walk_files():
        if not dsc_real.endswith('.dsc'):
            continue

        repo.include_init_dsc(dsc_real, 'initvm')

    repo.finalize()

    if xml is not None:
        options = get_iso_options(xml)

        for arch_vol in xml.all('src-cdrom/archive'):
            volume_attr = arch_vol.et.get('volume')

            if volume_attr == 'all':
                volume_list = repo.volume_indexes
            else:
                volume_list = [int(v) for v in volume_attr.split(",")]
            for volume_number in volume_list:
                with archive_tmpfile(arch_vol.text(".")) as fp:
                    if volume_number in repo.volume_indexes:
                        do('tar xvfj "%s" -h -C "%s"' % (fp.name,
                                repo.get_volume_fs(volume_number).path))
                    else:
                        logging.warning("The src-cdrom archive's volume value "
                                "is not contained in the actual volumes")
    else:
        options = ""

    return repo.buildiso(os.path.join(target, "src-cdrom.iso"), options=options)
Пример #3
0
def mk_source_cdrom(
        rfs,
        arch,
        codename,
        init_codename,
        target,
        log,
        cdrom_size=CDROM_SIZE,
        xml=None):

    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-branches

    hostfs.mkdir_p('/var/cache/elbe/sources')
    rfs.mkdir_p('/var/cache/elbe/sources')

    if xml is not None:
        mirror = xml.get_primary_mirror(rfs.fname("cdrom"))
    else:
        mirror = 'http://ftp.de.debian.org/debian'

    repo = CdromSrcRepo(codename, init_codename,
                        os.path.join(target, "srcrepo"),
                        log,
                        cdrom_size,
                        mirror)

    cache = get_rpcaptcache(rfs, "aptcache.log", arch)
    cache.update()
    pkglist = cache.get_installed_pkgs()

    forbiddenPackages = []
    if xml is not None and xml.has('target/pkg-list'):
        for i in xml.node('target/pkg-list'):
            try:
                if i.tag == 'pkg' and i.et.attrib['on_src_cd'] == 'False':
                    forbiddenPackages.append(i.text('.').strip())

            except KeyError:
                pass

    for pkg in pkglist:
        # Do not include forbidden packages in src cdrom
        if pkg.name in forbiddenPackages:
            continue
        try:
            dsc = cache.download_source(pkg.name, '/var/cache/elbe/sources')
            repo.includedsc(dsc, force=True)
        except ValueError:
            log.printo(
                "No sources for Package " +
                pkg.name +
                "-" +
                pkg.installed_version)
        except FetchError:
            log.printo(
                "Source for Package " +
                pkg.name +
                "-" +
                pkg.installed_version +
                " could not be downloaded")

    # elbe fetch_initvm_pkgs has downloaded all sources to
    # /var/cache/elbe/sources
    # use walk_files to scan it, and add all dsc files.
    #
    # we can not just copy the source repo, like we do
    # with the bin repo, because the src cdrom can be split
    # into multiple cdroms

    initvm_repo = Filesystem('/var/cache/elbe/sources')

    for _ , dsc_real in initvm_repo.walk_files():
        if not dsc_real.endswith('.dsc'):
            continue

        repo.include_init_dsc(dsc_real, 'initvm')

    repo.finalize()

    return repo.buildiso(os.path.join(target, "src-cdrom.iso"))