]> code.ossystems Code Review - openembedded-core.git/commitdiff
utils: Add hardlinkdir shell function
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 24 Apr 2014 09:17:18 +0000 (10:17 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 25 Apr 2014 16:10:57 +0000 (17:10 +0100)
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@linuxfoundation.org>
meta/classes/utils.bbclass

index 0a533afb1f657916d0ede8f12d7e97e88f47c0b8..89ad8c55314d70937c70808d13f606ac4820995c 100644 (file)
@@ -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)