Skip to content

Commit

Permalink
Fix several inst functions.
Browse files Browse the repository at this point in the history
Move file existence checking into the individual inst functions. This makes
things a bit easier to understand and maintain.
  • Loading branch information
Victor Lowther authored and haraldh committed Mar 4, 2009
1 parent a344b76 commit 54b4419
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions dracut-functions
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
<# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Authors:
# Peter Jones <pjones@redhat.com>
Expand All @@ -31,7 +31,9 @@ strstr() { [[ ! ${1#*$2*} = $1 ]]; }
# $2 (optional) Name for the file on the ramdisk
# Location of the image dir is assumed to be $initdir
inst_simple() {
local src=$1 target="${initdir}${2:-$1}"
local src target
[[ -f $1 ]] || return 1
src=$1 target="${initdir}${2:-$1}"
[[ -f $target ]] && return 0
mkdir -p "${target%/*}"
echo "Installing $src" >&2
Expand Down Expand Up @@ -76,7 +78,9 @@ find_file() {
# If the file is a binary executable, install all its
# shared library dependencies, if any.
inst_binary() {
local bin="$1" target="${2:-$1}"
local bin target
bin=$(find_binary "$1") || return 1
shift
local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
[[ -f $initdir$target ]] && return 0
# I love bash!
Expand Down Expand Up @@ -107,12 +111,13 @@ inst_binary() {
}
inst_library "$FILE"
done < <(ldd $bin 2>/dev/null)
inst_simple "$bin" "$target"
inst_simple "$bin" "$@"
}

# same as above, except for shell scripts.
# If your shell script does not start with shebang, it is not a shell script.
inst_script() {
[[ -f $1 ]] || return 1
local src=$1 target=${2:-$1} line
read -r -n 80 line <"$src"
[[ $line =~ (#! *)(/[^ ]+).* ]] || return 1
Expand Down Expand Up @@ -152,13 +157,8 @@ inst() {
echo "usage: inst <file> <root> [<destination file>]"
return 1
fi
local src=$(find_file "$1") || {
echo "Cannot find requested file $1. Exiting."
exit 1
}
local dest=${2:-$src}
for x in inst_symlink inst_script inst_binary inst_simple; do
$x "$src" "$dest" && return 0
$x "$@" && return 0
done
return 1
}
Expand Down

0 comments on commit 54b4419

Please sign in to comment.