示例#1
0
def modify(name, root, cfg):
    rpms = expand_rpms(cfg.get('rpms'))
    if not rpms:
        return
    util.print_iterable(rpms,
                        header=("Installing the following rpms"
                                " in module %s" % (util.quote(name))))
    util.ensure_dir(util.abs_join(root, 'tmp'))
    cleanup_fns = []
    for fn in rpms:
        cp_to = util.abs_join(root, 'tmp', os.path.basename(fn))
        util.copy(fn, cp_to)
        cleanup_fns.append(cp_to)
    real_fns = []
    for fn in rpms:
        real_fns.append(os.path.join('/tmp', os.path.basename(fn)))
    cmd = ['chroot', root,
           'yum', '--nogpgcheck', '-y',
           'localinstall']
    cmd.extend(real_fns)
    try:
        util.subp(cmd, capture=False)
    finally:
        # Ensure cleaned up
        for fn in cleanup_fns:
            util.del_file(fn)
示例#2
0
 def _adjust_real_root(self, arch_path):
     if self.root_file:
         print("Oh you really meant %s, finding that file..." % (util.quote(self.root_file)))
         # Extract and then copy over the right file...
         with util.tempdir() as tdir:
             arch_dir = os.path.join(tdir, 'archive')
             os.makedirs(arch_dir)
             util.subp(['tar', '-xzf', arch_path, '-C', arch_dir])
             root_gz = util.find_file(self.root_file, arch_dir)
             if not root_gz:
                 raise RuntimeError(("Needed file %r not found in"
                                     " extracted contents of %s") 
                                     % (self.root_file, arch_path))
             else:
                 util.copy(root_gz, arch_path)
     return arch_path