forked from ungleich-public/cdist
		
	Merge remote-tracking branch 'dheule/type__package_zypper'
This commit is contained in:
		
				commit
				
					
						f955191d77
					
				
			
		
					 6 changed files with 38 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -3,3 +3,4 @@ version
 | 
			
		|||
type
 | 
			
		||||
pkgsite
 | 
			
		||||
state
 | 
			
		||||
pstate
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
#
 | 
			
		||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
# 2013 Daniel Heule (hda at sfs.biz)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +19,7 @@
 | 
			
		|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# Retrieve the status of a package
 | 
			
		||||
# Retrieve the status of a package off different types
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
if [ -f "$__object/parameter/name" ]; then
 | 
			
		||||
| 
						 | 
				
			
			@ -27,4 +28,21 @@ else
 | 
			
		|||
   name="$__object_id"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
rpm -q --whatprovides "$name"  | grep -v 'no package provides' || true
 | 
			
		||||
if [ -f "$__object/parameter/ptype" ]; then
 | 
			
		||||
   ptype="$(cat "$__object/parameter/ptype")"
 | 
			
		||||
else
 | 
			
		||||
   ptype="package"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
case "$ptype" in
 | 
			
		||||
    package)
 | 
			
		||||
        zypper search --details --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3,7 || true
 | 
			
		||||
    ;;
 | 
			
		||||
    patch|pattern|product|srcpackage)
 | 
			
		||||
        zypper search --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3 || true
 | 
			
		||||
    ;;
 | 
			
		||||
    *)
 | 
			
		||||
        echo "unknown ptype in __package_zypper explorer" &>2
 | 
			
		||||
        exit 1
 | 
			
		||||
    ;;
 | 
			
		||||
esac
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
#
 | 
			
		||||
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
# 2013 Daniel Heule (hda at sfs.biz)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +40,12 @@ else
 | 
			
		|||
   state_should="present"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -f "$__object/parameter/ptype" ]; then
 | 
			
		||||
   ptype="$(cat "$__object/parameter/ptype")"
 | 
			
		||||
else
 | 
			
		||||
   ptype="package"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
 | 
			
		||||
if [ -z "$pkg_version" ]; then
 | 
			
		||||
    state_is="absent"
 | 
			
		||||
| 
						 | 
				
			
			@ -51,10 +58,10 @@ fi
 | 
			
		|||
 | 
			
		||||
case "$state_should" in
 | 
			
		||||
   present)
 | 
			
		||||
         echo zypper $globalopts install --auto-agree-with-licenses \"$name\" ">/dev/null"
 | 
			
		||||
         echo zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" ">/dev/null"
 | 
			
		||||
   ;;
 | 
			
		||||
   absent)
 | 
			
		||||
         echo zypper $globalopts remove \"$name\" ">/dev/null"
 | 
			
		||||
         echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null"
 | 
			
		||||
   ;;
 | 
			
		||||
   *)
 | 
			
		||||
      echo "Unknown state: $state_should" >&2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,9 @@ name::
 | 
			
		|||
state::
 | 
			
		||||
    Either "present" or "absent", defaults to "present"
 | 
			
		||||
 | 
			
		||||
ptype::
 | 
			
		||||
    Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
EXAMPLES
 | 
			
		||||
--------
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +42,9 @@ __package_zypper python --state present --name python2
 | 
			
		|||
 | 
			
		||||
# Remove package
 | 
			
		||||
__package_zypper cfengine --state absent
 | 
			
		||||
 | 
			
		||||
# install all packages which belongs to pattern x11
 | 
			
		||||
__package_zypper x11 --ptype pattern --state present
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								cdist/conf/type/__package_zypper/parameter/default/ptype
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__package_zypper/parameter/default/ptype
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
package
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +1,3 @@
 | 
			
		|||
name
 | 
			
		||||
state
 | 
			
		||||
ptype
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue