Merge branch 'apt-pin-type' into 'master'
New type: __apt_pin - manage apt pinning See merge request ungleich-public/cdist!1005
This commit is contained in:
commit
8b160841ad
6 changed files with 147 additions and 0 deletions
79
cdist/conf/type/__apt_pin/man.rst
Normal file
79
cdist/conf/type/__apt_pin/man.rst
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
cdist-type__apt_pin(7)
|
||||||
|
======================
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__apt_pin - Manage apt pinning rules
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
Adds/removes/edits rules to pin some packages to a specific distribution. Useful if using multiple debian repositories at the same time. (Useful, if one wants to use a few specific packages from backports or perhaps Debain testing... or even sid.)
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
distribution
|
||||||
|
Specifies what distribution the package should be pinned to. Accepts both codenames (buster/bullseye/sid) and suite names (stable/testing/...).
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
package
|
||||||
|
Package name, glob or regular expression to match (multiple) packages. If not specified `__object_id` is used.
|
||||||
|
|
||||||
|
priority
|
||||||
|
The priority value to assign to matching packages. Deafults to 500. (To match the default target distro's priority)
|
||||||
|
|
||||||
|
state
|
||||||
|
Will be passed to underlying `__file` type; see there for valid values and defaults.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
None.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
# Add the bullseye repo to buster, but do not install any packages by default,
|
||||||
|
# only if explicitely asked for (-1 means "never" for apt)
|
||||||
|
__apt_pin bullseye-default \
|
||||||
|
--package "*" \
|
||||||
|
--distribution bullseye \
|
||||||
|
--priority -1
|
||||||
|
|
||||||
|
require="__apt_pin/bullseye-default" __apt_source bullseye \
|
||||||
|
--uri http://deb.debian.org/debian/ \
|
||||||
|
--distribution bullseye \
|
||||||
|
--component main
|
||||||
|
|
||||||
|
__apt_pin foo --package "foo foo-*" --distribution bullseye
|
||||||
|
|
||||||
|
__foo # Assuming, this installs the `foo` package internally
|
||||||
|
|
||||||
|
__package foo-plugin-extras # Assuming we also need some extra stuff
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
:strong:`apt_preferences`\ (5)
|
||||||
|
:strong:`cdist-type__apt_source`\ (7)
|
||||||
|
:strong:`cdist-type__apt_backports`\ (7)
|
||||||
|
:strong:`cdist-type__file`\ (7)
|
||||||
|
|
||||||
|
AUTHORS
|
||||||
|
-------
|
||||||
|
Daniel Fancsali <fancsali@gmail.com>
|
||||||
|
|
||||||
|
|
||||||
|
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.
|
63
cdist/conf/type/__apt_pin/manifest
Executable file
63
cdist/conf/type/__apt_pin/manifest
Executable file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
name="$__object_id"
|
||||||
|
|
||||||
|
os=$(cat "$__global/explorer/os")
|
||||||
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/package" ]; then
|
||||||
|
package="$(cat "$__object/parameter/package")"
|
||||||
|
else
|
||||||
|
package=$name
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $distribution in
|
||||||
|
stable|testing|unstable|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
|
0
cdist/conf/type/__apt_pin/nonparallel
Normal file
0
cdist/conf/type/__apt_pin/nonparallel
Normal file
1
cdist/conf/type/__apt_pin/parameter/default/state
Normal file
1
cdist/conf/type/__apt_pin/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
2
cdist/conf/type/__apt_pin/parameter/optional
Normal file
2
cdist/conf/type/__apt_pin/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
state
|
||||||
|
package
|
2
cdist/conf/type/__apt_pin/parameter/required
Normal file
2
cdist/conf/type/__apt_pin/parameter/required
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
distribution
|
||||||
|
priority
|
Loading…
Reference in a new issue