diff options
author | Seppia <seppia@seppia.net> | 2018-06-03 13:51:24 +0200 |
---|---|---|
committer | Seppia <seppia@seppia.net> | 2018-06-03 13:51:24 +0200 |
commit | f849f35bdbffe7a22268df08cd906e134a5c5c9a (patch) | |
tree | c0759a489e58a2454e8cadd9d15ac48221615c28 | |
parent | b3af000e629971b609e9bc41887a81505776a83c (diff) | |
download | repofish-f849f35bdbffe7a22268df08cd906e134a5c5c9a.tar.gz repofish-f849f35bdbffe7a22268df08cd906e134a5c5c9a.tar.bz2 repofish-f849f35bdbffe7a22268df08cd906e134a5c5c9a.zip |
Support o multiple packages
This completes the support for multiple packages commands, adding it
to clean, update and upgrade functions.
-rwxr-xr-x | repo.sh | 54 |
1 files changed, 36 insertions, 18 deletions
@@ -56,7 +56,10 @@ list_packages() { clean_packages() { if [ "$1" != '' ]; then - find ${SRC_PATH} -type f -iname "*$1*.pkg.tar.xz" -exec rm {} \; + declare -a pkg=("${!1}") + for i in "${pkg[@]}"; do + find ${SRC_PATH} -type f -iname "*$i*.pkg.tar.xz" -exec rm {} \; + done else find ${SRC_PATH} -type f -iname "*.pkg.tar.xz" -exec rm {} \; fi @@ -80,9 +83,12 @@ build_packages() { upgrade_packages() { if [ "$1" != '' ]; then - cd $(find ${SRC_PATH}/* -type d -prune -iname "*$1") - git pull - makepkg -Cs + declare -a pkg=("${!1}") + for i in "${pkg[@]}"; do + cd $(find ${SRC_PATH}/* -type d -prune -iname "*$i") + git pull + makepkg -Cs + done else for i in $(find ${SRC_PATH}/* -type d -prune) do @@ -108,8 +114,11 @@ install_package() { update_repo() { if [ "$1" != '' ]; then - find ${SRC_PATH} -type f -iname "*$1*pkg.tar.xz" -exec cp {} ${REPO_PATH}/x86_64/ \; - repo-add ${REPO_PATH}/x86_64/${REPO_NAME}.db.tar.gz ${REPO_PATH}/x86_64/*$1*.pkg.tar.xz + declare -a pkg=("${!1}") + for i in "${pkg[@]}"; do + find ${SRC_PATH} -type f -iname "*$i*pkg.tar.xz" -exec cp {} ${REPO_PATH}/x86_64/ \; + repo-add ${REPO_PATH}/x86_64/${REPO_NAME}.db.tar.gz ${REPO_PATH}/x86_64/*$i*.pkg.tar.xz + done else find ${SRC_PATH} -type f -iname "*pkg.tar.xz" -exec cp {} ${REPO_PATH}/x86_64/ \; repo-add ${REPO_PATH}/x86_64/${REPO_NAME}.db.tar.gz ${REPO_PATH}/x86_64/*.pkg.tar.xz @@ -223,16 +232,19 @@ elif [ "$1" == 'list' ]; then list_packages fi elif [ "$1" == 'update' ]; then - if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' - elif [ "${REPO_PATH}" == '' ];then + if [ "${REPO_PATH}" == '' ];then echo 'ERROR: REPO_PATH variable not set.' elif [ ! -d "${REPO_PATH}" ]; then echo 'ERROR: REPO_PATH variable set to invalid path.' elif [ "${REPO_NAME}" == '' ];then echo 'ERROR: REPO_NAME variable not set.' elif [ "$2" != '' ]; then - update_repo $2 + N=2 + while [ "${!N}" != '' ]; do + packages[$((N-2))]=${!N} + let N=N+1 + done + update_repo packages[@] else update_repo fi @@ -248,10 +260,13 @@ elif [ "$1" == 'build' ]; then build_packages fi elif [ "$1" == 'upgrade' ]; then - if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' - elif [ "$2" != '' ]; then - upgrade_packages $2 + if [ "$2" != '' ]; then + N=2 + while [ "${!N}" != '' ]; do + packages[$((N-2))]=${!N} + let N=N+1 + done + upgrade_packages packages[@] else upgrade_packages fi @@ -267,10 +282,13 @@ elif [ "$1" == 'install' ]; then install_package packages[@] fi elif [ "$1" == 'clean' ]; then - if [ "$3" != '' ]; then - echo 'ERROR: too many arguments.' - elif [ "$2" != '' ]; then - clean_packages $2 + if [ "$2" != '' ]; then + N=2 + while [ "${!N}" != '' ]; do + packages[$((N-2))]=${!N} + let N=N+1 + done + clean_packages packages[@] else clean_packages fi |