made repos an array again
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
updatesAvailable() {
|
updatesAvailable() {
|
||||||
repos=$(grep '^\[' /etc/pacman.conf | sed -e 's/[][]//g' | grep -E 'x86-64-v[2-4]')
|
readarray -t repos < <(grep '^\[' /etc/pacman.conf | sed -e 's/[][]//g' | grep -E 'x86-64-v[2-4]')
|
||||||
|
|
||||||
output_json=false
|
output_json=false
|
||||||
check_pkg=""
|
check_pkg=""
|
||||||
@@ -10,7 +10,7 @@ updatesAvailable() {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
-j|--json) output_json=true; shift ;;
|
-j|--json) output_json=true; shift ;;
|
||||||
--check-pkg)
|
--check-pkg)
|
||||||
check_pkg="$2"
|
check_pkg=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -22,18 +22,18 @@ updatesAvailable() {
|
|||||||
|
|
||||||
declare -A pkgs
|
declare -A pkgs
|
||||||
|
|
||||||
pacman -Sl "${repos[@]}" | while read -r _ name version status; do
|
while read -r _ name version status; do
|
||||||
if [[ $status == *installed* ]]; then
|
if [[ $status == *installed* ]]; then
|
||||||
pkgs["$name"]=1
|
pkgs[$name]=1
|
||||||
fi
|
fi
|
||||||
done
|
done < <(pacman -Sl ${repos[@]})
|
||||||
|
|
||||||
repo_query=$(printf '&repo=%s' "${repos[@]}")
|
repo_query=$(printf '&repo=%s' "${repos[@]}")
|
||||||
api_url="https://api.alhp.dev/packages?limit=0&offset=0&status=queued&status=building${repo_query}"
|
api_url="https://api.alhp.dev/packages?limit=0&offset=0&status=queued&status=building${repo_query}"
|
||||||
|
|
||||||
if [[ -n "$check_pkg" ]]; then
|
if [[ -n $check_pkg ]]; then
|
||||||
building_pkgs=$(curl -s "$api_url" \
|
building_pkgs=$(curl -s $api_url \
|
||||||
| jq -r --arg pkg "$check_pkg" '.packages[] | select(.split_packages[] == $pkg) | .split_packages[]')
|
| jq -r --arg pkg $check_pkg '.packages[] | select(.split_packages[] == $pkg) | .split_packages[]')
|
||||||
|
|
||||||
matches=()
|
matches=()
|
||||||
for bpkg in $building_pkgs; do
|
for bpkg in $building_pkgs; do
|
||||||
@@ -51,17 +51,17 @@ updatesAvailable() {
|
|||||||
else
|
else
|
||||||
matches=()
|
matches=()
|
||||||
while read -r pkgname; do
|
while read -r pkgname; do
|
||||||
if [[ -n "${pkgs[$pkgname]}" ]]; then
|
if [[ -n ${pkgs[$pkgname]} ]]; then
|
||||||
matches+=("$pkgname")
|
matches+=($pkgname)
|
||||||
fi
|
fi
|
||||||
done < <(curl -s "$api_url" | jq -r '.packages[] | .split_packages[]')
|
done < <(curl -s $api_url | jq -r '.packages[] | .split_packages[]')
|
||||||
|
|
||||||
if $output_json; then
|
if $output_json; then
|
||||||
printf '%s\n' "${matches[@]}" | jq -Rn '[inputs]'
|
printf '%s\n' ${matches[@]} | jq -Rn '[inputs]'
|
||||||
else
|
else
|
||||||
printf '%s\n' "${matches[@]}"
|
printf '%s\n' ${matches[@]}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
updatesAvailable "$@"
|
updatesAvailable $@
|
||||||
|
Reference in New Issue
Block a user