summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeppia <seppia@seppia.net>2018-05-31 12:43:44 +0200
committerSeppia <seppia@seppia.net>2018-05-31 12:43:44 +0200
commitae8a54f4652e4385be11a72838e4c0420104f27e (patch)
tree0d73044036afc915c9aaf338221df3825f39c30c
parent34197addaeb85f5a51dde716265309643b769961 (diff)
downloadrepofish-ae8a54f4652e4385be11a72838e4c0420104f27e.tar.gz
repofish-ae8a54f4652e4385be11a72838e4c0420104f27e.tar.bz2
repofish-ae8a54f4652e4385be11a72838e4c0420104f27e.zip
Search function
Adds support for searching packages form aur using keywords matching name and/or description
-rwxr-xr-xrepo.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/repo.sh b/repo.sh
index 1b11af2..c22ff31 100755
--- a/repo.sh
+++ b/repo.sh
@@ -6,6 +6,9 @@
#REPO_PATH='/path/to/archlinux/repo'
#REPO_NAME='repo_name'
+## Search variables
+URL_PREFIX='https://aur.archlinux.org/rpc/?v=5&type=search&by=name-desc&arg='
+
add_package() {
if [ ! -d "${SRC_PATH}/$(echo $1 | awk -F '/' '{print $NF}' | cut -d '.' -f 1)" ]; then
cd ${SRC_PATH}
@@ -91,6 +94,16 @@ update_repo() {
fi
}
+search_packages() {
+ declare -a key=("${!1}")
+ CURL_JSN=$(curl -s $(echo ${URL_PREFIX}"${key[@]}" | sed -e 's/ /+/g'))
+ OUT_STR=$(jq -r '.results | .[] | [.Name, .Version], .Description' <<< ${CURL_JSN})
+ printf 'You searched using the following keywords (matching package name and/or description): "'
+ printf '%s ' "${key[@]}"
+ printf '\b"\n'
+ echo ${OUT_STR} | sed -e 's/\[ /\n/g' -e 's/ *\] /\n\t/g' -e 's/"*, /\//g' -e 's/"//g'
+}
+
print_help() {
echo 'repo.sh SEPPIOFISH repo tool'
echo
@@ -105,6 +118,7 @@ print_help() {
echo ' upgrade upgrades the packages'
echo ' install builds and installs the package'
echo ' clean cleans the packages'
+ echo ' search searches packages in AUR'
echo ' help prints this help'
echo
}
@@ -191,6 +205,17 @@ elif [ "$1" == 'clean' ]; then
else
clean_packages
fi
+elif [ "$1" == 'search' ]; then
+ if [ "$2" == '' ]; then
+ echo 'error: missing argument(s).'
+ else
+ N=2
+ while [ "${!N}" != '' ]; do
+ keywords[$((N-2))]=${!N}
+ let N=N+1
+ done
+ search_packages keywords[@]
+ fi
elif [ "$1" == 'help' ]; then
if [ "$2" != '' ]; then
echo 'error: too many arguments.'