summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2018-11-12 09:50:25 +0000
committerLinaro Code Review <review@review.linaro.org>2018-11-12 09:50:25 +0000
commit509ddb3a96eaf8eae575a05f240db34ee5a35036 (patch)
tree4b077608ec0bcbfa4590a21c19ee4317f31639c9
parent5ff76d31255784d149c58fd7d21f63bb812cb55e (diff)
parent67957577fc72e772a556eced037b8df8ebaf5bbd (diff)
Merge "sh-test-lib: add remove_pkgs()"
-rwxr-xr-xautomated/lib/sh-test-lib25
1 files changed, 25 insertions, 0 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index bf72984..c71a884 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -234,6 +234,31 @@ install_deps() {
fi
}
+remove_pkgs() {
+ pkgs="$1"
+ [ -z "${pkgs}" ] && error_msg "Usage: remove_pkgs pkgs"
+ ! check_root && error_msg "remove_pkgs() requires root permission."
+ info_msg "Removing ${pkgs} ..."
+ dist_name
+ case "${dist}" in
+ debian|ubuntu)
+ # shellcheck disable=SC2086
+ DEBIAN_FRONTEND=noninteractive apt-get -y purge ${pkgs}
+ ;;
+ centos)
+ # shellcheck disable=SC2086
+ yum -y remove ${pkgs}
+ ;;
+ fedora)
+ # shellcheck disable=SC2086
+ dnf -y remove ${pkgs}
+ ;;
+ *)
+ warn_msg "Unsupported distro: ${dist}! Package uninstallation skipped."
+ ;;
+ esac
+}
+
# Return the exit code of the first command when using pipe.
pipe0_status() {
[ "$#" -ne 2 ] && error_msg "Usage: pipe0_status cmd1 cmd2"