Exemplo n.º 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)
Exemplo n.º 2
0
 def download(self):
     (cache_pth, exists_there) = self._check_cache()
     if exists_there:
         return cache_pth
     print("Downloading from: %s" % (util.quote(self.where_from)))
     util.ensure_dirs([os.path.dirname(cache_pth)])
     print("To: %s" % (util.quote(cache_pth)))
     util.download_url(self.where_from, cache_pth)
     try:
         meta_js = {
             'cached_on': util.time_rfc2822(),
             'from': self.where_from,
             'root_file': self.root_file,
         }
         util.write_file("%s.json" % (cache_pth),
                         "%s\n" % (json.dumps(meta_js, indent=4)))
         return self._adjust_real_root(cache_pth)
     except:
         util.del_file(cache_pth)
         raise