diff options
| -rwxr-xr-x | meta/recipes-devtools/icecc-create-env/icecc-create-env/icecc-create-env | 112 |
1 files changed, 77 insertions, 35 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 3015f4e215..b88c53a424 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 | |||
| @@ -99,48 +99,90 @@ normalize_path () | |||
| 99 | echo $path | 99 | echo $path |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | add_file () | 102 | add_file_common() |
| 103 | { | ||
| 104 | local p="$1" | ||
| 105 | local path="$2" | ||
| 106 | local alias="$3" | ||
| 107 | |||
| 108 | add_alias "$path" "$p" | ||
| 109 | if test -n "$alias"; then | ||
| 110 | add_alias "$path" "$alias" | ||
| 111 | fi | ||
| 112 | |||
| 113 | add_path "$path" || return 1 | ||
| 114 | print_debug "Adding file '$path'" | ||
| 115 | |||
| 116 | return 0 | ||
| 117 | } | ||
| 118 | |||
| 119 | add_deps() | ||
| 120 | { | ||
| 121 | local path="$1" | ||
| 122 | local interp="$2" | ||
| 123 | |||
| 124 | if test -n "$interp" && test -x "$interp"; then | ||
| 125 | # Use the dynamic loaders --list argument to list the | ||
| 126 | # dependencies. The program may have a different program | ||
| 127 | # interpreter (typical when using uninative tarballs), which is | ||
| 128 | # why we can't just call ldd. | ||
| 129 | deps="`$interp --list "$path"`" | ||
| 130 | else | ||
| 131 | deps="`ldd "$path"`" | ||
| 132 | fi | ||
| 133 | |||
| 134 | print_debug "Dependencies are:" | ||
| 135 | print_debug "$deps" | ||
| 136 | if test -n "$deps"; then | ||
| 137 | for lib in $deps; do | ||
| 138 | # ldd now outputs ld as /lib/ld-linux.so.xx on current nptl | ||
| 139 | # based glibc this regexp parse the outputs like: | ||
| 140 | # ldd /usr/bin/gcc | ||
| 141 | # linux-gate.so.1 => (0xffffe000) | ||
| 142 | # libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000) | ||
| 143 | # /lib/ld-linux.so.2 (0xb7fe8000) | ||
| 144 | # covering both situations ( with => and without ) | ||
| 145 | lib="`echo "$lib" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`" | ||
| 146 | |||
| 147 | test -f "$lib" || continue | ||
| 148 | # Check whether the same library also exists in the parent | ||
| 149 | # directory, and prefer that on the assumption that it is a | ||
| 150 | # more generic one. | ||
| 151 | local baselib=`echo "$lib" | sed 's,\(/[^/]*\)/.*\(/[^/]*\)$,\1\2,'` | ||
| 152 | test -f "$baselib" && lib=$baselib | ||
| 153 | add_dependency "$lib" "$interp" | ||
| 154 | done | ||
| 155 | fi | ||
| 156 | } | ||
| 157 | |||
| 158 | add_dependency() | ||
| 103 | { | 159 | { |
| 104 | local p=`normalize_path $1` | 160 | local p=`normalize_path $1` |
| 105 | # readlink is required for Yocto, so we can use it | 161 | # readlink is required for Yocto, so we can use it |
| 106 | local path=`readlink -f "$p"` | 162 | local path=`readlink -f "$p"` |
| 163 | local interp="$2" | ||
| 107 | 164 | ||
| 108 | add_alias "$path" "$p" | 165 | add_file_common "$p" "$path" || return |
| 109 | if test -n "$2"; then | 166 | |
| 110 | add_alias "$path" "$2" | 167 | if test -x "$path" && is_dynamic_elf "$path"; then |
| 168 | add_deps "$path" "$interp" | ||
| 111 | fi | 169 | fi |
| 170 | } | ||
| 112 | 171 | ||
| 113 | add_path "$path" || return | 172 | add_file () |
| 114 | 173 | { | |
| 115 | if test -x "$path"; then | 174 | local p=`normalize_path $1` |
| 116 | # Only call ldd when it makes sense | 175 | # readlink is required for Yocto, so we can use it |
| 117 | if is_dynamic_elf "$path"; then | 176 | local path=`readlink -f "$p"` |
| 118 | # Request the program interpeter (dynamic loader) | 177 | |
| 119 | interp=`readelf -w -l "$path" | grep "Requesting program interpreter:" | sed "s/\s*\[Requesting program interpreter:\s*\(.*\)\]/\1/g"` | 178 | add_file_common "$p" "$path" "$2" || return |
| 120 | 179 | ||
| 121 | if test -n "$interp" && test -x "$interp"; then | 180 | if test -x "$path" && is_dynamic_elf "$path"; then |
| 122 | # Use the dynamic loaders --list argument to list the | 181 | # Request the program interpeter (dynamic loader) |
| 123 | # depenencies. The program may have a a different program | 182 | interp=`readelf -W -l "$path" | grep "Requesting program interpreter:" | sed "s/\s*\[Requesting program interpreter:\s*\(.*\)\]/\1/g"` |
| 124 | # interpeter (typical when using uninative tarballs), which is | 183 | print_debug "Interpreter is '$interp'" |
| 125 | # why we can't just call ldd. | 184 | |
| 126 | # | 185 | add_deps "$path" "$interp" |
| 127 | # ldd now outputs ld as /lib/ld-linux.so.xx on current nptl based glibc | ||
| 128 | # this regexp parse the outputs like: | ||
| 129 | # ldd /usr/bin/gcc | ||
| 130 | # linux-gate.so.1 => (0xffffe000) | ||
| 131 | # libc.so.6 => /lib/tls/libc.so.6 (0xb7e81000) | ||
| 132 | # /lib/ld-linux.so.2 (0xb7fe8000) | ||
| 133 | # covering both situations ( with => and without ) | ||
| 134 | for lib in `$interp --list "$path" | sed -n 's,^[^/]*\(/[^ ]*\).*,\1,p'`; do | ||
| 135 | test -f "$lib" || continue | ||
| 136 | # Check wether the same library also exists in the parent directory, | ||
| 137 | # and prefer that on the assumption that it is a more generic one. | ||
| 138 | local baselib=`echo "$lib" | sed 's,\(/[^/]*\)/.*\(/[^/]*\)$,\1\2,'` | ||
| 139 | test -f "$baselib" && lib=$baselib | ||
| 140 | add_file "$lib" | ||
| 141 | done | ||
| 142 | fi | ||
| 143 | fi | ||
| 144 | fi | 186 | fi |
| 145 | } | 187 | } |
| 146 | 188 | ||
