Guest User

Untitled

a guest
Dec 17th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # Download, build and install an Archlinux's aur package
  4. #
  5. # Usage: $ aurinstall PACKAGE_SNAPSHOT_URL
  6. #
  7.  
  8. set -o nounset
  9. set -o errexit
  10.  
  11. declare -r AUR_BUILDS_DIR=$HOME/.aur_builds
  12.  
  13. function usage() {
  14. echo "Usage: $0 PACKAGE_SNAPSHOT_URL"
  15. }
  16.  
  17. function _check_required_programs() {
  18. required=(tar wget makepkg)
  19. for p in ${required[@]}; do
  20. hash "${p}" 2>&- || \
  21. {
  22. echo >&2 " Required program \"${p}\" not installed or in search PATH.";
  23. exit 1;
  24. }
  25. done
  26. }
  27.  
  28. function main() {
  29. if [[ $# -ne 1 ]] ; then
  30. usage;
  31. exit 1;
  32. fi
  33.  
  34. local package_url=$1
  35.  
  36. _check_required_programs
  37.  
  38. mkdir -p $AUR_BUILDS_DIR
  39. cd $AUR_BUILDS_DIR
  40.  
  41. # 1. Fetch snapshot
  42. # -nc skip if file exists
  43. wget -nc $package_url
  44.  
  45. # 2. Extract files
  46. tar -xvf $(basename "$package_url")
  47.  
  48. extracted_dir=`tar -xvf $(basename "$package_url") | head -1 | cut -f1 -d"/"`
  49. cd $extracted_dir
  50.  
  51. # 3. Build and install
  52. # -i install, -s syncdeps, -L log, --noconfirm skip pacman confirmation
  53. makepkg -isL --noconfirm
  54. }
  55.  
  56. main "$@"
Add Comment
Please, Sign In to add comment