forked from ahurac/dotfiles
38 lines
905 B
Text
38 lines
905 B
Text
|
#!/usr/bin/env sh
|
||
|
|
||
|
get_field() {
|
||
|
echo "$2" | cut -d / -f "$1"
|
||
|
}
|
||
|
|
||
|
error() {
|
||
|
exit_code="$1"
|
||
|
shift
|
||
|
>&2 printf '\033[1;31m==> ERROR:\033[0m \033[1m%s\033[0m\n' "$*"
|
||
|
exit "$exit_code"
|
||
|
}
|
||
|
|
||
|
repo=$(get_field 1 "$1")
|
||
|
package=$(get_field 2 "$1")
|
||
|
|
||
|
case "$repo" in
|
||
|
system|world|galaxy|lib32)
|
||
|
url=gitea.artixlinux.org/packages/%s/raw/branch/master/PKGBUILD
|
||
|
;;
|
||
|
extra|multilib)
|
||
|
#url=gitlab.archlinux.org/archlinux/packaging/packages
|
||
|
url=gitlab.archlinux.org/archlinux/packaging/packages/%s/-/raw/main/PKGBUILD
|
||
|
;;
|
||
|
aur)
|
||
|
url='aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=%s'
|
||
|
;;
|
||
|
*)
|
||
|
error 1 "Invalid repository name \"${repo}\""
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
# Format is in my variable
|
||
|
# shellcheck disable=2059
|
||
|
url=$(printf "https://${url}" "$package")
|
||
|
|
||
|
curl -f -L -- "$url" || error 2 "Failed to retrieve PKGBUILD from \"${url}\""
|