dev-lang/go: add system-bootstrap use flag
authorWilliam Hubbs <williamh@gentoo.org>
Mon, 29 Apr 2019 16:24:04 +0000 (11:24 -0500)
committerWilliam Hubbs <williamh@gentoo.org>
Mon, 29 Apr 2019 16:30:30 +0000 (11:30 -0500)
If a previous version of dev-lang/go is installed, you can use this use
flag to skip downloading the bootstrap archives and bootstrap the new
version using the already-installed version.

For the initial installation of dev-lang/go, we have to download all of
the bootstrap archives to make the go ebuild work under crossdev. For
this reason, system-bootstrap cannot be turned on by default.

Bug: https://bugs.gentoo.org/671394
closes: https://bugs.gentoo.org/684652
Copyright: Sony Interactive Entertainment Inc.
Package-Manager: Portage-2.3.62, Repoman-2.3.12
Signed-off-by: William Hubbs <williamh@gentoo.org>
dev-lang/go/go-1.11.9.ebuild
dev-lang/go/go-1.12.4.ebuild
dev-lang/go/metadata.xml

index 8fafeb455ba24bc531e1e27f586f824220546b95..a53df7c09567a04977bb3140c1f37b2ca95424ed 100644 (file)
@@ -48,20 +48,20 @@ case ${PV}  in
        esac
 esac
 
-# If gccgo is not being used to build Go, there is no way to know the
-# architecture or operating system of the build machine, so we need to
-# download all of our bootstrap archives to allow this ebuild to work
-# under crossdev.
+# If gccgo or a previously installed version of dev-lang/go is not being
+# used to build Go, there is no way to know the architecture or operating system
+# of the build machine, so we need to download all of our bootstrap
+# archives to allow this ebuild to work under crossdev.
 #
 # https://bugs.gentoo.org/671394
-SRC_URI+="!gccgo? ( ${BOOTSTRAP_URI} )"
+SRC_URI+="!gccgo? ( !system-bootstrap? ( ${BOOTSTRAP_URI} ) )"
 
 DESCRIPTION="A concurrent garbage collected and typesafe programming language"
 HOMEPAGE="https://golang.org"
 
 LICENSE="BSD"
 SLOT="0/${PV}"
-IUSE="gccgo"
+IUSE="gccgo system-bootstrap"
 
 BDEPEND="gccgo? ( >=sys-devel/gcc-5[go] )"
 RDEPEND="!<dev-go/go-tools-0_pre20150902"
@@ -151,6 +151,9 @@ pkg_pretend()
        if [[ $(go_tuple) != $(go_tuple ${CTARGET}) ]]; then
                die "CHOST CTARGET pair unsupported: CHOST=${CHOST} CTARGET=${CTARGET}"
        fi
+       [[ ${MERGE_TYPE} != binary ]] &&
+               use system-bootstrap && ! has_version "dev-lang/go" &&
+               die "dev-lang/go must be installed to use the system-bootstrap use flag"
 }
 
 src_unpack()
@@ -160,7 +163,7 @@ src_unpack()
        else
                unpack "go${MY_PV}.src.tar.gz"
        fi
-       use gccgo ||
+       use gccgo || use system-bootstrap ||
                unpack "go-$(go_os ${CBUILD})-$(go_arch ${CBUILD})-${BOOTSTRAP_VERSION}.tbz"
 }
 
@@ -176,6 +179,8 @@ src_compile()
                [[ -x ${go_binary} ]] ||
                        die "go-$(gcc-major-version): command not found"
                ln -s "${go_binary}" "${GOROOT_BOOTSTRAP}/bin/go" || die
+       elif use system-bootstrap; then
+               export GOROOT_BOOTSTRAP="${EPREFIX}"/usr/lib/go
        fi
        export GOROOT_FINAL="${EPREFIX}"/usr/lib/go
        export GOROOT="$(pwd)"
index 8fafeb455ba24bc531e1e27f586f824220546b95..a53df7c09567a04977bb3140c1f37b2ca95424ed 100644 (file)
@@ -48,20 +48,20 @@ case ${PV}  in
        esac
 esac
 
-# If gccgo is not being used to build Go, there is no way to know the
-# architecture or operating system of the build machine, so we need to
-# download all of our bootstrap archives to allow this ebuild to work
-# under crossdev.
+# If gccgo or a previously installed version of dev-lang/go is not being
+# used to build Go, there is no way to know the architecture or operating system
+# of the build machine, so we need to download all of our bootstrap
+# archives to allow this ebuild to work under crossdev.
 #
 # https://bugs.gentoo.org/671394
-SRC_URI+="!gccgo? ( ${BOOTSTRAP_URI} )"
+SRC_URI+="!gccgo? ( !system-bootstrap? ( ${BOOTSTRAP_URI} ) )"
 
 DESCRIPTION="A concurrent garbage collected and typesafe programming language"
 HOMEPAGE="https://golang.org"
 
 LICENSE="BSD"
 SLOT="0/${PV}"
-IUSE="gccgo"
+IUSE="gccgo system-bootstrap"
 
 BDEPEND="gccgo? ( >=sys-devel/gcc-5[go] )"
 RDEPEND="!<dev-go/go-tools-0_pre20150902"
@@ -151,6 +151,9 @@ pkg_pretend()
        if [[ $(go_tuple) != $(go_tuple ${CTARGET}) ]]; then
                die "CHOST CTARGET pair unsupported: CHOST=${CHOST} CTARGET=${CTARGET}"
        fi
+       [[ ${MERGE_TYPE} != binary ]] &&
+               use system-bootstrap && ! has_version "dev-lang/go" &&
+               die "dev-lang/go must be installed to use the system-bootstrap use flag"
 }
 
 src_unpack()
@@ -160,7 +163,7 @@ src_unpack()
        else
                unpack "go${MY_PV}.src.tar.gz"
        fi
-       use gccgo ||
+       use gccgo || use system-bootstrap ||
                unpack "go-$(go_os ${CBUILD})-$(go_arch ${CBUILD})-${BOOTSTRAP_VERSION}.tbz"
 }
 
@@ -176,6 +179,8 @@ src_compile()
                [[ -x ${go_binary} ]] ||
                        die "go-$(gcc-major-version): command not found"
                ln -s "${go_binary}" "${GOROOT_BOOTSTRAP}/bin/go" || die
+       elif use system-bootstrap; then
+               export GOROOT_BOOTSTRAP="${EPREFIX}"/usr/lib/go
        fi
        export GOROOT_FINAL="${EPREFIX}"/usr/lib/go
        export GOROOT="$(pwd)"
index f981de1f10bc833094c54b52469840ab7f3ed96d..8d9af604ec98e19fd6b4064d640e886c3e9cb91d 100644 (file)
                channels and a clean syntax.  
        </longdescription>
        <use>
-               <flag name="gccgo">Enable bootstrapping using gccgo</flag>
+               <flag name="gccgo">
+                       Bootstrap using <pkg>sys-devel/gcc</pkg>[go]
+               </flag>
+               <flag name="system-bootstrap">
+                       Bootstrap using previously installed <pkg>dev-lang/go</pkg>
+               </flag>
        </use>
 </pkgmetadata>