本文整理汇总了Python中pyanaconda.iutil.getSysroot函数的典型用法代码示例。如果您正苦于以下问题:Python getSysroot函数的具体用法?Python getSysroot怎么用?Python getSysroot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSysroot函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: writeStorageLate
def writeStorageLate(self):
"""Some packaging payloads require that the storage configuration be
written out after doing installation. Right now, this is basically
every payload except for dnf. Payloads should only implement one of
these methods by overriding the unneeded one with a pass.
"""
if not flags.dirInstall:
if iutil.getSysroot() != iutil.getTargetPhysicalRoot():
setSysroot(iutil.getTargetPhysicalRoot(), iutil.getSysroot())
# Now that we have the FS layout in the target, umount
# things that were in the legacy sysroot, and put them in
# the target root, except for the physical /. First,
# unmount all target filesystems.
self.storage.umountFilesystems()
# Explicitly mount the root on the physical sysroot
rootmnt = self.storage.mountpoints.get('/')
rootmnt.setup()
rootmnt.format.setup(options=rootmnt.format.options, chroot=iutil.getTargetPhysicalRoot())
self.prepareMountTargets(self.storage)
# Everything else goes in the target root, including /boot
# since the bootloader code will expect to find /boot
# inside the chroot.
self.storage.mountFilesystems(skipRoot=True)
self.storage.write()
开发者ID:NealSCarffery,项目名称:anaconda,代码行数:29,代码来源:__init__.py
示例2: prepareMountTargets
def prepareMountTargets(self, storage):
""" Prepare the ostree root """
ostreesetup = self.data.ostreesetup
# Currently, blivet sets up mounts in the physical root.
# We used to unmount them and remount them in the sysroot, but
# since 664ef7b43f9102aa9332d0db5b7d13f8ece436f0 we now just set up
# bind mounts.
# Make /usr readonly like ostree does at runtime normally
self._setupInternalBindmount('/usr', bind_ro=True, src_physical=False)
# Explicitly do API mounts; some of these may be tracked by blivet, but
# we'll skip them below.
api_mounts = ["/dev", "/proc", "/run", "/sys"]
for path in api_mounts:
self._setupInternalBindmount(path)
# Handle /var; if the admin didn't specify a mount for /var, we need
# to do the default ostree one.
# https://github.com/ostreedev/ostree/issues/855
varroot = '/ostree/deploy/' + ostreesetup.osname + '/var'
if storage.mountpoints.get("/var") is None:
self._setupInternalBindmount(varroot, dest='/var', recurse=False)
else:
# Otherwise, bind it
self._setupInternalBindmount('/var', recurse=False)
# Now that we have /var, start filling in any directories that may be
# required later there. We explicitly make /var/lib, since
# systemd-tmpfiles doesn't have a --prefix-only=/var/lib. We rely on
# 80-setfilecons.ks to set the label correctly.
iutil.mkdirChain(iutil.getSysroot() + '/var/lib')
# Next, run tmpfiles to make subdirectories of /var. We need this for
# both mounts like /home (really /var/home) and %post scripts might
# want to write to e.g. `/srv`, `/root`, `/usr/local`, etc. The
# /var/lib/rpm symlink is also critical for having e.g. `rpm -qa` work
# in %post. We don't iterate *all* tmpfiles because we don't have the
# matching NSS configuration inside Anaconda, and we can't "chroot" to
# get it because that would require mounting the API filesystems in the
# target.
for varsubdir in ('home', 'roothome', 'lib/rpm', 'opt', 'srv',
'usrlocal', 'mnt', 'media', 'spool', 'spool/mail'):
self._safeExecWithRedirect("systemd-tmpfiles",
["--create", "--boot", "--root=" + iutil.getSysroot(),
"--prefix=/var/" + varsubdir])
# Handle mounts like /boot (except avoid /boot/efi; we just need the
# toplevel), and any admin-specified points like /home (really
# /var/home). Note we already handled /var above. Avoid recursion since
# sub-mounts will be in the list too. We sort by length as a crude
# hack to try to simulate the tree relationship; it looks like this
# is handled in blivet in a different way.
for mount in sorted(storage.mountpoints, key=len):
if mount in ('/', '/var') or mount in api_mounts:
continue
self._setupInternalBindmount(mount, recurse=False)
# And finally, do a nonrecursive bind for the sysroot
self._setupInternalBindmount("/", dest="/sysroot", recurse=False)
开发者ID:jaymzh,项目名称:anaconda,代码行数:60,代码来源:rpmostreepayload.py
示例3: execute
def execute(self, storage, ksdata, instClass, users, payload):
""" Execute the addon
:param storage: Blivet storage object
:param ksdata: Kickstart data object
:param instClass: Anaconda installclass object
:param users: Anaconda users object
:param payload: object managing packages and environment groups
for the installation
"""
if not self.enabled:
return
log.info("Executing docker addon")
# This gets called after installation, before initramfs regeneration and kickstart %post scripts.
execWithRedirect("mount", ["-o", "bind", getSysroot()+"/var/lib/docker", "/var/lib/docker"])
execWithRedirect("mount", ["-o", "bind", getSysroot()+"/etc/docker", "/etc/docker"])
# Start up the docker daemon
log.debug("Starting docker daemon")
docker_cmd = ["docker", "daemon"]
if ksdata.selinux.selinux:
docker_cmd += ["--selinux-enabled"]
# Add storage specific arguments to the command
docker_cmd += self.storage.docker_cmd(storage, ksdata, instClass, users)
docker_cmd += ["--ip-forward=false", "--iptables=false"]
docker_cmd += self.extra_args
docker_proc = startProgram(docker_cmd, stdout=open("/tmp/docker-daemon.log", "w"), reset_lang=True)
log.debug("Running docker commands")
script = AnacondaKSScript(self.content, inChroot=False, logfile="/tmp/docker-addon.log")
script.run("/")
# Kill the docker process
log.debug("Shutting down docker daemon")
docker_proc.kill()
log.debug("Writing docker configs")
self.storage.write_configs(storage, ksdata, instClass, users)
# Rewrite the OPTIONS entry with the extra args and/or storage specific changes
try:
docker_cfg = SimpleConfigFile(getSysroot()+"/etc/sysconfig/docker")
docker_cfg.read()
options = self.storage.options(docker_cfg.get("OPTIONS"))
if self.save_args:
log.info("Adding extra args to docker OPTIONS")
options += " " + " ".join(self.extra_args)
docker_cfg.set(("OPTIONS", options))
docker_cfg.write()
except IOError as e:
log.error("Error updating OPTIONS in /etc/sysconfig/docker: %s", e)
# Copy the log files to the system
dstdir = "/var/log/anaconda/"
os.makedirs(dstdir, exist_ok=True)
for l in ["docker-daemon.log", "docker-addon.log"]:
shutil.copy2("/tmp/"+l, dstdir+l)
开发者ID:rhinstaller,项目名称:docker-anaconda-addon,代码行数:60,代码来源:docker.py
示例4: _copyBootloaderData
def _copyBootloaderData(self):
# Copy bootloader data files from the deployment
# checkout to the target root. See
# https://bugzilla.gnome.org/show_bug.cgi?id=726757 This
# happens once, at installation time.
# extlinux ships its modules directly in the RPM in /boot.
# For GRUB2, Anaconda installs device.map there. We may need
# to add other bootloaders here though (if they can't easily
# be fixed to *copy* data into /boot at install time, instead
# of shipping it in the RPM).
physboot = iutil.getTargetPhysicalRoot() + '/boot'
ostree_boot_source = iutil.getSysroot() + '/usr/lib/ostree-boot'
if not os.path.isdir(ostree_boot_source):
ostree_boot_source = iutil.getSysroot() + '/boot'
for fname in os.listdir(ostree_boot_source):
srcpath = os.path.join(ostree_boot_source, fname)
destpath = os.path.join(physboot, fname)
# We're only copying directories
if not os.path.isdir(srcpath):
continue
# Special handling for EFI, as it's a mount point that's
# expected to already exist (so if we used copytree, we'd
# traceback). If it doesn't, we're not on a UEFI system,
# so we don't want to copy the data.
if fname == 'efi' and os.path.isdir(destpath):
for subname in os.listdir(srcpath):
sub_srcpath = os.path.join(srcpath, subname)
sub_destpath = os.path.join(destpath, subname)
self._safeExecWithRedirect('cp', ['-r', '-p', sub_srcpath, sub_destpath])
else:
log.info("Copying bootloader data: " + fname)
self._safeExecWithRedirect('cp', ['-r', '-p', srcpath, destpath])
开发者ID:rtruxal,项目名称:anaconda,代码行数:34,代码来源:rpmostreepayload.py
示例5: prepareMountTargets
def prepareMountTargets(self, storage):
ostreesetup = self.data.ostreesetup
varroot = iutil.getTargetPhysicalRoot() + '/ostree/deploy/' + ostreesetup.osname + '/var'
# Set up bind mounts as if we've booted the target system, so
# that %post script work inside the target.
binds = [(iutil.getTargetPhysicalRoot(),
iutil.getSysroot() + '/sysroot'),
(varroot,
iutil.getSysroot() + '/var'),
(iutil.getSysroot() + '/usr', None)]
for (src, dest) in binds:
self._safeExecWithRedirect("mount",
["--bind", src, dest if dest else src])
if dest is None:
self._safeExecWithRedirect("mount",
["--bind", "-o", "ro", src, src])
# Now, ensure that all other potential mount point directories such as
# (/home) are created. We run through the full tmpfiles here in order
# to also allow Anaconda and %post scripts to write to directories like
# /root. We don't iterate *all* tmpfiles because we don't have the
# matching NSS configuration inside Anaconda, and we can't "chroot" to
# get it because that would require mounting the API filesystems in the
# target.
for varsubdir in ('home', 'roothome', 'lib/rpm', 'opt', 'srv',
'usrlocal', 'mnt', 'media', 'spool/mail'):
self._safeExecWithRedirect("systemd-tmpfiles",
["--create", "--boot", "--root=" + iutil.getSysroot(),
"--prefix=/var/" + varsubdir])
开发者ID:rtruxal,项目名称:anaconda,代码行数:32,代码来源:rpmostreepayload.py
示例6: execute
def execute(self, storage, ksdata, instClass, users):
""" Execute the addon
:param storage: Blivet storage object
:param ksdata: Kickstart data object
:param instClass: Anaconda installclass object
:param users: Anaconda users object
"""
log.info("Executing docker addon")
# This gets called after installation, before initramfs regeneration and kickstart %post scripts.
execWithRedirect("mount", ["-o", "bind", getSysroot()+"/var/lib/docker", "/var/lib/docker"])
execWithRedirect("mount", ["-o", "bind", getSysroot()+"/etc/docker", "/etc/docker"])
# Start up the docker daemon
log.debug("Starting docker daemon")
dm_fs = "dm.fs=%s" % self.fstype
pool_name = "dm.thinpooldev=/dev/mapper/%s-docker--pool" % self.vgname
docker_cmd = ["docker", "daemon"]
if ksdata.selinux.selinux:
docker_cmd += ["--selinux-enabled"]
docker_cmd += ["--storage-driver", "devicemapper",
"--storage-opt", dm_fs,
"--storage-opt", pool_name, "--ip-forward=false", "--iptables=false"]
docker_cmd += self.extra_args
docker_proc = startProgram(docker_cmd, stdout=open("/tmp/docker-daemon.log", "w"), reset_lang=True)
log.debug("Running docker commands")
script = AnacondaKSScript(self.content, inChroot=False, logfile="/tmp/docker-addon.log")
script.run("/")
# Kill the docker process
log.debug("Shutting down docker daemon")
docker_proc.kill()
log.debug("Writing docker configs")
with open(getSysroot()+"/etc/sysconfig/docker-storage", "w") as fp:
fp.write('DOCKER_STORAGE_OPTIONS="--storage-driver devicemapper '
'--storage-opt %s --storage-opt %s"\n' % (dm_fs, pool_name))
with open(getSysroot()+"/etc/sysconfig/docker-storage-setup", "a") as fp:
fp.write("VG=%s\n" % self.vgname)
# Rewrite the OPTIONS entry with the extra args, if requested.
if self.extra_args and self.save_args:
try:
docker_cfg = SimpleConfigFile(getSysroot()+"/etc/sysconfig/docker")
docker_cfg.read()
options = docker_cfg.get("OPTIONS")+" " + " ".join(self.extra_args)
docker_cfg.set(("OPTIONS", options))
docker_cfg.write()
except IOError as e:
log.error("Error updating OPTIONS in /etc/sysconfig/docker: %s", e)
# Copy the log files to the system
dstdir = "/var/log/anaconda/"
os.makedirs(dstdir, exist_ok=True)
for l in ["docker-daemon.log", "docker-addon.log"]:
shutil.copy2("/tmp/"+l, dstdir+l)
开发者ID:bcl,项目名称:docker-anaconda-addon,代码行数:58,代码来源:docker.py
示例7: mount_root
def mount_root(self):
"""Mounts selected root and runs scripts."""
# mount root fs
try:
mount_existing_system(self._storage.fsset, self.root.device, read_only=self.ro)
log.info("System has been mounted under: %s", iutil.getSysroot())
except StorageError as e:
log.error("Mounting system under %s failed: %s", iutil.getSysroot(), e)
self.status = RescueModeStatus.MOUNT_FAILED
return False
# turn on swap
if not flags.imageInstall or not self.ro:
try:
self._storage.turn_on_swap()
except StorageError:
log.error("Error enabling swap.")
# turn on selinux also
if flags.selinux:
# we have to catch the possible exception, because we
# support read-only mounting
try:
fd = open("%s/.autorelabel" % iutil.getSysroot(), "w+")
fd.close()
except IOError as e:
log.warning("Error turning on selinux: %s", e)
# set a libpath to use mounted fs
libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":")
mounted = ["/mnt/sysimage%s" % ldir for ldir in libdirs]
iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted))
# do we have bash?
try:
if os.access("/usr/bin/bash", os.R_OK):
os.symlink("/usr/bin/bash", "/bin/bash")
except OSError as e:
log.error("Error symlinking bash: %s", e)
# make resolv.conf in chroot
if not self.ro:
self._storage.make_mtab()
try:
makeResolvConf(iutil.getSysroot())
except(OSError, IOError) as e:
log.error("Error making resolv.conf: %s", e)
# create /etc/fstab in ramdisk so it's easier to work with RO mounted fs
makeFStab()
# run %post if we've mounted everything
if not self.ro and self._scripts:
runPostScripts(self._scripts)
self.status = RescueModeStatus.MOUNTED
return True
开发者ID:jaymzh,项目名称:anaconda,代码行数:57,代码来源:rescue.py
示例8: _writeModuleBlacklist
def _writeModuleBlacklist(self):
""" Copy modules from modprobe.blacklist=<module> on cmdline to
/etc/modprobe.d/anaconda-blacklist.conf so that modules will
continue to be blacklisted when the system boots.
"""
if "modprobe.blacklist" not in flags.cmdline:
return
iutil.mkdirChain(iutil.getSysroot() + "/etc/modprobe.d")
with open(iutil.getSysroot() + "/etc/modprobe.d/anaconda-blacklist.conf", "w") as f:
f.write("# Module blacklists written by anaconda\n")
for module in flags.cmdline["modprobe.blacklist"].split():
f.write("blacklist %s\n" % module)
开发者ID:NealSCarffery,项目名称:anaconda,代码行数:13,代码来源:__init__.py
示例9: write_configs
def write_configs(self, storage, ksdata, instClass, users):
""" Write configuration file(s)
:param storage: Blivet storage object
:param ksdata: Kickstart data object
:param instClass: Anaconda installclass object
:param users: Anaconda users object
"""
with open(getSysroot()+"/etc/sysconfig/docker-storage", "w") as fp:
fp.write('DOCKER_STORAGE_OPTIONS="--storage-driver devicemapper '
'--storage-opt %s --storage-opt %s"\n' % (self.dm_fs, self.pool_name))
with open(getSysroot()+"/etc/sysconfig/docker-storage-setup", "a") as fp:
fp.write("VG=%s\n" % self.addon.vgname)
开发者ID:rhinstaller,项目名称:docker-anaconda-addon,代码行数:14,代码来源:docker.py
示例10: write
def write(self):
"""Write the desktop & default target settings to disk."""
if self.desktop:
with open(iutil.getSysroot() + "/etc/sysconfig/desktop", "w") as f:
f.write("DESKTOP=%s\n" % self.desktop)
if not os.path.isdir(iutil.getSysroot() + '/etc/systemd/system'):
log.warning("There is no /etc/systemd/system directory, cannot update default.target!")
return
default_target = iutil.getSysroot() + '/etc/systemd/system/default.target'
if os.path.islink(default_target):
os.unlink(default_target)
os.symlink('/lib/systemd/system/%s' % self.default_target, default_target)
开发者ID:adrelanos,项目名称:qubes-installer-qubes-os,代码行数:14,代码来源:desktop.py
示例11: write
def write(self):
if self.desktop:
with open(iutil.getSysroot() + "/etc/sysconfig/desktop", "w") as f:
f.write("DESKTOP=%s\n" % self.desktop)
if not os.path.isdir(iutil.getSysroot() + '/etc/systemd/system'):
log.warning("there is no /etc/systemd/system directory, cannot update default.target!")
return
default_target = iutil.getSysroot() + '/etc/systemd/system/default.target'
if os.path.islink(default_target):
os.unlink(default_target)
os.symlink('/lib/systemd/system/%s' % RUNLEVELS[self.runlevel],
default_target)
开发者ID:nandakishore1006,项目名称:anaconda,代码行数:14,代码来源:desktop.py
示例12: install
def install(self):
""" Install the payload. """
if self.source_size <= 0:
raise PayloadInstallError("Nothing to install")
self.pct_lock = Lock()
self.pct = 0
threadMgr.add(AnacondaThread(name=THREAD_LIVE_PROGRESS,
target=self.progress))
cmd = "rsync"
# preserve: permissions, owners, groups, ACL's, xattrs, times,
# symlinks, hardlinks
# go recursively, include devices and special files, don't cross
# file system boundaries
args = ["-pogAXtlHrDx", "--exclude", "/dev/", "--exclude", "/proc/",
"--exclude", "/sys/", "--exclude", "/run/", "--exclude", "/boot/*rescue*",
"--exclude", "/etc/machine-id", INSTALL_TREE+"/", iutil.getSysroot()]
try:
rc = iutil.execWithRedirect(cmd, args)
except (OSError, RuntimeError) as e:
msg = None
err = str(e)
log.error(err)
else:
err = None
msg = "%s exited with code %d" % (cmd, rc)
log.info(msg)
if err or rc == 12:
exn = PayloadInstallError(err or msg)
if errorHandler.cb(exn) == ERROR_RAISE:
raise exn
# Wait for progress thread to finish
with self.pct_lock:
self.pct = 100
threadMgr.wait(THREAD_LIVE_PROGRESS)
# Live needs to create the rescue image before bootloader is written
if not os.path.exists(iutil.getSysroot() + "/usr/sbin/new-kernel-pkg"):
log.error("new-kernel-pkg does not exist - grubby wasn't installed? skipping")
return
for kernel in self.kernelVersionList:
log.info("Generating rescue image for %s", kernel)
iutil.execInSysroot("new-kernel-pkg",
["--rpmposttrans", kernel])
开发者ID:marmarek,项目名称:qubes-installer-qubes-os,代码行数:49,代码来源:livepayload.py
示例13: postInstall
def postInstall(self):
super(RPMOSTreePayload, self).postInstall()
gi.require_version("OSTree", "1.0")
from gi.repository import OSTree
cancellable = None
# Following up on the "remote delete" above, we removed the
# remote from /ostree/repo/config. But we want it in /etc, so
# re-add it to /etc/ostree/remotes.d, using the sysroot path.
#
# However, we ignore the case where the remote already exists,
# which occurs when the content itself provides the remote
# config file.
# Note here we use the deployment as sysroot, because it's
# that version of /etc that we want.
sysroot_file = Gio.File.new_for_path(iutil.getSysroot())
sysroot = OSTree.Sysroot.new(sysroot_file)
sysroot.load(cancellable)
repo = sysroot.get_repo(None)[1]
repo.remote_change(sysroot_file,
OSTree.RepoRemoteChange.ADD_IF_NOT_EXISTS,
self.data.ostreesetup.remote, self.data.ostreesetup.url,
GLib.Variant('a{sv}', self._remoteOptions),
cancellable)
boot = iutil.getSysroot() + '/boot'
# If we're using GRUB2, move its config file, also with a
# compatibility symlink.
boot_grub2_cfg = boot + '/grub2/grub.cfg'
if os.path.isfile(boot_grub2_cfg):
boot_loader = boot + '/loader'
target_grub_cfg = boot_loader + '/grub.cfg'
log.info("Moving %s -> %s", boot_grub2_cfg, target_grub_cfg)
os.rename(boot_grub2_cfg, target_grub_cfg)
os.symlink('../loader/grub.cfg', boot_grub2_cfg)
# Skip kernel args setup for dirinstall, there is no bootloader or rootDevice setup.
if not flags.dirInstall:
# OSTree owns the bootloader configuration, so here we give it
# the argument list we computed from storage, architecture and
# such.
set_kargs_args = ["admin", "instutil", "set-kargs"]
set_kargs_args.extend(self.storage.bootloader.boot_args)
set_kargs_args.append("root=" + self.storage.root_device.fstab_spec)
self._safeExecWithRedirect("ostree", set_kargs_args, root=iutil.getSysroot())
开发者ID:jaymzh,项目名称:anaconda,代码行数:48,代码来源:rpmostreepayload.py
示例14: createGroup
def createGroup(self, group_name, **kwargs):
"""Create a new user on the system with the given name. Optional kwargs:
:keyword int gid: The GID for the new user. If none is given, the next available one is used.
:keyword str root: The directory of the system to create the new user in.
homedir will be interpreted relative to this. Defaults
to iutil.getSysroot().
"""
root = kwargs.get("root", iutil.getSysroot())
if self._getgrnam(group_name, root):
raise ValueError("Group %s already exists" % group_name)
args = ["-R", root]
if kwargs.get("gid") is not None:
args.extend(["-g", str(kwargs["gid"])])
args.append(group_name)
with self._ensureLoginDefs(root):
status = iutil.execWithRedirect("groupadd", args)
if status == 4:
raise ValueError("GID %s already exists" % kwargs.get("gid"))
elif status == 9:
raise ValueError("Group %s already exists" % group_name)
elif status != 0:
raise OSError("Unable to create group %s: status=%s" % (group_name, status))
开发者ID:dougsland,项目名称:anaconda,代码行数:27,代码来源:users.py
示例15: check
def check(self):
"""Check configured storage against software selections. When this
method is complete (which should be pretty quickly), the following
attributes are available for inspection:
success -- A simple boolean defining whether there's enough
space or not.
deficit -- If unsuccessful, how much space the system is
short for current software selections.
error_message -- If unsuccessful, an error message describing the
situation. This message is suitable for putting
in the info bar at the bottom of a Hub.
"""
self.reset()
stat = iutil.eintr_retry_call(os.statvfs, iutil.getSysroot())
free = Size(stat.f_bsize * stat.f_bfree)
needed = self.payload.spaceRequired
log.info("fs space: %s needed: %s", free, needed)
self.success = (free > needed)
if not self.success:
dev_required_size = self.payload.requiredDeviceSize(self.storage.rootDevice.format)
self.deficit = dev_required_size - self.storage.rootDevice.size
self.error_message = _(self.error_template) % self.deficit
return self.success
开发者ID:jsilhan,项目名称:anaconda,代码行数:25,代码来源:space.py
示例16: recreateInitrds
def recreateInitrds(self):
""" Recreate the initrds by calling new-kernel-pkg
This needs to be done after all configuration files have been
written, since dracut depends on some of them.
:returns: None
"""
if not os.path.exists(iutil.getSysroot() + "/usr/sbin/new-kernel-pkg"):
log.error("new-kernel-pkg does not exist - grubby wasn't installed? skipping")
return
for kernel in self.kernelVersionList:
log.info("recreating initrd for %s", kernel)
if not flags.imageInstall:
iutil.execInSysroot("new-kernel-pkg",
["--mkinitrd", "--dracut",
"--depmod", "--update", kernel])
else:
# hostonly is not sensible for disk image installations
# using /dev/disk/by-uuid/ is necessary due to disk image naming
iutil.execInSysroot("dracut",
["-N",
"--persistent-policy", "by-uuid",
"-f", "/boot/initramfs-%s.img" % kernel,
kernel])
开发者ID:NealSCarffery,项目名称:anaconda,代码行数:26,代码来源:__init__.py
示例17: setUserSshKey
def setUserSshKey(self, username, key, **kwargs):
root = kwargs.get("root", iutil.getSysroot())
pwent = self._getpwnam(username, root)
if not pwent:
raise ValueError("setUserSshKey: user %s does not exist" % username)
homedir = root + pwent[5]
if not os.path.exists(homedir):
log.error("setUserSshKey: home directory for %s does not exist", username)
raise ValueError("setUserSshKey: home directory for %s does not exist" % username)
uid = pwent[2]
gid = pwent[3]
sshdir = os.path.join(homedir, ".ssh")
if not os.path.isdir(sshdir):
os.mkdir(sshdir, 0o700)
os.chown(sshdir, int(uid), int(gid))
authfile = os.path.join(sshdir, "authorized_keys")
authfile_existed = os.path.exists(authfile)
with iutil.open_with_perm(authfile, "a", 0o600) as f:
f.write(key + "\n")
# Only change ownership if we created it
if not authfile_existed:
os.chown(authfile, int(uid), int(gid))
iutil.execWithRedirect("restorecon", ["-r", sshdir])
开发者ID:dougsland,项目名称:anaconda,代码行数:29,代码来源:users.py
示例18: write_out_config_file
def write_out_config_file(self, config_path=None):
"""Write the user interaction config file to persistent storage.
- we always read the config file from the top level filesystem, as:
-> on live media the file will be there
-> on non-live media the config file (if any) will be injected to the top level
-> filesystem by image generation tools or by an updates/product image
- on the other hand the "output" config file needs to always end on the installed
system, so that post installation setup tools (such as Initial Setup or
Gnome Initial Setup) can use it
-> therefore we always write the config file to the sysroot path
"""
if config_path is None:
config_path = iutil.getSysroot() + CONFIG_FILE_PATH
with self._lock:
new_config_file = not os.path.exists(config_path)
try:
with open(config_path, "wt") as f:
if new_config_file:
# we are creating a new file, so add a header that it was created by Anaconda,
# including its version number
f.write(self._get_new_config_header())
self._config.write(f)
except OSError:
log.exception("Can't write user interaction config file.")
开发者ID:dougsland,项目名称:anaconda,代码行数:27,代码来源:screen_access.py
示例19: enable_installer_mode
def enable_installer_mode():
""" Configure the module for use by anaconda (OS installer). """
global iutil
global ROOT_PATH
global _storageRoot
global _sysroot
global shortProductName
global get_bootloader
global errorHandler
global ERROR_RAISE
from pyanaconda import iutil # pylint: disable=redefined-outer-name
from pyanaconda.constants import shortProductName # pylint: disable=redefined-outer-name
from pyanaconda.bootloader import get_bootloader # pylint: disable=redefined-outer-name
from pyanaconda.errors import errorHandler # pylint: disable=redefined-outer-name
from pyanaconda.errors import ERROR_RAISE # pylint: disable=redefined-outer-name
if hasattr(iutil, 'getTargetPhysicalRoot'):
# For anaconda versions > 21.43
_storageRoot = iutil.getTargetPhysicalRoot() # pylint: disable=no-name-in-module
_sysroot = iutil.getSysroot()
else:
# For prior anaconda versions
from pyanaconda.constants import ROOT_PATH # pylint: disable=redefined-outer-name,no-name-in-module
_storageRoot = _sysroot = ROOT_PATH
from pyanaconda.anaconda_log import program_log_lock
util.program_log_lock = program_log_lock
flags.installer_mode = True
开发者ID:rkuska,项目名称:blivet,代码行数:30,代码来源:__init__.py
示例20: setUserSshKey
def setUserSshKey(self, username, key, **kwargs):
childpid = self._prepareChroot(kwargs.get("root", iutil.getSysroot()))
if childpid == 0:
user = self.admin.lookupUserByName(username)
if not user:
log.error("setUserSshKey: user %s does not exist", username)
os._exit(1)
homedir = user.get(libuser.HOMEDIRECTORY)[0]
if not os.path.exists(homedir):
log.error("setUserSshKey: home directory for %s does not exist", username)
os._exit(1)
sshdir = os.path.join(homedir, ".ssh")
if not os.path.isdir(sshdir):
os.mkdir(sshdir, 0o700)
iutil.eintr_retry_call(os.chown, sshdir, user.get(libuser.UIDNUMBER)[0], user.get(libuser.GIDNUMBER)[0])
authfile = os.path.join(sshdir, "authorized_keys")
authfile_existed = os.path.exists(authfile)
with open(authfile, "a") as f:
f.write(key + "\n")
# Only change mode and ownership if we created it
if not authfile_existed:
iutil.eintr_retry_call(os.chmod, authfile, 0o600)
iutil.eintr_retry_call(os.chown, authfile, user.get(libuser.UIDNUMBER)[0], user.get(libuser.GIDNUMBER)[0])
iutil.execWithRedirect("restorecon", ["-r", sshdir])
os._exit(0)
else:
return self._finishChroot(childpid)
开发者ID:KosiehBarter,项目名称:anaconda,代码行数:32,代码来源:users.py
注:本文中的pyanaconda.iutil.getSysroot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论