diff options
author | Brian C. Lane <bcl@redhat.com> | 2012-06-20 15:34:11 -0700 |
---|---|---|
committer | Brian C. Lane <bcl@redhat.com> | 2012-06-20 15:34:11 -0700 |
commit | 7e1b1abc04a7dde1a4153d5e61bf0207f77d583c (patch) | |
tree | 5a184496f757df6a61c5fd423667b94ecdb04859 /pyanaconda/iutil.py | |
parent | cbebb0210fba5ed5e74e01715f832d5e5929a8d5 (diff) | |
parent | 11b3901231af7e8f57aa362873d5d18caee14386 (diff) | |
download | anaconda-7e1b1abc04a7dde1a4153d5e61bf0207f77d583c.tar.gz anaconda-7e1b1abc04a7dde1a4153d5e61bf0207f77d583c.tar.xz anaconda-7e1b1abc04a7dde1a4153d5e61bf0207f77d583c.zip |
Merge branch 'master' into newui-merge
Conflicts:
Makefile.am
anaconda
anaconda.spec.in
loader/loader.c
loader/net.c
loader/unpack.c
po/POTFILES.in
pyanaconda/__init__.py
pyanaconda/bootloader.py
pyanaconda/cmdline.py
pyanaconda/constants.py
pyanaconda/dispatch.py
pyanaconda/errors.py
pyanaconda/flags.py
pyanaconda/iutil.py
pyanaconda/kickstart.py
pyanaconda/platform.py
pyanaconda/storage/__init__.py
pyanaconda/storage/devicetree.py
pyanaconda/storage/fcoe.py
pyanaconda/storage/formats/swap.py
pyanaconda/storage/iscsi.py
pyanaconda/storage/partitioning.py
pyanaconda/yuminstall.py
scripts/makeupdates
Diffstat (limited to 'pyanaconda/iutil.py')
-rw-r--r-- | pyanaconda/iutil.py | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/pyanaconda/iutil.py b/pyanaconda/iutil.py index 69ad6bf2d..abf720fd4 100644 --- a/pyanaconda/iutil.py +++ b/pyanaconda/iutil.py @@ -90,7 +90,7 @@ def augmentEnv(): # @param root The directory to chroot to before running command. # @return The return code of command. def execWithRedirect(command, argv, stdin = None, stdout = None, - stderr = None, root = '/'): + stderr = None, root = '/', env_prune=[]): if flags.testing: log.info("not running command because we're testing: %s %s" % (command, " ".join(argv))) @@ -113,6 +113,7 @@ def execWithRedirect(command, argv, stdin = None, stdout = None, elif stdin is None or not isinstance(stdin, file): stdin = sys.stdin.fileno() + orig_stdout = stdout if isinstance(stdout, str): stdout = os.open(stdout, os.O_RDWR|os.O_CREAT) stdoutclose = lambda : os.close(stdout) @@ -121,7 +122,9 @@ def execWithRedirect(command, argv, stdin = None, stdout = None, elif stdout is None or not isinstance(stdout, file): stdout = sys.stdout.fileno() - if isinstance(stderr, str): + if isinstance(stderr, str) and isinstance(orig_stdout, str) and stderr == orig_stdout: + stderr = stdout + elif isinstance(stderr, str): stderr = os.open(stderr, os.O_RDWR|os.O_CREAT) stderrclose = lambda : os.close(stderr) elif isinstance(stderr, int): @@ -135,6 +138,10 @@ def execWithRedirect(command, argv, stdin = None, stdout = None, pstdout, pstdin = os.pipe() perrout, perrin = os.pipe() + for var in env_prune: + if env.has_key(var): + del env[var] + try: #prepare tee proceses proc_std = tee(pstdout, stdout, program_log.info, command) @@ -697,11 +704,10 @@ def isMactel(): if not isX86(): mactel = False - elif not os.path.exists("/usr/sbin/dmidecode"): + elif not os.path.isfile(DMI_CHASSIS_VENDOR): mactel = False else: - buf = execWithCapture("/usr/sbin/dmidecode", - ["dmidecode", "-s", "system-manufacturer"]) + buf = open(DMI_CHASSIS_VENDOR).read() if buf.lower().find("apple") != -1: mactel = True else: @@ -776,6 +782,9 @@ def isAlpha(): def isSparc(): return os.uname()[4].startswith('sparc') +def isARM(): + return os.uname()[4].startswith('arm') + def getArch(): if isX86(bits=32): return 'i386' @@ -789,6 +798,8 @@ def getArch(): return 'alpha' elif isSparc(): return 'sparc' + elif isARM(): + return 'arm' else: return os.uname()[4] @@ -1043,3 +1054,28 @@ def service_running(service): ret = _run_systemctl("status", service) return ret == 0 + +def dracut_eject(device): + """ + Use dracut shutdown hook to eject media after the system is shutdown. + This is needed because we are running from the squashfs.img on the media + so ejecting too early will crash the installer. + """ + if not device: + return + + try: + if not os.path.exists(DRACUT_SHUTDOWN_EJECT): + f = open(DRACUT_SHUTDOWN_EJECT, "w") + f.write("#!/bin/sh\n") + f.write("# Created by Anaconda\n") + else: + f = open(DRACUT_SHUTDOWN_EJECT, "a") + + f.write("eject %s\n" % (device,)) + f.close() + os.chmod(DRACUT_SHUTDOWN_EJECT, 0755) + log.info("Wrote dracut shutdown eject hook for %s" % (device,)) + except Exception, e: + log.error("Error writing dracut shutdown eject hook for %s: %s" % (device, e)) + |