commit:     30b0ca3905ccd1bff0a5f1641adf2226d57f23b1
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 18:07:12 2020 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 18:08:29 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=30b0ca39

sys-apps/file: refactor cross-compile logic

Add build_src_configure and need_build_file helper functions.
Pass --disable-{bzlib,xzlib,zlib} to configure in build_src_configure.
Use tc-env_build helper in build_src_configure.
Convert "ROOT=/ has_version" to PMS-compliant "has_version -b".
Make ECONF_SOURCE and PATH local variables.

Closes: https://bugs.gentoo.org/704776
Package-Manager: Portage-2.3.84_p2, Repoman-2.3.20_p24
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 sys-apps/file/file-5.38.ebuild | 42 ++++++++++++++++++++++++------------------
 sys-apps/file/file-9999.ebuild | 42 ++++++++++++++++++++++++------------------
 2 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/sys-apps/file/file-5.38.ebuild b/sys-apps/file/file-5.38.ebuild
index 74b955f43b6..93d716314d5 100644
--- a/sys-apps/file/file-5.38.ebuild
+++ b/sys-apps/file/file-5.38.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -55,28 +55,34 @@ multilib_src_configure() {
                $(use_enable static-libs static)
                $(use_enable zlib)
        )
-       ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+       econf "${myeconfargs[@]}"
 }
 
-src_configure() {
+build_src_configure() {
+       local myeconfargs=(
+               --disable-shared
+               --disable-libseccomp
+               --disable-bzlib
+               --disable-xzlib
+               --disable-zlib
+       )
+       tc-env_build econf "${myeconfargs[@]}"
+}
+
+need_build_file() {
        # when cross-compiling, we need to build up our own file
        # because people often don't keep matching host/target
        # file versions #362941
-       if tc-is-cross-compiler && ! ROOT=/ has_version ~${CATEGORY}/${P} ; then
+       tc-is-cross-compiler && ! has_version -b "~${CATEGORY}/${P}"
+}
+
+src_configure() {
+       local ECONF_SOURCE=${S}
+
+       if need_build_file; then
                mkdir -p "${WORKDIR}"/build || die
                cd "${WORKDIR}"/build || die
-               tc-export_build_env BUILD_C{C,XX}
-               ECONF_SOURCE="${S}" \
-               ac_cv_header_zlib_h=no \
-               ac_cv_lib_z_gzopen=no \
-               CHOST=${CBUILD} \
-               CFLAGS=${BUILD_CFLAGS} \
-               CXXFLAGS=${BUILD_CXXFLAGS} \
-               CPPFLAGS=${BUILD_CPPFLAGS} \
-               LDFLAGS="${BUILD_LDFLAGS} -static" \
-               CC=${BUILD_CC} \
-               CXX=${BUILD_CXX} \
-               econf --disable-shared --disable-libseccomp
+               build_src_configure
        fi
 
        multilib-minimal_src_configure
@@ -93,10 +99,10 @@ multilib_src_compile() {
 }
 
 src_compile() {
-       if tc-is-cross-compiler && ! ROOT=/ has_version "~${CATEGORY}/${P}" ; 
then
+       if need_build_file; then
                emake -C "${WORKDIR}"/build/src magic.h #586444
                emake -C "${WORKDIR}"/build/src file
-               PATH="${WORKDIR}/build/src:${PATH}"
+               local -x PATH="${WORKDIR}/build/src:${PATH}"
        fi
        multilib-minimal_src_compile
 

diff --git a/sys-apps/file/file-9999.ebuild b/sys-apps/file/file-9999.ebuild
index fb29c4f2a25..d834362dd1e 100644
--- a/sys-apps/file/file-9999.ebuild
+++ b/sys-apps/file/file-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -56,28 +56,34 @@ multilib_src_configure() {
                $(use_enable static-libs static)
                $(use_enable zlib)
        )
-       ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+       econf "${myeconfargs[@]}"
 }
 
-src_configure() {
+build_src_configure() {
+       local myeconfargs=(
+               --disable-shared
+               --disable-libseccomp
+               --disable-bzlib
+               --disable-xzlib
+               --disable-zlib
+       )
+       tc-env_build econf "${myeconfargs[@]}"
+}
+
+need_build_file() {
        # when cross-compiling, we need to build up our own file
        # because people often don't keep matching host/target
        # file versions #362941
-       if tc-is-cross-compiler && ! ROOT=/ has_version ~${CATEGORY}/${P} ; then
+       tc-is-cross-compiler && ! has_version -b "~${CATEGORY}/${P}"
+}
+
+src_configure() {
+       local ECONF_SOURCE=${S}
+
+       if need_build_file; then
                mkdir -p "${WORKDIR}"/build || die
                cd "${WORKDIR}"/build || die
-               tc-export_build_env BUILD_C{C,XX}
-               ECONF_SOURCE="${S}" \
-               ac_cv_header_zlib_h=no \
-               ac_cv_lib_z_gzopen=no \
-               CHOST=${CBUILD} \
-               CFLAGS=${BUILD_CFLAGS} \
-               CXXFLAGS=${BUILD_CXXFLAGS} \
-               CPPFLAGS=${BUILD_CPPFLAGS} \
-               LDFLAGS="${BUILD_LDFLAGS} -static" \
-               CC=${BUILD_CC} \
-               CXX=${BUILD_CXX} \
-               econf --disable-shared $(use_enable seccomp libseccomp)
+               build_src_configure
        fi
 
        multilib-minimal_src_configure
@@ -94,10 +100,10 @@ multilib_src_compile() {
 }
 
 src_compile() {
-       if tc-is-cross-compiler && ! ROOT=/ has_version "~${CATEGORY}/${P}" ; 
then
+       if need_build_file; then
                emake -C "${WORKDIR}"/build/src magic.h #586444
                emake -C "${WORKDIR}"/build/src file
-               PATH="${WORKDIR}/build/src:${PATH}"
+               local -x PATH="${WORKDIR}/build/src:${PATH}"
        fi
        multilib-minimal_src_compile
 

Reply via email to