Skip to content

Commit

Permalink
Improve readability
Browse files Browse the repository at this point in the history
+ Add expac/aursearch comments
+ Inverse reposelect logic
+ Move jshon/xargs to function
  • Loading branch information
Alad Wenter committed Mar 31, 2016
1 parent 457c2d4 commit 5565e83
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions repofind
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ reposelect() {
avail[$repo]=$server
done < <(repofind)

if [[ ! ${avail[@]} ]]; then
error "No file:// repository found"
exit 2
elif ((${#avail[@]} > 1)); then
select repo in "${!avail[@]}"; do
if ((${#avail[@]} > 1)); then
select repo in "${!avail[@]}"; do
break
done
elif [[ ${avail[@]} ]]; then
repo=${!avail[*]}
else
repo=${!avail[*]}
error "No file:// repository found"
exit 2
fi

pool=${avail[$repo]#file://}
Expand All @@ -53,21 +53,27 @@ reposelect() {
printf '%s %s\n' "$repo" "$pool"
}

namever() {
jshon -a -e results -a -e Name -u -p -e Version -u | xargs -n2
}

quickcheck() {
declare pkg ver
declare -A set_l set_r

# Check if the repo is configured
# Check if the repo is configured.
pacconf --repo="$1" >/dev/null


# If stdin is empty, expac -S lists all sync db packages.
while read -r pkg ver; do
set_l[$pkg]=$ver
done < <(pacsift --exact --repo="$1" <&- | xargs -r expac -S '%n %v')


# Get remote versions from aursearch JSON output.
if [[ ${set_l[@]} ]]; then
while read -r pkg ver; do
set_r[$pkg]=$ver
done < <(aursearch -Fr "${!set_l[@]}" | jshon -a -e results -a -e Name -u -p -e Version -u | xargs -n2)
done < <(aursearch -Fr "${!set_l[@]}" | namever)
else
error "No data available"
exit 61
Expand Down

0 comments on commit 5565e83

Please sign in to comment.