Esempio n. 1
0
def generate_elbe_internal_key():
    hostfs.mkdir_p("/var/cache/elbe/gnupg")
    os.environ['GNUPGHOME'] = "/var/cache/elbe/gnupg"
    ctx = gpgme.Context()
    key = ctx.genkey(elbe_internal_key_param)

    return key.fpr
Esempio n. 2
0
def generate_elbe_internal_key():
    hostfs.mkdir_p("/var/cache/elbe/gnupg")
    hostfs.write_file("/var/cache/elbe/gnupg/gpg-agent.conf", 0o600,
                      "allow-preset-passphrase")
    ctx = core.Context()
    ctx.set_engine_info(PROTOCOL_OpenPGP, None, '/var/cache/elbe/gnupg')
    ctx.op_genkey(elbe_internal_key_param, None, None)
    key = ctx.op_genkey_result()

    return key.fpr
Esempio n. 3
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"))
Esempio n. 4
0
def generate_elbe_internal_key():
    hostfs.mkdir_p("/var/cache/elbe/gnupg")
    hostfs.write_file("/var/cache/elbe/gnupg/gpg-agent.conf", 0o600,
                      "allow-preset-passphrase")
    ctx = core.Context()
    ctx.set_engine_info(PROTOCOL_OpenPGP,
                        None,
                        '/var/cache/elbe/gnupg')
    ctx.op_genkey(elbe_internal_key_param, None, None)
    key = ctx.op_genkey_result()

    return key.fpr
Esempio n. 5
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" ) )
Esempio n. 6
0
def run_command(argv):

    # TODO - Set threshold and remove pylint directives
    #
    # We might want to make the threshold higher for certain
    # files/directories or just globaly.

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

    oparser = OptionParser(
        usage="usage: %prog fetch_initvm_pkgs [options] <xmlfile>")

    oparser.add_option("-b",
                       "--binrepo",
                       dest="binrepo",
                       default="/var/cache/elbe/initvm-bin-repo",
                       help="directory where the bin repo should reside")

    oparser.add_option("-s",
                       "--srcrepo",
                       dest="srcrepo",
                       default="/var/cache/elbe/initvm-src-repo",
                       help="directory where the src repo should reside")

    oparser.add_option("--skip-validation",
                       action="store_true",
                       dest="skip_validation",
                       default=False,
                       help="Skip xml schema validation")

    oparser.add_option("--cdrom-mount-path",
                       dest="cdrom_path",
                       help="path where cdrom is mounted")

    oparser.add_option("--cdrom-device",
                       dest="cdrom_device",
                       help="cdrom device, in case it has to be mounted")

    oparser.add_option("--apt-archive",
                       dest="archive",
                       default="/var/cache/elbe/binaries/main",
                       help="path where binary packages are downloaded to.")

    oparser.add_option("--src-archive",
                       dest="srcarchive",
                       default="/var/cache/elbe/sources",
                       help="path where src packages are downloaded to.")

    oparser.add_option("--skip-build-sources",
                       action="store_false",
                       dest="build_sources",
                       default=True,
                       help="Skip downloading Source Packages")

    oparser.add_option("--skip-build-bin",
                       action="store_false",
                       dest="build_bin",
                       default=True,
                       help="Skip downloading binary packages")

    (opt, args) = oparser.parse_args(argv)

    if len(args) != 1:
        print("wrong number of arguments")
        oparser.print_help()
        sys.exit(20)

    try:
        xml = ElbeXML(args[0], skip_validate=opt.skip_validation)
    except ValidationError as e:
        print(str(e))
        print("xml validation failed. Bailing out")
        sys.exit(20)

    with elbe_logging({"streams": sys.stdout}):

        if opt.cdrom_path:
            if opt.cdrom_device:
                do('mount "%s" "%s"' % (opt.cdrom_device, opt.cdrom_path))

            # a cdrom build is identified by the cdrom option
            # the xml file that is copied into the initvm
            # by the initrd does not have the cdrom tags setup.
            mirror = "file://%s" % opt.cdrom_path
        else:
            mirror = xml.get_initvm_primary_mirror(opt.cdrom_path)

        init_codename = xml.get_initvm_codename()

        # Binary Repo
        #
        repo = CdromInitRepo(init_codename, opt.binrepo, mirror)

        hostfs.mkdir_p(opt.archive)

        if opt.build_bin:
            pkglist = get_initvm_pkglist()
            cache = Cache()
            cache.open()
            for pkg in pkglist:
                pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
                try:
                    p = cache[pkg.name]
                    pkgver = p.installed
                    deb = fetch_binary(pkgver, opt.archive,
                                       ElbeAcquireProgress(cb=None))
                    repo.includedeb(deb, 'main')
                except ValueError:
                    logging.exception('No package "%s"', pkg_id)
                except FetchError:
                    logging.exception(
                        'Package "%s-%s" could not be downloaded', pkg.name,
                        pkgver.version)
                except TypeError:
                    logging.exception('Package "%s" missing name or version',
                                      pkg_id)

        repo.finalize()

        # Source Repo
        #
        repo = CdromSrcRepo(init_codename, init_codename, opt.srcrepo, 0,
                            mirror)
        hostfs.mkdir_p(opt.srcarchive)

        # a cdrom build does not have sources
        # skip adding packages to the source repo
        #
        # FIXME: we need a way to add source cdroms later on
        if opt.cdrom_path:
            opt.build_sources = False

        if opt.build_sources:
            for pkg in pkglist:
                pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
                try:
                    p = cache[pkg.name]
                    pkgver = p.installed
                    dsc = pkgver.fetch_source(opt.srcarchive,
                                              ElbeAcquireProgress(cb=None),
                                              unpack=False)
                    repo.include_init_dsc(dsc, 'initvm')
                except ValueError:
                    logging.exception('No package "%s"', pkg_id)
                except FetchError:
                    logging.exception(
                        'Package "%s-%s" could not be downloaded', pkg.name,
                        pkgver.version)
                except TypeError:
                    logging.exception('Package "%s" missing name or version',
                                      pkg_id)

        repo.finalize()

        if opt.cdrom_device:
            do('umount "%s"' % opt.cdrom_device)
Esempio n. 7
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)
Esempio n. 8
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()]
Esempio n. 9
0
def mk_binary_cdrom(rfs,
                    arch,
                    codename,
                    init_codename,
                    xml,
                    target,
                    log,
                    cdrom_size=CDROM_SIZE):

    rfs.mkdir_p('/var/cache/elbe/binaries/added')
    rfs.mkdir_p('/var/cache/elbe/binaries/main')
    hostfs.mkdir_p('/var/cache/elbe/binaries/main')

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

    repo_path = os.path.join(target, "binrepo")

    repo = CdromBinRepo(arch, codename, init_codename, repo_path, log,
                        cdrom_size, mirror)

    if not xml is None:
        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
                deb = pkgver.fetch_binary('/var/cache/elbe/binaries/main',
                                          ElbeAcquireProgress(cb=None))
                repo.include_init_deb(deb, 'main')
            except ValueError as ve:
                log.printo("No Package " + pkg.name + "-" +
                           str(pkg.installed_version))
            except FetchError as fe:
                log.printo("Package " + pkg.name + "-" + pkgver.version +
                           " could not be downloaded")
            except TypeError as te:
                log.printo("Package " + pkg.name + "-" +
                           str(pkg.installed_version) +
                           " missing name or version")

        cache = get_rpcaptcache(rfs, "aptcache.log", arch)
        for p in xml.node("debootstrappkgs"):
            pkg = XMLPackage(p, arch)
            try:
                deb = cache.download_binary(pkg.name,
                                            '/var/cache/elbe/binaries/main',
                                            pkg.installed_version)
                repo.includedeb(deb, 'main')
            except ValueError as ve:
                log.printo("No Package " + pkg.name + "-" +
                           pkg.installed_version)
            except FetchError as fe:
                log.printo("Package " + pkg.name + "-" +
                           pkg.installed_version + " could not be downloaded")
            except TypeError as te:
                log.printo("Package " + pkg.name + "-" +
                           pkg.installed_version + " missing name or version")

    cache = get_rpcaptcache(rfs, "aptcache.log", arch)
    pkglist = cache.get_installed_pkgs()
    for pkg in pkglist:
        try:
            deb = cache.download_binary(pkg.name,
                                        '/var/cache/elbe/binaries/added',
                                        pkg.installed_version)
            repo.includedeb(deb, 'added')
        except KeyError as ke:
            log.printo(str(ke))
        except ValueError as ve:
            log.printo("No Package " + pkg.name + "-" + pkg.installed_version)
        except FetchError as fe:
            log.printo("Package " + pkg.name + "-" +
                       str(pkg.installed_version) + " could not be downloaded")
        except TypeError as te:
            log.printo("Package " + pkg.name + "-" + pkg.installed_version +
                       " missing name or version")

    # Mark the binary repo with the necessary Files
    # to make the installer accept this as a CDRom
    repo_fs = Filesystem(repo_path)
    repo_fs.mkdir_p(".disk")
    repo_fs.write_file(".disk/base_installable", 0644, "main\n")
    repo_fs.write_file(".disk/base_components", 0644, "main\n")
    repo_fs.write_file(".disk/cd_type", 0644, "not_complete\n")
    repo_fs.write_file(".disk/info", 0644, "elbe inst cdrom - full cd\n")
    repo_fs.symlink(".", "debian", allow_exists=True)
    repo_fs.write_file("md5sum.txt", 0644, "")

    # write source xml onto cdrom
    xml.xml.write(repo_fs.fname('source.xml'))

    return repo.buildiso(os.path.join(target, "bin-cdrom.iso"))
Esempio n. 10
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"))
Esempio n. 11
0
File: cdroms.py Progetto: 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"))
Esempio n. 12
0
def mk_binary_cdrom(rfs, arch, codename, init_codename, xml, target, log, cdrom_size=CDROM_SIZE):

    rfs.mkdir_p( '/var/cache/elbe/binaries/added' )
    rfs.mkdir_p( '/var/cache/elbe/binaries/main' )
    hostfs.mkdir_p( '/var/cache/elbe/binaries/main' )

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

    repo_path = os.path.join (target, "binrepo")

    repo = CdromBinRepo (arch, codename, init_codename,
                         repo_path, log, cdrom_size, mirror)

    if not xml is None:
        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
                deb = pkgver.fetch_binary ('/var/cache/elbe/binaries/main',
                                            ElbeAcquireProgress (cb=None) )
                repo.include_init_deb(deb, 'main')
            except ValueError as ve:
                log.printo( "No Package " + pkg.name + "-" + str(pkg.installed_version) )
            except FetchError as fe:
                log.printo( "Package " + pkg.name + "-" + pkgver.version + " could not be downloaded" )
            except TypeError as te:
                log.printo( "Package " + pkg.name + "-" + str(pkg.installed_version) + " missing name or version" )

        cache = get_rpcaptcache( rfs, "aptcache.log", arch )
        for p in xml.node("debootstrappkgs"):
            pkg = XMLPackage(p, arch)
            try:
                deb = cache.download_binary( pkg.name,
                                             '/var/cache/elbe/binaries/main',
                                             pkg.installed_version )
                repo.includedeb(deb, 'main')
            except ValueError as ve:
                log.printo( "No Package " + pkg.name + "-" + pkg.installed_version )
            except FetchError as fe:
                log.printo( "Package " + pkg.name + "-" + pkg.installed_version + " could not be downloaded" )
            except TypeError as te:
                log.printo( "Package " + pkg.name + "-" + pkg.installed_version + " missing name or version" )

    cache = get_rpcaptcache( rfs, "aptcache.log", arch )
    pkglist = cache.get_installed_pkgs ()
    for pkg in pkglist:
        try:
            deb = cache.download_binary( pkg.name,
                                        '/var/cache/elbe/binaries/added',
                                        pkg.installed_version )
            repo.includedeb(deb, 'added')
        except KeyError as ke:
            log.printo( str (ke) )
        except ValueError as ve:
            log.printo( "No Package " + pkg.name + "-" + pkg.installed_version )
        except FetchError as fe:
            log.printo( "Package " + pkg.name + "-" + str (pkg.installed_version) + " could not be downloaded" )
        except TypeError as te:
            log.printo( "Package " + pkg.name + "-" + pkg.installed_version + " missing name or version" )

    # Mark the binary repo with the necessary Files
    # to make the installer accept this as a CDRom
    repo_fs = Filesystem( repo_path )
    repo_fs.mkdir_p (".disk")
    repo_fs.write_file (".disk/base_installable", 0644, "main\n")
    repo_fs.write_file (".disk/base_components", 0644, "main\n")
    repo_fs.write_file (".disk/cd_type", 0644, "not_complete\n")
    repo_fs.write_file (".disk/info", 0644, "elbe inst cdrom - full cd\n")
    repo_fs.symlink (".", "debian", allow_exists=True)
    repo_fs.write_file ("md5sum.txt", 0644, "")

    # write source xml onto cdrom
    xml.xml.write (repo_fs.fname ('source.xml'))

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