diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2018-02-12 10:52:02 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-02-15 13:20:27 +0000 |
commit | 256f8f6cc5b520b59cfdc44aa076f71990e18e2c (patch) | |
tree | f63e6cae5f451ce9594e20c7d450253056315c63 /meta/recipes-devtools/icecc-create-env | |
parent | 96d5831ef0e535d3f91acd3e979316355fbde04e (diff) | |
download | openembedded-core-contrib-256f8f6cc5b520b59cfdc44aa076f71990e18e2c.tar.gz |
icecc-create-env: Symlink alternate names
Instead of renaming files to a new path in the toolchain archive, keep
the files with their original paths and create a relative symbolic link
from the new path to the original file.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/icecc-create-env')
-rwxr-xr-x | meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env | 64 |
1 files changed, 57 insertions, 7 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 7636d090a4..0791bd54b2 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 @@ -21,10 +21,28 @@ is_contained () esac } +normalize_path () +{ + # Normalizes the path to a file or directory, removing all "." and ".." + # entries. Use pwd -L to explicitly prevent symlink expansion + local path=$1 + if test -f "$path"; then + pushd $(dirname $path) > /dev/null 2>&1 + dir_path=$(pwd -L) + path=$dir_path/$(basename $path) + popd > /dev/null 2>&1 + elif test -d "$path"; then + pushd $path > /dev/null 2>&1 + path=$(pwd -L) + popd > /dev/null 2>&1 + fi + echo $path +} + add_file () { - local name="$1" - local path="$1"; + local path=`normalize_path $1` + local name="$path" if test -n "$2"; then name="$2" fi @@ -129,7 +147,7 @@ if test -n "$specfile" && test -e "$specfile"; then fi ltofile=`$added_gcc -print-prog-name=lto1` -pluginfile="${ltofile%lto1}liblto_plugin.so" +pluginfile=`normalize_path "${ltofile%lto1}liblto_plugin.so"` if test -r "$pluginfile" then add_file $pluginfile ${pluginfile#*usr} @@ -146,6 +164,19 @@ else exit 1 fi +link_rel () +{ + local target="$1" + local name="$2" + local base="$3" + + local prefix=`dirname $name` + + prefix=`echo $prefix | sed 's,[^/]\+,..,g' | sed 's,^/*,,g'` + + ln -s $prefix/$target $base/$name +} + tempdir=`mktemp -d /tmp/iceccenvXXXXXX` new_target_files= for i in $target_files; do @@ -159,11 +190,30 @@ for i in $target_files; do target=$i ;; esac - mkdir -p $tempdir/`dirname $target` - cp -p $path $tempdir/$target - if test -f $tempdir/$target -a -x $tempdir/$target; then - strip -s $tempdir/$target 2>/dev/null + 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 + 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 + + path=`echo $path | cut -b2-` + new_target_files="$new_target_files $path" fi + target=`echo $target | cut -b2-` new_target_files="$new_target_files $target" done |