abuild: fix so APKBUILD env var works properly

We also make sure we source the APKBUILD when we are in the directory
holding the APKBUILD file. Some of the packages sources others
with relative references. (for example kernel 3rd party packages)
This commit is contained in:
Natanael Copa 2009-10-24 20:37:20 +00:00
parent c50ab80bfa
commit f150027100
2 changed files with 23 additions and 13 deletions

View File

@ -25,6 +25,7 @@ else
FULL_VERSION := $(VERSION) FULL_VERSION := $(VERSION)
endif endif
CHMOD := chmod
SED := sed SED := sed
TAR := tar TAR := tar
@ -39,9 +40,11 @@ SSL_LIBS := $(shell pkg-config --libs openssl)
.SUFFIXES: .sh.in .in .SUFFIXES: .sh.in .in
.sh.in.sh: .sh.in.sh:
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
${CHMOD} +x $@
.in: .in:
${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
${CHMOD} +x $@
P=$(PACKAGE)-$(VERSION) P=$(PACKAGE)-$(VERSION)

View File

@ -14,16 +14,9 @@ apkcache=@apkcache@
datadir=@datadir@ datadir=@datadir@
program=${0##*/} program=${0##*/}
startdir="$PWD" abuild_path=$(readlink -f $0)
srcdir=${srcdir:-"$startdir/src"}
pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
pkgrel=0
repo=${startdir%/*}
repo=${repo##*/}
# defaults # defaults
SRCDEST=${SRCDEST:-$startdir}
PKGDEST=${PKGDEST:-$startdir}
BUILD_BASE="build-base" BUILD_BASE="build-base"
SUDO=${SUDO:-"sudo"} SUDO=${SUDO:-"sudo"}
@ -635,7 +628,8 @@ rootpkg() {
fi fi
cd "$startdir" cd "$startdir"
msg "Entering fakeroot..." msg "Entering fakeroot..."
fakeroot $0 $do_build prepare_subpackages prepare_package create_apks fakeroot "$abuild_path" $do_build prepare_subpackages prepare_package \
create_apks
} }
srcpkg() { srcpkg() {
@ -1017,15 +1011,28 @@ while getopts "dfhi:kinp:P:qrRs:u" opt; do
done done
shift $(( $OPTIND - 1 )) shift $(( $OPTIND - 1 ))
# find startdir
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
APKBUILD=$(readlink -f "$APKBUILD")
startdir="${APKBUILD%/*}"
srcdir=${srcdir:-"$startdir/src"}
pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
pkgrel=0
repo=${startdir%/*}
repo=${repo##*/}
SRCDEST=${SRCDEST:-$startdir}
PKGDEST=${PKGDEST:-$startdir}
cd "$startdir" || die
. "$APKBUILD"
# If REPODEST is set then it will override the PKGDEST # If REPODEST is set then it will override the PKGDEST
if [ -n "$REPODEST" ]; then if [ -n "$REPODEST" ]; then
PKGDEST="$REPODEST/$repo" PKGDEST="$REPODEST/$repo"
fi fi
# source the buildfile
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
. "$APKBUILD"
# If we are handling a sub package then reset subpackages and install # If we are handling a sub package then reset subpackages and install
if [ -n "$subpkgname" ]; then if [ -n "$subpkgname" ]; then
origsubpackages="$subpackages" origsubpackages="$subpackages"