forked from ahurac/dotfiles
Ajout : script getpkg
This commit is contained in:
parent
468b0a5575
commit
94f97e32a3
1 changed files with 37 additions and 0 deletions
37
bin/getpkg
Executable file
37
bin/getpkg
Executable file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/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}\""
|
Loading…
Reference in a new issue