* [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds @ 2015-06-04 19:10 William Hubbs 2015-06-04 19:27 ` Andrew Udvare 2015-06-05 4:54 ` Mike Frysinger 0 siblings, 2 replies; 16+ messages in thread From: William Hubbs @ 2015-06-04 19:10 UTC (permalink / raw To: gentoo development [-- Attachment #1.1: Type: text/plain, Size: 280 bytes --] All, we are starting to get more go packages in the tree, so we need an eclass that properly deals with go live ebuilds. Attached you will find my proposal for this eclass. I will commit it on 6 Jun UTC if there is no feedback, so let me know what you think. Thanks, William [-- Attachment #1.2: go-live.eclass --] [-- Type: text/plain, Size: 3259 bytes --] # Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: go-live.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> # @BLURB: Eclass for fetching and unpacking go repositories. # @DESCRIPTION: # This eclass is written to ease the maintenance of live ebuilds # of software written in the Go programming language. case "${EAPI:-0}" in 5) ;; *) die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})" ;; esac EXPORT_FUNCTIONS src_unpack if [[ ! ${_GO_LIVE} ]]; then _GO_LIVE=1 DEPEND=">=dev-lang/go-1.4.2" # @ECLASS-VARIABLE: EGO_PN # @REQUIRED # @DESCRIPTION: # This is the import path for the go package. Please emerge dev-lang/go # and read "go help importpath" for syntax. # # Example: # @CODE # EGO_PN="github.com/user/project" # @CODE # @ECLASS-VARIABLE: EGO_STORE_DIR # @DESCRIPTION: # Storage directory for Go sources. # # This is intended to be set by the user in make.conf. Ebuilds must not set # it. # # EGO_STORE_DIR=${DISTDIR}/go-src # @ECLASS-VARIABLE: EVCS_OFFLINE # @DEFAULT_UNSET # @DESCRIPTION: # If non-empty, this variable prevents any online operations. # @ECLASS-VARIABLE: EVCS_UMASK # @DEFAULT_UNSET # @DESCRIPTION: # Set this variable to a custom umask. This is intended to be set by # users. By setting this to something like 002, it can make life easier # for people who do development as non-root (but are in the portage # group) and use FEATURES=userpriv. # @FUNCTION: _go-live_env_setup # @INTERNAL # @DESCRIPTION: # Create EGO_STORE_DIR if necessary and set GOPATH. _go-live_env_setup() { debug-print-function ${FUNCNAME} "$@" local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}} : ${EGO_STORE_DIR:=${distdir}/go-src} local saved_umask if [[ ${EVCS_UMASK} ]]; then saved_umask=$(umask) umask "${EVCS_UMASK}" || die "${ECLASS}: bad options to umask: ${EVCS_UMASK}" fi if [[ ! -d ${EGO_STORE_DIR} ]]; then ( addwrite / mkdir -p "${EGO_STORE_DIR}" || die ) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}" fi addwrite "${EGO_STORE_DIR}" export GOPATH="${EGO_STORE_DIR}" if [[ ${saved_umask} ]]; then umask "${saved_umask}" || die "${ECLASS}: unable to restore saved umask" fi mkdir -p "${S}" || die "${ECLASS}: unable to create ${S}" } # @FUNCTION: _go-live_fetch # @INTERNAL # @DESCRIPTION: # Retrieve the EGO_PN go package along with its dependencies. _go-live_fetch() { debug-print-function ${FUNCNAME} "$@" [[ ${EGO_PN} ]] || die "${ECLASS}: EGO_PN is not set" if [[ ${EVCS_OFFLINE} ]]; then export GOPATH="${S}:${GOPATH}" return fi local saved_umask if [[ ${EVCS_UMASK} ]]; then saved_umask=$(umask) umask "${EVCS_UMASK}" || die "${ECLASS}: Bad options to umask: ${EVCS_UMASK}" fi go get -d -t -u -v -x "$EGO_PN" [[ ! -d "${EGO_STORE_DIR}/src/${EGO_PN}" ]] && die "${ECLASS}: unable to retrieve ${EGO_PN} or a dependency" if [[ ${saved_umask} ]]; then umask "${saved_umask}" || die "${ECLASS}: unable to restore saved umask" fi export GOPATH="${S}:${GOPATH}" } go-live_src_fetch() { debug-print-function ${FUNCNAME} "$@" _go-live_env_setup _go-live_fetch } go-live_src_unpack() { debug-print-function ${FUNCNAME} "$@" go-live_src_fetch } fi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-04 19:10 [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds William Hubbs @ 2015-06-04 19:27 ` Andrew Udvare 2015-06-04 19:45 ` William Hubbs 2015-06-05 4:54 ` Mike Frysinger 1 sibling, 1 reply; 16+ messages in thread From: Andrew Udvare @ 2015-06-04 19:27 UTC (permalink / raw To: gentoo-dev > On 2015-06-04, at 12:10, William Hubbs <williamh@gentoo.org> wrote: > > All, > > we are starting to get more go packages in the tree, so we need an > eclass that properly deals with go live ebuilds. Why live only? Your eclass does what every other live and non-live ebuild does for Go: create a temporary Go environment without the package in question. This is fine (I hate how Go is designed in this respect). I just think non-live Go packages definitely need an eclass. Andrew ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-04 19:27 ` Andrew Udvare @ 2015-06-04 19:45 ` William Hubbs 0 siblings, 0 replies; 16+ messages in thread From: William Hubbs @ 2015-06-04 19:45 UTC (permalink / raw To: gentoo-dev [-- Attachment #1: Type: text/plain, Size: 1107 bytes --] On Thu, Jun 04, 2015 at 12:27:39PM -0700, Andrew Udvare wrote: > > > On 2015-06-04, at 12:10, William Hubbs <williamh@gentoo.org> wrote: > > > > All, > > > > we are starting to get more go packages in the tree, so we need an > > eclass that properly deals with go live ebuilds. > > Why live only? > > Your eclass does what every other live and non-live ebuild does for Go: create a temporary Go environment without the package in question. This is fine (I hate how Go is designed in this respect). I just think non-live Go packages definitely need an eclass. The function of this eclass is to take the place of the git-* eclass in the go live ebuilds. You can't rely on git being the vcs upstream uses, and there is no way to tell what the vcs or the vcs URL is reliably from the name of a package, so it is best to use "go get" to grab the source. Please look at "go help importpath" for more details about this. I will start another discussion about non-live ebuilds once this eclass is in the tree, because I do think I see an issue with how they are being done. William [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-04 19:10 [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds William Hubbs 2015-06-04 19:27 ` Andrew Udvare @ 2015-06-05 4:54 ` Mike Frysinger 2015-06-05 14:34 ` William Hubbs 1 sibling, 1 reply; 16+ messages in thread From: Mike Frysinger @ 2015-06-05 4:54 UTC (permalink / raw To: gentoo development [-- Attachment #1: Type: text/plain, Size: 3057 bytes --] On 04 Jun 2015 14:10, William Hubbs wrote: > # @ECLASS: go-live.eclass since we're going to have a common go eclass, and i don't think we'll want to call it "go.eclass", this too probably should not be go-xxx. if we assume the base one will be "golang.eclass", then this should be golang-xxx.eclass. i'd prefer golang-vcs.eclass myself as that's the naming we've been moving towards. > # @MAINTAINER: > # William Hubbs <williamh@gentoo.org> > # @BLURB: Eclass for fetching and unpacking go repositories. > # @DESCRIPTION: > # This eclass is written to ease the maintenance of live ebuilds > # of software written in the Go programming language. this should note the ebuild is responsible for depending on the right vcs packages. e.g. if you use git, then you need to depend on git. although ... > # @ECLASS-VARIABLE: EGO_PN > # @REQUIRED > # @DESCRIPTION: > # This is the import path for the go package. Please emerge dev-lang/go > # and read "go help importpath" for syntax. > # > # Example: > # @CODE > # EGO_PN="github.com/user/project" > # @CODE can't we automate some of the common hosts ? if it says github, we know it's going to be using at least git. > local saved_umask > if [[ ${EVCS_UMASK} ]]; then > saved_umask=$(umask) > umask "${EVCS_UMASK}" || > die "${ECLASS}: bad options to umask: ${EVCS_UMASK}" > fi use `eumask_push` instead on a related note, i don't think we should encourage the implicit -n operator. it adds no overhead and really no code maintenance to specify it. conversely, i'm not sure it can be considered common usage. and even if it is, i still don't see a good reason to not just use the explicit -n as it's clear to the reader what it's doing. > if [[ ! -d ${EGO_STORE_DIR} ]]; then > ( > addwrite / > mkdir -p "${EGO_STORE_DIR}" || die > ) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}" > fi the inner die is redundant > if [[ ${saved_umask} ]]; then > umask "${saved_umask}" || > die "${ECLASS}: unable to restore saved umask" > fi use `eumask_pop` instead > [[ ${EGO_PN} ]] || > die "${ECLASS}: EGO_PN is not set" prefer -z && myself [[ -z ${EGO_PN} ]] && die ... > if [[ ${EVCS_OFFLINE} ]]; then > export GOPATH="${S}:${GOPATH}" what if GOPATH isn't set ? should this always be appending a colon ? > local saved_umask > if [[ ${EVCS_UMASK} ]]; then > saved_umask=$(umask) > umask "${EVCS_UMASK}" || > die "${ECLASS}: Bad options to umask: ${EVCS_UMASK}" > fi use `eumask_push` instead > go get -d -t -u -v -x "$EGO_PN" needs braces around ${EGO_PN}, and shouldn't this be calling `die` ? would also be useful to show the command you're running: set -- go get -d -t -u -v -x "${EGO_PN}" echo "$@" "$@" || die > if [[ ${saved_umask} ]]; then > umask "${saved_umask}" || > die "${ECLASS}: unable to restore saved umask" > fi use `eumask_pop` instead > export GOPATH="${S}:${GOPATH}" same questions here -mike [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-05 4:54 ` Mike Frysinger @ 2015-06-05 14:34 ` William Hubbs 2015-06-05 19:12 ` William Hubbs 2015-06-06 1:22 ` [gentoo-dev] " Mike Frysinger 0 siblings, 2 replies; 16+ messages in thread From: William Hubbs @ 2015-06-05 14:34 UTC (permalink / raw To: gentoo-dev [-- Attachment #1.1: Type: text/plain, Size: 3248 bytes --] On Fri, Jun 05, 2015 at 12:54:45AM -0400, Mike Frysinger wrote: > On 04 Jun 2015 14:10, William Hubbs wrote: > > # @ECLASS: go-live.eclass > > since we're going to have a common go eclass, and i don't think we'll want to > call it "go.eclass", this too probably should not be go-xxx. if we assume the > base one will be "golang.eclass", then this should be golang-xxx.eclass. i'd > prefer golang-vcs.eclass myself as that's the naming we've been moving towards. I'm not convinced yet that we are going to have a base eclass for all go ebuilds, but I can rename this one easily enough to golang-vcs.eclass. > > # @MAINTAINER: > > # William Hubbs <williamh@gentoo.org> > > # @BLURB: Eclass for fetching and unpacking go repositories. > > # @DESCRIPTION: > > # This eclass is written to ease the maintenance of live ebuilds > > # of software written in the Go programming language. > > this should note the ebuild is responsible for depending on the right vcs > packages. e.g. if you use git, then you need to depend on git. Since "go get" fetches $EGO_PN and its dependencies, there is no way an ebuild author could get this right without reading all of the import statements in the source for their package and all of its dependencies. I don't really want to ask ebuild authors to keep up with all of that. > although ... > > > # @ECLASS-VARIABLE: EGO_PN > > # @REQUIRED > > # @DESCRIPTION: > > # This is the import path for the go package. Please emerge dev-lang/go > > # and read "go help importpath" for syntax. > > # > > # Example: > > # @CODE > > # EGO_PN="github.com/user/project" > > # @CODE > > can't we automate some of the common hosts ? if it says github, we know it's > going to be using at least git. I'm seeing two options. I can either let users emerge the vcs's they need if something breaks or pull in all vcs's go supports. Which way is best? ... > > if [[ ${EVCS_OFFLINE} ]]; then > > export GOPATH="${S}:${GOPATH}" > > what if GOPATH isn't set ? should this always be appending a colon ? I thought it would always be set at this point because it was initially set to ${EGO_STORE_DIR} in the env_setup function. What I can do, if it makes things more clear, is to replace the value of GOPATH instead of prepending it. ... > > go get -d -t -u -v -x "$EGO_PN" > > needs braces around ${EGO_PN}, and shouldn't this be calling `die` ? > > would also be useful to show the command you're running: > set -- go get -d -t -u -v -x "${EGO_PN}" > echo "$@" > "$@" || die You are correct; we should be calling die here. However, I suspect an upstream bug because the following returns an error: $ cd /home/william/go $ export GOPATH=/home/william/go $ go get -d -t -u -v -x golang.org/x/tools go downloads everything, then errors out with a message about "no buildable source files in /home/william/go/src/golang.org/x/tools" This isn't an error because you build the tools from the subdirectories of the project. ... > > export GOPATH="${S}:${GOPATH}" > > same questions here See my comment above about GOPATH; the same thing applies here. The eclass with your changes is attached. William [-- Attachment #1.2: golang-vcs.eclass --] [-- Type: text/plain, Size: 2981 bytes --] # Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: golang-vcs.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> # @BLURB: Eclass for fetching and unpacking go repositories. # @DESCRIPTION: # This eclass is written to ease the maintenance of live ebuilds # of software written in the Go programming language. inherit eutils case "${EAPI:-0}" in 5) ;; *) die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})" ;; esac EXPORT_FUNCTIONS src_unpack if [[ -z ${_GOLANG_VCS} ]]; then _GO_LIVE=1 DEPEND=">=dev-lang/go-1.4.2" # @ECLASS-VARIABLE: EGO_PN # @REQUIRED # @DESCRIPTION: # This is the import path for the go package. Please emerge dev-lang/go # and read "go help importpath" for syntax. # # Example: # @CODE # EGO_PN="github.com/user/project" # @CODE # @ECLASS-VARIABLE: EGO_STORE_DIR # @DESCRIPTION: # Storage directory for Go sources. # # This is intended to be set by the user in make.conf. Ebuilds must not set # it. # # EGO_STORE_DIR=${DISTDIR}/go-src # @ECLASS-VARIABLE: EVCS_OFFLINE # @DEFAULT_UNSET # @DESCRIPTION: # If non-empty, this variable prevents any online operations. # @ECLASS-VARIABLE: EVCS_UMASK # @DEFAULT_UNSET # @DESCRIPTION: # Set this variable to a custom umask. This is intended to be set by # users. By setting this to something like 002, it can make life easier # for people who do development as non-root (but are in the portage # group) and use FEATURES=userpriv. # @FUNCTION: _golang-vcs_env_setup # @INTERNAL # @DESCRIPTION: # Create EGO_STORE_DIR if necessary and set GOPATH. _golang-vcs_env_setup() { debug-print-function ${FUNCNAME} "$@" local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}} : ${EGO_STORE_DIR:=${distdir}/go-src} [[ -n ${EVCS_UMASK} ]] && umask_push $EVCS_UMASK if [[ ! -d ${EGO_STORE_DIR} ]]; then ( addwrite / mkdir -p "${EGO_STORE_DIR}" ) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}" fi addwrite "${EGO_STORE_DIR}" export GOPATH="${EGO_STORE_DIR}" [[ -n ${EVCS_UMASK} ]] && umask_pop mkdir -p "${S}" || die "${ECLASS}: unable to create ${S}" } # @FUNCTION: _golang-vcs_fetch # @INTERNAL # @DESCRIPTION: # Retrieve the EGO_PN go package along with its dependencies. _golang-vcs_fetch() { debug-print-function ${FUNCNAME} "$@" [[ -z ${EGO_PN} ]] && die "${ECLASS}: EGO_PN is not set" if [[ -n ${EVCS_OFFLINE} ]]; then export GOPATH="${S}:${EGO_STORE_DIR}" return fi [[ -n ${EVCS_UMASK} ]] && umask_push ${EVCS_UMASK} set -- go get -d -t -u -v -x "${EGO_PN}" echo "$@" "$@" [[ ! -d "${EGO_STORE_DIR}/src/${EGO_PN}" ]] && die "${ECLASS}: unable to retrieve ${EGO_PN} or a dependency" [[ -n ${EVCS_UMASK} ]] && umask_pop export GOPATH="${S}:${EGO_STORE_DIR}" } golang-vcs_src_fetch() { debug-print-function ${FUNCNAME} "$@" _golang-vcs_env_setup _golang-vcs_fetch } golang-vcs_src_unpack() { debug-print-function ${FUNCNAME} "$@" golang-vcs_src_fetch } fi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-05 14:34 ` William Hubbs @ 2015-06-05 19:12 ` William Hubbs 2015-06-06 6:44 ` [gentoo-dev] " Duncan 2015-06-06 1:22 ` [gentoo-dev] " Mike Frysinger 1 sibling, 1 reply; 16+ messages in thread From: William Hubbs @ 2015-06-05 19:12 UTC (permalink / raw To: gentoo-dev [-- Attachment #1: Type: text/plain, Size: 1882 bytes --] On Fri, Jun 05, 2015 at 09:34:42AM -0500, William Hubbs wrote: > On Fri, Jun 05, 2015 at 12:54:45AM -0400, Mike Frysinger wrote: > > On 04 Jun 2015 14:10, William Hubbs wrote: > > > # @MAINTAINER: > > > # William Hubbs <williamh@gentoo.org> > > > # @BLURB: Eclass for fetching and unpacking go repositories. > > > # @DESCRIPTION: > > > # This eclass is written to ease the maintenance of live ebuilds > > > # of software written in the Go programming language. > > > > this should note the ebuild is responsible for depending on the right vcs > > packages. e.g. if you use git, then you need to depend on git. > > Since "go get" fetches $EGO_PN and its dependencies, there is no way an > ebuild author could get this right without reading all of the import > statements in the source for their package and all of its dependencies. > I don't really want to ask ebuild authors to keep up with all of that. > > > although ... > > > > > # @ECLASS-VARIABLE: EGO_PN > > > # @REQUIRED > > > # @DESCRIPTION: > > > # This is the import path for the go package. Please emerge dev-lang/go > > > # and read "go help importpath" for syntax. > > > # > > > # Example: > > > # @CODE > > > # EGO_PN="github.com/user/project" > > > # @CODE > > > > can't we automate some of the common hosts ? if it says github, we know it's > > going to be using at least git. > > I'm seeing two options. I can either let users emerge the vcs's they > need if something breaks or pull in all vcs's go supports. > > Which way is best? The more I think about this, I don't want to DEPEND on any vcs's and it is not reasonable to ask developers to do so in their go vcs ebuilds for the reason I stated above. Since these are live ebuilds, I think we can assume more about the users that use them and not require the vcs's as runtime dependencies. William [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* [gentoo-dev] Re: new eclass: go-live.eclass for handling go live ebuilds 2015-06-05 19:12 ` William Hubbs @ 2015-06-06 6:44 ` Duncan 0 siblings, 0 replies; 16+ messages in thread From: Duncan @ 2015-06-06 6:44 UTC (permalink / raw To: gentoo-dev William Hubbs posted on Fri, 05 Jun 2015 14:12:51 -0500 as excerpted: > On Fri, Jun 05, 2015 at 09:34:42AM -0500, William Hubbs wrote: >> On Fri, Jun 05, 2015 at 12:54:45AM -0400, Mike Frysinger wrote: >>> On 04 Jun 2015 14:10, William Hubbs wrote: >>>> # @DESCRIPTION: >>>> # This eclass is written to ease the maintenance of live ebuilds >>>> # of software written in the Go programming language. >>> >>> this should note the ebuild is responsible for depending on the right >>> vcs packages. e.g. if you use git, then you need to depend on git. >> >> Since "go get" fetches $EGO_PN and its dependencies, there is no way an >> ebuild author could get this right without reading all of the import >> statements in the source for their package and all of its dependencies. >> I don't really want to ask ebuild authors to keep up with all of that. >> I'm seeing two options. I can either let users emerge the vcs's they >> need if something breaks or pull in all vcs's go supports. >> >> Which way is best? > > The more I think about this, I don't want to DEPEND on any vcs's and it > is not reasonable to ask developers to do so in their go vcs ebuilds for > the reason I stated above. > > Since these are live ebuilds, I think we can assume more about the users > that use them and not require the vcs's as runtime dependencies. The way layman, for example, handles this is with USE flags for the various VCSs, and a post_inst message about what may not be supported due to missing VCSs. But that won't work here, as it'd add all sorts of unrelated VCS flags to anything inheriting the eclass. Maybe a USE_EXPAND variable? That should be a bit better as it'd at least group the flags and make it more obvious what they're for and that not all may apply to every package. Like many USE_EXPANDs, behavior could be default to them all if the USE_EXPAND isn't set, but the user can set it specifically to only what they know is needed, if they prefer. -- Duncan - List replies preferred. No HTML msgs. "Every nonfree program has a lord, a master -- and if you use the program, he is your master." Richard Stallman ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-05 14:34 ` William Hubbs 2015-06-05 19:12 ` William Hubbs @ 2015-06-06 1:22 ` Mike Frysinger 2015-06-08 19:38 ` William Hubbs 1 sibling, 1 reply; 16+ messages in thread From: Mike Frysinger @ 2015-06-06 1:22 UTC (permalink / raw To: gentoo-dev [-- Attachment #1: Type: text/plain, Size: 1914 bytes --] On 05 Jun 2015 09:34, William Hubbs wrote: > On Fri, Jun 05, 2015 at 12:54:45AM -0400, Mike Frysinger wrote: > > On 04 Jun 2015 14:10, William Hubbs wrote: > > > # @MAINTAINER: > > > # William Hubbs <williamh@gentoo.org> > > > # @BLURB: Eclass for fetching and unpacking go repositories. > > > # @DESCRIPTION: > > > # This eclass is written to ease the maintenance of live ebuilds > > > # of software written in the Go programming language. > > > > this should note the ebuild is responsible for depending on the right vcs > > packages. e.g. if you use git, then you need to depend on git. > > Since "go get" fetches $EGO_PN and its dependencies, there is no way an > ebuild author could get this right without reading all of the import > statements in the source for their package and all of its dependencies. > I don't really want to ask ebuild authors to keep up with all of that. i'm aware. my point is that with some sites, you know they're going to be using *at least* one vcs. if they're pointing to github, that will be git. if the project ends up only pulling from git, then you've automatically made it work for them. if they need additional vcs's, then they can simply depend on it directly. we don't need to be perfect here, and if we can cover the majority of cases, i think it's worth the effort. > > > if [[ ${EVCS_OFFLINE} ]]; then > > > export GOPATH="${S}:${GOPATH}" > > > > what if GOPATH isn't set ? should this always be appending a colon ? > > I thought it would always be set at this point because it was initially > set to ${EGO_STORE_DIR} in the env_setup function. What I can do, if it > makes things more clear, is to replace the value of GOPATH instead of > prepending it. you're right, i forgot about that line. it should be fine. it'll clobber GOPATH that the user has, but we probably want that anyways right ? -mike [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-06 1:22 ` [gentoo-dev] " Mike Frysinger @ 2015-06-08 19:38 ` William Hubbs 2015-06-10 3:34 ` Dean Stephens 2015-06-10 15:53 ` Mike Frysinger 0 siblings, 2 replies; 16+ messages in thread From: William Hubbs @ 2015-06-08 19:38 UTC (permalink / raw To: gentoo-dev; +Cc: vapier [-- Attachment #1.1: Type: text/plain, Size: 144 bytes --] All, here is the latest version of this eclass, which I will commit an hour from now if no one has any objections. Thanks, William [-- Attachment #1.2: golang-vcs.eclass --] [-- Type: text/plain, Size: 3551 bytes --] # Copyright 2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: golang-vcs.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> # @BLURB: Eclass for fetching and unpacking go repositories. # @DESCRIPTION: # This eclass is written to ease the maintenance of live ebuilds # of software written in the Go programming language. inherit eutils case "${EAPI:-0}" in 5) ;; *) die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})" ;; esac EXPORT_FUNCTIONS src_unpack if [[ -z ${_GOLANG_VCS} ]]; then _GOLANG_VCS=1 # We depend on dev-vcs/git since it is the most used vcs for Go # packages. However we will not depend on all vcs's Go supports at the # eclass level. If your package, or one of its dependencies, uses # another vcs, please depend on it directly. DEPEND=">=dev-lang/go-1.4.2 dev-vcs/git" # @ECLASS-VARIABLE: EGO_PN # @REQUIRED # @DESCRIPTION: # This is the import path for the go package. Please emerge dev-lang/go # and read "go help importpath" for syntax. # # Example: # @CODE # EGO_PN="github.com/user/project" # @CODE # @ECLASS-VARIABLE: EGO_STORE_DIR # @DESCRIPTION: # Storage directory for Go sources. # # This is intended to be set by the user in make.conf. Ebuilds must not set # it. # # EGO_STORE_DIR=${DISTDIR}/go-src # @ECLASS-VARIABLE: EVCS_OFFLINE # @DEFAULT_UNSET # @DESCRIPTION: # If non-empty, this variable prevents any online operations. # @ECLASS-VARIABLE: EVCS_UMASK # @DEFAULT_UNSET # @DESCRIPTION: # Set this variable to a custom umask. This is intended to be set by # users. By setting this to something like 002, it can make life easier # for people who do development as non-root (but are in the portage # group) and use FEATURES=userpriv. # @FUNCTION: _golang-vcs_env_setup # @INTERNAL # @DESCRIPTION: # Create EGO_STORE_DIR if necessary and set GOPATH. _golang-vcs_env_setup() { debug-print-function ${FUNCNAME} "$@" local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}} : ${EGO_STORE_DIR:=${distdir}/go-src} [[ -n ${EVCS_UMASK} ]] && umask_push $EVCS_UMASK if [[ ! -d ${EGO_STORE_DIR} ]]; then ( addwrite / mkdir -p "${EGO_STORE_DIR}" ) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}" fi addwrite "${EGO_STORE_DIR}" export GOPATH="${EGO_STORE_DIR}" [[ -n ${EVCS_UMASK} ]] && umask_pop mkdir -p "${S}" || die "${ECLASS}: unable to create ${S}" } # @FUNCTION: _golang-vcs_fetch # @INTERNAL # @DESCRIPTION: # Retrieve the EGO_PN go package along with its dependencies. _golang-vcs_fetch() { debug-print-function ${FUNCNAME} "$@" [[ -z ${EGO_PN} ]] && die "${ECLASS}: EGO_PN is not set" if [[ -n ${EVCS_OFFLINE} ]]; then export GOPATH="${S}:${EGO_STORE_DIR}" return fi [[ -n ${EVCS_UMASK} ]] && umask_push ${EVCS_UMASK} set -- go get -d -t -u -v -x "${EGO_PN}" echo "$@" "$@" # I can't call die here, depending on the outcome of the following # upstream issue. # https://github.com/golang/go/issues/11090 # Hopefully this will be fixed so that "go get -d" is successful if # everything is downloaded. In that case, I can call die. # That would also remove the test below this line. [[ ! -d "${EGO_STORE_DIR}/src/${EGO_PN}" ]] && die "${ECLASS}: unable to retrieve ${EGO_PN} or a dependency" [[ -n ${EVCS_UMASK} ]] && umask_pop export GOPATH="${S}:${EGO_STORE_DIR}" } golang-vcs_src_fetch() { debug-print-function ${FUNCNAME} "$@" _golang-vcs_env_setup _golang-vcs_fetch } golang-vcs_src_unpack() { debug-print-function ${FUNCNAME} "$@" golang-vcs_src_fetch } fi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-08 19:38 ` William Hubbs @ 2015-06-10 3:34 ` Dean Stephens 2015-06-10 15:08 ` William Hubbs 2015-06-10 15:53 ` Mike Frysinger 1 sibling, 1 reply; 16+ messages in thread From: Dean Stephens @ 2015-06-10 3:34 UTC (permalink / raw To: gentoo-dev On 06/08/15 15:38, William Hubbs wrote: > All, > > here is the latest version of this eclass, which I will commit an > hour from now if no one has any objections. > > Thanks, > > William > Not an objection to the eclass as posted, but to the one hour timeout for feedback on a mailing list. While I realize that feedback had already been given and acted upon, bare minimum feedback windows for global mailing lists start at not less than 12 hours and are preferably at least twice that long. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-10 3:34 ` Dean Stephens @ 2015-06-10 15:08 ` William Hubbs 2015-06-11 4:28 ` Dean Stephens 0 siblings, 1 reply; 16+ messages in thread From: William Hubbs @ 2015-06-10 15:08 UTC (permalink / raw To: gentoo-dev [-- Attachment #1: Type: text/plain, Size: 874 bytes --] On Tue, Jun 09, 2015 at 11:34:34PM -0400, Dean Stephens wrote: > On 06/08/15 15:38, William Hubbs wrote: > > All, > > > > here is the latest version of this eclass, which I will commit an > > hour from now if no one has any objections. > > > > Thanks, > > > > William > > > Not an objection to the eclass as posted, but to the one hour timeout > for feedback on a mailing list. While I realize that feedback had > already been given and acted upon, bare minimum feedback windows for > global mailing lists start at not less than 12 hours and are > preferably at least twice that long. This hasn't been committed yet, because I'm considering adding a command to copy the code from EGO_STORE_DIR to WORKDIR after it is downloaded. Is a one line change enough to justify another poasting, or should I just commit once that works? William [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-10 15:08 ` William Hubbs @ 2015-06-11 4:28 ` Dean Stephens 0 siblings, 0 replies; 16+ messages in thread From: Dean Stephens @ 2015-06-11 4:28 UTC (permalink / raw To: gentoo-dev On 06/10/15 11:08, William Hubbs wrote: > On Tue, Jun 09, 2015 at 11:34:34PM -0400, Dean Stephens wrote: >> On 06/08/15 15:38, William Hubbs wrote: >>> All, >>> >>> here is the latest version of this eclass, which I will commit >>> an hour from now if no one has any objections. >>> >>> Thanks, >>> >>> William >>> >> Not an objection to the eclass as posted, but to the one hour >> timeout for feedback on a mailing list. While I realize that >> feedback had already been given and acted upon, bare minimum >> feedback windows for global mailing lists start at not less than >> 12 hours and are preferably at least twice that long. > > This hasn't been committed yet, because I'm considering adding a > command to copy the code from EGO_STORE_DIR to WORKDIR after it is > downloaded. > > Is a one line change enough to justify another poasting, or should > I just commit once that works? > > William > The answer to that would seem to be prescribed by policy[1]. [1] https://devmanual.gentoo.org/eclass-writing/index.html ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-08 19:38 ` William Hubbs 2015-06-10 3:34 ` Dean Stephens @ 2015-06-10 15:53 ` Mike Frysinger 2015-06-10 17:32 ` William Hubbs 1 sibling, 1 reply; 16+ messages in thread From: Mike Frysinger @ 2015-06-10 15:53 UTC (permalink / raw To: gentoo-dev [-- Attachment #1: Type: text/plain, Size: 537 bytes --] On 08 Jun 2015 14:38, William Hubbs wrote: > # Copyright 2015 Gentoo Foundation normally we use the header from skel.ebuild everywhere > # We depend on dev-vcs/git since it is the most used vcs for Go > # packages. However we will not depend on all vcs's Go supports at the > # eclass level. If your package, or one of its dependencies, uses > # another vcs, please depend on it directly. > > DEPEND=">=dev-lang/go-1.4.2 > dev-vcs/git" that really isn't what i was suggesting nor does it seem to be justified ? -mike [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-10 15:53 ` Mike Frysinger @ 2015-06-10 17:32 ` William Hubbs 2015-06-11 15:27 ` William Hubbs 0 siblings, 1 reply; 16+ messages in thread From: William Hubbs @ 2015-06-10 17:32 UTC (permalink / raw To: gentoo-dev; +Cc: vapier [-- Attachment #1: Type: text/plain, Size: 1128 bytes --] On Wed, Jun 10, 2015 at 11:53:28AM -0400, Mike Frysinger wrote: > On 08 Jun 2015 14:38, William Hubbs wrote: > > # Copyright 2015 Gentoo Foundation > > normally we use the header from skel.ebuild everywhere Ok, I can fix that. > > > # We depend on dev-vcs/git since it is the most used vcs for Go > > # packages. However we will not depend on all vcs's Go supports at the > > # eclass level. If your package, or one of its dependencies, uses > > # another vcs, please depend on it directly. > > > > DEPEND=">=dev-lang/go-1.4.2 > > dev-vcs/git" > > that really isn't what i was suggesting nor does it seem to be justified ? Please clarify -- what are you suggesting then? The options as I see them are to either: 1. try to pick the most common vcs and depend on it. 2. depend on all vcs's go supports (git, mercurial, svn and bzr). 3. depend on no vcs's and leave it up to ebuild authors to pull them in if they choose, although they would have the same issue -- not knowing for sure which type of hosting their packages or any of their packages' dependencies use. Thanks, William [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-10 17:32 ` William Hubbs @ 2015-06-11 15:27 ` William Hubbs 2015-06-16 21:03 ` William Hubbs 0 siblings, 1 reply; 16+ messages in thread From: William Hubbs @ 2015-06-11 15:27 UTC (permalink / raw To: gentoo-dev; +Cc: vapier [-- Attachment #1.1: Type: text/plain, Size: 1542 bytes --] On Wed, Jun 10, 2015 at 12:32:54PM -0500, William Hubbs wrote: > On Wed, Jun 10, 2015 at 11:53:28AM -0400, Mike Frysinger wrote: > > On 08 Jun 2015 14:38, William Hubbs wrote: > > > # We depend on dev-vcs/git since it is the most used vcs for Go > > > # packages. However we will not depend on all vcs's Go supports at the > > > # eclass level. If your package, or one of its dependencies, uses > > > # another vcs, please depend on it directly. > > > > > > DEPEND=">=dev-lang/go-1.4.2 > > > dev-vcs/git" > > > > that really isn't what i was suggesting nor does it seem to be justified ? > > Please clarify -- what are you suggesting then? > > The options as I see them are to either: > > 1. try to pick the most common vcs and depend on it. > 2. depend on all vcs's go supports (git, mercurial, svn and bzr). > 3. depend on no vcs's and leave it up to ebuild authors to pull them in > if they choose, although they would have the same issue -- not knowing > for sure which type of hosting their packages or any of their packages' > dependencies use. I chose option 3, which is where I was to begin with, since we can't know for sure which vcs's are needed. Also, I looked more into "go get" and "go get -d" does not error out if you specify a package correctly, so I have changed the code to die and added documentation about this and the upstream issue where it is being discussed. The other change is to point out in the documentation that EGO_PN can list more than one go package. William [-- Attachment #1.2: golang-vcs.eclass --] [-- Type: text/plain, Size: 3325 bytes --] # Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: golang-vcs.eclass # @MAINTAINER: # William Hubbs <williamh@gentoo.org> # @BLURB: Eclass for fetching and unpacking go repositories. # @DESCRIPTION: # This eclass is written to ease the maintenance of live ebuilds # of software written in the Go programming language. inherit eutils case "${EAPI:-0}" in 5) ;; *) die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})" ;; esac EXPORT_FUNCTIONS src_unpack if [[ -z ${_GOLANG_VCS} ]]; then _GOLANG_VCS=1 DEPEND=">=dev-lang/go-1.4.2" # @ECLASS-VARIABLE: EGO_PN # @REQUIRED # @DESCRIPTION: # This is the import path for the go package(s). Please emerge dev-lang/go # and read "go help importpath" for syntax. # # Example: # @CODE # EGO_PN="github.com/user/package" # EGO_PN="github.com/user1/package1 github.com/user2/package2" # @CODE # @ECLASS-VARIABLE: EGO_STORE_DIR # @DESCRIPTION: # Storage directory for Go sources. # # This is intended to be set by the user in make.conf. Ebuilds must not set # it. # # EGO_STORE_DIR=${DISTDIR}/go-src # @ECLASS-VARIABLE: EVCS_OFFLINE # @DEFAULT_UNSET # @DESCRIPTION: # If non-empty, this variable prevents any online operations. # @ECLASS-VARIABLE: EVCS_UMASK # @DEFAULT_UNSET # @DESCRIPTION: # Set this variable to a custom umask. This is intended to be set by # users. By setting this to something like 002, it can make life easier # for people who do development as non-root (but are in the portage # group) and use FEATURES=userpriv. # @FUNCTION: _golang-vcs_env_setup # @INTERNAL # @DESCRIPTION: # Create EGO_STORE_DIR if necessary and set GOPATH. _golang-vcs_env_setup() { debug-print-function ${FUNCNAME} "$@" local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}} : ${EGO_STORE_DIR:=${distdir}/go-src} [[ -n ${EVCS_UMASK} ]] && umask_push $EVCS_UMASK if [[ ! -d ${EGO_STORE_DIR} ]]; then ( addwrite / mkdir -p "${EGO_STORE_DIR}" ) || die "${ECLASS}: unable to create ${EGO_STORE_DIR}" fi addwrite "${EGO_STORE_DIR}" export GOPATH="${EGO_STORE_DIR}" [[ -n ${EVCS_UMASK} ]] && umask_pop mkdir -p "${S}" || die "${ECLASS}: unable to create ${S}" return 0 } # @FUNCTION: _golang-vcs_fetch # @INTERNAL # @DESCRIPTION: # Retrieve the EGO_PN go package along with its dependencies. _golang-vcs_fetch() { debug-print-function ${FUNCNAME} "$@" [[ -z ${EGO_PN} ]] && die "${ECLASS}: EGO_PN is not set" if [[ -n ${EVCS_OFFLINE} ]]; then export GOPATH="${S}:${GOPATH}" return 0 fi [[ -n ${EVCS_UMASK} ]] && umask_push ${EVCS_UMASK} set -- go get -d -t -u -v -x "${EGO_PN}" echo "$@" "$@" || die # The above dies if you pass repositories in EGO_PN instead of # packages, e.g. golang.org/x/tools instead of golang.org/x/tools/cmd/vet. # This is being discussed in the following upstream issue: # https://github.com/golang/go/issues/11090 # I am hoping this will be fixed so "go get -d" is successful if # downloading the top level repository is successful. [[ -n ${EVCS_UMASK} ]] && umask_pop export GOPATH="${S}:${EGO_STORE_DIR}" return 0 } golang-vcs_src_fetch() { debug-print-function ${FUNCNAME} "$@" _golang-vcs_env_setup _golang-vcs_fetch } golang-vcs_src_unpack() { debug-print-function ${FUNCNAME} "$@" golang-vcs_src_fetch } fi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds 2015-06-11 15:27 ` William Hubbs @ 2015-06-16 21:03 ` William Hubbs 0 siblings, 0 replies; 16+ messages in thread From: William Hubbs @ 2015-06-16 21:03 UTC (permalink / raw To: gentoo-dev; +Cc: vapier [-- Attachment #1.1: Type: text/plain, Size: 317 bytes --] There have been no more comments on this eclass. I did, however, find some typos that I fixed. I will attach the patch with the fixes here then commit the eclass. Without these fixes the eclass generates "command not found" errors. The fixes involve s/umask_push/eumask_push/ and s/umask_pop/eumask_pop/. William [-- Attachment #1.2: golang-vcs-fixes.patch --] [-- Type: text/x-diff, Size: 1136 bytes --] --- a/golang-vcs.eclass 2015-06-16 15:00:31.995528578 -0500 +++ b/golang-vcs.eclass 2015-06-16 14:47:00.484815701 -0500 @@ -72,7 +72,7 @@ local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}} : ${EGO_STORE_DIR:=${distdir}/go-src} - [[ -n ${EVCS_UMASK} ]] && umask_push $EVCS_UMASK + [[ -n ${EVCS_UMASK} ]] && eumask_push $EVCS_UMASK if [[ ! -d ${EGO_STORE_DIR} ]]; then ( @@ -84,7 +84,7 @@ addwrite "${EGO_STORE_DIR}" export GOPATH="${EGO_STORE_DIR}" - [[ -n ${EVCS_UMASK} ]] && umask_pop + [[ -n ${EVCS_UMASK} ]] && eumask_pop mkdir -p "${S}" || die "${ECLASS}: unable to create ${S}" return 0 @@ -105,7 +105,7 @@ return 0 fi - [[ -n ${EVCS_UMASK} ]] && umask_push ${EVCS_UMASK} + [[ -n ${EVCS_UMASK} ]] && eumask_push ${EVCS_UMASK} set -- go get -d -t -u -v -x "${EGO_PN}" echo "$@" @@ -117,7 +117,7 @@ # I am hoping this will be fixed so "go get -d" is successful if # downloading the top level repository is successful. - [[ -n ${EVCS_UMASK} ]] && umask_pop + [[ -n ${EVCS_UMASK} ]] && eumask_pop export GOPATH="${S}:${EGO_STORE_DIR}" return 0 } [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 181 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-06-16 21:03 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-06-04 19:10 [gentoo-dev] new eclass: go-live.eclass for handling go live ebuilds William Hubbs 2015-06-04 19:27 ` Andrew Udvare 2015-06-04 19:45 ` William Hubbs 2015-06-05 4:54 ` Mike Frysinger 2015-06-05 14:34 ` William Hubbs 2015-06-05 19:12 ` William Hubbs 2015-06-06 6:44 ` [gentoo-dev] " Duncan 2015-06-06 1:22 ` [gentoo-dev] " Mike Frysinger 2015-06-08 19:38 ` William Hubbs 2015-06-10 3:34 ` Dean Stephens 2015-06-10 15:08 ` William Hubbs 2015-06-11 4:28 ` Dean Stephens 2015-06-10 15:53 ` Mike Frysinger 2015-06-10 17:32 ` William Hubbs 2015-06-11 15:27 ` William Hubbs 2015-06-16 21:03 ` William Hubbs
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox