W dniu pią, 22.06.2018 o godzinie 13∶22 +0200, użytkownik Michael
Haubenwallner napisał:
> On 06/20/2018 09:56 PM, Michał Górny wrote:
> > W dniu śro, 20.06.2018 o godzinie 19∶49 +0200, użytkownik Michael
> > Haubenwallner napisał:
> > > Download and apply patches found in Cygwin's gcc.cygport, maintained
> > > at
> > > github/cygwinports/gcc, for a compiler running on cygwin.  The ebuild
> > > can define the cygwinports' git commit id as CYGWINPORTS_GITREV.
> > > ---
> > >  eclass/toolchain.eclass | 28 ++++++++++++++++++++++++++++
> > >  1 file changed, 28 insertions(+)
> > > 
> > > diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
> > > index faf96d2a41f..a16bfadc301 100644
> > > --- a/eclass/toolchain.eclass
> > > +++ b/eclass/toolchain.eclass
> > > @@ -309,6 +309,14 @@ gentoo_urls() {
> > >  #                        ten Brugge's bounds-checking patches. If
> > > you want to use a patch
> > >  #                        for an older gcc version with a new gcc,
> > > make sure you set
> > >  #                        HTB_GCC_VER to that version of gcc.
> > > +#
> > > +#        CYGWINPORTS_GITREV
> > > +#                        If set, this variable signals that we
> > > should apply additional patches
> > > +#                        maintained by upstream Cygwin developers at
> > > github/cygwinports/gcc,
> > > +#                        using the specified git commit id
> > > there.  The list of patches to
> > > +#                        apply is extracted from gcc.cygport,
> > > maintained there as well.
> > > +#                        This is done for compilers running on
> > > Cygwin, not for cross compilers
> > > +#                        with a Cygwin target.
> > >  get_gcc_src_uri() {
> > >   export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
> > >   export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
> > > @@ -375,6 +383,10 @@ get_gcc_src_uri() {
> > >           fi
> > >   fi
> > >  
> > > + # Cygwin patches from https://github.com/cygwinports/gcc
> > > + [[ -n ${CYGWINPORTS_GITREV} ]] && \
> > > +         GCC_SRC_URI+=" elibc_Cygwin? (
> > > https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.zip
> > > )"
> > 
> > Why not .tar.gz?
> 
> Didn't know .tar.gz works - the webpage provides [Download ZIP] only, thanks!
> 
> > 
> > > +
> > >   echo "${GCC_SRC_URI}"
> > >  }
> > >  
> > > @@ -481,6 +493,8 @@ gcc_quick_unpack() {
> > >  
> > >   use_if_iuse boundschecking && unpack "bounds-checking-gcc-
> > > ${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
> > >  
> > > + [[ -n ${CYGWINPORTS_GITREV} ]] && use elibc_Cygwin && unpack
> > > "${CYGWINPORTS_GITREV}.zip"
> > > +
> > >   popd > /dev/null
> > >  }
> > >  
> > > @@ -505,6 +519,7 @@ toolchain_src_prepare() {
> > >   fi
> > >   do_gcc_HTB_patches
> > >   do_gcc_PIE_patches
> > > + do_gcc_CYGWINPORTS_patches
> > >   epatch_user
> > >  
> > >   if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened )
> > > && ! use vanilla ; then
> > > @@ -645,6 +660,19 @@ do_gcc_PIE_patches() {
> > >   BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-
> > > ${PIE_VER}"
> > >  }
> > >  
> > > +do_gcc_CYGWINPORTS_patches() {
> > > + [[ -n ${CYGWINPORTS_GITREV} ]] || return 0
> > > + use elibc_Cygwin || return 0
> > > +
> > > + local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}"
> > > + for p in $(
> > > +         eval "$(sed -ne '/PATCH_URI="/,/"/p' <
> > > "${d}"/gcc.cygport)"
> > 
> > The eval here is completely unnecessary, and can easily wreak havoc. 
> > Don't do that.
> 
> Erm - multiline commands from $() seem to fail without eval:
> 
> # sed -ne '/PATCH_URI="/,/"/p' < ./gcc.cygport
> PATCH_URI="
> 0001-share-mingw-fset-stack-executable-with-cygwin.patch
> ...
> "
> 
> # $(sed -ne '/PATCH_URI="/,/"/p' < ./gcc.cygport)
> -bash: PATCH_URI=": command not found
> 
> # eval "$(sed -ne '/PATCH_URI="/,/"/p' < ./gcc.cygport)"
> 
> # declare -p PATCH_URI
> declare -- PATCH_URI="
> 0001-share-mingw-fset-stack-executable-with-cygwin.patch
> ...
> "
> 

It's not very hard if you try to find another solution to the problem
rather than trying to force your solution to work without eval.

For example:

local patches=()
readarray -t patches < <(sed -e '1,/PATCH_URI="/d;/"/,$d' < gcc.cygport)

-- 
Best regards,
Michał Górny

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

Reply via email to