forked from ungleich-public/cdist
		
	__package_pkg_openbsd: support --version
This commit is contained in:
		
					parent
					
						
							
								72001b237e
							
						
					
				
			
			
				commit
				
					
						db32d0de3a
					
				
			
		
					 3 changed files with 22 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -29,6 +29,10 @@
 | 
			
		|||
os_version="$(cat "$__global/explorer/os_version")"
 | 
			
		||||
machine="$(cat "$__global/explorer/machine")"
 | 
			
		||||
 | 
			
		||||
if [ -f "$__object/parameter/version" ]; then
 | 
			
		||||
	version="$(cat "$__object/parameter/version")"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -f "$__object/parameter/flavor" ]; then
 | 
			
		||||
	flavor="$(cat "$__object/parameter/flavor")"
 | 
			
		||||
fi
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +46,16 @@ else
 | 
			
		|||
   name="$__object_id"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ -n "$version" -a -n "$flavor" ]; then
 | 
			
		||||
   pkgid="$name-$version-$flavor"
 | 
			
		||||
elif [ -n "$version" ]; then
 | 
			
		||||
   pkgid="$name-$version"
 | 
			
		||||
elif [ -n "$flavor" ]; then
 | 
			
		||||
   pkgid="$name--$flavor"
 | 
			
		||||
else
 | 
			
		||||
   pkgid="$name"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
state_should="$(cat "$__object/parameter/state")"
 | 
			
		||||
 | 
			
		||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
 | 
			
		||||
| 
						 | 
				
			
			@ -65,8 +79,8 @@ case "$state_should" in
 | 
			
		|||
        # use this because pkg_add doesn't properly handle errors
 | 
			
		||||
        cat << eof
 | 
			
		||||
export PKG_PATH="$pkg_path"                                              
 | 
			
		||||
status=\$(pkg_add "$pkgopts" "$name--$flavor" 2>&1)
 | 
			
		||||
pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1
 | 
			
		||||
status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1)
 | 
			
		||||
pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
 | 
			
		||||
 | 
			
		||||
# We didn't find the package in the list of 'installed packages', so it failed
 | 
			
		||||
# This is necessary because pkg_add doesn't return properly
 | 
			
		||||
| 
						 | 
				
			
			@ -83,8 +97,8 @@ eof
 | 
			
		|||
    absent)
 | 
			
		||||
        # use this because pkg_add doesn't properly handle errors
 | 
			
		||||
        cat << eof
 | 
			
		||||
status=\$(pkg_delete "$pkgopts" "$name--$flavor")
 | 
			
		||||
pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1
 | 
			
		||||
status=\$(pkg_delete "$pkgopts" "$pkgid")
 | 
			
		||||
pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
 | 
			
		||||
 | 
			
		||||
# We found the package in the list of 'installed packages'
 | 
			
		||||
# This would indicate that pkg_delete failed, send the output of pkg_delete
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,9 @@ name
 | 
			
		|||
flavor
 | 
			
		||||
    If supplied, use to avoid ambiguity.
 | 
			
		||||
 | 
			
		||||
version
 | 
			
		||||
    If supplied, use to avoid ambiguity.
 | 
			
		||||
 | 
			
		||||
state
 | 
			
		||||
    Either "present" or "absent", defaults to "present"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
name
 | 
			
		||||
version
 | 
			
		||||
flavor
 | 
			
		||||
state
 | 
			
		||||
pkg_path
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue