[alpine] add support for alpine in __package and __package_apk
This commit is contained in:
parent
4c8037764a
commit
3a2041019b
7 changed files with 145 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2019 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -44,6 +45,7 @@ else
|
|||
suse) type="zypper" ;;
|
||||
openwrt) type="opkg" ;;
|
||||
openbsd) type="pkg_openbsd" ;;
|
||||
alpine) type="apk" ;;
|
||||
*)
|
||||
echo "Don't know how to manage packages on: $os" >&2
|
||||
exit 1
|
||||
|
|
36
cdist/conf/type/__package_apk/explorer/state
Executable file
36
cdist/conf/type/__package_apk/explorer/state
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2019 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# Retrieve the status of a package - parsed dpkg output
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
output=
|
||||
|
||||
if [ "$(apk list -I "$name")" ]; then
|
||||
echo present
|
||||
else
|
||||
echo absent
|
||||
fi
|
49
cdist/conf/type/__package_apk/gencode-remote
Executable file
49
cdist/conf/type/__package_apk/gencode-remote
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2019 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# Manage packages on Debian and co.
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
|
||||
# Nothing to be done
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo "apk add -q '$name'"
|
||||
echo "installed" >> "$__messages_out"
|
||||
;;
|
||||
absent)
|
||||
echo "apk del -q '$name'"
|
||||
echo "removed" >> "$__messages_out"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
55
cdist/conf/type/__package_apk/man.rst
Normal file
55
cdist/conf/type/__package_apk/man.rst
Normal file
|
@ -0,0 +1,55 @@
|
|||
cdist-type__package_akp(7)
|
||||
==========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__package_akp - Manage packages with akp
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
apk is usually used on Alpine to manage packages.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
state
|
||||
Either "present" or "absent", defaults to "present"
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Ensure zsh in installed
|
||||
__package_apk zsh --state present
|
||||
|
||||
# Remove package
|
||||
__package_apk apache2 --state absent
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
:strong:`cdist-type__package`\ (7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2019 Nico Schottelius. 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.
|
0
cdist/conf/type/__package_apk/nonparallel
Normal file
0
cdist/conf/type/__package_apk/nonparallel
Normal file
1
cdist/conf/type/__package_apk/parameter/default/state
Normal file
1
cdist/conf/type/__package_apk/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
|||
present
|
2
cdist/conf/type/__package_apk/parameter/optional
Normal file
2
cdist/conf/type/__package_apk/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
name
|
||||
state
|
Loading…
Reference in a new issue