[oe-commits] Richard Purdie : utils: Add hardlinkdir shell function

git at git.openembedded.org git at git.openembedded.org
Fri Apr 25 16:19:48 UTC 2014


Module: openembedded-core.git
Branch: master
Commit: 14ef03182e1e5fe7cf6b4112f29e6609631aa78d
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=14ef03182e1e5fe7cf6b4112f29e6609631aa78d

Author: Richard Purdie <richard.purdie at linuxfoundation.org>
Date:   Thu Apr 24 10:17:18 2014 +0100

utils: Add hardlinkdir shell function

In a number of places it would be helpful to be able to copy trees of
files using hardlinks. This turns out to be harder than you'd expect
since there is no good single command that does this well and handles
all file types correctly.

Abstracting this into a function therefore makes sense, cpio seems
as good an option as any other.

Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/classes/utils.bbclass | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index 0a533af..89ad8c5 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -292,6 +292,15 @@ END
 	chmod +x $cmd
 }
 
+# Copy files/directories from $1 to $2 but using hardlinks
+# (preserve symlinks)
+hardlinkdir () {
+	from=$1
+	to=$2
+	(cd $from; find . -print0 | cpio --null -pdlu $to)
+}
+
+
 def check_app_exists(app, d):
     app = d.expand(app)
     path = d.getVar('PATH', d, True)



More information about the Openembedded-commits mailing list