mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-22 07:00:28 +00:00
abuild: move functions to a shared lib
This commit is contained in:
parent
395a795126
commit
e48c520d54
6
Makefile
6
Makefile
@ -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
47
abuild
@ -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
34
functions.sh
Normal 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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user