__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/>.
|
||||
#
|
||||
#
|
||||
# Retrieve the status of a package off different types
|
||||
# Retrieve the status of a package of different types
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
|
|
|
@ -46,21 +46,38 @@ else
|
|||
ptype="package"
|
||||
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")"
|
||||
if [ -z "$pkg_version" ]; then
|
||||
state_is="absent"
|
||||
version_is=""
|
||||
else
|
||||
state_is="present"
|
||||
version_is=${pkg_version##* }
|
||||
fi
|
||||
|
||||
# Exit if nothing is needed to be done
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
case "$state_should" in
|
||||
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"
|
||||
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)
|
||||
[ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything
|
||||
echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null"
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
cdist-type__package_zypper(7)
|
||||
=============================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
Daniel Heule <hda--@--sfs.biz>
|
||||
|
||||
|
||||
NAME
|
||||
|
@ -26,6 +26,11 @@ name::
|
|||
state::
|
||||
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::
|
||||
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
|
||||
|
||||
# If you don't want to follow pythonX packages, but always use python
|
||||
__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
|
||||
__package_zypper cfengine --state absent
|
||||
|
||||
|
@ -56,5 +64,6 @@ SEE ALSO
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
Copyright \(C) 2012 Nico Schottelius.
|
||||
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
|
||||
state
|
||||
ptype
|
||||
version
|
||||
|
|
Loading…
Reference in a new issue