Merge branch 'feature/__package_apt/recommends' into 'master'

__package_apt: add --install-recommends parameter

See merge request ungleich-public/cdist!949
This commit is contained in:
poljakowski 2020-11-08 13:26:39 +01:00
commit fe8920740f
3 changed files with 26 additions and 7 deletions

View file

@ -42,6 +42,13 @@ else
target_release=""
fi
if [ -f "$__object/parameter/install-recommends" ]; then
# required if __apt_norecommends is used
recommendsparam="-o APT::Install-Recommends=1"
else
recommendsparam="-o APT::Install-Recommends=0"
fi
if [ -f "$__object/parameter/purge-if-absent" ]; then
purgeparam="--purge"
else
@ -62,16 +69,16 @@ case "$state_is" in
;;
esac
# Hint if we need to avoid questions at some point:
# DEBIAN_PRIORITY=critical can reduce the number of questions
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes -o APT::Install-Recommends=0 -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
if [ "$state_is" = "$state_should" ]; then
if [ -z "$version" ] || [ "$version" = "$version_is" ]; then
exit 0;
fi
fi
# Hint if we need to avoid questions at some point:
# DEBIAN_PRIORITY=critical can reduce the number of questions
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
case "$state_should" in
present)
# following is bit ugly, but important hack.
@ -85,7 +92,7 @@ EOF
if [ -n "$version" ]; then
name="${name}=${version}"
fi
echo "$aptget install $target_release '$name'"
echo "$aptget $recommendsparam install $target_release '$name'"
echo "installed" >> "$__messages_out"
;;
absent)

View file

@ -9,7 +9,9 @@ cdist-type__package_apt - Manage packages with apt-get
DESCRIPTION
-----------
apt-get is usually used on Debian and variants (like Ubuntu) to
manage packages.
manage packages. The package will be installed without recommended
or suggested packages. If such packages are required, install them
separatly or use the parameter ``--install-recommends``.
This type will also update package index, if it is older
than one day, to avoid missing package error messages.
@ -39,6 +41,15 @@ version
BOOLEAN PARAMETERS
------------------
install-recommends
If the package will be installed, it also installs recommended packages
with it. It will not install recommended packages if the original package
is already installed.
In most cases, it is recommended to install recommended packages separatly
to control which additional packages will be installed to avoid useless
installed packages.
purge-if-absent
If this parameter is given when state is `absent`, the package is
purged from the system (using `--purge`).

View file

@ -1 +1,2 @@
install-recommends
purge-if-absent