parlay

yet another gentoo overlay
git clone https://git.parazyd.org/parlay
Log | Files | Refs | README

go-1.12.1.ebuild (5950B)


      1 # Copyright 2019 Gentoo Authors
      2 # Distributed under the terms of the GNU General Public License v2
      3 
      4 EAPI=6
      5 
      6 export CBUILD=${CBUILD:-${CHOST}}
      7 export CTARGET=${CTARGET:-${CHOST}}
      8 
      9 MY_PV=${PV/_/}
     10 
     11 inherit toolchain-funcs
     12 
     13 DESCRIPTION="A concurrent garbage collected and typesafe programming language"
     14 HOMEPAGE="https://golang.org"
     15 
     16 LICENSE="BSD"
     17 SLOT="0/${PV}"
     18 IUSE="gccgo elibc_musl"
     19 
     20 BOOTSTRAP_DIST="https://dev.gentoo.org/~williamh/dist"
     21 BOOTSTRAP_VERSION="bootstrap-1.8"
     22 BOOTSTRAP_URI="
     23 amd64? ( ${BOOTSTRAP_DIST}/go-linux-amd64-${BOOTSTRAP_VERSION}.tbz )
     24 arm? ( ${BOOTSTRAP_DIST}/go-linux-arm-${BOOTSTRAP_VERSION}.tbz )
     25 arm64? ( ${BOOTSTRAP_DIST}/go-linux-arm64-${BOOTSTRAP_VERSION}.tbz )
     26 ppc64? (
     27 	${BOOTSTRAP_DIST}/go-linux-ppc64-${BOOTSTRAP_VERSION}.tbz
     28 	${BOOTSTRAP_DIST}/go-linux-ppc64le-${BOOTSTRAP_VERSION}.tbz
     29 )
     30 s390? ( ${BOOTSTRAP_DIST}/go-linux-s390x-${BOOTSTRAP_VERSION}.tbz )
     31 x86? ( ${BOOTSTRAP_DIST}/go-linux-386-${BOOTSTRAP_VERSION}.tbz )
     32 amd64-fbsd? ( ${BOOTSTRAP_DIST}/go-freebsd-amd64-${BOOTSTRAP_VERSION}.tbz )
     33 x86-fbsd? ( ${BOOTSTRAP_DIST}/go-freebsd-386-${BOOTSTRAP_VERSION}.tbz )
     34 x64-macos? ( ${BOOTSTRAP_DIST}/go-darwin-amd64-${BOOTSTRAP_VERSION}.tbz )
     35 x64-solaris? ( ${BOOTSTRAP_DIST}/go-solaris-amd64-${BOOTSTRAP_VERSION}.tbz )
     36 "
     37 
     38 BOOTSTRAP_DIST_MUSL="https://parazyd.org/pub/mirror/gentoo/distfiles"
     39 BOOTSTRAP_VERSION_MUSL="bootstrap-1.4.3"
     40 BOOTSTRAP_URI_MUSL="
     41 amd64? ( ${BOOTSTRAP_DIST_MUSL}/go-linux-amd64-${BOOTSTRAP_VERSION_MUSL}.tbz )
     42 "
     43 
     44 case ${PV}  in
     45 *9999*)
     46 	EGIT_REPO_URI="https://github.com/golang/go.git"
     47 	inherit git-r3
     48 	;;
     49 *)
     50 	SRC_URI="https://storage.googleapis.com/golang/go${MY_PV}.src.tar.gz "
     51 	S="${WORKDIR}"/go
     52 	case ${PV} in
     53 	*_beta*|*_rc*) ;;
     54 	*)
     55 		KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc64 ~s390 ~x86 ~amd64-fbsd ~x86-fbsd ~x64-macos ~x64-solaris"
     56 		# The upstream tests fail under portage but pass if the build is
     57 		# run according to their documentation [1].
     58 		# I am restricting the tests on released versions until this is
     59 		# solved.
     60 		# [1] https://golang.org/issues/18442
     61 		RESTRICT="test"
     62 		;;
     63 	esac
     64 esac
     65 SRC_URI+="
     66 	!gccgo? (
     67 		!elibc_musl? ( ${BOOTSTRAP_URI} )
     68 		elibc_musl? ( ${BOOTSTRAP_URI_MUSL} )
     69 	)
     70 "
     71 
     72 DEPEND="gccgo? ( >=sys-devel/gcc-5[go] )"
     73 RDEPEND="!<dev-go/go-tools-0_pre20150902"
     74 
     75 # These test data objects have writable/executable stacks.
     76 QA_EXECSTACK="
     77 	usr/lib/go/src/debug/elf/testdata/*.obj
     78 	usr/lib/go/src/go/internal/gccgoimporter/testdata/escapeinfo.gox
     79 	usr/lib/go/src/go/internal/gccgoimporter/testdata/unicode.gox
     80 	usr/lib/go/src/go/internal/gccgoimporter/testdata/time.gox
     81 	"
     82 
     83 # Do not complain about CFLAGS, etc, since Go doesn't use them.
     84 QA_FLAGS_IGNORED='.*'
     85 
     86 REQUIRES_EXCLUDE="/usr/lib/go/src/debug/elf/testdata/*"
     87 
     88 # The tools in /usr/lib/go should not cause the multilib-strict check to fail.
     89 QA_MULTILIB_PATHS="usr/lib/go/pkg/tool/.*/.*"
     90 
     91 # Do not strip this package. Stripping is unsupported upstream and may
     92 # fail.
     93 RESTRICT+=" strip"
     94 
     95 DOCS=(
     96 AUTHORS
     97 CONTRIBUTING.md
     98 CONTRIBUTORS
     99 PATENTS
    100 README.md
    101 )
    102 
    103 go_arch()
    104 {
    105 	# By chance most portage arch names match Go
    106 	local portage_arch=$(tc-arch $@)
    107 	case "${portage_arch}" in
    108 		x86)	echo 386;;
    109 		x64-*)	echo amd64;;
    110 		ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;;
    111 		s390) echo s390x ;;
    112 		*)		echo "${portage_arch}";;
    113 	esac
    114 }
    115 
    116 go_arm()
    117 {
    118 	case "${1:-${CHOST}}" in
    119 		armv5*)	echo 5;;
    120 		armv6*)	echo 6;;
    121 		armv7*)	echo 7;;
    122 		*)
    123 			die "unknown GOARM for ${1:-${CHOST}}"
    124 			;;
    125 	esac
    126 }
    127 
    128 go_os()
    129 {
    130 	case "${1:-${CHOST}}" in
    131 		*-linux*)	echo linux;;
    132 		*-darwin*)	echo darwin;;
    133 		*-freebsd*)	echo freebsd;;
    134 		*-netbsd*)	echo netbsd;;
    135 		*-openbsd*)	echo openbsd;;
    136 		*-solaris*)	echo solaris;;
    137 		*-cygwin*|*-interix*|*-winnt*)
    138 			echo windows
    139 			;;
    140 		*)
    141 			die "unknown GOOS for ${1:-${CHOST}}"
    142 			;;
    143 	esac
    144 }
    145 
    146 go_tuple()
    147 {
    148 	echo "$(go_os $@)_$(go_arch $@)"
    149 }
    150 
    151 go_cross_compile()
    152 {
    153 	[[ $(go_tuple ${CBUILD}) != $(go_tuple) ]]
    154 }
    155 
    156 pkg_pretend()
    157 {
    158 	# make.bash does not understand cross-compiling a cross-compiler
    159 	if [[ $(go_tuple) != $(go_tuple ${CTARGET}) ]]; then
    160 		die "CHOST CTARGET pair unsupported: CHOST=${CHOST} CTARGET=${CTARGET}"
    161 	fi
    162 }
    163 
    164 src_unpack()
    165 {
    166 	if [[ ${PV} = 9999 ]]; then
    167 		git-r3_src_unpack
    168 	fi
    169 	default
    170 }
    171 
    172 src_compile()
    173 {
    174 	export GOROOT_BOOTSTRAP="${WORKDIR}"/go-$(go_os)-$(go_arch)-bootstrap
    175 	if use gccgo; then
    176 		mkdir -p "${GOROOT_BOOTSTRAP}/bin" || die
    177 		local go_binary=$(gcc-config --get-bin-path)/go-$(gcc-major-version)
    178 		[[ -x ${go_binary} ]] || go_binary=$(
    179 			find "${EPREFIX}"/usr/${CHOST}/gcc-bin/*/go-$(gcc-major-version) |
    180 				sort -V | tail -n1)
    181 		[[ -x ${go_binary} ]] ||
    182 			die "go-$(gcc-major-version): command not found"
    183 		ln -s "${go_binary}" "${GOROOT_BOOTSTRAP}/bin/go" || die
    184 	fi
    185 	export GOROOT_FINAL="${EPREFIX}"/usr/lib/go
    186 	export GOROOT="$(pwd)"
    187 	export GOBIN="${GOROOT}/bin"
    188 
    189 	# Go's build script does not use BUILD/HOST/TARGET consistently. :(
    190 	export GOHOSTARCH=$(go_arch ${CBUILD})
    191 	export GOHOSTOS=$(go_os ${CBUILD})
    192 	export CC=$(tc-getBUILD_CC)
    193 
    194 	export GOARCH=$(go_arch)
    195 	export GOOS=$(go_os)
    196 	export CC_FOR_TARGET=$(tc-getCC)
    197 	export CXX_FOR_TARGET=$(tc-getCXX)
    198 	if [[ ${ARCH} == arm ]]; then
    199 		export GOARM=$(go_arm)
    200 	fi
    201 	einfo "GOROOT_BOOTSTRAP is ${GOROOT_BOOTSTRAP}"
    202 
    203 	cd src
    204 	CGO_ENABLED=1 ./make.bash || die "build failed"
    205 }
    206 
    207 src_test()
    208 {
    209 	go_cross_compile && return 0
    210 
    211 	cd src
    212 	PATH="${GOBIN}:${PATH}" \
    213 	./run.bash -no-rebuild || die "tests failed"
    214 }
    215 
    216 src_install()
    217 {
    218 	local bin_path f x
    219 
    220 	dodir /usr/lib/go
    221 
    222 	# There is a known issue which requires the source tree to be installed [1].
    223 	# Once this is fixed, we can consider using the doc use flag to control
    224 	# installing the doc and src directories.
    225 	# [1] https://golang.org/issue/2775
    226 	#
    227 	# deliberately use cp to retain permissions
    228 	cp -R api bin doc lib pkg misc src test "${ED}"/usr/lib/go
    229 	if go_cross_compile; then
    230 		bin_path="bin/$(go_tuple)"
    231 	else
    232 		bin_path=bin
    233 	fi
    234 	for x in ${bin_path}/*; do
    235 		f=${x##*/}
    236 		dosym ../lib/go/${bin_path}/${f} /usr/bin/${f}
    237 	done
    238 	einstalldocs
    239 }