__package_pkg_openbsd: support --version

This commit is contained in:
Andres Erbsen 2016-09-02 11:13:37 -04:00
parent 72001b237e
commit db32d0de3a
3 changed files with 22 additions and 4 deletions

View File

@ -29,6 +29,10 @@
os_version="$(cat "$__global/explorer/os_version")" os_version="$(cat "$__global/explorer/os_version")"
machine="$(cat "$__global/explorer/machine")" machine="$(cat "$__global/explorer/machine")"
if [ -f "$__object/parameter/version" ]; then
version="$(cat "$__object/parameter/version")"
fi
if [ -f "$__object/parameter/flavor" ]; then if [ -f "$__object/parameter/flavor" ]; then
flavor="$(cat "$__object/parameter/flavor")" flavor="$(cat "$__object/parameter/flavor")"
fi fi
@ -42,6 +46,16 @@ else
name="$__object_id" name="$__object_id"
fi 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")" state_should="$(cat "$__object/parameter/state")"
pkg_version="$(cat "$__object/explorer/pkg_version")" 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 # use this because pkg_add doesn't properly handle errors
cat << eof cat << eof
export PKG_PATH="$pkg_path" export PKG_PATH="$pkg_path"
status=\$(pkg_add "$pkgopts" "$name--$flavor" 2>&1) status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1)
pkg_info | grep "^${name}.*${flavor}" > /dev/null 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 # 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 # This is necessary because pkg_add doesn't return properly
@ -83,8 +97,8 @@ eof
absent) absent)
# use this because pkg_add doesn't properly handle errors # use this because pkg_add doesn't properly handle errors
cat << eof cat << eof
status=\$(pkg_delete "$pkgopts" "$name--$flavor") status=\$(pkg_delete "$pkgopts" "$pkgid")
pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
# We found the package in the list of 'installed packages' # We found the package in the list of 'installed packages'
# This would indicate that pkg_delete failed, send the output of pkg_delete # This would indicate that pkg_delete failed, send the output of pkg_delete

View File

@ -24,6 +24,9 @@ name
flavor flavor
If supplied, use to avoid ambiguity. If supplied, use to avoid ambiguity.
version
If supplied, use to avoid ambiguity.
state state
Either "present" or "absent", defaults to "present" Either "present" or "absent", defaults to "present"

View File

@ -1,4 +1,5 @@
name name
version
flavor flavor
state state
pkg_path pkg_path