forked from ungleich-public/cdist
[type/__update_alternatives] dry-run fixes
This commit is contained in:
parent
a7d6481a7d
commit
0b3b47396f
3 changed files with 16 additions and 7 deletions
|
@ -31,8 +31,11 @@ do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$link" ]
|
if [ -z "$link" ] && [ -z "${__cdist_dry_run+dry run}" ]
|
||||||
then
|
then
|
||||||
|
# NOTE: ignore error for dry-runs because a package providing the link
|
||||||
|
# might be managed by another cdist object (which wasn't executed,
|
||||||
|
# because dry run…).
|
||||||
echo "unable to get link for ${__object_id:?}" >&2
|
echo "unable to get link for ${__object_id:?}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
path_is="$( update-alternatives --display "${__object_id:?}" 2>/dev/null \
|
path_is="$( update-alternatives --display "${__object_id:?}" 2>/dev/null \
|
||||||
| awk '/link currently points to/ {print $5}' )"
|
| awk '/link currently points to/ {print $5}' )"
|
||||||
|
|
||||||
if [ -z "$path_is" ]
|
if [ -z "$path_is" ] && [ -z "${__cdist_dry_run+dry run}" ]
|
||||||
then
|
then
|
||||||
|
# NOTE: ignore error for dry-runs because a package providing the
|
||||||
|
# alternative might be managed by another cdist object (which
|
||||||
|
# wasn't executed, because dry run…).
|
||||||
echo "unable to get current path for ${__object_id:?}" >&2
|
echo "unable to get current path for ${__object_id:?}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -38,16 +38,19 @@ name=${__object_id:?}
|
||||||
|
|
||||||
if ! grep -Fxq "$path_should" "${__object:?}/explorer/alternatives"
|
if ! grep -Fxq "$path_should" "${__object:?}/explorer/alternatives"
|
||||||
then
|
then
|
||||||
if [ ! -f "$__object/parameter/install" ]
|
if [ -f "${__object:?}/parameter/install" ]
|
||||||
then
|
then
|
||||||
|
link="$( cat "${__object:?}/explorer/link" )"
|
||||||
|
echo "update-alternatives --install '$link' '$name' '$path_should' 1000"
|
||||||
|
elif [ -z "${__cdist_dry_run+dry run}" ]
|
||||||
|
then
|
||||||
|
# NOTE: ignore error for dry-runs because a package providing the link
|
||||||
|
# to be installed might be managed by another cdist object (which
|
||||||
|
# wasn't executed, because dry run…).
|
||||||
echo "$path_should is not in $name alternatives." >&2
|
echo "$path_should is not in $name alternatives." >&2
|
||||||
echo 'Please install missing packages or use --install to add path to alternatives.' >&2
|
echo 'Please install missing packages or use --install to add path to alternatives.' >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
link="$( cat "$__object/explorer/link" )"
|
|
||||||
|
|
||||||
echo "update-alternatives --install '$link' '$name' '$path_should' 1000"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "update-alternatives --set '$name' '$path_should'"
|
echo "update-alternatives --set '$name' '$path_should'"
|
||||||
|
|
Loading…
Reference in a new issue