Merge branch 'master' into refactor-openbsd-pkg-type

This commit is contained in:
sideeffect42 2018-12-14 21:33:42 +01:00 committed by GitHub
commit 57a3257a26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 64 additions and 17 deletions

View file

@ -39,12 +39,12 @@ pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then if [ -z "$pkg_version" ]; then
state_is="absent" state_is="absent"
elif [ -z "$version" ] && [ "$(echo "$pkg_version" | wc -l)" -gt 1 ]; then elif [ -z "$version" ] && [ "$(echo "$pkg_version" | wc -l)" -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:" echo "Package name is not unique! The following packages are installed:" >&2
echo "$pkg_version" echo "$pkg_version" >&2
exit 1 exit 1
elif [ -n "$version" ] && [ "$(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l)" -gt 1 ]; then elif [ -n "$version" ] && [ "$(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l)" -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:" echo "Package name is not unique! The following packages are installed:" >&2
echo "$pkg_version" echo "$pkg_version" >&2
exit 1 exit 1
else else
state_is="present" state_is="present"
@ -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

View file

@ -6,10 +6,11 @@ flaggie_installed="$(cat "$__object/explorer/flaggie_installed")"
if [ "${gentoolkit_installed}" != "true" ]; then if [ "${gentoolkit_installed}" != "true" ]; then
# emerge app-portage/gentoolkit # emerge app-portage/gentoolkit
echo "emerge app-portage/gentoolkit &> /dev/null || exit 1" echo "emerge app-portage/gentoolkit &> /dev/null || exit 1"
echo "installed app-portage/gentoolkit" >> "$__messages_out"
fi fi
if [ "${flaggie_installed}" != "true" ]; then if [ "${flaggie_installed}" != "true" ]; then
# emerge app-portage/flaggie # emerge app-portage/flaggie
echo "emerge app-portage/flaggie &> /dev/null || exit 1" echo "emerge app-portage/flaggie &> /dev/null || exit 1"
echo "installed app-portage/flaggie" >> "$__messages_out"
fi fi

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -76,7 +76,7 @@ case "${state_should}" in
fi fi
# 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_add ${pkgopts} '${pkgid}' 2>&1 || true) status=\$(pkg_add ${pkgopts} '${pkgid}' 2>&1 || true)
if ! pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}$' 2>/dev/null if ! pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}$' 2>/dev/null
@ -96,8 +96,8 @@ EOF
absent) absent)
# Use this because pkg_delete doesn't properly handle errors # Use this because pkg_delete doesn't properly handle errors
cat << EOF cat <<EOF
status=\$(pkg_delete ${pkgopts} '${pkgid}' || true) status=\$(pkg_delete ${pkgopts} '${pkgid}' 2>&1 || true)
if pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}' 2>/dev/null if pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}' 2>/dev/null
then then

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
# #
# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Steven Armstrong (steven-cdist at armstrong.cc)
# 2018 Takashi Yoshi (takashi at yoshi.email)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -28,12 +29,26 @@ fi
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
case "$os" in case "$os" in
redhat|centos|ubuntu|debian|devuan|archlinux|coreos) # Linux
flag='-w' redhat|centos|ubuntu|debian|devuan|archlinux|gentoo|coreos)
;; flag='-w'
frebsd) ;;
flag='' # BusyBox
;; alpine|openwrt)
flag='-w'
;;
macosx)
# NOTE: Older versions of Mac OS X require the -w option.
# Even though the flag is not mentioned in new man pages anymore,
# it still works.
flag='-w'
;;
netbsd)
flag='-w'
;;
freebsd|openbsd)
flag=''
;;
esac esac
# set the current runtime value # set the current runtime value

View file

@ -1,6 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
# #
# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Steven Armstrong (steven-cdist at armstrong.cc)
# 2018 Takashi Yoshi (takashi at yoshi.email)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -22,7 +23,12 @@
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
case "$os" in case "$os" in
redhat|centos|ubuntu|debian|devuan|archlinux|coreos|freebsd) # Linux
redhat|centos|ubuntu|debian|devuan|archlinux|coreos)
:
;;
# BSD
freebsd|macosx|netbsd|openbsd)
: :
;; ;;
*) *)

View file

@ -8,6 +8,8 @@ next:
* Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon) * Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon)
* Documentation: Fix broken links (Rage <OxR463>) * Documentation: Fix broken links (Rage <OxR463>)
* Type __docker: Add version parameter (Jonas Weber) * Type __docker: Add version parameter (Jonas Weber)
* Type __sysctl: Refactor for better OS support (Takashi Yoshi)
* Types __package_*: Add messaging upon installation/removal (Takashi Yoshi)
4.10.4: 2018-11-03 4.10.4: 2018-11-03
* Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha)