aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--community/go/APKBUILD36
-rwxr-xr-xscripts/bootstrap.sh6
2 files changed, 35 insertions, 7 deletions
diff --git a/community/go/APKBUILD b/community/go/APKBUILD
index 5de082af39..afdaa0cbc5 100644
--- a/community/go/APKBUILD
+++ b/community/go/APKBUILD
@@ -15,24 +15,37 @@ makedepends="bash go-bootstrap"
options="!strip"
provides="go-bootstrap=$pkgver-r$pkgrel"
install=""
-subpackages="$pkgname-doc $pkgname-tools"
+subpackages="$pkgname-doc"
source="http://golang.org/dl/go${pkgver/_/}.src.tar.gz
- $pkgname-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
+ go-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
default-buildmode-pie.patch
"
# NOTE: building go for x86 with grsec kernel requires:
# sysctl -w kernel.modify_ldt=1
-_gotools="cover godoc stringer"
-_tooldir="$srcdir"/tools-${_toolsver}
+if [ "$CBUILD" = "$CTARGET" ]; then
+ makedepends="go-bootstrap $makedepends"
+ provides="go-bootstrap=$pkgver-r$pkgrel"
+ subpackages="$subpackages $pkgname-tools"
+ _gotools="cover godoc stringer"
+ _gocross="darwin freebsd openbsd windows"
+else
+ pkgname="go-bootstrap"
+ makedepends="go $makedepends"
+ # Go expect host linker instead of the cross-compiler
+ export CC_FOR_TARGET="$CC"
+ export CC="${HOSTLD:-gcc}"
+ export CXX="${HOSTLD:-g++}"
+ export LD="${HOSTLD:-ld}"
+fi
-_gocross="darwin freebsd openbsd windows"
+_tooldir="$srcdir"/tools-${_toolsver}
for os in $_gocross; do
subpackages="$subpackages $pkgname-cross-${os}:_crosspkg"
done
-builddir="$srcdir"/$pkgname
+builddir="$srcdir"/go
build() {
cd "$builddir/src"
@@ -46,6 +59,7 @@ build() {
*) die "Unsupported arch" ;;
esac
+ export GOOS="linux"
export GOPATH="$srcdir"
export GOROOT="$builddir"
export GOBIN="$GOROOT"/bin
@@ -64,6 +78,16 @@ build() {
done
done
+ # copied from bootstrap.bash to fixup cross-built bootstrap go
+ if [ "$CBUILD" != "$CTARGET" ]; then
+ local gohostos="$(../bin/go env GOHOSTOS)"
+ local gohostarch="$(../bin/go env GOHOSTARCH)"
+ mv ../bin/*_*/* ../bin
+ rmdir ../bin/*_*
+ rm -rf "../pkg/${gohostos}_${gohostarch}"* "../pkg/tool/${gohostos}_${gohostarch}"*
+ rm -rf ../pkg/bootstrap ../pkg/obj
+ fi
+
# FIXME some tests fail:
# PATH="$GOROOT/bin:$PATH" ./run.bash -no-rebuild || return 1
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh
index a9fd7547b9..de2cf7e4ed 100755
--- a/scripts/bootstrap.sh
+++ b/scripts/bootstrap.sh
@@ -20,7 +20,10 @@ CBUILDROOT="$(CTARGET=$TARGET_ARCH . /usr/share/abuild/functions.sh ; echo $CBUI
[ -e "$APORTS/main/build-base" ] || die "Unable to deduce aports base checkout"
apkbuildname() {
- echo $APORTS/main/$1/APKBUILD
+ local repo="${1%%/*}"
+ local pkg="${1##*/}"
+ [ "$repo" = "$1" ] && repo="main"
+ echo $APORTS/$repo/$pkg/APKBUILD
}
msg() {
@@ -100,6 +103,7 @@ for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \
attr libcap patch sudo acl fakeroot tar \
pax-utils abuild openssh \
ncurses util-linux lvm2 popt xz cryptsetup kmod lddtree mkinitfs \
+ community/go \
$KERNEL_PKG ; do
CHOST=$TARGET_ARCH BOOTSTRAP=bootimage APKBUILD=$(apkbuildname $PKG) abuild -r