[poky] [PATCH 3/3] staging.bbclass: use hardlink when staging files to sysroot-destdir
Dongxiao Xu
dongxiao.xu at intel.com
Mon Dec 6 04:37:36 PST 2010
Use hardlink to replace copy when staging files to sysroot-destdir.
If fail, it will fall back to copy function.
Signed-off-by: Dongxiao Xu <dongxiao.xu at intel.com>
---
meta/classes/staging.bbclass | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass
index e82db83..159562d 100644
--- a/meta/classes/staging.bbclass
+++ b/meta/classes/staging.bbclass
@@ -3,6 +3,31 @@ packagedstaging_fastpath () {
:
}
+hardlink() {
+ local src="$1"
+ local dest="$2"
+ local name names srcname destname
+
+ if [ ! -d "$dest" ]; then
+ mkdir -p "$dest"
+ fi
+
+ names=$(ls $src)
+ for name in $names
+ do
+ srcname=$src"/"$name
+ destname=$dest"/"$name
+ if [ -d "$srcname" ]; then
+ hardlink $srcname $destname
+ else
+ ln -f $srcname $destname || true
+ if [ ! -e $destname ]; then
+ cp -fpPR $srcname $destname
+ fi
+ fi
+ done
+}
+
sysroot_stage_dir() {
src="$1"
dest="$2"
@@ -17,7 +42,7 @@ sysroot_stage_dir() {
# However we always want to stage a $src itself, even if it's empty
mkdir -p "$dest"
if [ -d "$src" ]; then
- cp -fpPR "$src"/* "$dest"
+ hardlink "$src" "$dest"
fi
}
--
1.6.3.3
More information about the poky
mailing list