2-paru 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env bash
  2. # NAME: Install paru AUR helper
  3. set -euo pipefail
  4. # Source common functions
  5. source "$(dirname "$0")/../common.sh" || {
  6. echo "[ERROR] Could not source common.sh" >&2
  7. exit 1
  8. }
  9. check_requirements() {
  10. local required_commands=(git makepkg)
  11. for cmd in "${required_commands[@]}"; do
  12. if ! command_exists "$cmd"; then
  13. log_error "Required command not found: $cmd"
  14. exit 1
  15. fi
  16. done
  17. }
  18. install_paru() {
  19. if command_exists paru; then
  20. log_info "paru is already installed"
  21. return 0
  22. fi
  23. log_info "Installing build dependencies"
  24. sudo pacman -S --needed --noconfirm base-devel git
  25. local tmpdir
  26. tmpdir=$(mktemp -d)
  27. log_info "Using temporary directory: $tmpdir"
  28. cd "$tmpdir"
  29. log_info "Cloning paru repository"
  30. git clone https://aur.archlinux.org/paru.git
  31. cd paru
  32. log_info "Building and installing paru"
  33. makepkg -si --noconfirm
  34. log_info "Cleaning up temporary files"
  35. cd /
  36. rm -rf "$tmpdir"
  37. }
  38. main() {
  39. init_script
  40. check_requirements
  41. install_paru
  42. finish_script 0
  43. }
  44. main "$@"