new type __debian_backports

This new type will setup the backports distribution for the current
Debian release.
This commit is contained in:
matze 2020-12-10 21:24:26 +01:00
parent a58f5ffa7f
commit a5169ad858
6 changed files with 153 additions and 0 deletions

View file

@ -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
`<http://deb.debian.org/debian/>`_.
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 <https://backports.debian.org/>`_
:strong:`cdist-type__apt_source`\ (7)
AUTHORS
-------
Matthias Stecher <matthiasstecher at gmx.de>
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.

View file

@ -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 <http://www.gnu.org/licenses/>.
#
#
# 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"

View file

@ -0,0 +1 @@
http://deb.debian.org/debian/

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,2 @@
state
mirror