From c4d19a23193ec13eda96a3d7536ba338d0801825 Mon Sep 17 00:00:00 2001 From: Matthias Stecher Date: Sat, 12 Dec 2020 09:36:17 +0100 Subject: [PATCH] __debian_backports -> __apt_backports; add wider os support As discussed in the chat, this type now supports a broader list of OSes which it supports backports for. Because of this, it was renamed to something more generic. "apt" should fit in. --- .../man.rst | 27 ++++++++---- .../manifest | 41 ++++++++++++++----- .../parameter/default/state | 0 .../parameter/optional | 0 .../singleton | 0 .../parameter/default/mirror | 1 - 6 files changed, 49 insertions(+), 20 deletions(-) rename cdist/conf/type/{__debian_backports => __apt_backports}/man.rst (66%) rename cdist/conf/type/{__debian_backports => __apt_backports}/manifest (59%) rename cdist/conf/type/{__debian_backports => __apt_backports}/parameter/default/state (100%) rename cdist/conf/type/{__debian_backports => __apt_backports}/parameter/optional (100%) rename cdist/conf/type/{__debian_backports => __apt_backports}/singleton (100%) delete mode 100644 cdist/conf/type/__debian_backports/parameter/default/mirror diff --git a/cdist/conf/type/__debian_backports/man.rst b/cdist/conf/type/__apt_backports/man.rst similarity index 66% rename from cdist/conf/type/__debian_backports/man.rst rename to cdist/conf/type/__apt_backports/man.rst index ba353f4e..7d269fbb 100644 --- a/cdist/conf/type/__debian_backports/man.rst +++ b/cdist/conf/type/__apt_backports/man.rst @@ -3,13 +3,13 @@ cdist-type__debian_backports(7) NAME ---- -cdist-type__debian_backports - Install backports for Debain systems +cdist-type__apt_backports - Install backports DESCRIPTION ----------- -This singleton type installs backports for the current Debian version. -It aborts if backports are not supported for the specified os or no +This singleton type installs backports for the current OS release. +It aborts if backports are not supported for the specified OS or no version codename could be fetched (like Debian unstable). @@ -27,8 +27,8 @@ state 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 - ``_. + The mirror to fetch the backports from. Will defaults to the generic + mirror of the current OS. Will be directly passed to :strong:`cdist-type__apt_source`\ (7). @@ -49,12 +49,12 @@ EXAMPLES .. code-block:: sh # setup the backports - __debian_backports - __debian_backports --state absent - __debian_backports --state present --mirror "http://ftp.de.debian.org/debian/" + __apt_backports + __apt_backports --state absent + __apt_backports --state present --mirror "http://ftp.de.debian.org/debian/" # update - require="__debian_backports" __apt_update_index + require="__apt_backports" __apt_update_index # install a backports package # currently for the buster release backports @@ -70,6 +70,15 @@ Aborts if no distribuition codename could be detected. This is common for the unstable distribution, but there is no backports repository for it already. +CAVEATS +------- +For Ubuntu, it setup all componenents for the backports repository: ``main``, +``restricted``, ``universe`` and ``multiverse``. The user may not want to +install proprietary packages, which will only be installed if the user +explicitly uses the backports target-release. The user may change this behavior +to install backports packages without the need of explicitly select it. + + SEE ALSO -------- `Official Debian Backports site `_ diff --git a/cdist/conf/type/__debian_backports/manifest b/cdist/conf/type/__apt_backports/manifest similarity index 59% rename from cdist/conf/type/__debian_backports/manifest rename to cdist/conf/type/__apt_backports/manifest index 661e5281..e5358dea 100755 --- a/cdist/conf/type/__debian_backports/manifest +++ b/cdist/conf/type/__apt_backports/manifest @@ -1,5 +1,5 @@ #!/bin/sh -e -# __debian_backports/manifest +# __apt_backports/manifest # # 2020 Matthias Stecher (matthiasstecher at gmx.de) # @@ -23,18 +23,34 @@ # +# Get the distribution codename by /etc/os-release. +# is already executed in a subshell by string substitution +# lsb_release may not be given in all installations +codename_os_release() { + # shellcheck disable=SC1090 + . "$__global/explorer/os-release" + printf "%s" "$VERSION_CODENAME" +} + # 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="$( - # shellcheck disable=SC1090 - . "$__global/explorer/os-release" - printf "%s" "$VERSION_CODENAME" - )" + dist="$( codename_os_release )" + components="main" + mirror="http://deb.debian.org/debian/" ;; + devuan) + dist="$( codename_os_release )" + components="main" + mirror="http://deb.devuan.org/merged" + ;; + ubuntu) + dist="$( codename_os_release )" + components="main restricted universe multiverse" + mirror="http://archive.ubuntu.com/ubuntu" + ;; + *) printf "Backports for %s are not supported!\n" "$os" >&2 exit 1 @@ -50,11 +66,16 @@ fi # parameters state="$(cat "$__object/parameter/state")" -mirror="$(cat "$__object/parameter/mirror")" + +# mirror already set for the os, only override user-values +if [ -f "$__object/parameter/mirror" ]; then + mirror="$(cat "$__object/parameter/mirror")" +fi + # install the given backports repository __apt_source "${dist}-backports" \ --state "$state" \ --distribution "${dist}-backports" \ - --component main \ + --component "$components" \ --uri "$mirror" diff --git a/cdist/conf/type/__debian_backports/parameter/default/state b/cdist/conf/type/__apt_backports/parameter/default/state similarity index 100% rename from cdist/conf/type/__debian_backports/parameter/default/state rename to cdist/conf/type/__apt_backports/parameter/default/state diff --git a/cdist/conf/type/__debian_backports/parameter/optional b/cdist/conf/type/__apt_backports/parameter/optional similarity index 100% rename from cdist/conf/type/__debian_backports/parameter/optional rename to cdist/conf/type/__apt_backports/parameter/optional diff --git a/cdist/conf/type/__debian_backports/singleton b/cdist/conf/type/__apt_backports/singleton similarity index 100% rename from cdist/conf/type/__debian_backports/singleton rename to cdist/conf/type/__apt_backports/singleton diff --git a/cdist/conf/type/__debian_backports/parameter/default/mirror b/cdist/conf/type/__debian_backports/parameter/default/mirror deleted file mode 100644 index 0965ef04..00000000 --- a/cdist/conf/type/__debian_backports/parameter/default/mirror +++ /dev/null @@ -1 +0,0 @@ -http://deb.debian.org/debian/