summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-05-03 23:55:19 +0200
committerDave Reisner <dreisner@archlinux.org>2012-05-12 15:30:32 +0200
commitfff89b9c2af57f3bcb4b1adf701f596177badebd (patch)
treec7c8ab16a67018cf192dadae946c8608e92736d1
parent88b3dc63a1e0ba42952bc2b6478935590974e4cf (diff)
downloadmkinitcpio-fff89b9c2af57f3bcb4b1adf701f596177badebd.tar.gz
mkinitcpio-fff89b9c2af57f3bcb4b1adf701f596177badebd.tar.xz
functions: merge _add_file into add_file
This frontend/backend split is no longer necessary without the notion of a basedir. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--functions44
1 files changed, 16 insertions, 28 deletions
diff --git a/functions b/functions
index 924fd13..8ff1d09 100644
--- a/functions
+++ b/functions
@@ -192,24 +192,6 @@ in_array() {
return 1 # Not Found
}
-_add_file() {
- # add a file to $BUILDROOT
- # $1: pathname on initcpio
- # $2: source on disk
- # $3: mode
-
- (( $# == 3 )) || return $EINVAL
-
- if (( ! QUIET )); then
- if [[ -e "$BUILDROOT$1" ]]; then
- plain "overwriting file: %s" "$1"
- else
- plain "adding file: %s" "$1"
- fi
- fi
- command install -Dm$3 "$2" "$BUILDROOT$1"
-}
-
_add_symlink() {
# add a symlink to $buildroot
# $1: name on initcpio
@@ -302,7 +284,7 @@ add_module() {
;;
firmware)
if [[ -e /usr/lib/firmware/$value ]]; then
- _add_file "/usr/lib/firmware/$value" "/usr/lib/firmware/$value" 644
+ add_file "/usr/lib/firmware/$value" "/usr/lib/firmware/$value" 644
fi
;;
esac
@@ -376,23 +358,29 @@ add_file() {
# the singular file is added.
# $1: path to file
# $2: destination on initcpio (optional, defaults to same as source)
+ # $3: mode
(( $# )) || return 1
# determine source and destination
- local src= dest=${2:-$1} mode=
-
- src=$1
+ local src=$1 dest=${2:-$1} mode=$3
- [[ -f "$src" ]] || { error "file not found: \`%s'" "$src"; return 1; }
+ [[ -f $src ]] || { error "file not found: \`%s'" "$src"; return 1; }
- mode=$(stat -c %a "$src")
+ mode=${3:-$(stat -c %a "$src")}
if [[ -z "$mode" ]]; then
error "failed to stat file: \`%s'." "$src"
return 1
fi
- _add_file "$dest" "$src" "$mode"
+ if (( ! QUIET )); then
+ if [[ -e $BUILDROOT$dest ]]; then
+ plain "overwriting file: %s" "$dest"
+ else
+ plain "adding file: %s" "$dest"
+ fi
+ fi
+ command install -Dm$mode "$src" "$BUILDROOT$dest"
}
add_binary() {
@@ -416,7 +404,7 @@ add_binary() {
mode=$(stat -c %a "$binary")
# always add the binary itself
- _add_file "$dest" "$binary" "$mode"
+ add_file "$binary" "$dest" "$mode"
lddout=$(ldd "$binary" 2>/dev/null) || return 0 # not a binary!
@@ -427,13 +415,13 @@ add_binary() {
if [[ -f $sodep && ! -e $BUILDROOT$sodep ]]; then
if [[ ! -L $sodep ]]; then
- _add_file "$sodep" "$sodep" "$(stat -c %a "$sodep")"
+ add_file "$sodep" "$sodep" "$(stat -c %a "$sodep")"
else
resolved=$(readlink -e "$sodep")
dirname=${resolved%/*}
add_dir "$dirname" 755
_add_symlink "$sodep" "$resolved"
- _add_file "$resolved" "$resolved" 755
+ add_file "$resolved" "$resolved" 755
fi
fi
done <<< "$lddout"