On 15 July 2014 16:51, Holger Levsen <hol...@layer-acht.org> wrote: > $ git am < ~/piuparts_hardlinking_existing_chroot.commit > Patch does not have a valid e-mail address. > $ git am ~/piuparts_hardlinking_existing_chroot.commit > Patch format detection failed. > > how did you create it?
I didn't use format-patch. Now attached patch should be better.
From d7b2904f1083055ce1ff15c1d40df28867c558c4 Mon Sep 17 00:00:00 2001 From: Leo Iannacone <l...@ubuntu.com> Date: Tue, 15 Jul 2014 16:51:58 +0200 Subject: [PATCH] do hard-linking with --existing-chroot option if orig chroot and destination dir are on the same device instead of copying files --- piuparts.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/piuparts.py b/piuparts.py index aaec972..1316cfe 100644 --- a/piuparts.py +++ b/piuparts.py @@ -817,11 +817,18 @@ class Chroot: def setup_from_dir(self, dirname): """Create chroot from an existing one.""" - logging.debug("Copying %s into %s" % (dirname, self.name)) + # if on same device, make hard link + cmd = ["cp"] + if os.stat(dirname).st_dev == os.stat(self.name).st_dev: + cmd += ["-al"] + logging.debug("Hard linking %s to %s" % (dirname, self.name)) + else: + cmd += ["-ax"] + logging.debug("Copying %s into %s" % (dirname, self.name)) for name in os.listdir(dirname): src = os.path.join(dirname, name) dst = os.path.join(self.name, name) - run(["cp", "-ax", src, dst]) + run(cmd + [src, dst]) def run(self, command, ignore_errors=False): prefix = [] -- 1.9.1