diff options
| author | kj-sh604 <43.splash@gmail.com> | 2025-06-10 13:22:32 -0400 |
|---|---|---|
| committer | kj-sh604 <43.splash@gmail.com> | 2025-06-10 13:22:32 -0400 |
| commit | 99d22e189963e836d9655862427f4c8d18ba1421 (patch) | |
| tree | 50df3d6de0929cfcd2dec63e6b9251537692f27e | |
| parent | bb03272d630e53fbe736c0d9a29498f110051d23 (diff) | |
| -rw-r--r-- | README | 13 | ||||
| -rwxr-xr-x | gitaur | 60 |
2 files changed, 68 insertions, 5 deletions
@@ -1,14 +1,17 @@ -gitpkg +gitpkg/gitaur ------ -simple POSIX helper script that grabs the PKGBUILD of Arch Linux packages (in -the official repos) via `git`. +simple POSIX helper scripts that grabs the PKGBUILD of Arch Linux packages via +`git`. + +gitpkg = grabs PKGBUILDs from the Official Arch Repositories +gitaur = grabs PKGBUILDs from the Arch User Repository ------ usage: - gitpkg [-h|--help] - gitpkg <package name> <package name>... + $0 [-h|--help] + $0 <package name> <package name>... options: -h, --help @@ -0,0 +1,60 @@ +#!/bin/sh + +check_git_installed() { + if ! command -v git >/dev/null 2>&1; then + echo "error: git is not installed :( please git wget to use $0." + exit 1 + fi +} + +_base_url='https://aur.archlinux.org' + +get_url_function() { + _pkg="$1" + _url="${_base_url}/${_pkg}.git" + + echo "$_url" +} + +run_grabber_function() { + _pkg="$(echo "$1" | tr -d '[:space:]')" + _url="$(get_url_function "$_pkg")" + + git clone "$_url" +} + +grabber_function() { + for _pkg in "$@"; do + run_grabber_function "$_pkg" & + done + wait +} + +usage_function() { + cat <<EOF +usage: + $0 [-h|--help] + $0 <pkg> <pkg>... + +options: + -h, --help + print this help message +EOF +} + +check_git_installed + +while [ $# -gt 0 ]; do + case "$1" in + -*) + usage_function + exit 0 + ;; + *) + grabber_function "$@" + exit 0 + ;; + esac +done + +# vim: set filetype=sh foldmethod=marker foldlevel=0: |
