コード例 #1
0
def mk_binary_cdrom(rfs, arch, codename, init_codename, xml, target):
    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-branches
    # pylint: disable=too-many-statements

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

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

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

    # initvm repo has been built upon initvm creation
    # just copy it. the repo __init__() afterwards will
    # not touch the repo config, nor generate a new key.
    try:
        do('cp -av /var/cache/elbe/initvm-bin-repo "%s"' % repo_path)
    except CommandError:
        # When /var/cache/elbe/initvm-bin-repo has not been created
        # (because the initvm install was an old version or somthing,
        #  log an error, and continue with an empty directory.
        logging.exception("/var/cache/elbe/initvm-bin-repo does not exist\n"
                          "The generated CDROM will not contain initvm pkgs\n"
                          "This happened because the initvm was probably\n"
                          "generated with --skip-build-bin")

        do('mkdir -p "%s"' % repo_path)

    repo = CdromInitRepo(init_codename, repo_path, mirror)

    target_repo = CdromBinRepo(arch, codename, None,
                               target_repo_path, mirror)

    if xml is not None:
        cache = get_rpcaptcache(rfs, arch)
        for p in xml.node("debootstrappkgs"):
            pkg = XMLPackage(p, arch)
            pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
            try:
                deb = cache.download_binary(pkg.name,
                                            '/var/cache/elbe/binaries/main',
                                            pkg.installed_version)
                target_repo.includedeb(deb, 'main')
            except ValueError:
                logging.error("No package '%s'", pkg_id)
            except FetchError:
                logging.error("Package '%s' could not be downloaded", pkg_id)
            except TypeError:
                logging.error("Package '%s' missing name or version", pkg_id)

    cache = get_rpcaptcache(rfs, arch)
    pkglist = cache.get_installed_pkgs()
    for pkg in pkglist:
        pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
        try:
            deb = cache.download_binary(pkg.name,
                                        '/var/cache/elbe/binaries/added',
                                        pkg.installed_version)
            target_repo.includedeb(deb, 'added', pkg.name, True)
        except KeyError as ke:
            logging.error(str(ke))
        except ValueError:
            logging.error("No package '%s'", pkg_id)
        except FetchError:
            logging.error("Package '%s' could not be downloaded", pkg_id)
        except TypeError:
            logging.error("Package '%s' missing name or version", pkg_id)

    target_repo.finalize()

    # 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", 0o644, "main\n")
    repo_fs.write_file(".disk/base_components", 0o644, "main\n")
    repo_fs.write_file(".disk/cd_type", 0o644, "not_complete\n")
    repo_fs.write_file(".disk/info", 0o644, "elbe inst cdrom - full cd\n")
    repo_fs.symlink(".", "debian", allow_exists=True)
    repo_fs.write_file("md5sum.txt", 0o644, "")

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

    # copy initvm-cdrom.gz and vmlinuz
    copyfile('/var/cache/elbe/installer/initrd-cdrom.gz',
             repo_fs.fname('initrd-cdrom.gz'))
    copyfile('/var/cache/elbe/installer/vmlinuz',
             repo_fs.fname('vmlinuz'))

    target_repo_fs = Filesystem(target_repo_path)
    target_repo_fs.write_file(".aptignr", 0o644, "")

    return repo.buildiso(os.path.join(target, "bin-cdrom.iso"))
コード例 #2
0
ファイル: cdroms.py プロジェクト: Linutronix/elbe
def mk_binary_cdrom(
        rfs,
        arch,
        codename,
        init_codename,
        xml,
        target,
        log,
        cdrom_size=CDROM_SIZE):
    # pylint: disable=too-many-arguments
    # pylint: disable=too-many-locals
    # pylint: disable=too-many-branches
    # pylint: disable=too-many-statements

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

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

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

    # initvm repo has been built upon initvm creation
    # just copy it. the repo __init__() afterwards will
    # not touch the repo config, nor generate a new key.
    try:
        log.do('cp -av /var/cache/elbe/initvm-bin-repo "%s"' % repo_path)
    except CommandError:
        # When /var/cache/elbe/initvm-bin-repo has not been created
        # (because the initvm install was an old version or somthing,
        #  log an error, and continue with an empty directory.
        log.printo('ERROR: /var/cache/elbe/initvm-bin-repo does not exist')
        log.printo('       The generated CDROM will not contain initvm pkgs')
        log.printo('       This happened because the initvm was probably')
        log.printo('       generated with --skip-build-bin')
        log.do('mkdir -p "%s"' % repo_path)

    repo = CdromInitRepo(init_codename, repo_path, log, cdrom_size, mirror)

    target_repo = CdromBinRepo(arch, codename, None,
                               target_repo_path, log, cdrom_size, mirror)

    if xml is not None:
        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)
                target_repo.includedeb(deb, 'main')
            except ValueError:
                log.printo(
                    "No Package " +
                    pkg.name +
                    "-" +
                    pkg.installed_version)
            except FetchError:
                log.printo(
                    "Package " +
                    pkg.name +
                    "-" +
                    pkg.installed_version +
                    " could not be downloaded")
            except TypeError:
                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)
            target_repo.includedeb(deb, 'added', pkg.name, True)
        except KeyError as ke:
            log.printo(str(ke))
        except ValueError:
            log.printo("No Package " + pkg.name + "-" + pkg.installed_version)
        except FetchError:
            log.printo("Package " +
                       pkg.name +
                       "-" +
                       str(pkg.installed_version) +
                       " could not be downloaded")
        except TypeError:
            log.printo(
                "Package " +
                pkg.name +
                "-" +
                pkg.installed_version +
                " missing name or version")

    target_repo.finalize()

    # 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", 0o644, "main\n")
    repo_fs.write_file(".disk/base_components", 0o644, "main\n")
    repo_fs.write_file(".disk/cd_type", 0o644, "not_complete\n")
    repo_fs.write_file(".disk/info", 0o644, "elbe inst cdrom - full cd\n")
    repo_fs.symlink(".", "debian", allow_exists=True)
    repo_fs.write_file("md5sum.txt", 0o644, "")

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

    # copy initvm-cdrom.gz and vmlinuz
    copyfile('/var/cache/elbe/installer/initrd-cdrom.gz',
             repo_fs.fname('initrd-cdrom.gz'))
    copyfile('/var/cache/elbe/installer/vmlinuz',
             repo_fs.fname('vmlinuz'))

    target_repo_fs = Filesystem(target_repo_path)
    target_repo_fs.write_file(".aptignr", 0o644, "")

    return repo.buildiso(os.path.join(target, "bin-cdrom.iso"))
コード例 #3
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"))
コード例 #4
0
ファイル: cdroms.py プロジェクト: atoz-chevara/elbe
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" ) )