diff options
author | Seppia <seppia@seppia.net> | 2018-06-03 13:12:08 +0200 |
---|---|---|
committer | Seppia <seppia@seppia.net> | 2018-06-03 13:12:08 +0200 |
commit | ac177952ab96a624c8256a2a7f634e3d3be7a7fe (patch) | |
tree | 4bd705e04e62e9286c78af89e2d0e6a30ed42832 | |
parent | d89c4a44964ec9a1e946132c37e5322310724a89 (diff) | |
download | repofish-ac177952ab96a624c8256a2a7f634e3d3be7a7fe.tar.gz repofish-ac177952ab96a624c8256a2a7f634e3d3be7a7fe.tar.bz2 repofish-ac177952ab96a624c8256a2a7f634e3d3be7a7fe.zip |
Remove and install multiple packages at the same time
Added support for removing and installing multiple packages using just
one command.
-rwxr-xr-x | repo.sh | 52 |
1 files changed, 32 insertions, 20 deletions
@@ -32,11 +32,14 @@ clone_package() { } rm_package() { - if [ -d "${SRC_PATH}/$1" ]; then - rm -rf ${SRC_PATH}/$1 - else - echo 'WARNING: Package not present.' - fi + declare -a pkg=("${!1}") + for i in "${pkg[@]}"; do + if [ -d "${SRC_PATH}/$i" ]; then + rm -rf ${SRC_PATH}/$i + else + echo 'WARNING: Package '"$i"' not present.' + fi + done } check_package() { @@ -88,13 +91,16 @@ upgrade_packages() { } install_package() { - if [ -d "${SRC_PATH}/$1" ]; then - cd $(find ${SRC_PATH}/* -type d -prune -iname "*$1") - git pull - makepkg -Csi - else - echo 'WARNING: Package not found.' - fi + declare -a pkg=("${!1}") + for i in "${pkg[@]}"; do + if [ -d "${SRC_PATH}/$i" ]; then + cd $(find ${SRC_PATH}/* -type d -prune -iname "*$i") + git pull + makepkg -Csi + else + echo 'WARNING: Package '"$i"' not found.' + fi + done } update_repo() { @@ -189,12 +195,15 @@ elif [ "$1" == 'clone' ]; then clone_package $2 fi elif [ "$1" == 'rm' ]; then - if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' - elif [ "$2" == '' ]; then + if [ "$2" == '' ]; then echo 'ERROR: missing argument.' else - rm_package $2 + N=2 + while [ "${!N}" != '' ]; do + packages[$((N-2))]=${!N} + let N=N+1 + done + rm_package packages[@] fi elif [ "$1" == 'check' ]; then if [ "$3" != '' ]; then @@ -241,12 +250,15 @@ elif [ "$1" == 'upgrade' ]; then upgrade_packages fi elif [ "$1" == 'install' ]; then - if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' - elif [ "$2" == '' ]; then + if [ "$2" == '' ]; then echo 'ERROR: missing argument.' else - install_package $2 + N=2 + while [ "${!N}" != '' ]; do + packages[$((N-2))]=${!N} + let N=N+1 + done + install_package packages[@] fi elif [ "$1" == 'clean' ]; then if [ "$3" != '' ]; then |