mirror of
https://gitlab.archlinux.org/tpowa/archboot.git
synced 2024-09-20 03:50:37 +02:00
add 159 to patch
This commit is contained in:
parent
194f8fd63e
commit
945f87f74d
1 changed files with 26 additions and 12 deletions
|
@ -583,30 +583,44 @@ add_symlink() {
|
||||||
# Add a symlink to the initcpio image. There is no checking done
|
# Add a symlink to the initcpio image. There is no checking done
|
||||||
# to ensure that the target of the symlink exists.
|
# to ensure that the target of the symlink exists.
|
||||||
# $1: pathname of symlink on image
|
# $1: pathname of symlink on image
|
||||||
# $2: absolute path to target of symlink (optional, can be read from $1)
|
# $2: path to target of symlink (optional, can be read from $1)
|
||||||
|
|
||||||
local name=$1 target=$2
|
local name="$1" target="${2:-$1}" linkobject
|
||||||
|
|
||||||
(( $# == 1 || $# == 2 )) || return 1
|
(( $# == 1 || $# == 2 )) || return 1
|
||||||
|
|
||||||
if [[ -z "$target" || "$name" == "$target" ]]; then
|
if [[ "$name" == "$target" && -L "$target" ]]; then
|
||||||
target="$(find "$name" -prune -printf '%l')"
|
linkobject="$(find "$name" -prune -printf '%l')"
|
||||||
elif [[ -L "$target" ]]; then
|
# if the link name and target are the same, treat it as if no target is specified
|
||||||
target="$(realpath -eq -- "$target")"
|
target=''
|
||||||
fi
|
fi
|
||||||
if [[ -z "$target" ]]; then
|
|
||||||
|
if [[ -z "${target:-$linkobject}" ]]; then
|
||||||
error 'invalid symlink: %s' "$name"
|
error 'invalid symlink: %s' "$name"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
add_dir "${name%/*}"
|
[[ -d "${BUILDROOT}/${name%/*}" ]] || add_dir "${name%/*}"
|
||||||
|
|
||||||
if [[ -L $BUILDROOT$1 ]]; then
|
if [[ -L "${BUILDROOT}/${name}" ]]; then
|
||||||
quiet "overwriting symlink %s -> %s" "$name" "$target"
|
quiet "overwriting symlink %s -> %s" "$name" "${target:-$linkobject}"
|
||||||
else
|
else
|
||||||
quiet "adding symlink: %s -> %s" "$name" "$target"
|
quiet "adding symlink: %s -> %s" "$name" "${target:-$linkobject}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$linkobject" ]]; then
|
||||||
|
# copy the symlink to preserve relativity
|
||||||
|
cp -dT -- "$name" "${BUILDROOT}/${name}"
|
||||||
|
# Add nested symlinks
|
||||||
|
if [[ "${linkobject:0:1}" == '/' && -L "$linkobject" ]]; then
|
||||||
|
add_symlink "$linkobject"
|
||||||
|
elif [[ "${linkobject:0:1}" != '/' && -L "${name%/*}/${linkobject}" ]]; then
|
||||||
|
add_symlink "${name%/*}/${linkobject}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# create the symlink
|
||||||
|
ln -sfn "$target" "${BUILDROOT}/${name}"
|
||||||
fi
|
fi
|
||||||
ln -sfn "$target" "$BUILDROOT$name"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_file() {
|
add_file() {
|
||||||
|
|
Loading…
Reference in a new issue