forked from ungleich-public/cdist
[type/__package_*] Print installed/removed messages
Up-/downgraded packages will send an "installed" message.
This commit is contained in:
parent
5014fd2388
commit
7e9dce0ceb
11 changed files with 31 additions and 6 deletions
|
@ -64,9 +64,11 @@ fi
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "emerge '$name' &>/dev/null || exit 1"
|
echo "emerge '$name' &>/dev/null || exit 1"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "emerge -C '$name' &>/dev/null || exit 1"
|
echo "emerge -C '$name' &>/dev/null || exit 1"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -43,9 +43,11 @@ fi
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "luarocks install '$name'"
|
echo "luarocks install '$name'"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "luarocks remove '$name'"
|
echo "luarocks remove '$name'"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -43,12 +43,14 @@ esac
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
if [ "$present" = "notpresent" ]; then
|
if [ "$present" = "notpresent" ]; then
|
||||||
echo opkg --verbosity=0 update
|
echo "opkg --verbosity=0 update"
|
||||||
fi
|
fi
|
||||||
echo "opkg --verbosity=0 install '$name'"
|
echo "opkg --verbosity=0 install '$name'"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "opkg --verbosity=0 remove '$name'"
|
echo "opkg --verbosity=0 remove '$name'"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: ${state_should}" >&2
|
echo "Unknown state: ${state_should}" >&2
|
||||||
|
|
|
@ -46,9 +46,11 @@ fi
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "pacman --needed --noconfirm --noprogressbar -S '$name'"
|
echo "pacman --needed --noconfirm --noprogressbar -S '$name'"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "pacman --noconfirm --noprogressbar -R '$name'"
|
echo "pacman --noconfirm --noprogressbar -R '$name'"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -57,6 +57,7 @@ case "$state_should" in
|
||||||
else
|
else
|
||||||
echo $pip install -q "$name"
|
echo $pip install -q "$name"
|
||||||
fi
|
fi
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
if [ "$runas" ]
|
if [ "$runas" ]
|
||||||
|
@ -65,6 +66,7 @@ case "$state_should" in
|
||||||
else
|
else
|
||||||
echo $pip uninstall -q -y "$name"
|
echo $pip uninstall -q -y "$name"
|
||||||
fi
|
fi
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -39,7 +39,7 @@ assert () # If condition false,
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2039
|
||||||
echo "File \"$0\", line $lineno, called by $(caller 0)"
|
echo "File \"$0\", line $lineno, called by $(caller 0)"
|
||||||
exit $E_ASSERT_FAILED
|
exit $E_ASSERT_FAILED
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Debug
|
# Debug
|
||||||
|
@ -89,6 +89,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed
|
||||||
cmd="${rm_cmd} ${name}-${curr_version}"
|
cmd="${rm_cmd} ${name}-${curr_version}"
|
||||||
fi
|
fi
|
||||||
execcmd "remove" "${cmd}"
|
execcmd "remove" "${cmd}"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
exit 0
|
exit 0
|
||||||
else # Should be installed
|
else # Should be installed
|
||||||
if [ -n "$version" ]; then # Want a specific version
|
if [ -n "$version" ]; then # Want a specific version
|
||||||
|
@ -102,6 +103,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed
|
||||||
execcmd "remove" "${cmd}"
|
execcmd "remove" "${cmd}"
|
||||||
cmd="${add_cmd} -r ${name}-${version}"
|
cmd="${add_cmd} -r ${name}-${version}"
|
||||||
execcmd "add" "${cmd}"
|
execcmd "add" "${cmd}"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
else # Don't care what version to use
|
else # Don't care what version to use
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -120,6 +122,7 @@ else # PKG *isn't* installed
|
||||||
cmd="${cmd}-${version}"
|
cmd="${cmd}-${version}"
|
||||||
fi
|
fi
|
||||||
execcmd "add" "${cmd}"
|
execcmd "add" "${cmd}"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -62,15 +62,15 @@ state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
|
|
||||||
if [ -f "$__object/parameter/pkg_path" ]; then
|
if [ -f "$__object/parameter/pkg_path" ]; then
|
||||||
pkg_path="$(cat "$__object/parameter/pkg_path")"
|
pkg_path="$(cat "$__object/parameter/pkg_path")"
|
||||||
else
|
else
|
||||||
has_installurl=$(cat "${__object}/explorer/has_installurl")
|
has_installurl=$(cat "${__object}/explorer/has_installurl")
|
||||||
if [ Xyes != X"${has_installurl}" ]; then
|
if [ Xyes != X"${has_installurl}" ]; then
|
||||||
# there is no default PKG_PATH, try to provide one
|
# there is no default PKG_PATH, try to provide one
|
||||||
pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/"
|
pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$pkg_version" ]; then
|
if [ "$pkg_version" ]; then
|
||||||
state_is="present"
|
state_is="present"
|
||||||
|
@ -99,11 +99,12 @@ if [ \$? -ne 0 ]; then
|
||||||
echo "Error: \$status"
|
echo "Error: \$status"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
eof
|
eof
|
||||||
;;
|
;;
|
||||||
|
|
||||||
absent)
|
absent)
|
||||||
# use this because pkg_add doesn't properly handle errors
|
# use this because pkg_delete doesn't properly handle errors
|
||||||
cat << eof
|
cat << eof
|
||||||
status=\$(pkg_delete "$pkgopts" "$pkgid")
|
status=\$(pkg_delete "$pkgopts" "$pkgid")
|
||||||
pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
|
pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1
|
||||||
|
@ -117,6 +118,7 @@ if [ \$? -eq 0 ]; then
|
||||||
echo "Error: \$status"
|
echo "Error: \$status"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
eof
|
eof
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -57,12 +57,15 @@ execcmd(){
|
||||||
case "$1" in
|
case "$1" in
|
||||||
add)
|
add)
|
||||||
_cmd="${add_cmd} $2"
|
_cmd="${add_cmd} $2"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
rm)
|
rm)
|
||||||
_cmd="${rm_cmd} $2"
|
_cmd="${rm_cmd} $2"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
upg)
|
upg)
|
||||||
_cmd="${upg_cmd} $2"
|
_cmd="${upg_cmd} $2"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "Error. Don't understand command: %s" "$1" >&2
|
printf "Error. Don't understand command: %s" "$1" >&2
|
||||||
|
|
|
@ -40,9 +40,11 @@ fi
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "gem install '$name' --no-ri --no-rdoc"
|
echo "gem install '$name' --no-ri --no-rdoc"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "gem uninstall '$name'"
|
echo "gem uninstall '$name'"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -61,9 +61,11 @@ fi
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "yum $opts install '$install_name'"
|
echo "yum $opts install '$install_name'"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "yum $opts remove '$name'"
|
echo "yum $opts remove '$name'"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -62,14 +62,17 @@ case "$state_should" in
|
||||||
if [ -z "$version_should" ]; then
|
if [ -z "$version_should" ]; then
|
||||||
[ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything
|
[ "$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"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
else
|
else
|
||||||
[ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything
|
[ "$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"
|
echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null"
|
||||||
|
echo "installed" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
[ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything
|
[ "$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"
|
||||||
|
echo "removed" >> "$__messages_out"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
Loading…
Reference in a new issue