From 9d8caa469ebd39199d4508a4ba649619b136a214 Mon Sep 17 00:00:00 2001 From: David Runge Date: Sun, 7 Feb 2021 21:13:39 +0100 Subject: pkgs: Add function to check for dependencies bin/pkgs: Add function to generically search for and fail in the abscence of dependencies to the script (e.g. svn and git). --- bin/pkgs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'bin/pkgs') diff --git a/bin/pkgs b/bin/pkgs index e8281b3..253ca91 100755 --- a/bin/pkgs +++ b/bin/pkgs @@ -33,7 +33,18 @@ declare -A package_dirs=( ["extra"]="${package_dir_base}extra" ) -# TODO: check whether git and subversion are installed +check_dependencies() { + # check whether required commands are installed + local _commands=('svn' 'git') + local _command + + for _command in "${_commands[@]}"; do + if ! command -v s > /dev/null; then + printf "The required command %s can not be found. Exiting...\n" "$_command" + exit 1 + fi + done +} create_tmp_packagelist() { local list_file="" @@ -247,6 +258,7 @@ case "${mode}" in echo "A package must be defined for adding a package." exit 1 else + check_dependencies add_package "$package" [ $new_package -gt 0 ] && create_package "$package" fi @@ -260,10 +272,12 @@ case "${mode}" in echo "A package must be defined for removing a package." exit 1 else + check_dependencies remove_package "$package" fi ;; update) + check_dependencies if [ -z "$repo" ];then for list in aur community core extra; do if [ -f "${package_lists[$list]}" ]; then @@ -289,6 +303,7 @@ case "${mode}" in fi ;; clean) + check_dependencies if [ -z "$repo" ]; then for list in aur community core extra; do repo="$list" -- cgit v1.2.3-70-g09d2