icecc-create-env: Allow multiple tool aliases

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.

(From OE-Core rev: 0a5bbad5810b69fa09dbd8d886e4f368310a5db9)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2018-02-12 10:52:06 -06:00
committed by Richard Purdie
parent 15f78b0ff3
commit f51f28b7b9

View File

@@ -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
target_files=
for path in $target_paths; do
mkdir -p $tempdir/`dirname $path`
cp -pH $path $tempdir/$path
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
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
fix_rpath $tempdir/$path `dirname $path`
path=`echo $path | cut -b2-`
new_target_files="$new_target_files $path"
if test -f $tempdir/$path -a -x $tempdir/$path; then
strip -s $tempdir/$path 2>/dev/null
fi
target=`echo $target | cut -b2-`
new_target_files="$new_target_files $target"
fix_rpath $tempdir/$path `dirname $path`
target_files="$target_files $path"
done
for i in $target_aliases; do
target=`echo $i | cut -d= -f1`
link_name=`echo $i | cut -d= -f2`
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
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