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)
def transfer_into_tarball(path, arc_name, tb): fns = [arc_name] util.print_iterable(fns, header="Adding the following to your tarball %s" % (util.quote(tb.name))) print("Please wait...") tb.add(path, arc_name, recursive=False)
def modify(name, root, cfg): user_names = cfg.get("add_users") if not user_names: return util.print_iterable(user_names, header="Adding the following sudo users in module %s" % (util.quote(name))) for uname in user_names: cmd = ["chroot", root, "useradd", "-m", str(uname)] util.subp(cmd, capture=False) if os.path.isfile(os.path.join(root, "etc", "sudoers")): with open(os.path.join(root, "etc", "sudoers"), "a") as fh: new_entry = "%s ALL=(ALL) ALL" % (uname) fh.write("%s\n" % (new_entry))