From d8ffc9a7b12a48cca39864e05a1bcf5e0603870a Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Wed, 7 Aug 2013 04:50:51 -0400 Subject: [PATCH] split save fs code to savefs_before_chroot Signed-off-by: Gui Chen --- mic/chroot.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/mic/chroot.py b/mic/chroot.py index 391640c..a3fbfbc 100644 --- a/mic/chroot.py +++ b/mic/chroot.py @@ -226,21 +226,7 @@ def cleanup_chrootenv(chrootdir, bindmounts=None, globalmounts=()): ### CHROOT STUFF ##################################################################### -def cleanup_after_chroot(targettype, imgmount, tmpdir, tmpmnt): - if imgmount and targettype == "img": - imgmount.cleanup() - - if tmpdir: - shutil.rmtree(tmpdir, ignore_errors = True) - - if tmpmnt: - shutil.rmtree(tmpmnt, ignore_errors = True) - -def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): - def mychroot(): - os.chroot(chrootdir) - os.chdir("/") - +def savefs_before_chroot(chrootdir, saveto = None): if configmgr.chroot['saveto']: savefs = True saveto = configmgr.chroot['saveto'] @@ -270,12 +256,29 @@ def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): else: msger.warning(wrnmsg) +def cleanup_after_chroot(targettype, imgmount, tmpdir, tmpmnt): + if imgmount and targettype == "img": + imgmount.cleanup() + + if tmpdir: + shutil.rmtree(tmpdir, ignore_errors = True) + + if tmpmnt: + shutil.rmtree(tmpmnt, ignore_errors = True) + +def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): + def mychroot(): + os.chroot(chrootdir) + os.chdir("/") + arch = ELF_arch(chrootdir) if arch == "arm": qemu_emulator = misc.setup_qemu_emulator(chrootdir, "arm") else: qemu_emulator = None + savefs_before_chroot(chrootdir, None) + try: msger.info("Launching shell. Exit to continue.\n" "----------------------------------") -- 2.7.4