diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2018-02-12 10:52:06 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-02-15 13:28:54 +0000 |
commit | f51f28b7b927fde9489e244cb812b562f28bbafa (patch) | |
tree | e2bef997c228da75236e8a68cd6eb73dd4d139dd | |
parent | 15f78b0ff35d743d44fd80aabb8c2f0ec7aa4e73 (diff) | |
download | poky-f51f28b7b927fde9489e244cb812b562f28bbafa.tar.gz |
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>
-rwxr-xr-x | meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env | 110 |
1 files 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 90d249df9f..537e38a9ba 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 @@ | |||
4 | # Copyright (C) 2004 by the Icecream Authors | 4 | # Copyright (C) 2004 by the Icecream Authors |
5 | # GPL | 5 | # GPL |
6 | 6 | ||
7 | target_files= | 7 | target_paths= |
8 | target_aliases= | ||
8 | 9 | ||
9 | is_dynamic_elf () | 10 | is_dynamic_elf () |
10 | { | 11 | { |
@@ -32,15 +33,33 @@ fix_rpath () | |||
32 | fi | 33 | fi |
33 | } | 34 | } |
34 | 35 | ||
35 | is_contained () | 36 | add_path () |
36 | { | 37 | { |
37 | case " $target_files " in | 38 | case " $target_paths " in |
38 | *" $1 "* ) return 0 ;; | 39 | *" $1 "*) |
39 | *"=$1 "* ) return 0;; | 40 | return 1 |
40 | * ) return 1 ;; | 41 | ;; |
42 | *) | ||
43 | target_paths="$target_paths $1" | ||
44 | return 0 | ||
45 | ;; | ||
41 | esac | 46 | esac |
42 | } | 47 | } |
43 | 48 | ||
49 | add_alias () | ||
50 | { | ||
51 | if test "$1" != "$2"; then | ||
52 | local alias="$1=$2" | ||
53 | case " $target_aliases " in | ||
54 | *" $alias "*) | ||
55 | ;; | ||
56 | *) | ||
57 | target_aliases="$target_aliases $alias" | ||
58 | ;; | ||
59 | esac | ||
60 | fi | ||
61 | } | ||
62 | |||
44 | normalize_path () | 63 | normalize_path () |
45 | { | 64 | { |
46 | # Normalizes the path to a file or directory, removing all "." and ".." | 65 | # Normalizes the path to a file or directory, removing all "." and ".." |
@@ -61,20 +80,17 @@ normalize_path () | |||
61 | 80 | ||
62 | add_file () | 81 | add_file () |
63 | { | 82 | { |
64 | local path=`normalize_path $1` | 83 | local p=`normalize_path $1` |
65 | local name="$path" | ||
66 | if test -n "$2"; then | ||
67 | name="$2" | ||
68 | fi | ||
69 | test -z "$name" && return | ||
70 | # readlink is required for Yocto, so we can use it | 84 | # readlink is required for Yocto, so we can use it |
71 | path=`readlink -f "$path"` | 85 | local path=`readlink -f "$p"` |
72 | toadd="$name=$path" | 86 | |
73 | is_contained "$toadd" && return | 87 | add_alias "$path" "$p" |
74 | if test -z "$silent"; then | 88 | if test -n "$2"; then |
75 | echo "adding file $toadd" | 89 | add_alias "$path" "$2" |
76 | fi | 90 | fi |
77 | target_files="$target_files $toadd" | 91 | |
92 | add_path "$path" || return | ||
93 | |||
78 | if test -x "$path"; then | 94 | if test -x "$path"; then |
79 | # Only call ldd when it makes sense | 95 | # Only call ldd when it makes sense |
80 | if is_dynamic_elf "$path"; then | 96 | if is_dynamic_elf "$path"; then |
@@ -208,52 +224,34 @@ link_rel () | |||
208 | } | 224 | } |
209 | 225 | ||
210 | tempdir=`mktemp -d /tmp/iceccenvXXXXXX` | 226 | tempdir=`mktemp -d /tmp/iceccenvXXXXXX` |
211 | new_target_files= | 227 | target_files= |
212 | for i in $target_files; do | 228 | for path in $target_paths; do |
213 | case $i in | 229 | mkdir -p $tempdir/`dirname $path` |
214 | *=/*) | 230 | cp -pH $path $tempdir/$path |
215 | target=`echo $i | cut -d= -f1` | ||
216 | path=`echo $i | cut -d= -f2` | ||
217 | ;; | ||
218 | *) | ||
219 | path=$i | ||
220 | target=$i | ||
221 | ;; | ||
222 | esac | ||
223 | if test "$target" == "$path"; then | ||
224 | mkdir -p $tempdir/`dirname $target` | ||
225 | cp -pH $target $tempdir/$target | ||
226 | |||
227 | if test -f $tempdir/$target -a -x $tempdir/$target; then | ||
228 | strip -s $tempdir/$target 2>/dev/null | ||
229 | fi | ||
230 | |||
231 | fix_rpath $tempdir/$target `dirname $target` | ||
232 | else | ||
233 | mkdir -p $tempdir/`dirname $path` | ||
234 | cp -pH $path $tempdir/$path | ||
235 | 231 | ||
236 | mkdir -p $tempdir/`dirname $target` | 232 | if test -f $tempdir/$path -a -x $tempdir/$path; then |
237 | # Relative links are used because the files are checked for being | 233 | strip -s $tempdir/$path 2>/dev/null |
238 | # executable outside the chroot | 234 | fi |
239 | link_rel $path $target $tempdir | ||
240 | 235 | ||
241 | if test -f $tempdir/$path -a -x $tempdir/$path; then | 236 | fix_rpath $tempdir/$path `dirname $path` |
242 | strip -s $tempdir/$path 2>/dev/null | 237 | target_files="$target_files $path" |
243 | fi | 238 | done |
244 | 239 | ||
245 | fix_rpath $tempdir/$path `dirname $path` | 240 | for i in $target_aliases; do |
241 | target=`echo $i | cut -d= -f1` | ||
242 | link_name=`echo $i | cut -d= -f2` | ||
246 | 243 | ||
247 | path=`echo $path | cut -b2-` | 244 | mkdir -p $tempdir/`dirname $link_name` |
248 | new_target_files="$new_target_files $path" | 245 | # Relative links are used because the files are checked for being |
249 | fi | 246 | # executable outside the chroot |
247 | link_rel $target $link_name $tempdir | ||
250 | 248 | ||
251 | target=`echo $target | cut -b2-` | 249 | link_name=`echo $link_name | cut -b2-` |
252 | new_target_files="$new_target_files $target" | 250 | target_files="$target_files $link_name" |
253 | done | 251 | done |
254 | 252 | ||
255 | #sort the files | 253 | #sort the files |
256 | target_files=`for i in $new_target_files; do echo $i; done | sort` | 254 | target_files=`for i in $target_files; do echo $i; done | sort` |
257 | 255 | ||
258 | #test if an archive name was supplied | 256 | #test if an archive name was supplied |
259 | #if not use the md5 of all files as the archive name | 257 | #if not use the md5 of all files as the archive name |