Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 22nd, 2010 | Syntax: None | Size: 3.66 KB | Hits: 63 | Expires: Never
Copy text to clipboard
  1. #!/bin/sh
  2. #
  3. #   Yogurt: AUR unsupported packages builder
  4. #
  5. #   Copyright (C) 2005, Federico Pelloni <federico.pelloni@gmail.com>
  6. #
  7. #   This program is free software; you can redistribute it and/or modify
  8. #   it under the terms of the GNU General Public License as published by
  9. #   the Free Software Foundation; either version 2 of the License, or
  10. #   (at your option) any later version.
  11. #
  12. #   This program is distributed in the hope that it will be useful,
  13. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #   GNU General Public License for more details.
  16. #
  17. #   You should have received a copy of the GNU General Public License
  18. #   along with this program; if not, write to the Free Software
  19. #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20. #
  21.  
  22. COL_WHITE="\033[1;37m"
  23. COL_LIGHT_BLUE="\033[1;34m"
  24. COL_YELLOW="\033[1;33m"
  25. COL_NORMAL="\033[0m"
  26. COL_RED="\033[1;31m"
  27.  
  28. NAME="yogurt"
  29. READER="less"
  30.  
  31. error() {
  32.         echo -e "$COL_RED""Error""$COL_NORMAL"": $1\n"
  33.         exit 1
  34. }
  35.  
  36. usage() {
  37.         echo -e "$COL_WHITE""Usage""$COL_NORMAL"": yogurt {package-name}\n"
  38.         exit 1
  39. }
  40.  
  41.  
  42. echo
  43. echo -e "$COL_WHITE""Yogurt: AUR unsupported packages builder""$COL_NORMAL"
  44. echo
  45.  
  46. [ -z "$1" ] && usage
  47.  
  48. PKG="$1"
  49.  
  50. echo -e "Installing package '""$COL_LIGHT_BLUE""$PKG$COL_NORMAL'"
  51. echo
  52.  
  53. WDIR="aur-$PKG"
  54.  
  55. if [ -d "$WDIR" ]; then
  56.  
  57.         echo -n -e " $COL_RED!!$COL_NORMAL"" Directory $WDIR already exists. Delete it? [Y/n] "
  58.         read DELETE_DIR
  59.        
  60.         if [ -z "$DELETE_DIR" ] || [ "$DELETE_DIR" == "y" ] || [ "$DELETE_DIR" == "Y" ]; then
  61.                 rm -rf "$WDIR" || error "Unable to delete directory $WDIR. Please remove it using root privileges."
  62.         else
  63.                 echo -e "\n$COL_RED""Error:$COL_NORMAL"" Unable to work without using that directory.\n"
  64.                 exit 1
  65.         fi
  66. fi
  67.  
  68. mkdir "$WDIR" || error "Unable to create directory $WDIR. Please move to a writable directory."
  69. cd "$WDIR/"
  70.  
  71. echo
  72. echo "Retrieving the tarball..."
  73.  
  74. wget -q "http://aur.archlinux.org/packages/$PKG/$PKG.tar.gz" || error "Unable to retrieve the tarball."
  75.  
  76. tar xfvz "$PKG.tar.gz" > /dev/null
  77.  
  78. cd "$PKG/"
  79.  
  80. echo "Do you want to see the PKGBUILD? [Y/n] "
  81. read SEE_PKGBUILD
  82.  
  83. if [ "$SEE_PKGBUILD" != "n" ] && [ "$SEE_PKGBUILD" != "N" ]; then
  84.  
  85.         $READER PKGBUILD
  86.        
  87. fi
  88.  
  89. echo
  90.  
  91. echo "Continue building and installing '$PKG'? [Y/n] "
  92. read CONTINUE_INSTALLING
  93.  
  94. if [ "$CONTINUE_INSTALLING" == "n" ] || [ "$CONTINUE_INSTALLING" == "N" ]; then
  95.  
  96.         exit
  97.        
  98. fi
  99.  
  100.  
  101. echo
  102.  
  103. DEPS=$(grep '^depends=' PKGBUILD | cut -c 9- | tr -d "()'")
  104. DEPS="$DEPS $(grep '^makedepends=' PKGBUILD | cut -c 13- | tr -d \(\)\')"
  105.  
  106. echo -e "$COL_WHITE$PKG dependencies:$COL_NORMAL"
  107.  
  108. DEP_AUR=""
  109. DEP_PACMAN=0
  110.  
  111. for D in $DEPS; do
  112.  
  113.         pacman -Q "$D" > /dev/null 2>&1 && echo -e " - $COL_WHITE$D$COL_NORMAL (already installed)" && continue
  114.        
  115.         pacman -Si "$D" > /dev/null 2>&1 && echo -e " - $COL_LIGHT_BLUE$D$COL_NORMAL (package found)" && DEP_PACMAN=1 && continue
  116.        
  117.         echo -e " - $COL_YELLOW$D$COL_NORMAL (building from AUR)" && DEP_AUR="$DEP_AUR $D"
  118.        
  119. done
  120.  
  121. echo
  122.  
  123. if [ -n "$DEP_AUR" ]; then
  124.  
  125.         DEP_AUR=$(echo "$DEP_AUR" | cut -c 2-)
  126.         echo "Building missing dependencies from AUR:"
  127.         echo "$DEP_AUR"
  128.        
  129.         for xD in $DEP_AUR; do
  130.        
  131.                 $0 "$xD"
  132.                
  133.         done
  134.  
  135. fi
  136.  
  137. echo
  138.  
  139. echo -e "$COL_WHITE""Building and installing package$COL_NORMAL\n"
  140.  
  141. echo "Please provide the root password to let me install the package."
  142. sudo makepkg -s -i || error "Makepkg was unable to create or install the package."
  143.  
  144. mv *.pkg.tar.gz .. || sudo mv *.pkg.tar.gz ..
  145.  
  146. cd ..
  147.  
  148. sudo rm -rf "$WDIR" || error "Unable to delete directory $WDIR."
  149.  
  150. exit