コード例 #1
0
def make_tarball(bundlecfg, bundle, basearch, dver, packages, patch_dirs, prog_dir, stage_dir, relnum="0", extra_repos=None, version=None):
    """Run all the steps to make a non-root tarball.
    Returns (success (bool), tarball_path (relative), tarball_size (in bytes))

    """
    repofile = get_repofile(prog_dir, bundlecfg, bundle, basearch=basearch, dver=dver)

    extra_repos = extra_repos or []

    with yumconf.YumInstaller(repofile, dver, basearch, extra_repos) as yum:
        if not version:
            if bundlecfg.has_option(bundle, 'versionrpm'):
                version = yum.repoquery(bundlecfg.get(bundle, 'versionrpm'), "--queryformat=%{VERSION}").rstrip()
            else:
                version = 'unknown'
        tarball_path = bundlecfg.get(bundle, 'tarballname') % locals()

        post_scripts_dir = os.path.join(prog_dir, "post-install")

        statusmsg("Making stage 2 tarball for %s" % (packages))
        if not stage2.make_stage2_tarball(
                stage_dir        = stage_dir,
                packages         = packages,
                tarball          = tarball_path,
                patch_dirs       = patch_dirs,
                post_scripts_dir = post_scripts_dir,
                repofile         = repofile,
                dver             = dver,
                basearch         = basearch,
                relnum           = relnum,
                extra_repos      = extra_repos):
            errormsg("Making stage 2 tarball for %s unsuccessful. Files have been left in %r" % (packages, stage_dir))
            return (False, None, 0)
        tarball_size = os.stat(tarball_path)[6]
        return (True, tarball_path, tarball_size)
コード例 #2
0
ファイル: stage2.py プロジェクト: edquist/tarball-client
def install_packages(stage_dir_abs, packages, repofile, dver, basearch, extra_repos=None):
    """Install packages into a stage1 dir"""
    if isinstance(packages, str):
        packages = [packages]

    with common.MountProcFS(stage_dir_abs):
        with yumconf.YumInstaller(repofile, dver, basearch, extra_repos) as yum:
            yum.install(installroot=stage_dir_abs, packages=packages)

    # Check that the packages got installed
    for pkg in packages:
        if pkg.startswith('@'):
            continue # can't check on groups
        if not package_installed(stage_dir_abs, pkg):
            raise Error("%r not installed after yum install" % pkg)
コード例 #3
0
def install_stage1_packages(stage1_root, repofile, dver, basearch,
                            pkglist_file):
    stage1_packages = get_stage1_packages(pkglist_file)
    with common.MountProcFS(stage1_root):
        with yumconf.YumInstaller(repofile, dver, basearch) as yum:
            _install_stage1_packages(yum, dver, stage1_root, stage1_packages)