forked from ungleich-public/cdist
__package_zypper can now handle the version parameter
This commit is contained in:
parent
785e54b311
commit
aaa142d76b
4 changed files with 50 additions and 23 deletions
|
@ -19,7 +19,7 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Retrieve the status of a package off different types
|
# Retrieve the status of a package of different types
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -f "$__object/parameter/name" ]; then
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
|
|
@ -46,21 +46,38 @@ else
|
||||||
ptype="package"
|
ptype="package"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/version" ]; then
|
||||||
|
version_should="$(cat "$__object/parameter/version")"
|
||||||
|
if [ "$ptype" != "package" ]; then
|
||||||
|
echo "version support only for type package implemented" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
version_should=""
|
||||||
|
fi
|
||||||
|
|
||||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
if [ -z "$pkg_version" ]; then
|
if [ -z "$pkg_version" ]; then
|
||||||
state_is="absent"
|
state_is="absent"
|
||||||
|
version_is=""
|
||||||
else
|
else
|
||||||
state_is="present"
|
state_is="present"
|
||||||
|
version_is=${pkg_version##* }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit if nothing is needed to be done
|
|
||||||
[ "$state_is" = "$state_should" ] && exit 0
|
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
|
if [ -z "$version_should" ]; then
|
||||||
|
[ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything
|
||||||
echo zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" ">/dev/null"
|
echo zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" ">/dev/null"
|
||||||
|
else
|
||||||
|
[ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything
|
||||||
|
echo zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" ">/dev/null"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
|
[ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything
|
||||||
echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null"
|
echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cdist-type__package_zypper(7)
|
cdist-type__package_zypper(7)
|
||||||
=============================
|
=============================
|
||||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
Daniel Heule <hda--@--sfs.biz>
|
||||||
|
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
|
@ -26,6 +26,11 @@ name::
|
||||||
state::
|
state::
|
||||||
Either "present" or "absent", defaults to "present"
|
Either "present" or "absent", defaults to "present"
|
||||||
|
|
||||||
|
version::
|
||||||
|
The version of the package to install. Default is to install the version
|
||||||
|
choosen by the local package manager. For a list of version have a look to
|
||||||
|
the output of "zypper se -s packagename"
|
||||||
|
|
||||||
ptype::
|
ptype::
|
||||||
Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper.
|
Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper.
|
||||||
|
|
||||||
|
@ -34,12 +39,15 @@ EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure zsh in installed
|
# Ensure zsh is installed
|
||||||
__package_zypper zsh --state present
|
__package_zypper zsh --state present
|
||||||
|
|
||||||
# If you don't want to follow pythonX packages, but always use python
|
# If you don't want to follow pythonX packages, but always use python
|
||||||
__package_zypper python --state present --name python2
|
__package_zypper python --state present --name python2
|
||||||
|
|
||||||
|
# Ensure binutils is installed and the version is forced to be 2.23.1-0.19.2
|
||||||
|
__package_zypper binutils --state present --version 2.23.1-0.19.2
|
||||||
|
|
||||||
# Remove package
|
# Remove package
|
||||||
__package_zypper cfengine --state absent
|
__package_zypper cfengine --state absent
|
||||||
|
|
||||||
|
@ -56,5 +64,6 @@ SEE ALSO
|
||||||
|
|
||||||
COPYING
|
COPYING
|
||||||
-------
|
-------
|
||||||
Copyright \(C) 2012 Nico Schottelius. Free use of this software is
|
Copyright \(C) 2012 Nico Schottelius.
|
||||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
Copyright \(C) 2013 Daniel Heule.
|
||||||
|
Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
name
|
name
|
||||||
state
|
state
|
||||||
ptype
|
ptype
|
||||||
|
version
|
||||||
|
|
Loading…
Reference in a new issue