[gentoo-portage-dev] [PATCH] Apply 'nonfatal' to helpers only

2014-08-18 Thread Michał Górny
Make 'nonfatal' modifier affect helpers only rather than disabling 'die'
completely. This improves the PMS conformance.
---
 bin/isolated-functions.sh | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index a22af57..d41f0b3 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -106,7 +106,7 @@ __bashpid() {
 }
 
 __helpers_die() {
-   if ___eapi_helpers_can_die; then
+   if ___eapi_helpers_can_die  [[ ${PORTAGE_NONFATAL} != 1 ]]; then
die $@
else
echo -e $@ 2
@@ -116,11 +116,6 @@ __helpers_die() {
 die() {
local IFS=$' \t\n'
 
-   if [[ $PORTAGE_NONFATAL -eq 1 ]]; then
-   echo -e  $WARN*$NORMAL ${FUNCNAME[1]}: WARNING: $@ 2
-   return 1
-   fi
-
set +e
if [ -n ${QA_INTERCEPTORS} ] ; then
# die was called from inside inherit. We need to clean up
-- 
2.0.4




Re: [gentoo-portage-dev] [PATCH] Apply 'nonfatal' to helpers only

2014-08-18 Thread Arfrever Frehtes Taifersar Arahesis
2014-08-18 11:02 Michał Górny napisał(a):
 Make 'nonfatal' modifier affect helpers only rather than disabling 'die'
 completely. This improves the PMS conformance.

It is better to leave current code, until there is replacement functionality.

--
Arfrever Frehtes Taifersar Arahesis


signature.asc
Description: This is a digitally signed message part.


Re: [gentoo-portage-dev] [PATCH] Apply 'nonfatal' to helpers only

2014-08-18 Thread Michał Górny
Dnia 2014-08-18, o godz. 14:00:08
Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com napisał(a):

 2014-08-18 11:02 Michał Górny napisał(a):
  Make 'nonfatal' modifier affect helpers only rather than disabling 'die'
  completely. This improves the PMS conformance.
 
 It is better to leave current code, until there is replacement functionality.

The replacement functionality is in EAPI 6.

-- 
Best regards,
Michał Górny


signature.asc
Description: PGP signature


[gentoo-portage-dev] [PATCH] Rewrite default ebuild phase setting code

2014-08-18 Thread Michał Górny
Replace the ebuild phase setting code for EAPI 2 and newer with a
simpler approach; first set proper default_* functions, and call them
within the phase. Disallow calling default_* for other phase functions
than the one being run.
---
 bin/phase-functions.sh | 117 ++---
 bin/save-ebuild-env.sh |   2 +-
 2 files changed, 53 insertions(+), 66 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index f39a024..954f1a3 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -734,91 +734,78 @@ __ebuild_phase_funcs() {
[ $# -ne 2 ]  die expected exactly 2 args, got $#: $*
local eapi=$1
local phase_func=$2
-   local default_phases=pkg_nofetch src_unpack src_prepare src_configure
-   src_compile src_install src_test
-   local x y default_func=
-
-   for x in pkg_nofetch src_unpack src_test ; do
-   declare -F $x /dev/null || \
-   eval $x() { __eapi0_$x \\$@\ ; }
+   local all_phases=src_compile pkg_config src_configure pkg_info
+   src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
+   src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack
+   local x
+
+   # First, set up the error handlers for default*
+   for x in ${all_phases} ; do
+   eval default_${x}() {
+   die \default_${x}() is not supported in EAPI='${eapi}' 
in phase ${phase_func}\
+   }
done
 
+   # We can just call the specific handler -- it will either error out
+   # on invalid phase or run it.
+   eval default() {
+   default_${phase_func}
+   }
+
case $eapi in
+   0|1) # EAPIs not supporting 'default'
 
-   0|1)
+   for x in pkg_nofetch src_unpack src_test ; do
+   declare -F $x /dev/null || \
+   eval $x() { __eapi0_$x; }
+   done
 
if ! declare -F src_compile /dev/null ; then
case $eapi in
0)
-   src_compile() { 
__eapi0_src_compile $@ ; }
+   src_compile() { 
__eapi0_src_compile; }
;;
*)
-   src_compile() { 
__eapi1_src_compile $@ ; }
+   src_compile() { 
__eapi1_src_compile; }
;;
esac
fi
-
-   for x in $default_phases ; do
-   eval default_$x() {
-   die \default_$x() is not supported 
with EAPI='$eapi' during phase $phase_func\
-   }
-   done
-
-   eval default() {
-   die \default() is not supported with 
EAPI='$eapi' during phase $phase_func\
-   }
-
;;
 
-   *)
-
+   *) # EAPIs supporting 'default'
+
+   # defaults starting with EAPI 0
+   [[ ${phase_func} == pkg_nofetch ]]  \
+   default_pkg_nofetch() { __eapi0_pkg_nofetch; }
+   [[ ${phase_func} == src_unpack ]]  \
+   default_src_unpack() { __eapi0_src_unpack; }
+   [[ ${phase_func} == src_test ]]  \
+   default_src_test() { __eapi0_src_test; }
+
+   # defaults starting with EAPI 2
+   [[ ${phase_func} == src_configure ]]  \
+   default_src_configure() { 
__eapi2_src_configure; }
+   [[ ${phase_func} == src_compile ]]  \
+   default_src_compile() { __eapi2_src_compile; }
+
+   # bind supported phases to the defaults
+   declare -F src_unpack /dev/null || \
+   src_unpack() { default; }
declare -F src_configure /dev/null || \
-   src_configure() { __eapi2_src_configure $@ ; }
-
+   src_configure() { default; }
declare -F src_compile /dev/null || \
-   src_compile() { __eapi2_src_compile $@ ; }
-
-   has $eapi 2 3 || declare -F src_install /dev/null || \
-   src_install() { __eapi4_src_install $@ ; }
+   src_compile() { default; }
+   declare -F src_test /dev/null || \
+  

Re: [gentoo-portage-dev] [PATCH] Apply 'nonfatal' to helpers only

2014-08-18 Thread Brian Dolbec
On Mon, 18 Aug 2014 14:04:32 +0200
Michał Górny mgo...@gentoo.org wrote:

 Dnia 2014-08-18, o godz. 14:00:08
 Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com
 napisał(a):
 
  2014-08-18 11:02 Michał Górny napisał(a):
   Make 'nonfatal' modifier affect helpers only rather than
   disabling 'die' completely. This improves the PMS conformance.
  
  It is better to leave current code, until there is replacement
  functionality.
 
 The replacement functionality is in EAPI 6.
 

Then perhaps your commit message should have stated this is an EAPI 6
involved change.  Also, EAPI 6 is no where near started to be supported
in portage.   So if this is an EAPI 6 change, it is the first.

-- 
Brian Dolbec dolsen



signature.asc
Description: PGP signature


[gentoo-portage-dev] [PATCH 4/6] Make eapi_is_supported() reuse _supported_eapis list

2014-08-18 Thread Michał Górny
Make the eapi_is_supported() function use the generated list of
supported EAPIs rather than partial lists and integer comparison.
---
 pym/portage/__init__.py | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 18b2599..66bfeb0 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -505,19 +505,7 @@ def eapi_is_supported(eapi):
eapi = str(eapi)
eapi = eapi.strip()
 
-   if _eapi_is_deprecated(eapi):
-   return True
-
-   if eapi in _testing_eapis:
-   return True
-
-   try:
-   eapi = int(eapi)
-   except ValueError:
-   eapi = -1
-   if eapi  0:
-   return False
-   return eapi = portage.const.EAPI
+   return eapi in _supported_eapis
 
 # This pattern is specified by PMS section 7.3.1.
 _pms_eapi_re = re.compile(r^[ \t]*EAPI=(['\]?)([A-Za-z0-9+_.-]*)\1[ \t]*([ 
\t]#.*)?$)
-- 
2.0.4




[gentoo-portage-dev] [PATCH 5/6] Apply 'nonfatal' to helpers only

2014-08-18 Thread Michał Górny
Make 'nonfatal' modifier affect helpers only rather than disabling 'die'
completely. This improves the PMS conformance.
---
 bin/isolated-functions.sh | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index a22af57..d41f0b3 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -106,7 +106,7 @@ __bashpid() {
 }
 
 __helpers_die() {
-   if ___eapi_helpers_can_die; then
+   if ___eapi_helpers_can_die  [[ ${PORTAGE_NONFATAL} != 1 ]]; then
die $@
else
echo -e $@ 2
@@ -116,11 +116,6 @@ __helpers_die() {
 die() {
local IFS=$' \t\n'
 
-   if [[ $PORTAGE_NONFATAL -eq 1 ]]; then
-   echo -e  $WARN*$NORMAL ${FUNCNAME[1]}: WARNING: $@ 2
-   return 1
-   fi
-
set +e
if [ -n ${QA_INTERCEPTORS} ] ; then
# die was called from inside inherit. We need to clean up
-- 
2.0.4




[gentoo-portage-dev] [PATCH 1/6] econf: Replace unnecessary 'case' statements with 'if's

2014-08-18 Thread Michał Górny
Replace the 'case' statements used to match 'configure' output with
simpler pattern-matching 'if's.

Acked-by: Alexander Berntsen berna...@gentoo.org
---
 bin/phase-helpers.sh | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 47bd843..6a5ce85 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -525,19 +525,15 @@ econf() {
local conf_help=$(${ECONF_SOURCE}/configure --help 
2/dev/null)
 
if ___eapi_econf_passes_--disable-dependency-tracking; 
then
-   case ${conf_help} in
-   *--disable-dependency-tracking*)
-   set -- 
--disable-dependency-tracking $@
-   ;;
-   esac
+   if [[ ${conf_help} == 
*--disable-dependency-tracking* ]]; then
+   set -- --disable-dependency-tracking 
$@
+   fi
fi
 
if ___eapi_econf_passes_--disable-silent-rules; then
-   case ${conf_help} in
-   *--disable-silent-rules*)
-   set -- --disable-silent-rules 
$@
-   ;;
-   esac
+   if [[ ${conf_help} == *--disable-silent-rules* 
]]; then
+   set -- --disable-silent-rules $@
+   fi
fi
fi
 
-- 
2.0.4




[gentoo-portage-dev] [PATCHES] Random issues and refactoring before EAPI6 series

2014-08-18 Thread Michał Górny
dol-sen asked me to send all of them in a serie. Those are minor
bugfixes and code refactoring done to prepare for EAPI6 code.

1  2 cleans up econf. In EAPI6 we will likely be adding --docdir
and --htmldir there, so we should add it in nice code rather than
copying the bad one.

3-4 aim to clean up EAPI handling a bit. It's far from perfect, but 3 at
least fixes the bug that EAPI 5 is considered unsupported. Further
changes can be done in the future.

5 fixes PMS incompatibility that causes 'nonfatal' to prevent 'die' from
working correctly. I'm pretty sure the bug was mentioned by PMS team
already but nobody considered it important enough to report a bug. EAPI
6 'nonfatal die' support will land in place of that conditional.

6 aims to simplify the phase setting function that is hard to understand
and the moment, and has a few unnecessary, hard-to-understand side
effects like declaring non-existent __eapi2_src_*() phases. The new code
is much cleaner and makes adding new phases in future EAPIs trivial. It
also prevents from calling default_* function for another phase as
forbidden by PMS.

--
Michał Górny




[gentoo-portage-dev] [PATCH 6/6] Rewrite default ebuild phase setting code

2014-08-18 Thread Michał Górny
Replace the ebuild phase setting code for EAPI 2 and newer with a
simpler approach; first set proper default_* functions, and call them
within the phase. Disallow calling default_* for other phase functions
than the one being run.
---
 bin/phase-functions.sh | 117 ++---
 bin/save-ebuild-env.sh |   2 +-
 2 files changed, 53 insertions(+), 66 deletions(-)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index f39a024..b7fb5d7 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -734,91 +734,78 @@ __ebuild_phase_funcs() {
[ $# -ne 2 ]  die expected exactly 2 args, got $#: $*
local eapi=$1
local phase_func=$2
-   local default_phases=pkg_nofetch src_unpack src_prepare src_configure
-   src_compile src_install src_test
-   local x y default_func=
-
-   for x in pkg_nofetch src_unpack src_test ; do
-   declare -F $x /dev/null || \
-   eval $x() { __eapi0_$x \\$@\ ; }
+   local all_phases=src_compile pkg_config src_configure pkg_info
+   src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
+   src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack
+   local x
+
+   # First, set up the error handlers for default*
+   for x in ${all_phases} ; do
+   eval default_${x}() {
+   die \default_${x}() is not supported in EAPI='${eapi}' 
in phase ${phase_func}\
+   }
done
 
+   # We can just call the specific handler -- it will either error out
+   # on invalid phase or run it.
+   eval default() {
+   default_${phase_func}
+   }
+
case $eapi in
+   0|1) # EAPIs not supporting 'default'
 
-   0|1)
+   for x in pkg_nofetch src_unpack src_test ; do
+   declare -F $x /dev/null || \
+   eval $x() { __eapi0_$x; }
+   done
 
if ! declare -F src_compile /dev/null ; then
case $eapi in
0)
-   src_compile() { 
__eapi0_src_compile $@ ; }
+   src_compile() { 
__eapi0_src_compile; }
;;
*)
-   src_compile() { 
__eapi1_src_compile $@ ; }
+   src_compile() { 
__eapi1_src_compile; }
;;
esac
fi
-
-   for x in $default_phases ; do
-   eval default_$x() {
-   die \default_$x() is not supported 
with EAPI='$eapi' during phase $phase_func\
-   }
-   done
-
-   eval default() {
-   die \default() is not supported with 
EAPI='$eapi' during phase $phase_func\
-   }
-
;;
 
-   *)
-
+   *) # EAPIs supporting 'default'
+
+   # defaults starting with EAPI 0
+   [[ ${phase_func} == pkg_nofetch ]]  \
+   default_pkg_nofetch() { __eapi0_pkg_nofetch; }
+   [[ ${phase_func} == src_unpack ]]  \
+   default_src_unpack() { __eapi0_src_unpack; }
+   [[ ${phase_func} == src_test ]]  \
+   default_src_test() { __eapi0_src_test; }
+
+   # defaults starting with EAPI 2
+   [[ ${phase_func} == src_configure ]]  \
+   default_src_configure() { 
__eapi2_src_configure; }
+   [[ ${phase_func} == src_compile ]]  \
+   default_src_compile() { __eapi2_src_compile; }
+
+   # bind supported phases to the defaults
+   declare -F src_unpack /dev/null || \
+   src_unpack() { default; }
declare -F src_configure /dev/null || \
-   src_configure() { __eapi2_src_configure $@ ; }
-
+   src_configure() { default; }
declare -F src_compile /dev/null || \
-   src_compile() { __eapi2_src_compile $@ ; }
-
-   has $eapi 2 3 || declare -F src_install /dev/null || \
-   src_install() { __eapi4_src_install $@ ; }
+   src_compile() { default; }
+   declare -F src_test /dev/null || \
+  

[gentoo-portage-dev] [PATCH 2/6] econf: Add EAPI-conditional arguments via array

2014-08-18 Thread Michał Górny
Use a dedicated array variable to add EAPI-conditional arguments to
the configure script instead of prepending them to the command
parameters.
---
 bin/phase-helpers.sh | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 6a5ce85..b96c3f5 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -521,18 +521,19 @@ econf() {
done
fi
 
+   local conf_args=()
if ___eapi_econf_passes_--disable-dependency-tracking || 
___eapi_econf_passes_--disable-silent-rules; then
local conf_help=$(${ECONF_SOURCE}/configure --help 
2/dev/null)
 
if ___eapi_econf_passes_--disable-dependency-tracking; 
then
if [[ ${conf_help} == 
*--disable-dependency-tracking* ]]; then
-   set -- --disable-dependency-tracking 
$@
+   conf_args+=( 
--disable-dependency-tracking )
fi
fi
 
if ___eapi_econf_passes_--disable-silent-rules; then
if [[ ${conf_help} == *--disable-silent-rules* 
]]; then
-   set -- --disable-silent-rules $@
+   conf_args+=( --disable-silent-rules )
fi
fi
fi
@@ -550,7 +551,9 @@ econf() {
CONF_PREFIX=${CONF_PREFIX#*=}
[[ ${CONF_PREFIX} != /* ]]  
CONF_PREFIX=/${CONF_PREFIX}
[[ ${CONF_LIBDIR} != /* ]]  
CONF_LIBDIR=/${CONF_LIBDIR}
-   set -- --libdir=$(__strip_duplicate_slashes 
${CONF_PREFIX}${CONF_LIBDIR}) $@
+   conf_args+=(
+   --libdir=$(__strip_duplicate_slashes 
${CONF_PREFIX}${CONF_LIBDIR})
+   )
fi
 
# Handle arguments containing quoted whitespace (see bug 
#457136).
@@ -566,6 +569,7 @@ econf() {
--datadir=${EPREFIX}/usr/share \
--sysconfdir=${EPREFIX}/etc \
--localstatedir=${EPREFIX}/var/lib \
+   ${conf_args[@]} \
$@ \
${EXTRA_ECONF[@]}
__vecho ${ECONF_SOURCE}/configure $@
-- 
2.0.4




[gentoo-portage-dev] [PATCH 01/13] Support EAPI=6_pre1 for testing EAPI6 features

2014-08-18 Thread Michał Górny
---
 pym/portage/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 66bfeb0..0046161 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -491,7 +491,7 @@ def abssymlink(symlink, target=None):
 
 _doebuild_manifest_exempt_depend = 0
 
-_testing_eapis = frozenset([4-python, 4-slot-abi, 5-progress, 
5-hdepend])
+_testing_eapis = frozenset([4-python, 4-slot-abi, 5-progress, 
5-hdepend, 6_pre1])
 _deprecated_eapis = frozenset([4_pre1, 3_pre2, 3_pre1, 5_pre1, 
5_pre2])
 _supported_eapis = frozenset([str(x) for x in range(portage.const.EAPI + 1)] + 
list(_testing_eapis) + list(_deprecated_eapis))
 
-- 
2.0.4




[gentoo-portage-dev] [PATCH 03/13] Add tentative support for EAPI6 get_libdir()

2014-08-18 Thread Michał Górny
Add get_libdir() function to obtain the basename of libdir using
the same algorithm that econf uses.
---
 bin/eapi.sh  |  4 
 bin/phase-helpers.sh | 11 +++
 2 files changed, 15 insertions(+)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 5f96c3b..6ace20d 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -64,6 +64,10 @@ ___eapi_has_usex() {
[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
+___eapi_has_get_libdir() {
+   [[ ! ${1-${EAPI}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
 ___eapi_has_master_repositories() {
[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
 }
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index c2161f6..8edbc07 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -842,6 +842,17 @@ best_version() {
esac
 }
 
+if ___eapi_has_get_libdir; then
+   get_libdir() {
+   local libdir_var=LIBDIR_${ABI}
+   local libdir=lib
+
+   [[ -n ${ABI}  -n ${!libdir_var} ]]  libdir=${!libdir_var}
+
+   echo ${libdir}
+   }
+fi
+
 if ___eapi_has_master_repositories; then
master_repositories() {
local output repository=$1 retval
-- 
2.0.4




[gentoo-portage-dev] [PATCH 02/13] Add tentative support for EAPI6 --docdir and --htmldir

2014-08-18 Thread Michał Górny
Pass --docdir and --htmldir to configure scripts that support it.
---
 bin/eapi.sh  |  4 
 bin/phase-helpers.sh | 12 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 623b89f..5f96c3b 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -110,6 +110,10 @@ ___eapi_econf_passes_--disable-silent-rules() {
[[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]]
 }
 
+___eapi_econf_passes_--docdir_and_--htmldir() {
+   [[ ! ${1-${EAPI}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
 ___eapi_use_enable_and_use_with_support_empty_third_argument() {
[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
 }
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index b96c3f5..c2161f6 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -522,7 +522,7 @@ econf() {
fi
 
local conf_args=()
-   if ___eapi_econf_passes_--disable-dependency-tracking || 
___eapi_econf_passes_--disable-silent-rules; then
+   if ___eapi_econf_passes_--disable-dependency-tracking || 
___eapi_econf_passes_--disable-silent-rules || 
___eapi_econf_passes_--docdir_and_--htmldir; then
local conf_help=$(${ECONF_SOURCE}/configure --help 
2/dev/null)
 
if ___eapi_econf_passes_--disable-dependency-tracking; 
then
@@ -536,6 +536,16 @@ econf() {
conf_args+=( --disable-silent-rules )
fi
fi
+
+   if ___eapi_econf_passes_--docdir_and_--htmldir; then
+   if [[ ${conf_help} == *--docdir* ]]; then
+   conf_args+=( 
--docdir=${EPREFIX}/usr/share/doc/${PF} )
+   fi
+
+   if [[ ${conf_help} == *--htmldir* ]]; then
+   conf_args+=( 
--htmldir=${EPREFIX}/usr/share/doc/${PF}/html )
+   fi
+   fi
fi
 
# if the profile defines a location to install libs to aside 
from default, pass it on.
-- 
2.0.4




[gentoo-portage-dev] [PATCH 09/13] Add tentative EAPI6 .txz unpack support

2014-08-18 Thread Michał Górny
Support unpacking .txz-suffixed archives.
---
 bin/eapi.sh  |  4 
 bin/phase-helpers.sh | 13 +
 2 files changed, 17 insertions(+)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index fa57999..878f8e7 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -118,6 +118,10 @@ ___eapi_unpack_supports_xz() {
[[ ! ${1-${EAPI}} =~ ^(0|1|2)$ ]]
 }
 
+___eapi_unpack_supports_txz() {
+   [[ ! ${1-${EAPI}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
 ___eapi_econf_passes_--disable-dependency-tracking() {
[[ ! ${1-${EAPI}} =~ ^(0|1|2|3)$ ]]
 }
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 49b5547..0be79fd 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -456,6 +456,19 @@ unpack() {
__vecho unpack ${x}: file format not 
recognized. Ignoring.
fi
;;
+   txz)
+   if ___eapi_unpack_is_case_sensitive  \
+   [[  txz  != * ${suffix} * ]] ; then
+   eqawarn QA Notice: unpack called with 
\
+   suffix '${suffix}' which is 
unofficially supported \
+   with EAPI '${EAPI}'. Instead 
use 'txz'.
+   fi
+   if ___eapi_supports_txz; then
+   tar xoJf $srcdir$x || die $myfail
+   else
+   __vecho unpack ${x}: file format not 
recognized. Ignoring.
+   fi
+   ;;
*)
__vecho unpack ${x}: file format not 
recognized. Ignoring.
;;
-- 
2.0.4




[gentoo-portage-dev] [PATCHES] Initial EAPI6 patch set for review

2014-08-18 Thread Michał Górny
Here are my patches drafting the first implementations of various parts
of EAPI6, based on top of my cleaned up portage base (see the previous
patch serie).

Unless I've missed something, it includes all Council-approved items
except for runtime USE, and additionally --docdir and --htmldir. Please
review, comment and possibly test.

The easy way:

portage_LIVE_REPO=https://github.com/mgorny/portage.git
portage_LIVE_BRANCH=eapi6

--
Michał Górny




[gentoo-portage-dev] [PATCH 08/13] Enable tentative support for EAPI6 profile-level directories

2014-08-18 Thread Michał Górny
Enable the support for package.* and use.* directories on profile and
repository level.
---
 pym/portage/eapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 4f77910..7217d23 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -81,7 +81,7 @@ def eapi_supports_stable_use_forcing_and_masking(eapi):
return eapi not in (0, 1, 2, 3, 4, 4-python, 4-slot-abi)
 
 def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
-   return eapi in (4-python, 5-progress)
+   return eapi not in (0, 1, 2, 3, 4, 4-slot-abi, 5)
 
 def eapi_has_use_aliases(eapi):
return eapi in (4-python, 5-progress)
-- 
2.0.4




[gentoo-portage-dev] [PATCH 10/13] Add tentative EAPI6 absolute path support to unpack()

2014-08-18 Thread Michał Górny
Add support for absolute paths in unpack(). Allow subdirectory-level
relative paths not to start with './'.
---
 bin/eapi.sh  |  4 
 bin/phase-helpers.sh | 25 ++---
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 878f8e7..6716b1c 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -162,6 +162,10 @@ ___eapi_unpack_is_case_sensitive() {
[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
 }
 
+___eapi_unpack_supports_absolute_paths() {
+   [[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
+}
+
 # OTHERS
 
 ___eapi_enables_failglob_in_global_scope() {
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 0be79fd..60f7a39 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -276,14 +276,25 @@ unpack() {
y=${y##*.}
y_insensitive=$(LC_ALL=C tr [:upper:] [:lower:]  ${y})
 
-   if [[ ${x} == ./* ]] ; then
-   srcdir=
-   elif [[ ${x} == ${DISTDIR%/}/* ]] ; then
-   die Arguments to unpack() cannot begin with 
\${DISTDIR}.
-   elif [[ ${x} == /* ]] ; then
-   die Arguments to unpack() cannot be absolute
+   # wrt PMS 11.3.3.13 Misc Commands
+   if [[ ${x} != */* ]]; then
+   # filename without path of any kind
+   srcdir=${DISTDIR}/
+   elif [[ ${x} == ./* ]]; then
+   # relative path starting with './'
+   srcdir=
else
-   srcdir=${DISTDIR}/
+   # non-'./' filename with path of some kind
+   if ___eapi_unpack_supports_absolute_paths; then
+   # EAPI 6 allows absolute and deep relative paths
+   srcdir=
+   elif [[ ${x} == ${DISTDIR%/}/* ]]; then
+   die Arguments to unpack() cannot begin with 
\${DISTDIR} in EAPI ${EAPI}
+   elif [[ ${x} == /* ]] ; then
+   die Arguments to unpack() cannot be absolute 
in EAPI ${EAPI}
+   else
+   die Relative paths to unpack() must be 
prefixed with './' in EAPI ${EAPI}
+   fi
fi
[[ ! -s ${srcdir}${x} ]]  die ${x} does not exist
 
-- 
2.0.4




[gentoo-portage-dev] [PATCH 11/13] Add tentative EAPI6 nonfatal support to die()

2014-08-18 Thread Michał Górny
Add support for die() to respect 'nonfatal' modifier if
'--respect-nonfatal' (or '-n') option is used. This allows eclasses
to create custom ebuild helpers that mimic built-in helper behavior.
---
 bin/eapi.sh   | 4 
 bin/isolated-functions.sh | 7 +++
 2 files changed, 11 insertions(+)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index 6716b1c..c650a4c 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -166,6 +166,10 @@ ___eapi_unpack_supports_absolute_paths() {
[[ ${1-${EAPI}} =~ ^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend)$ ]]
 }
 
+___eapi_die_can_respect_nonfatal() {
+   [[ ! ${1-${EAPI}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
 # OTHERS
 
 ___eapi_enables_failglob_in_global_scope() {
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index d41f0b3..f9bc90d 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -116,6 +116,13 @@ __helpers_die() {
 die() {
local IFS=$' \t\n'
 
+   if ___eapi_die_can_respect_nonfatal; then
+   if [[ ${1} == -n || ${1} == --respect-nonfatal ]]; then
+   [[ ${PORTAGE_NONFATAL} == 1 ]]  return 1
+   shift
+   fi
+   fi
+
set +e
if [ -n ${QA_INTERCEPTORS} ] ; then
# die was called from inside inherit. We need to clean up
-- 
2.0.4




[gentoo-portage-dev] [PATCH 13/13] Add tentative EAPI6 phase functions

2014-08-18 Thread Michał Górny
---
 bin/phase-functions.sh | 11 +++
 bin/phase-helpers.sh   | 18 ++
 2 files changed, 29 insertions(+)

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index b7fb5d7..f2088bd 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -806,6 +806,17 @@ __ebuild_phase_funcs() {
declare -F src_install /dev/null || \
src_install() { default; }
fi
+
+   # defaults starting with EAPI 6
+   if ! has ${eapi} 2 3 4 4-python 4-slot-abi 5 5-progress 
5-hdepend; then
+   [[ ${phase_func} == src_prepare ]]  \
+   default_src_prepare() { 
__eapi6_src_prepare; }
+   [[ ${phase_func} == src_install ]]  \
+   default_src_install() { 
__eapi6_src_install; }
+
+   declare -F src_prepare /dev/null || \
+   src_prepare() { default; }
+   fi
;;
esac
 }
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 2eada2f..e64fe8b 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -748,6 +748,24 @@ __eapi4_src_install() {
fi
 }
 
+__eapi6_src_prepare() {
+   if [[ $(declare -p PATCHES) == declare -a * ]]; then
+   eapply ${PATCHES[@]}
+   elif [[ -n ${PATCHES} ]]; then
+   eapply ${PATCHES}
+   fi
+
+   eapply_user
+}
+
+__eapi6_src_install() {
+   if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then
+   emake DESTDIR=${D} install
+   fi
+
+   einstalldocs
+}
+
 # @FUNCTION: has_version
 # @USAGE: [--host-root] DEPEND ATOM
 # @DESCRIPTION:
-- 
2.0.4




[gentoo-portage-dev] [PATCH 12/13] Add tentative EAPI6 in_iuse() function

2014-08-18 Thread Michał Górny
Add a function to query IUSE_EFFECTIVE for flags.
---
 bin/eapi.sh|  4 
 bin/phase-helpers.sh   | 16 
 pym/portage/eapi.py|  3 +++
 pym/portage/package/ebuild/doebuild.py |  2 +-
 4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/bin/eapi.sh b/bin/eapi.sh
index c650a4c..e0ade02 100644
--- a/bin/eapi.sh
+++ b/bin/eapi.sh
@@ -80,6 +80,10 @@ ___eapi_has_eapply_user() {
[[ ! ${1-${EAPI}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
 }
 
+___eapi_has_in_iuse() {
+   [[ ! ${1-${EAPI}} =~ 
^(0|1|2|3|4|4-python|4-slot-abi|5|5-hdepend|5-progress)$ ]]
+}
+
 ___eapi_has_master_repositories() {
[[ ${1-${EAPI}} =~ ^(5-progress)$ ]]
 }
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 60f7a39..2eada2f 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -973,6 +973,22 @@ if ___eapi_has_eapply_user; then
}
 fi
 
+if ___eapi_has_in_iuse; then
+   in_iuse() {
+   local use=${1}
+
+   if [[ -z ${use} ]]; then
+   echo !!! in_iuse() called without a parameter. 2
+   echo !!! in_iuse USEFLAG 2
+   die in_iuse() called without a parameter
+   fi
+
+   local liuse=( ${IUSE_EFFECTIVE} )
+
+   has ${use} ${liuse[@]#[+-]}
+   }
+fi
+
 if ___eapi_has_master_repositories; then
master_repositories() {
local output repository=$1 retval
diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 7217d23..386c81d 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -68,6 +68,9 @@ def eapi_has_required_use_at_most_one_of(eapi):
 def eapi_has_use_dep_defaults(eapi):
return eapi not in (0, 1, 2, 3)
 
+def eapi_has_in_iuse(eapi):
+   return eapi not in (0, 1, 2, 3, 4, 4-python, 4-slot-abi, 
5, 5-progress)
+
 def eapi_has_repo_deps(eapi):
return eapi in (4-python, 5-progress)
 
diff --git a/pym/portage/package/ebuild/doebuild.py 
b/pym/portage/package/ebuild/doebuild.py
index 01707ae..29fb0df 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -54,7 +54,7 @@ from portage.dep import Atom, check_required_use, \
 from portage.eapi import eapi_exports_KV, eapi_exports_merge_type, \
eapi_exports_replace_vars, eapi_exports_REPOSITORY, \
eapi_has_required_use, eapi_has_src_prepare_and_src_configure, \
-   eapi_has_pkg_pretend, _get_eapi_attrs
+   eapi_has_pkg_pretend, _get_eapi_attrs, eapi_has_in_iuse
 from portage.elog import elog_process, _preload_elog_modules
 from portage.elog.messages import eerror, eqawarn
 from portage.exception import DigestException, FileNotFound, \
-- 
2.0.4