When files are added to the environment, multiple aliases can be given
for the file (by calling add_path multiple times with a second
argument). All of these names will end up with a symlink to the original
file.

Signed-off-by: Joshua Watt <jpewhac...@gmail.com>
---
 .../icecc-create-env/icecc-create-env              | 110 ++++++++++-----------
 1 file changed, 54 insertions(+), 56 deletions(-)

diff --git 
a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env 
b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
index 90d249df9f3..537e38a9ba0 100755
--- a/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
+++ b/meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env
@@ -4,7 +4,8 @@
 # Copyright (C) 2004 by the Icecream Authors
 # GPL
 
-target_files=
+target_paths=
+target_aliases=
 
 is_dynamic_elf ()
 {
@@ -32,15 +33,33 @@ fix_rpath ()
     fi
 }
 
-is_contained ()
+add_path ()
 {
-    case " $target_files " in
-        *" $1 "* ) return 0 ;;
-        *"=$1 "* ) return 0;;
-        * ) return 1 ;;
+    case " $target_paths " in
+        *" $1 "*)
+            return 1
+            ;;
+        *)
+            target_paths="$target_paths $1"
+            return 0
+            ;;
     esac
 }
 
+add_alias ()
+{
+    if test "$1" != "$2"; then
+        local alias="$1=$2"
+        case " $target_aliases " in
+            *" $alias "*)
+                ;;
+            *)
+                target_aliases="$target_aliases $alias"
+                ;;
+        esac
+    fi
+}
+
 normalize_path ()
 {
     # Normalizes the path to a file or directory, removing all "." and ".."
@@ -61,20 +80,17 @@ normalize_path ()
 
 add_file ()
 {
-    local path=`normalize_path $1`
-    local name="$path"
-    if test -n "$2"; then
-        name="$2"
-    fi
-    test -z "$name" && return
+    local p=`normalize_path $1`
     # readlink is required for Yocto, so we can use it
-    path=`readlink -f "$path"`
-    toadd="$name=$path"
-    is_contained "$toadd" && return
-    if test -z "$silent"; then
-        echo "adding file $toadd"
+    local path=`readlink -f "$p"`
+
+    add_alias "$path" "$p"
+    if test -n "$2"; then
+        add_alias "$path" "$2"
     fi
-    target_files="$target_files $toadd"
+
+    add_path "$path" || return
+
     if test -x "$path"; then
         # Only call ldd when it makes sense
         if is_dynamic_elf "$path"; then
@@ -208,52 +224,34 @@ link_rel ()
 }
 
 tempdir=`mktemp -d /tmp/iceccenvXXXXXX`
-new_target_files=
-for i in $target_files; do
-    case $i in
-        *=/*)
-            target=`echo $i | cut -d= -f1`
-            path=`echo $i | cut -d= -f2`
-            ;;
-        *)
-            path=$i
-            target=$i
-            ;;
-    esac
-    if test "$target" == "$path"; then
-        mkdir -p $tempdir/`dirname $target`
-        cp -pH $target $tempdir/$target
-
-        if test -f $tempdir/$target -a -x $tempdir/$target; then
-            strip -s $tempdir/$target 2>/dev/null
-        fi
-
-        fix_rpath $tempdir/$target `dirname $target`
-    else
-        mkdir -p $tempdir/`dirname $path`
-        cp -pH $path $tempdir/$path
+target_files=
+for path in $target_paths; do
+    mkdir -p $tempdir/`dirname $path`
+    cp -pH $path $tempdir/$path
 
-        mkdir -p $tempdir/`dirname $target`
-        # Relative links are used because the files are checked for being
-        # executable outside the chroot
-        link_rel $path $target $tempdir
+    if test -f $tempdir/$path -a -x $tempdir/$path; then
+        strip -s $tempdir/$path 2>/dev/null
+    fi
 
-        if test -f $tempdir/$path -a -x $tempdir/$path; then
-            strip -s $tempdir/$path 2>/dev/null
-        fi
+    fix_rpath $tempdir/$path `dirname $path`
+    target_files="$target_files $path"
+done
 
-        fix_rpath $tempdir/$path `dirname $path`
+for i in $target_aliases; do
+    target=`echo $i | cut -d= -f1`
+    link_name=`echo $i | cut -d= -f2`
 
-        path=`echo $path | cut -b2-`
-        new_target_files="$new_target_files $path"
-    fi
+    mkdir -p $tempdir/`dirname $link_name`
+    # Relative links are used because the files are checked for being
+    # executable outside the chroot
+    link_rel $target $link_name $tempdir
 
-    target=`echo $target | cut -b2-`
-    new_target_files="$new_target_files $target"
+    link_name=`echo $link_name | cut -b2-`
+    target_files="$target_files $link_name"
 done
 
 #sort the files
-target_files=`for i in $new_target_files; do echo $i; done | sort`
+target_files=`for i in $target_files; do echo $i; done | sort`
 
 #test if an archive name was supplied
 #if not use the md5 of all files as the archive name
-- 
2.14.3

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to