Re: [gentoo-portage-dev] [PATCH 08/10] dolib.{a,so}: inline the logic from dolib

2018-03-04 Thread Michał Górny
W dniu pon, 26.02.2018 o godzinie 16∶59 +0100, użytkownik Michał Górny
napisał:
> This cleans up the kinda-ugly logic necessary to preserve dolib.a/so
> while removing dolib in EAPI 7, and removes the undesirable symlink
> handling in dolib.a.
> ---
>  bin/ebuild-helpers/dolib|  2 +-
>  bin/ebuild-helpers/dolib.a  | 42 +-
>  bin/ebuild-helpers/dolib.so | 44 +++-
>  3 files changed, 85 insertions(+), 3 deletions(-)
> 
> diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
> index 62e04b385..4be4aa4ea 100755
> --- a/bin/ebuild-helpers/dolib
> +++ b/bin/ebuild-helpers/dolib
> @@ -4,7 +4,7 @@
>  
>  source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
>  
> -if [[ -z ${PORTAGE_INTERNAL_DOLIB} ]] && ! ___eapi_has_dolib_libopts; then
> +if ! ___eapi_has_dolib_libopts; then
>   die "'${0##*/}' has been banned for EAPI '$EAPI'"
>   exit 1
>  fi
> diff --git a/bin/ebuild-helpers/dolib.a b/bin/ebuild-helpers/dolib.a
> index 5ea126b5d..9c1cbeca1 100755
> --- a/bin/ebuild-helpers/dolib.a
> +++ b/bin/ebuild-helpers/dolib.a
> @@ -2,4 +2,44 @@
>  # Copyright 1999-2018 Gentoo Foundation
>  # Distributed under the terms of the GNU General Public License v2
>  
> -LIBOPTIONS='-m0644' PORTAGE_INTERNAL_DOLIB=1 exec dolib "$@"
> +source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
> +
> +if ! ___eapi_has_prefix_variables; then
> + ED=${D}
> +fi
> +
> +# Setup ABI cruft
> +LIBDIR_VAR="LIBDIR_${ABI}"
> +if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
> + CONF_LIBDIR=${!LIBDIR_VAR}
> +fi
> +unset LIBDIR_VAR
> +# we need this to default to lib so that things dont break
> +CONF_LIBDIR=${CONF_LIBDIR:-lib}
> +libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
> +
> +
> +if [[ $# -lt 1 ]] ; then
> + __helpers_die "${0##*/}: at least one argument needed"
> + exit 1
> +fi
> +if [[ ! -d ${libdir} ]] ; then
> + install -d "${libdir}" || { __helpers_die "${0##*/}: failed to install 
> ${libdir}"; exit 1; }
> +fi
> +
> +ret=0
> +
> +for x in "$@" ; do
> + if [[ -e ${x} ]] ; then
> + install -m0644 "${x}" "${libdir}"
> + else
> + echo "!!! ${0##*/}: ${x} does not exist" 1>&2
> + false
> + fi
> + ((ret|=$?))
> +done
> +
> +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
> +exit ${ret}
> +
> +# vim:ft=sh
> diff --git a/bin/ebuild-helpers/dolib.so b/bin/ebuild-helpers/dolib.so
> index a3b579e5e..e99962ae4 100755
> --- a/bin/ebuild-helpers/dolib.so
> +++ b/bin/ebuild-helpers/dolib.so
> @@ -2,4 +2,46 @@
>  # Copyright 1999-2018 Gentoo Foundation
>  # Distributed under the terms of the GNU General Public License v2
>  
> -LIBOPTIONS='-m0755' PORTAGE_INTERNAL_DOLIB=1 exec dolib "$@"
> +source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
> +
> +if ! ___eapi_has_prefix_variables; then
> + ED=${D}
> +fi
> +
> +# Setup ABI cruft
> +LIBDIR_VAR="LIBDIR_${ABI}"
> +if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
> + CONF_LIBDIR=${!LIBDIR_VAR}
> +fi
> +unset LIBDIR_VAR
> +# we need this to default to lib so that things dont break
> +CONF_LIBDIR=${CONF_LIBDIR:-lib}
> +libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
> +
> +
> +if [[ $# -lt 1 ]] ; then
> + __helpers_die "${0##*/}: at least one argument needed"
> + exit 1
> +fi
> +if [[ ! -d ${libdir} ]] ; then
> + install -d "${libdir}" || { __helpers_die "${0##*/}: failed to install 
> ${libdir}"; exit 1; }
> +fi
> +
> +ret=0
> +
> +for x in "$@" ; do
> + if [[ -e ${x} ]] ; then
> + if [[ ! -L ${x} ]] ; then
> + install -m0755 "${x}" "${libdir}"
> + else
> + ln -s "$(readlink "${x}")" "${libdir}/${x##*/}"
> + fi
> + else
> + echo "!!! ${0##*/}: ${x} does not exist" 1>&2
> + false
> + fi
> + ((ret|=$?))
> +done
> +
> +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
> +exit ${ret}

I withdraw this patch, we can't remove symlink logic from dolib.a
without breaking existing ebuilds.

-- 
Best regards,
Michał Górny




[gentoo-portage-dev] [PATCH 08/10] dolib.{a,so}: inline the logic from dolib

2018-02-26 Thread Michał Górny
This cleans up the kinda-ugly logic necessary to preserve dolib.a/so
while removing dolib in EAPI 7, and removes the undesirable symlink
handling in dolib.a.
---
 bin/ebuild-helpers/dolib|  2 +-
 bin/ebuild-helpers/dolib.a  | 42 +-
 bin/ebuild-helpers/dolib.so | 44 +++-
 3 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/bin/ebuild-helpers/dolib b/bin/ebuild-helpers/dolib
index 62e04b385..4be4aa4ea 100755
--- a/bin/ebuild-helpers/dolib
+++ b/bin/ebuild-helpers/dolib
@@ -4,7 +4,7 @@
 
 source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
 
-if [[ -z ${PORTAGE_INTERNAL_DOLIB} ]] && ! ___eapi_has_dolib_libopts; then
+if ! ___eapi_has_dolib_libopts; then
die "'${0##*/}' has been banned for EAPI '$EAPI'"
exit 1
 fi
diff --git a/bin/ebuild-helpers/dolib.a b/bin/ebuild-helpers/dolib.a
index 5ea126b5d..9c1cbeca1 100755
--- a/bin/ebuild-helpers/dolib.a
+++ b/bin/ebuild-helpers/dolib.a
@@ -2,4 +2,44 @@
 # Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-LIBOPTIONS='-m0644' PORTAGE_INTERNAL_DOLIB=1 exec dolib "$@"
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+
+if ! ___eapi_has_prefix_variables; then
+   ED=${D}
+fi
+
+# Setup ABI cruft
+LIBDIR_VAR="LIBDIR_${ABI}"
+if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
+   CONF_LIBDIR=${!LIBDIR_VAR}
+fi
+unset LIBDIR_VAR
+# we need this to default to lib so that things dont break
+CONF_LIBDIR=${CONF_LIBDIR:-lib}
+libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
+
+
+if [[ $# -lt 1 ]] ; then
+   __helpers_die "${0##*/}: at least one argument needed"
+   exit 1
+fi
+if [[ ! -d ${libdir} ]] ; then
+   install -d "${libdir}" || { __helpers_die "${0##*/}: failed to install 
${libdir}"; exit 1; }
+fi
+
+ret=0
+
+for x in "$@" ; do
+   if [[ -e ${x} ]] ; then
+   install -m0644 "${x}" "${libdir}"
+   else
+   echo "!!! ${0##*/}: ${x} does not exist" 1>&2
+   false
+   fi
+   ((ret|=$?))
+done
+
+[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}
+
+# vim:ft=sh
diff --git a/bin/ebuild-helpers/dolib.so b/bin/ebuild-helpers/dolib.so
index a3b579e5e..e99962ae4 100755
--- a/bin/ebuild-helpers/dolib.so
+++ b/bin/ebuild-helpers/dolib.so
@@ -2,4 +2,46 @@
 # Copyright 1999-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-LIBOPTIONS='-m0755' PORTAGE_INTERNAL_DOLIB=1 exec dolib "$@"
+source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1
+
+if ! ___eapi_has_prefix_variables; then
+   ED=${D}
+fi
+
+# Setup ABI cruft
+LIBDIR_VAR="LIBDIR_${ABI}"
+if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
+   CONF_LIBDIR=${!LIBDIR_VAR}
+fi
+unset LIBDIR_VAR
+# we need this to default to lib so that things dont break
+CONF_LIBDIR=${CONF_LIBDIR:-lib}
+libdir="${ED}${DESTTREE}/${CONF_LIBDIR}"
+
+
+if [[ $# -lt 1 ]] ; then
+   __helpers_die "${0##*/}: at least one argument needed"
+   exit 1
+fi
+if [[ ! -d ${libdir} ]] ; then
+   install -d "${libdir}" || { __helpers_die "${0##*/}: failed to install 
${libdir}"; exit 1; }
+fi
+
+ret=0
+
+for x in "$@" ; do
+   if [[ -e ${x} ]] ; then
+   if [[ ! -L ${x} ]] ; then
+   install -m0755 "${x}" "${libdir}"
+   else
+   ln -s "$(readlink "${x}")" "${libdir}/${x##*/}"
+   fi
+   else
+   echo "!!! ${0##*/}: ${x} does not exist" 1>&2
+   false
+   fi
+   ((ret|=$?))
+done
+
+[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
+exit ${ret}
-- 
2.16.2