summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-06-05 19:17:19 +0200
committerDave Reisner <d@falconindy.com>2011-06-16 20:19:12 +0200
commit32e3a80c2a8bd9c1278db3e33ea9b5963db0218a (patch)
treee1791a1b90051c66902e52ab9574a2bc63ec1268 /functions
parent7abf4110cf3d5bb52f515b6fe05a60bd44aa4385 (diff)
downloadmkinitcpio-32e3a80c2a8bd9c1278db3e33ea9b5963db0218a.tar.gz
mkinitcpio-32e3a80c2a8bd9c1278db3e33ea9b5963db0218a.tar.xz
functions: cleanup and refactor add_binary
Modify the sed filter to remove PIC addresses and ignore the first line which will always be the vdso. Also remove the tls filter, as glibc has had threaded support mainlined for many years now. If a user has a glibc this old, we don't have support for them elsewhere (udev, kernel). We also cleanup the logical flow through this function and remove a lot of cruft that would always return true, or that didn't quite make sense. Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'functions')
-rw-r--r--functions52
1 files changed, 19 insertions, 33 deletions
diff --git a/functions b/functions
index 4da4d4e..f58e42f 100644
--- a/functions
+++ b/functions
@@ -152,7 +152,7 @@ add_file ()
add_symlink "${fil}" "${lnk}"
fil="${lnk}"
fi
- if [ $# -eq 2 ]; then
+ if [[ $2 ]]; then
dest="${2}"
else
dest="${fil##$BASEDIR}"
@@ -221,48 +221,34 @@ add_module ()
add_binary ()
{
- local bin dest type lib
- bin=$(which "${1}")
- if [ $? -ne 0 ]; then
- bin="${1}"
- fi
+ local bin dest lib
- dest=""
- if [ $# -eq 2 ]; then
- dest=${2}
- fi
+ bin=$(type -P "$1")
+ dest=$2
- if [ ! -f "${bin}" ]; then
- err "'${bin}' is not a file"
+ if [[ ! -f "$bin" ]]; then
+ err "'$1' is not a file"
return 1
fi
- if [ $? -eq 0 ]; then
- type=$(file -b "${bin}")
- case "${type}" in
- *script*)
+ case "$(file -b "$bin")" in
+ *script*)
msg " adding '${type}' script, ensure proper interp exists..."
- add_file "${bin}" ${dest}
+ add_file "$bin" ${dest+"$dest"}
;;
- *executable*|*shared\ object*|*symbolic\ link*)
- add_file "${bin}" ${dest}
- #note, this will also handle 'not a dynamic executable' spit out by
- # static binaries... the deps will produce nothing
- for lib in $(ldd ${bin} 2>/dev/null | sed "s|.*=>\(.*\)|\1|"); do
- if [ -n "${lib}" ]; then
- #remove TLS libraries
- notls=$(echo ${lib} | sed 's|/lib/tls.*/\(lib.*\)|/lib/\1|')
- [ -e "${notls}" ] && lib="${notls}"
- [ -f "${lib}" ] && add_file "${lib}"
- fi
- done
+ *executable*|*shared\ object*|*symbolic\ link*)
+ add_file "$bin" ${dest+"$dest"}
+ # note, this will also handle 'not a dynamic executable' spit out
+ # by static binaries... the deps will produce nothing
+ while read -r lib; do
+ [[ -f "$lib" ]] && add_file "$lib"
+ done < <(ldd "$bin" 2>/dev/null | sed '1d;s|.*=>\(.*\)|\1|;s/(0x[0-9a-f]\+)//')
;;
- *)
- err "unknown type '${type}' for binary '${bin}'"
+ *)
+ err "unknown type '$type' for binary '$bin'"
return 1
;;
- esac
- fi
+ esac
}
parse_hook ()