From 3545d0157f7fdb3a398324946fa7ca1f2c1edd69 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Tue, 30 Jan 2018 12:04:19 +0100 Subject: [PATCH] Provide `--purge-if-absent` to __package_apt Configuration files are not purged under Debian when the package is deinstalled. If this parameter is given, they are deleted upon package deinstallation. --- cdist/conf/type/__package_apt/gencode-remote | 7 ++++++- cdist/conf/type/__package_apt/man.rst | 3 +++ cdist/conf/type/__package_apt/parameter/boolean | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 cdist/conf/type/__package_apt/parameter/boolean diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index e3e31c2b..1a86e72c 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/gencode-remote @@ -35,6 +35,11 @@ else target_release="" fi +if [ -f "$__object/parameter/purge-if-absent" ]; then + purgeparam="--purge" +else + purgeparam="" +fi # FIXME: use grep directly, state is a list, not a line! @@ -57,7 +62,7 @@ case "$state_should" in echo $aptget install $target_release \"$name\" ;; absent) - echo $aptget remove \"$name\" + echo $aptget remove $purgeparam \"$name\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_apt/man.rst b/cdist/conf/type/__package_apt/man.rst index 0a7958d4..991962e5 100644 --- a/cdist/conf/type/__package_apt/man.rst +++ b/cdist/conf/type/__package_apt/man.rst @@ -28,6 +28,9 @@ state target-release Passed on to apt-get install, see apt-get(8). Essentially allows you to retrieve packages from a different release +purge-if-absent + If this parameter is given when state is `absent`, the package is + purged from the system (using `--purge`). EXAMPLES -------- diff --git a/cdist/conf/type/__package_apt/parameter/boolean b/cdist/conf/type/__package_apt/parameter/boolean new file mode 100644 index 00000000..f9a0f6b0 --- /dev/null +++ b/cdist/conf/type/__package_apt/parameter/boolean @@ -0,0 +1 @@ +purge-if-absent