예제 #1
0
def mk_source_cdrom(rfs,
                    arch,
                    codename,
                    init_codename,
                    target,
                    log,
                    cdrom_size=CDROM_SIZE):

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

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

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

    pkglist = cache.get_installed_pkgs()

    for pkg in pkglist:
        try:
            dsc = cache.download_source(pkg.name, '/var/cache/elbe/sources')
            repo.includedsc(dsc)
        except ValueError as ve:
            log.printo("No sources for Package " + pkg.name + "-" +
                       pkg.installed_version)
        except FetchError as fe:
            log.printo("Source for Package " + pkg.name + "-" +
                       pkg.installed_version + " could not be downloaded")

    pkglist = get_initvm_pkglist()
    cache = Cache()
    cache.open()

    for pkg in pkglist:
        try:
            p = cache[pkg.name]
            if pkg.name == 'elbe-bootstrap':
                pkgver = p.versions[0]
            else:
                pkgver = p.installed

            dsc = pkgver.fetch_source('/var/cache/elbe/sources',
                                      ElbeAcquireProgress(cb=None),
                                      unpack=False)
            repo.includedsc(dsc)
        except ValueError as ve:
            log.printo("No sources for Package " + pkg.name + "-" +
                       str(pkg.installed_version))
        except FetchError as fe:
            log.printo("Source for Package " + pkg.name + "-" +
                       pkgver.version + " could not be downloaded")

    return repo.buildiso(os.path.join(target, "src-cdrom.iso"))
예제 #2
0
파일: cdroms.py 프로젝트: atoz-chevara/elbe
def mk_source_cdrom(rfs, arch, codename, init_codename, target, log, cdrom_size=CDROM_SIZE):

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

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

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

    pkglist = cache.get_installed_pkgs()

    for pkg in pkglist:
        try:
            dsc = cache.download_source( pkg.name, '/var/cache/elbe/sources' )
            repo.includedsc( dsc )
        except ValueError as ve:
            log.printo( "No sources for Package " + pkg.name + "-" + pkg.installed_version )
        except FetchError as fe:
            log.printo( "Source for Package " + pkg.name + "-" + pkg.installed_version + " could not be downloaded" )

    pkglist = get_initvm_pkglist()
    cache = Cache ()
    cache.open ()

    for pkg in pkglist:
        try:
            p = cache[pkg.name]
            if pkg.name == 'elbe-bootstrap':
                pkgver = p.versions [0]
            else:
                pkgver = p.installed

            dsc = pkgver.fetch_source ('/var/cache/elbe/sources',
                             ElbeAcquireProgress (cb=None), unpack=False)
            repo.includedsc( dsc )
        except ValueError as ve:
            log.printo( "No sources for Package " + pkg.name + "-" + str(pkg.installed_version) )
        except FetchError as fe:
            log.printo( "Source for Package " + pkg.name + "-" + pkgver.version + " could not be downloaded" )

    return repo.buildiso( os.path.join( target, "src-cdrom.iso" ) )
예제 #3
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)
예제 #4
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"))
예제 #5
0
파일: cdroms.py 프로젝트: zumbi/elbe
def mk_source_cdrom(rfs,
                    arch,
                    codename,
                    init_codename,
                    target,
                    log,
                    cdrom_size=CDROM_SIZE,
                    xml=None):

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

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

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

    pkglist = cache.get_installed_pkgs()

    forbiddenPackages = []
    if xml != 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 as ve:
            log.printo("No sources for Package " + pkg.name + "-" +
                       pkg.installed_version)
        except FetchError as fe:
            log.printo("Source for Package " + pkg.name + "-" +
                       pkg.installed_version + " could not be downloaded")

    repo.finalize()

    pkglist = get_initvm_pkglist()
    cache = Cache()
    cache.open()

    for pkg in pkglist:
        # Do not include forbidden packages in src cdrom
        if pkg.name in forbiddenPackages:
            continue
        try:
            p = cache[pkg.name]
            if pkg.name == 'elbe-bootstrap':
                pkgver = p.versions[0]
            else:
                pkgver = p.installed

            dsc = pkgver.fetch_source('/var/cache/elbe/sources',
                                      ElbeAcquireProgress(cb=None),
                                      unpack=False)
            repo.includedsc(dsc)
        except ValueError as ve:
            log.printo("No sources for Package " + pkg.name + "-" +
                       str(pkg.installed_version))
        except FetchError as fe:
            log.printo("Source for Package " + pkg.name + "-" +
                       pkgver.version + " could not be downloaded")

    repo.finalize()

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