# Distributed under the GPL v2
# $Id$
+ 13 Sep 2009; Andrew Gaffney <agaffney@gentoo.org>
+ modules/catalyst/target/generic_stage.py, modules/catalyst/util.py:
+ Create catalyst.util.move() helper and use it
+
13 Sep 2009; Andrew Gaffney <agaffney@gentoo.org>
modules/catalyst/target/generic_stage.py, modules/catalyst/util.py:
Add catalyst.util.copy() helper function and use it
specialties in there
"""
if os.path.exists(self.settings["chroot_path"]+"/etc/hosts"):
- cmd("mv "+self.settings["chroot_path"]+"/etc/hosts "+\
- self.settings["chroot_path"]+"/etc/hosts.catalyst",\
- "Could not backup /etc/hosts",env=self.env)
+ catalyst.util.move(self.settings["chroot_path"] + "/etc/hosts", \
+ self.settings["chroot_path"] + "/etc/hosts.catalyst")
catalyst.util.copy("/etc/hosts", self.settings["chroot_path"] + "/etc/hosts")
""" Modify and write out make.conf (for the chroot) """
""" Put /etc/hosts back into place """
if os.path.exists(self.settings["chroot_path"]+"/etc/hosts.catalyst"):
- cmd("mv -f "+self.settings["chroot_path"]+"/etc/hosts.catalyst "+\
- self.settings["chroot_path"]+"/etc/hosts",\
- "Could not replace /etc/hosts",env=self.env)
+ catalyst.util.move(self.settings["chroot_path"] + "/etc/hosts.catalyst", \
+ self.settings["chroot_path"]+"/etc/hosts", force=True)
""" Remove our overlay """
if os.path.exists(self.settings["chroot_path"]+"/usr/local/portage"):
if retval != 0:
raise CatalystError("Could not copy path '%s'" % (src,))
+def move(src, dest, force=False):
+ try:
+ if os.path.exists(dest):
+ remove_path(dest)
+ os.rename(src, dest)
+ except:
+ raise CatalystError("Could not rename '%s' to '%s'" % (src, dest))
+
# vim: ts=4 sw=4 sta noet sts=4 ai