Yogurt

Yet another AUR tool

It could have been Yaaurt, but Yogurt sound better, doesn’t it? :-)

What is

Yogurt is an ArchLinux related tool useful to build packages for unsupported software for which is only provided the PKGBUILD in the Archlinux User Repository (AUR). It is a little script that does something similar to aurbuild and qpkg that I wrote when I didn’t know yet of those two scripts.

Features

  • Fetching of the PKGBUILD directly from http://aur.archlinux.org
  • Dependency support both for repositories and from AUR unsupported packages
  • Can optional show the PKGBUILD through configurable reader/editor.
  • Building and installing of the package through makepkg
  • Package saving and working directory deletion
  • Can run as non-root, uses sudo when root privileges are needed

Dependency support

Yogurt features a (still) rudimental dependencies support both for repositories and from AUR unsupported packages. I.e., if a package (this happened to me with obextool) requires something of which no prepackaged binary exists, it tries to solve the dependency building the required package getting it from the AUR unsupported packages. There’s still need to work on it, but for simple things it should work.

Yogurt extracts the “depends” and “makedepends” rows from the PKGBUILD, then checks for each of them if a package with that name is installed (pacman -Q) or if it is available from a repository (pacman -Si). If both theese tests fails, then it assumes that the dependency must is a AUR unsupported package1). If the required package is available from a repository, then it will be installed by makepkg2). Otherwise, Yogurt will invoke itself recursively (hoping everything goes well) until every dependecy is installed.

Known troubles

Yogurt doesn’t work yet with version-dependencies (e.g. python>=2.4), so you’ll have to solve those dependencies by hand and let Yogurt say “Unable to retrieve the PKGBUILD.” for that package, this should not affect the package building.

Moreover, Yogurt can’t yet recognise aliases and group dependencies (as x-server or xfce4). Again, you should install what needed on your own and let Yogurt warn.

Show me it!

The code

#!/bin/sh
#
#   Yogurt: AUR unsupported packages builder
#
#   Copyright (C) 2005, Federico Pelloni <federico.pelloni@gmail.com>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
 
COL_WHITE="\033[1;37m"
COL_LIGHT_BLUE="\033[1;34m"
COL_YELLOW="\033[1;33m"
COL_NORMAL="\033[0m"
COL_RED="\033[1;31m"
 
NAME="yogurt"
READER="less"
 
error() {
	echo -e "$COL_RED""Error""$COL_NORMAL"": $1\n"
	exit 1
}
 
usage() {
	echo -e "$COL_WHITE""Usage""$COL_NORMAL"": yogurt {package-name}\n"
	exit 1
}
 
 
echo
echo -e "$COL_WHITE""Yogurt: AUR unsupported packages builder""$COL_NORMAL"
echo
 
[ -z "$1" ] && usage
 
PKG="$1"
 
echo -e "Installing package '""$COL_LIGHT_BLUE""$PKG$COL_NORMAL'"
echo
 
WDIR="aur-$PKG"
 
if [ -d "$WDIR" ]; then
 
	echo -n -e " $COL_RED!!$COL_NORMAL"" Directory $WDIR already exists. Delete it? [Y/n] "
	read DELETE_DIR
	
	if [ -z "$DELETE_DIR" ] || [ "$DELETE_DIR" == "y" ] || [ "$DELETE_DIR" == "Y" ]; then
		rm -rf "$WDIR" || error "Unable to delete directory $WDIR. Please remove it using root privileges."
	else
		echo -e "\n$COL_RED""Error:$COL_NORMAL"" Unable to work without using that directory.\n"
		exit 1
	fi
fi
 
mkdir "$WDIR" || error "Unable to create directory $WDIR. Please move to a writable directory."
cd "$WDIR/"
 
echo
echo "Retrieving the tarball..."
 
wget -q "http://aur.archlinux.org/packages/$PKG/$PKG.tar.gz" || error "Unable to retrieve the tarball."
 
tar xfvz "$PKG.tar.gz" > /dev/null
 
cd "$PKG/"
 
echo "Do you want to see the PKGBUILD? [Y/n] "
read SEE_PKGBUILD
 
if [ "$SEE_PKGBUILD" != "n" ] && [ "$SEE_PKGBUILD" != "N" ]; then
 
	$READER PKGBUILD
	
fi
 
echo
 
echo "Continue building and installing '$PKG'? [Y/n] "
read CONTINUE_INSTALLING
 
if [ "$CONTINUE_INSTALLING" == "n" ] || [ "$CONTINUE_INSTALLING" == "N" ]; then
 
	exit
	
fi
 
 
echo
 
DEPS=$(grep '^depends=' PKGBUILD | cut -c 9- | tr -d "()'")
DEPS="$DEPS $(grep '^makedepends=' PKGBUILD | cut -c 13- | tr -d \(\)\')"
 
echo -e "$COL_WHITE$PKG dependencies:$COL_NORMAL"
 
DEP_AUR=""
DEP_PACMAN=0
 
for D in $DEPS; do
 
	pacman -Q "$D" > /dev/null 2>&1 && echo -e " - $COL_WHITE$D$COL_NORMAL (already installed)" && continue
	
	pacman -Si "$D" > /dev/null 2>&1 && echo -e " - $COL_LIGHT_BLUE$D$COL_NORMAL (package found)" && DEP_PACMAN=1 && continue
	
	echo -e " - $COL_YELLOW$D$COL_NORMAL (building from AUR)" && DEP_AUR="$DEP_AUR $D"
	
done
 
echo
 
if [ -n "$DEP_AUR" ]; then
 
	DEP_AUR=$(echo "$DEP_AUR" | cut -c 2-)
	echo "Building missing dependencies from AUR:"
	echo "$DEP_AUR"
	
	for xD in $DEP_AUR; do
	
		$0 "$xD"
		
	done
 
fi
 
echo
 
echo -e "$COL_WHITE""Building and installing package$COL_NORMAL\n"
 
echo "Please provide the root password to let me install the package."
sudo makepkg -s -i || error "Makepkg was unable to create or install the package."
 
mv *.pkg.tar.gz .. || sudo mv *.pkg.tar.gz ..
 
cd ..
 
sudo rm -rf "$WDIR" || error "Unable to delete directory $WDIR."
 
exit
 

ChangeLog

2005-09-09:

  • Added this changelog
  • Modified help message. Now if yogurt is called without any argument, it says “Usage: yogurt {package-name}”
  • Quite-big improvement: now yogurt downloads the tarball from AUR instead of the only PKGBUILD. So it can handle packages with patches and *.install files (or better, it gets also those files needed by makepkg which ship with package.tar.gz from AUR)

Previous:

  • Some little-by-little improvements and fixes

Install

Copy the previous code and paste it in a new text file, then save it somewhere easy to reach (for example into /usr/bin) with the name you want (e.g.: /usr/bin/yogurt). Then make it executable with chmod a+x /usr/bin/yogurt.

Usage

Check that the software you want to install is available on http://aur.archlinux.org and that it is an unsupported package, then invoke “yogurt packagename” and follow the instructions Yogurt will provide.

There is no –help yet, sorry about this :-\.

1) This must and probably will be reworked in a future version of Yogurt
2) If this causes troubles Yogurt could easily be adapted to install prepackaged dependencies before invoking makepkg
 
scriptseprogrammi/yogurt.txt · Ultima modifica: 2005/09/23 16:01
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki