Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 485438 - eutils.eclass: please review prefix changes
Summary: eutils.eclass: please review prefix changes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: prefix-gx86
  Show dependency tree
 
Reported: 2013-09-19 18:48 UTC by Christoph Junghans (RETIRED)
Modified: 2013-12-03 10:02 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch against gx86 (eutils.eclass.patch,3.50 KB, patch)
2013-09-19 18:48 UTC, Christoph Junghans (RETIRED)
Details | Diff
patch against gx86 (eutils.eclass.patch,4.68 KB, patch)
2013-09-20 15:55 UTC, Christoph Junghans (RETIRED)
Details | Diff
patch against gx86 (eutils.eclass.patch,4.63 KB, patch)
2013-09-20 16:23 UTC, Christoph Junghans (RETIRED)
Details | Diff
patch against gx86 (eutils.eclass.patch,4.42 KB, patch)
2013-10-22 22:40 UTC, Christoph Junghans (RETIRED)
Details | Diff
patch against gx86 (eutils.eclass.patch,4.55 KB, patch)
2013-12-01 19:49 UTC, Christoph Junghans (RETIRED)
Details | Diff
patch against gx86 (eutils.eclass.patch,4.60 KB, patch)
2013-12-02 13:08 UTC, Christoph Junghans (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Junghans (RETIRED) gentoo-dev 2013-09-19 18:48:05 UTC
Created attachment 359048 [details, diff]
patch against gx86

Just following the idea of other eclasses.
Comment 1 Arfrever Frehtes Taifersar Arahesis 2013-09-20 10:25:07 UTC
'use' should not be called in global scope.
Comment 2 Christoph Junghans (RETIRED) gentoo-dev 2013-09-20 15:29:18 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #1)
> 'use' should not be called in global scope.
True, ruby-ng-gnome2.eclass does it the same way.
Comment 3 Christoph Junghans (RETIRED) gentoo-dev 2013-09-20 15:55:11 UTC
Created attachment 359136 [details, diff]
patch against gx86

Make calls to "use prefix" local.
Comment 4 Arfrever Frehtes Taifersar Arahesis 2013-09-20 16:11:47 UTC
Setting DYLD_LIBRARY_PATH is not necessary on non-Darwin systems.

  if [[ -n ${libdir} ]] ; then
    if [[ ${CHOST} == *-darwin* ]] ; then
      var=DYLD_LIBRARY_PATH
    else
      var=LD_LIBRARY_PATH
    fi

    cat <<-EOF
      if [ "\${${var}+set}" = "set" ] ; then
        export ${var}="\${${var}}:${EPREFIX}${libdir}"
      else
        export ${var}="${EPREFIX}${libdir}"
      fi
    EOF
  fi

('local var' is not required due to subshell.)
Comment 5 Christoph Junghans (RETIRED) gentoo-dev 2013-09-20 16:23:18 UTC
Created attachment 359138 [details, diff]
patch against gx86

(In reply to Arfrever Frehtes Taifersar Arahesis from comment #4)
> Setting DYLD_LIBRARY_PATH is not necessary on non-Darwin systems.
> 
>   if [[ -n ${libdir} ]] ; then
>     if [[ ${CHOST} == *-darwin* ]] ; then
>       var=DYLD_LIBRARY_PATH
>     else
>       var=LD_LIBRARY_PATH
>     fi
> 
>     cat <<-EOF
>       if [ "\${${var}+set}" = "set" ] ; then
>         export ${var}="\${${var}}:${EPREFIX}${libdir}"
>       else
>         export ${var}="${EPREFIX}${libdir}"
>       fi
>     EOF
>   fi
> 
> ('local var' is not required due to subshell.)
That is actually quite a bit nicer.
Comment 6 SpanKY gentoo-dev 2013-10-16 06:22:46 UTC
Comment on attachment 359138 [details, diff]
patch against gx86

>+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}" && EPREFIX=

wouldn't this be simpler:
  has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}

then you can copy & paste that line everywhere below.  or maybe make an internal func:
  _eutils_eprefix_init() {
    has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
  }

>+	# cannot preserve-libs on aix yet.
>+	[[ ${CHOST} == *-aix* ]] && {
>+		einfo "Not preserving libs on AIX (yet), not implemented."
>+		return 0
>+	}

no need for this funky syntax.  use standard `if ... ; then` rather than {...}
Comment 7 Michael Haubenwallner (RETIRED) gentoo-dev 2013-10-16 07:12:15 UTC
(In reply to SpanKY from comment #6)
> >+	# cannot preserve-libs on aix yet.
> >+	[[ ${CHOST} == *-aix* ]] && {
> >+		einfo "Not preserving libs on AIX (yet), not implemented."
> >+		return 0
> >+	}

"AIX" triggers my attention here:
IMO, the comment+message is not true any more and wrong now - better tell to always enable (or relying on) FEATURES=preserve-libs on AIX instead (who would want to disable it anyway?), it /is/ implemented in portage.
Comment 8 Christoph Junghans (RETIRED) gentoo-dev 2013-10-17 20:51:48 UTC
(In reply to SpanKY from comment #6)
> Comment on attachment 359138 [details, diff] [details, diff]
> patch against gx86
> 
> >+	has "${EAPI:-0}" 0 1 2 && ! use prefix && ED="${D}" && EPREFIX=
> 
> wouldn't this be simpler:
>   has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
This not exactly the same. If the user has ED to something odd on EAPI<2, we are screwed. The above variant will always set ED="${D}".

> 
> then you can copy & paste that line everywhere below.  or maybe make an
> internal func:
>   _eutils_eprefix_init() {
>     has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
>   }
What ever you prefer, I will one extra explicit line per function.

> 
> >+	# cannot preserve-libs on aix yet.
> >+	[[ ${CHOST} == *-aix* ]] && {
> >+		einfo "Not preserving libs on AIX (yet), not implemented."
> >+		return 0
> >+	}
> no need for this funky syntax.  use standard `if ... ; then` rather than
> {...}
Can go due to haubi's comments.
Comment 9 Christoph Junghans (RETIRED) gentoo-dev 2013-10-22 22:40:33 UTC
Created attachment 361676 [details, diff]
patch against gx86

Updated version of the patch, if preferred we can also go for the sloppy version to set EPREFIX and ED.
Comment 10 SpanKY gentoo-dev 2013-11-30 18:24:25 UTC
(In reply to Christoph Junghans from comment #8)

if the user is setting ED in their environment, then they should be failing.  we've used this style elsewhere in the tree, so they're already screwed.

then again, it's already conditional on EAPI level, so no need for the : ${:=} logic.
Comment 11 SpanKY gentoo-dev 2013-11-30 18:24:49 UTC
Comment on attachment 361676 [details, diff]
patch against gx86

merge the EAPI default var logic into a single func as suggested earlier
Comment 12 Christoph Junghans (RETIRED) gentoo-dev 2013-12-01 19:49:03 UTC
Created attachment 364366 [details, diff]
patch against gx86

Here we go again!
Comment 13 SpanKY gentoo-dev 2013-12-02 08:22:12 UTC
Comment on attachment 364366 [details, diff]
patch against gx86

>+# @FUNCTION: _eutils_eprefix_init
>+# @USAGE:
>+# @DESCRIPTION:
>+# Initialized prefix variables for EAPI<3.

drop the @USAGE and add @INTERNAL

>+_eutils_eprefix_init() {
>+	has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
>+}

to be clear, i just wanted one func.  if you want to drop the : logic, that's fine (as discussed earlier).
  has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}

i'm assuming that means you don't support prefix with EAPI=2 and older.

>-	local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE
>-	local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE
>+	local USEFILE="${EROOT}"/var/db/pkg/${PKG}/USE
>+	local IUSEFILE="${EROOT}"/var/db/pkg/${PKG}/IUSE

the quotes are pointless here

>@@ -1408,17 +1422,22 @@
> 	echo '#!/bin/sh'
> 	[[ -n ${chdir} ]] && printf 'cd "%s"\n' "${chdir}"
> 	if [[ -n ${libdir} ]] ; then
>+		if [[ ${CHOST} == *-darwin* ]] ; then
>+			var=DYLD_LIBRARY_PATH
>+		else
>+			var=LD_LIBRARY_PATH
>+		fi

missing `local var` decl

> 	# We don't want to quote ${bin} so that people can pass complex
> 	# things as ${bin} ... "./someprog --args"
>-	printf 'exec %s "$@"\n' "${bin}"
>+	printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}\/}"

hmm, you correctly handle the prefix in the program name, but i think it's missing handling when the chdir option is enabled
Comment 14 Christoph Junghans (RETIRED) gentoo-dev 2013-12-02 13:08:54 UTC
Created attachment 364446 [details, diff]
patch against gx86

(In reply to SpanKY from comment #13)
> Comment on attachment 364366 [details, diff] [details, diff]
> patch against gx86
> 
> >+# @FUNCTION: _eutils_eprefix_init
> >+# @USAGE:
> >+# @DESCRIPTION:
> >+# Initialized prefix variables for EAPI<3.
> 
> drop the @USAGE and add @INTERNAL
Done!

> 
> >+_eutils_eprefix_init() {
> >+	has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
> >+}
> 
> to be clear, i just wanted one func.  if you want to drop the : logic,
> that's fine (as discussed earlier).
>   has "${EAPI:-0}" 0 1 2 && ED=${D} EPREFIX= EROOT=${ROOT}
> 
> i'm assuming that means you don't support prefix with EAPI=2 and older.
Huh, there are EAPI<=2 ebuilds in the prefix overlay, so the := is needed as we only want to set it if it isn't already set by portage otherwise we would end up with empty EPREFIX for EAPI<=2.

> 
> >-	local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE
> >-	local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE
> >+	local USEFILE="${EROOT}"/var/db/pkg/${PKG}/USE
> >+	local IUSEFILE="${EROOT}"/var/db/pkg/${PKG}/IUSE
> 
> the quotes are pointless here
Done.

> 
> >@@ -1408,17 +1422,22 @@
> > 	echo '#!/bin/sh'
> > 	[[ -n ${chdir} ]] && printf 'cd "%s"\n' "${chdir}"
> > 	if [[ -n ${libdir} ]] ; then
> >+		if [[ ${CHOST} == *-darwin* ]] ; then
> >+			var=DYLD_LIBRARY_PATH
> >+		else
> >+			var=LD_LIBRARY_PATH
> >+		fi
> 
> missing `local var` decl
Added, but "('local var' is not required due to subshell.)" (comment #4).

> 
> > 	# We don't want to quote ${bin} so that people can pass complex
> > 	# things as ${bin} ... "./someprog --args"
> >-	printf 'exec %s "$@"\n' "${bin}"
> >+	printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}\/}"
> 
> hmm, you correctly handle the prefix in the program name, but i think it's
> missing handling when the chdir option is enabled
True, it seems we never used that in prefix.
Comment 15 SpanKY gentoo-dev 2013-12-03 08:10:44 UTC
(In reply to Christoph Junghans from comment #14)

well i'm completely lost then on _eutils_eprefix_init as it seems you've argued it both ways.  but it doesn't matter as this version is fine by me and fine by you.  committed:
http://sources.gentoo.org/eclass/eutils.eclass?r1=1.427&r2=1.428
Comment 16 Christoph Junghans (RETIRED) gentoo-dev 2013-12-03 10:02:18 UTC
(In reply to SpanKY from comment #15)
> (In reply to Christoph Junghans from comment #14)
> 
> well i'm completely lost then on _eutils_eprefix_init as it seems you've
> argued it both ways.  
I got a bit confused, too ;-)

> but it doesn't matter as this version is fine by me
> and fine by you.  committed:
> http://sources.gentoo.org/eclass/eutils.eclass?r1=1.427&r2=1.428
Great, thanks.