abuild: move functions to a shared lib

This commit is contained in:
Natanael Copa 2009-01-03 10:05:12 +00:00
parent 395a795126
commit e48c520d54
3 changed files with 52 additions and 35 deletions

View File

@ -5,6 +5,7 @@ DISTFILES=Makefile abuild abuild.conf APKBUILD.proto
prefix ?= /usr
sysconfdir ?= /etc
datadir ?= $(prefix)/share/$(PACKAGE)
P=$(PACKAGE)-$(VERSION)
@ -13,12 +14,13 @@ help:
@echo "usage: make install [ DESTDIR=<path> ]"
@echo " make dist"
install: abuild abuild.conf APKBUILD.proto
install: abuild abuild.conf APKBUILD.proto functions.sh
mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
$(DESTDIR)/$(prefix)/share/abuild
$(DESTDIR)/$(datadir)
cp abuild $(DESTDIR)/$(prefix)/bin/
cp abuild.conf $(DESTDIR)/$(sysconfdir)/
cp APKBUILD.proto $(DESTDIR)/$(prefix)/share/abuild
cp functions.sh $(DESTDIR)/$(datadir)/
dist: $(P).tar.gz

47
abuild
View File

@ -14,6 +14,20 @@ abuild_ver=0.9
MAKEAPK_CONF=${MAKEAPK_CONF:-/etc/abuild.conf}
[ -f "$MAKEAPK_CONF" ] && . "$MAKEAPK_CONF"
# source functions
# if abuild was not run from PATH, then look for func lib at same location
if [ -z "$FUNCLIB" ]; then
FUNCLIB="${0##/*}/functions.sh"
[ -f "$FUNCLIB" ] || FUNCLIB=/usr/share/abuild/functions.sh
fi
if ! [ -f "$FUNCLIB" ]; then
echo "$FUNCLIB: not found" >&2
exit 1
fi
. "$FUNCLIB"
startdir="$PWD"
srcdir=${srcdir:-"$startdir/src"}
pkgdir=${pkgdir:-"$startdir/pkg"}
@ -25,39 +39,6 @@ PKGDEST=${PKGDEST:-$startdir}
default_cmds="sanitycheck builddeps clean fetch md5check unpack rootpkg"
#colors
if [ -n "$USE_COLORS" ]; then
NORMAL="\033[1;0m"
STRONG="\033[1;1m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
fi
# functions
msg() {
local prompt="$GREEN>>>${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
[ -z "$quiet" ] && printf "${prompt} ${fake}${name}: $@\n" >&2
}
warning() {
local prompt="${YELLOW}>>> WARNING: ${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${fake}${name}: $@\n" >&2
}
error() {
local prompt="${RED}>>> ERROR: ${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${fake}${name}: $@\n" >&2
}
set_xterm_title() {
if [ "$TERM" = xterm ]; then
printf "\033]0;$1\007" >&2

34
functions.sh Normal file
View File

@ -0,0 +1,34 @@
#colors
if [ -n "$USE_COLORS" ]; then
NORMAL="\033[1;0m"
STRONG="\033[1;1m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
fi
# functions
msg() {
local prompt="$GREEN>>>${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
[ -z "$quiet" ] && printf "${prompt} ${fake}${name}: $@\n" >&2
}
warning() {
local prompt="${YELLOW}>>> WARNING: ${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${fake}${name}: $@\n" >&2
}
error() {
local prompt="${RED}>>> ERROR: ${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${fake}${name}: $@\n" >&2
}