aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2021-02-07 21:13:39 +0100
committerDavid Runge <dave@sleepmap.de>2021-02-07 21:13:39 +0100
commit9d8caa469ebd39199d4508a4ba649619b136a214 (patch)
treead4c7951b7ee823f59feb2db0cd38a0127f501d0
parent86734efa8c85293e9eb4b31794de5ae42af62111 (diff)
downloaddotfiles-9d8caa469ebd39199d4508a4ba649619b136a214.tar.gz
dotfiles-9d8caa469ebd39199d4508a4ba649619b136a214.tar.bz2
dotfiles-9d8caa469ebd39199d4508a4ba649619b136a214.tar.xz
dotfiles-9d8caa469ebd39199d4508a4ba649619b136a214.zip
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).
-rwxr-xr-xbin/pkgs17
1 files changed, 16 insertions, 1 deletions
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"