forked from ungleich-public/cdist
Merge pull request #619 from darko-poljak/package_apt_version
__package_apt ignores --version parameter #615
This commit is contained in:
commit
c8c627a077
3 changed files with 30 additions and 2 deletions
|
@ -31,7 +31,8 @@ fi
|
||||||
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
|
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
|
||||||
for p in $packages; do
|
for p in $packages; do
|
||||||
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
||||||
echo "present $p"
|
version=$(dpkg -s "$p" 2>/dev/null | grep "^Version:" | cut -d ' ' -f 2)
|
||||||
|
echo "present $p $version"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -29,6 +29,13 @@ fi
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
version_param="$__object/parameter/version"
|
||||||
|
|
||||||
|
version=""
|
||||||
|
if [ -f "$version_param" ]; then
|
||||||
|
version="$(cat "$version_param")"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f "$__object/parameter/target-release" ]; then
|
if [ -f "$__object/parameter/target-release" ]; then
|
||||||
target_release="--target-release $(cat "$__object/parameter/target-release")"
|
target_release="--target-release $(cat "$__object/parameter/target-release")"
|
||||||
else
|
else
|
||||||
|
@ -47,18 +54,29 @@ state_is="$(cat "$__object/explorer/state")"
|
||||||
case "$state_is" in
|
case "$state_is" in
|
||||||
present*)
|
present*)
|
||||||
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
||||||
|
version_is="$(echo "$state_is" | cut -d ' ' -f 3)"
|
||||||
state_is="present"
|
state_is="present"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
version_is=""
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Hint if we need to avoid questions at some point:
|
# Hint if we need to avoid questions at some point:
|
||||||
# DEBIAN_PRIORITY=critical can reduce the number of questions
|
# DEBIAN_PRIORITY=critical can reduce the number of questions
|
||||||
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
|
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
|
||||||
|
|
||||||
[ "$state_is" = "$state_should" ] && exit 0
|
if [ "$state_is" = "$state_should" ]; then
|
||||||
|
if [ -z "$version" ] || [ "$version" = "$version_is" ]; then
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
|
if [ -n "$version" ]; then
|
||||||
|
name="${name}=${version}"
|
||||||
|
fi
|
||||||
echo $aptget install $target_release \"$name\"
|
echo $aptget install $target_release \"$name\"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
|
|
|
@ -28,10 +28,19 @@ state
|
||||||
target-release
|
target-release
|
||||||
Passed on to apt-get install, see apt-get(8).
|
Passed on to apt-get install, see apt-get(8).
|
||||||
Essentially allows you to retrieve packages from a different release
|
Essentially allows you to retrieve packages from a different release
|
||||||
|
|
||||||
|
version
|
||||||
|
The version of the package to install. Default is to install the version
|
||||||
|
chosen by the local package manager.
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
purge-if-absent
|
purge-if-absent
|
||||||
If this parameter is given when state is `absent`, the package is
|
If this parameter is given when state is `absent`, the package is
|
||||||
purged from the system (using `--purge`).
|
purged from the system (using `--purge`).
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue