From 0734288483700e8e10cebd87c797b625aa83d55e Mon Sep 17 00:00:00 2001 From: Daniel Fancsali Date: Sun, 21 Feb 2021 19:59:57 +0000 Subject: [PATCH] First draft of __apt_pin --- cdist/conf/type/__apt_pin/man.rst | 53 ++++++++++++++++ cdist/conf/type/__apt_pin/manifest | 63 +++++++++++++++++++ .../type/__apt_pin/parameter/default/package | 1 + .../type/__apt_pin/parameter/default/state | 1 + cdist/conf/type/__apt_pin/parameter/optional | 2 + cdist/conf/type/__apt_pin/parameter/required | 2 + 6 files changed, 122 insertions(+) create mode 100644 cdist/conf/type/__apt_pin/man.rst create mode 100755 cdist/conf/type/__apt_pin/manifest create mode 100644 cdist/conf/type/__apt_pin/parameter/default/package create mode 100644 cdist/conf/type/__apt_pin/parameter/default/state create mode 100644 cdist/conf/type/__apt_pin/parameter/optional create mode 100644 cdist/conf/type/__apt_pin/parameter/required diff --git a/cdist/conf/type/__apt_pin/man.rst b/cdist/conf/type/__apt_pin/man.rst new file mode 100644 index 00000000..7fcae6f8 --- /dev/null +++ b/cdist/conf/type/__apt_pin/man.rst @@ -0,0 +1,53 @@ +cdist-type__apt_pin(7) +====================== + +NAME +---- +cdist-type__apt_pin - TODO + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +BOOLEAN PARAMETERS +------------------ +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + # TODO + __apt_pin + + +SEE ALSO +-------- +:strong:`TODO`\ (7) + + +AUTHORS +------- +Daniel Fancsali + + +COPYING +------- +Copyright \(C) 2021 Daniel Fancsali. 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/__apt_pin/manifest b/cdist/conf/type/__apt_pin/manifest new file mode 100755 index 00000000..8dd9770d --- /dev/null +++ b/cdist/conf/type/__apt_pin/manifest @@ -0,0 +1,63 @@ +#!/bin/sh -e +# +# 2021 Daniel Fancsali (fancsali@gmail.com) +# +# 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 . +# + + +os=$(cat "$__global/explorer/os") +state="$(cat "$__object/parameter/state")" +package="$(cat "$__object/parameter/package")" +distribution="$(cat "$__object/parameter/distribution")" +priority="$(cat "$__object/parameter/priority")" + + +case "$os" in + debian|ubuntu|devuan) + ;; + *) + printf "This type is specific to Debian and it's derivatives" >&2 + printf "If you feel there's an equivalent functionality in %s, please contribute..." "$os" >&2 + exit 1 + ;; +esac + +if [ "$package" = "*" ]; then + name="default" + +else + name="$__object_id" +fi + +case $distribution in + stabletesting|unsatbel|experimental) + pin="release a=$distribution" + ;; + *) + pin="release n=$distribution" + ;; +esac + + +__file /etc/apt/preferences.d/$name \ + --owner root --group root --mode 0644 \ + --state "$state" \ + --source - << EOF +Package: $package +Pin: $pin +Pin-Priority: $priority +EOF diff --git a/cdist/conf/type/__apt_pin/parameter/default/package b/cdist/conf/type/__apt_pin/parameter/default/package new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/cdist/conf/type/__apt_pin/parameter/default/package @@ -0,0 +1 @@ +* diff --git a/cdist/conf/type/__apt_pin/parameter/default/state b/cdist/conf/type/__apt_pin/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_pin/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_pin/parameter/optional b/cdist/conf/type/__apt_pin/parameter/optional new file mode 100644 index 00000000..52f01fd2 --- /dev/null +++ b/cdist/conf/type/__apt_pin/parameter/optional @@ -0,0 +1,2 @@ +state +package diff --git a/cdist/conf/type/__apt_pin/parameter/required b/cdist/conf/type/__apt_pin/parameter/required new file mode 100644 index 00000000..4b4e9741 --- /dev/null +++ b/cdist/conf/type/__apt_pin/parameter/required @@ -0,0 +1,2 @@ +distribution +priority