From a5169ad858a4d6e9c378184db5736f55a86306e0 Mon Sep 17 00:00:00 2001 From: Matthias Stecher Date: Thu, 10 Dec 2020 21:24:26 +0100 Subject: [PATCH] new type __debian_backports This new type will setup the backports distribution for the current Debian release. --- cdist/conf/type/__debian_backports/man.rst | 90 +++++++++++++++++++ cdist/conf/type/__debian_backports/manifest | 59 ++++++++++++ .../parameter/default/mirror | 1 + .../parameter/default/state | 1 + .../__debian_backports/parameter/optional | 2 + cdist/conf/type/__debian_backports/singleton | 0 6 files changed, 153 insertions(+) create mode 100644 cdist/conf/type/__debian_backports/man.rst create mode 100755 cdist/conf/type/__debian_backports/manifest create mode 100644 cdist/conf/type/__debian_backports/parameter/default/mirror create mode 100644 cdist/conf/type/__debian_backports/parameter/default/state create mode 100644 cdist/conf/type/__debian_backports/parameter/optional create mode 100644 cdist/conf/type/__debian_backports/singleton diff --git a/cdist/conf/type/__debian_backports/man.rst b/cdist/conf/type/__debian_backports/man.rst new file mode 100644 index 00000000..ba353f4e --- /dev/null +++ b/cdist/conf/type/__debian_backports/man.rst @@ -0,0 +1,90 @@ +cdist-type__debian_backports(7) +=============================== + +NAME +---- +cdist-type__debian_backports - Install backports for Debain systems + + +DESCRIPTION +----------- +This singleton type installs backports for the current Debian version. +It aborts if backports are not supported for the specified os or no +version codename could be fetched (like Debian unstable). + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state + Represents the state of the backports repository. ``present`` or + ``absent``, defaults to ``present``. + + Will be directly passed to :strong:`cdist-type__apt_source`\ (7). + +mirror + The mirror to fetch the backports from. Will defaults to the Debian default + ``_. + + Will be directly passed to :strong:`cdist-type__apt_source`\ (7). + + +BOOLEAN PARAMETERS +------------------ +None. + + +MESSAGES +-------- +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + # setup the backports + __debian_backports + __debian_backports --state absent + __debian_backports --state present --mirror "http://ftp.de.debian.org/debian/" + + # update + require="__debian_backports" __apt_update_index + + # install a backports package + # currently for the buster release backports + require="__apt_update_index" __package_apt wireguard \ + --target-release buster-backports + + +ABORTS +------ +Aborts if the detected os is not Debian. + +Aborts if no distribuition codename could be detected. This is common for the +unstable distribution, but there is no backports repository for it already. + + +SEE ALSO +-------- +`Official Debian Backports site `_ + +:strong:`cdist-type__apt_source`\ (7) + + +AUTHORS +------- +Matthias Stecher + + +COPYING +------- +Copyright \(C) 2020 Matthias Stecher. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__debian_backports/manifest b/cdist/conf/type/__debian_backports/manifest new file mode 100755 index 00000000..29bf9a43 --- /dev/null +++ b/cdist/conf/type/__debian_backports/manifest @@ -0,0 +1,59 @@ +#!/bin/sh -e +# __debian_backports/manifest +# +# 2020 Matthias Stecher (matthiasstecher at gmx.de) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Enables/disables backports repository. Utilies __apt_source for it. +# + + +# detect backport distribution +os="$(cat "$__global/explorer/os")" +case "$os" in + debian) + # distribution codename from /etc/os-release + # lsb_release may not be given in all debian installations + dist="$( + . "$__global/explorer/os-release" + printf "%s" "$VERSION_CODENAME" + )" + ;; + *) + printf "Backports for %s are not supported!\n" "$os" >&2 + exit 1 + ;; +esac + +# error if no codename given (e.g. on Debian unstable) +if [ -z "$dist" ]; then + printf "No backports for unkown version of distribution %s!\n" "$os" >&2 + exit 1 +fi + + +# parameters +state="$(cat "$__object/parameter/state")" +mirror="$(cat "$__object/parameter/mirror")" + +# install the given backports repository +__apt_source "${dist}-backports" \ + --state "$state" \ + --distribution "${dist}-backports" \ + --component main \ + --uri "$mirror" diff --git a/cdist/conf/type/__debian_backports/parameter/default/mirror b/cdist/conf/type/__debian_backports/parameter/default/mirror new file mode 100644 index 00000000..0965ef04 --- /dev/null +++ b/cdist/conf/type/__debian_backports/parameter/default/mirror @@ -0,0 +1 @@ +http://deb.debian.org/debian/ diff --git a/cdist/conf/type/__debian_backports/parameter/default/state b/cdist/conf/type/__debian_backports/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__debian_backports/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__debian_backports/parameter/optional b/cdist/conf/type/__debian_backports/parameter/optional new file mode 100644 index 00000000..4b05c235 --- /dev/null +++ b/cdist/conf/type/__debian_backports/parameter/optional @@ -0,0 +1,2 @@ +state +mirror diff --git a/cdist/conf/type/__debian_backports/singleton b/cdist/conf/type/__debian_backports/singleton new file mode 100644 index 00000000..e69de29b