diff options
author | Chase Qi <chase.qi@linaro.org> | 2018-11-12 17:45:31 +0800 |
---|---|---|
committer | Chase Qi <chase.qi@linaro.org> | 2018-11-12 17:45:31 +0800 |
commit | 67957577fc72e772a556eced037b8df8ebaf5bbd (patch) | |
tree | 70fa28293b32b3ac90ab11e227eb1e3e28381a9c | |
parent | ff49d31f433af4150f4ac374a2452cab273de65c (diff) |
sh-test-lib: add remove_pkgs()
Change-Id: I4f45cf42cb8c96687168126631e0525d32121aa0
Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-x | automated/lib/sh-test-lib | 25 |
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" |