diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index f3d91566..fbfca330 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/gencode-remote @@ -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) diff --git a/cdist/conf/type/__package_apt/man.rst b/cdist/conf/type/__package_apt/man.rst index a1691eac..4e6101a5 100644 --- a/cdist/conf/type/__package_apt/man.rst +++ b/cdist/conf/type/__package_apt/man.rst @@ -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. @@ -23,7 +25,7 @@ None OPTIONAL PARAMETERS ------------------- name - If supplied, use the name and not the object id as the package name. + If supplied, use the name and not the object id as the package name. state Either "present" or "absent", defaults to "present" @@ -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`). diff --git a/cdist/conf/type/__package_apt/parameter/boolean b/cdist/conf/type/__package_apt/parameter/boolean index f9a0f6b0..a2e433f3 100644 --- a/cdist/conf/type/__package_apt/parameter/boolean +++ b/cdist/conf/type/__package_apt/parameter/boolean @@ -1 +1,2 @@ +install-recommends purge-if-absent