Browse Source

[PATCH 22/50] Bashify inst function where ot makes things easier to read.

master
Victor Lowther 16 years ago committed by Dave Jones
parent
commit
170b260bd9
  1. 31
      dracut-functions

31
dracut-functions

@ -62,36 +62,35 @@ get_dso_deps() {
} }


inst() { inst() {
if [ "$#" != "2" -a "$#" != "3" ];then if (($# != 2 && $# != 3));then
echo "usage: inst <file> <root> [<destination file>]" echo "usage: inst <file> <root> [<destination file>]"
return 1 return 1
fi fi
local file="$1" ; shift local file="$1" ; shift
local root="${1%%/}/" ; shift local root="${1%%/}" ; shift
local dest="${1##/}" local dest="${1##/}"
[ -z "$dest" ] && local dest="${file##/}" [[ $dest ]] || dest="${file##/}"


mkdir -p "$root/$(dirname $dest)" mkdir -p "$root/${dest%/*}"


local RET=0 local RET=0
local target="" local target=""
[ -L "$file" ] && target=$(readlink "$file") [ -L "$file" ] && target=$(readlink "$file")
if [ -n "$target" -a "$dest" != "$target" ]; then if [[ $target && $dest != $target ]]; then
if [ -e "$root$dest" ]; then if [[ -e $root/$dest ]]; then
RET=0 RET=0
else else

ln -sf "$target" "$root/$dest"
ln -sf "$target" "$root$dest"
#inst "$target" "$root" #inst "$target" "$root"
local BASE=`basename "$target"` local BASE=${target##*/}
local LIBDIR=`echo "$file" | sed -e 's,\(\(.*\)/\)[^/]\+$,\1,'` local LIBDIR=`echo "$file" | sed -e 's,\(\(.*\)/\)[^/]\+$,\1,'`
if [ "$LIBDIR" = "$BASE" ]; then if [[ $LIBDIR = $BASE ]]; then
local LIBDIR=`echo "/$dest" | sed -e 's,\(\(.*\)/\)[^/]\+$,\1,'` local LIBDIR=`echo "/$dest" | sed -e 's,\(\(.*\)/\)[^/]\+$,\1,'`
fi fi


local TLIBDIR=`echo "$target" | sed -e 's,\(^/lib[^/]*\)/.*$,\1/,' \ local TLIBDIR=`echo "$target" | sed -e 's,\(^/lib[^/]*\)/.*$,\1/,' \
-e 's,\(\(.*\)/\)[^/]\+$,\1,'` -e 's,\(\(.*\)/\)[^/]\+$,\1,'`
if [ "$TLIBDIR" = "$BASE" ]; then if [[ $TLIBDIR = $BASE ]]; then
local TLIBDIR=`echo "/$dest" | sed \ local TLIBDIR=`echo "/$dest" | sed \
-e 's,\(^/lib[^/]*\)/.*$,\1/,' \ -e 's,\(^/lib[^/]*\)/.*$,\1/,' \
-e 's,\(\(.*\)/\)[^/]\+$,\1,'` -e 's,\(\(.*\)/\)[^/]\+$,\1,'`
@ -104,7 +103,7 @@ inst() {
fi fi


local SHEBANG=$(dd if="$file" bs=2 count=1 2>/dev/null) local SHEBANG=$(dd if="$file" bs=2 count=1 2>/dev/null)
if [ "$SHEBANG" == '#!' ]; then if [[ $SHEBANG = '#!' ]]; then
# We're intentionally not playing the "what did this moron run # We're intentionally not playing the "what did this moron run
# in his shell script" game. There's nothing but pain in that. # in his shell script" game. There's nothing but pain in that.
local interp=$(head -1 "$file" | sed 's/^#! *//') local interp=$(head -1 "$file" | sed 's/^#! *//')
@ -113,17 +112,17 @@ inst() {
return $RET return $RET
fi fi


if [ -e "$root$dest" ]; then if [[ -e $root/$dest ]]; then
RET=0 RET=0
else else
if [ -n "$target" -a -L "$target" ]; then if [[ $target && -L $target ]]; then
inst "$target" "$root" inst "$target" "$root"
RET=$? RET=$?
else else
cp -aL "$file" "$root$dest" cp -aL "$file" "$root/$dest"


local DEPS=$(get_dso_deps "$file") local DEPS=$(get_dso_deps "$file")
if [ -n "$DEPS" ]; then if [[ $DEPS ]]; then
IF_dynamic="yes" IF_dynamic="yes"
fi fi
for x in $DEPS ; do for x in $DEPS ; do

Loading…
Cancel
Save