#!/bin/bash # Copyright (C) 2005, NAGY Bence # This file can be distributed under the terms of the # GNU General Public License version 2. Fsrcdir="$startdir/src" Fdestdir="$startdir/pkg" Fprefix="/usr" Fmessage() { if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then echo -e "\033[1;32m[]\033[1;0m \033[1;1m$1\033[1;0m" >&2 else echo "[] $1" >&2 fi } Fcd() { if [ "$Fsrcdir" = `pwd` ]; then if [ "$#" -eq 1 ]; then Fmessage "Going to the source directory..." cd "$Fsrcdir/$1" elif [ "$#" -eq 0 ]; then Fcd "$pkgname-$pkgver" fi fi } Fmkdir() { local i for i in "$@"; do Fmessage "Creating directory: $i" mkdir -p "$Fdestdir/$i" || return 1 done } Frm() { local i for i in "$@"; do Fmessage "Deleting file(s): $i" rm -rf "$Fdestdir/$i" || return 1 done } Fcp() { if [ "$#" -eq 3 ]; then Fmessage "Copying file(s): $2" if [ "`ls -l $Fsrcdir/$2 | wc -l`" -gt 1 -a ! -d "$Fdestdir/$3" ]; then Fmkdir "$3" fi install -D -m "$1" "$Fsrcdir"/$2 "$Fdestdir"/$3 || return 1 elif [ "$#" -eq 2 ]; then Fcp "$1" `basename "$2"` "$2" || return 1 fi } Fcpexe() { Fcp 0755 "$@" } Fcpfile() { Fcp 0644 "$@" } Fln() { Fmessage "Creating symlink(s): $1" if [ `ls -l "$Fsrcdir/$1" | wc -l` -gt 1 -a ! -d "$Fdestdir/$2" ]; then Fmkdir "$2" fi ln -sf "$Fsrcdir"/$1 "$Fdestdir"/$2 } Fsed() { for i in ${@:3:$#}; do Fmessage "Using sed with file: $i" sed -i -e "s|$1|$2|g" "$i" done } Fpatch() { Fcd Fmessage "Using patch: $1" if [ -n "`echo $1 | grep \.patch0$`" ]; then patch -Np0 -i "$Fsrcdir/$1" || return 1 else patch -Np1 -i "$Fsrcdir/$1" || return 1 fi } Fpatchall() { for i in ${source[@]}; do if [ -n "`echo "$i" | grep \.patch[0-9]*$`" -o -n "`echo "$i" | grep \.diff$`" ]; then Fpatch "$i" fi done } Fmake() { Fcd Fmessage "Configuring..." if [ -x configure ]; then ./configure --prefix="$Fprefix" "$@" elif [ -f Makefile.PL ]; then perl Makefile.PL --prefix="$Fprefix" "$@" elif [ -f extconf.rb ]; then ruby extconf.rb --prefix="$Fprefix" "$@" elif [ -f configure.rb ]; then ./configure.rb --prefix="$Fprefix" "$@" fi Fmessage "Compiling..." if [ -f Makefile ]; then make || return 1 fi } Finstall() { if [ -f Makefile ]; then Fmessage "Installing to the package directory..." if [ -n "`grep DESTDIR Makefile`" ]; then make DESTDIR="$Fdestdir" install else make prefix="$Fdestdir"/"$Fprefix" install fi fi } Fbuild() { Fpatchall Fmake "$@" Finstall } # v0.1 Wed, 19 Jan 2005 11:43:53 +0100