First draft of __apt_pin

This commit is contained in:
fancsali 2021-02-21 19:59:57 +00:00
parent 7cf85c4659
commit 0734288483
6 changed files with 122 additions and 0 deletions

View File

@ -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 <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.

View 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/>.
#
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

View File

@ -0,0 +1 @@
*

View File

@ -0,0 +1 @@
present

View File

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

View File

@ -0,0 +1,2 @@
distribution
priority