base-files: automatically handle paths and symlinks for RAMFS_COPY_BIN

Depending on busybox applet selection, paths of basic utiilties may differ,
and may not work as symlinks to busybox. Simply using whatever binary is
found in PATH and detecting symlinks automatically is more robust and
easier to maintain.

The list of binaries is also slightly cleaned up and duplicates are
removed.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
Matthias Schiffer
2017-07-10 18:37:25 +02:00
parent f464da623d
commit 438dcbfe74
10 changed files with 40 additions and 46 deletions

View File

@@ -6,28 +6,33 @@ RAM_ROOT=/tmp/root
libs() { ldd $* 2>/dev/null | sed -r 's/(.* => )?(.*) .*/\2/'; }
install_file() { # <file> [ <file> ... ]
local target dest dir
for file in "$@"; do
if [ -L "$file" ]; then
target="$(readlink -f "$file")"
dest="$RAM_ROOT/$file"
[ ! -f "$dest" ] && {
dir="$(dirname "$dest")"
mkdir -p "$dir"
ln -s "$target" "$dest"
}
file="$target"
fi
dest="$RAM_ROOT/$file"
[ -f $file -a ! -f $dest ] && {
dir="$(dirname $dest)"
[ -f "$file" -a ! -f "$dest" ] && {
dir="$(dirname "$dest")"
mkdir -p "$dir"
cp $file $dest
cp "$file" "$dest"
}
done
}
install_bin() { # <file> [ <symlink> ... ]
install_bin() {
local src files
src=$1
files=$1
[ -x "$src" ] && files="$src $(libs $src)"
install_file $files
shift
for link in "$@"; do {
dest="$RAM_ROOT/$link"
dir="$(dirname $dest)"
mkdir -p "$dir"
[ -f "$dest" ] || ln -s $src $dest
}; done
}
run_hooks() {