1 |
W dniu pią, 22.06.2018 o godzinie 13∶22 +0200, użytkownik Michael |
2 |
Haubenwallner napisał: |
3 |
> On 06/20/2018 09:56 PM, Michał Górny wrote: |
4 |
> > W dniu śro, 20.06.2018 o godzinie 19∶49 +0200, użytkownik Michael |
5 |
> > Haubenwallner napisał: |
6 |
> > > Download and apply patches found in Cygwin's gcc.cygport, maintained |
7 |
> > > at |
8 |
> > > github/cygwinports/gcc, for a compiler running on cygwin. The ebuild |
9 |
> > > can define the cygwinports' git commit id as CYGWINPORTS_GITREV. |
10 |
> > > --- |
11 |
> > > eclass/toolchain.eclass | 28 ++++++++++++++++++++++++++++ |
12 |
> > > 1 file changed, 28 insertions(+) |
13 |
> > > |
14 |
> > > diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass |
15 |
> > > index faf96d2a41f..a16bfadc301 100644 |
16 |
> > > --- a/eclass/toolchain.eclass |
17 |
> > > +++ b/eclass/toolchain.eclass |
18 |
> > > @@ -309,6 +309,14 @@ gentoo_urls() { |
19 |
> > > # ten Brugge's bounds-checking patches. If |
20 |
> > > you want to use a patch |
21 |
> > > # for an older gcc version with a new gcc, |
22 |
> > > make sure you set |
23 |
> > > # HTB_GCC_VER to that version of gcc. |
24 |
> > > +# |
25 |
> > > +# CYGWINPORTS_GITREV |
26 |
> > > +# If set, this variable signals that we |
27 |
> > > should apply additional patches |
28 |
> > > +# maintained by upstream Cygwin developers at |
29 |
> > > github/cygwinports/gcc, |
30 |
> > > +# using the specified git commit id |
31 |
> > > there. The list of patches to |
32 |
> > > +# apply is extracted from gcc.cygport, |
33 |
> > > maintained there as well. |
34 |
> > > +# This is done for compilers running on |
35 |
> > > Cygwin, not for cross compilers |
36 |
> > > +# with a Cygwin target. |
37 |
> > > get_gcc_src_uri() { |
38 |
> > > export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}} |
39 |
> > > export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}} |
40 |
> > > @@ -375,6 +383,10 @@ get_gcc_src_uri() { |
41 |
> > > fi |
42 |
> > > fi |
43 |
> > > |
44 |
> > > + # Cygwin patches from https://github.com/cygwinports/gcc |
45 |
> > > + [[ -n ${CYGWINPORTS_GITREV} ]] && \ |
46 |
> > > + GCC_SRC_URI+=" elibc_Cygwin? ( |
47 |
> > > https://github.com/cygwinports/gcc/archive/${CYGWINPORTS_GITREV}.zip |
48 |
> > > )" |
49 |
> > |
50 |
> > Why not .tar.gz? |
51 |
> |
52 |
> Didn't know .tar.gz works - the webpage provides [Download ZIP] only, thanks! |
53 |
> |
54 |
> > |
55 |
> > > + |
56 |
> > > echo "${GCC_SRC_URI}" |
57 |
> > > } |
58 |
> > > |
59 |
> > > @@ -481,6 +493,8 @@ gcc_quick_unpack() { |
60 |
> > > |
61 |
> > > use_if_iuse boundschecking && unpack "bounds-checking-gcc- |
62 |
> > > ${HTB_GCC_VER}-${HTB_VER}.patch.bz2" |
63 |
> > > |
64 |
> > > + [[ -n ${CYGWINPORTS_GITREV} ]] && use elibc_Cygwin && unpack |
65 |
> > > "${CYGWINPORTS_GITREV}.zip" |
66 |
> > > + |
67 |
> > > popd > /dev/null |
68 |
> > > } |
69 |
> > > |
70 |
> > > @@ -505,6 +519,7 @@ toolchain_src_prepare() { |
71 |
> > > fi |
72 |
> > > do_gcc_HTB_patches |
73 |
> > > do_gcc_PIE_patches |
74 |
> > > + do_gcc_CYGWINPORTS_patches |
75 |
> > > epatch_user |
76 |
> > > |
77 |
> > > if ( tc_version_is_at_least 4.8.2 || use_if_iuse hardened ) |
78 |
> > > && ! use vanilla ; then |
79 |
> > > @@ -645,6 +660,19 @@ do_gcc_PIE_patches() { |
80 |
> > > BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie- |
81 |
> > > ${PIE_VER}" |
82 |
> > > } |
83 |
> > > |
84 |
> > > +do_gcc_CYGWINPORTS_patches() { |
85 |
> > > + [[ -n ${CYGWINPORTS_GITREV} ]] || return 0 |
86 |
> > > + use elibc_Cygwin || return 0 |
87 |
> > > + |
88 |
> > > + local p d="${WORKDIR}/gcc-${CYGWINPORTS_GITREV}" |
89 |
> > > + for p in $( |
90 |
> > > + eval "$(sed -ne '/PATCH_URI="/,/"/p' < |
91 |
> > > "${d}"/gcc.cygport)" |
92 |
> > |
93 |
> > The eval here is completely unnecessary, and can easily wreak havoc. |
94 |
> > Don't do that. |
95 |
> |
96 |
> Erm - multiline commands from $() seem to fail without eval: |
97 |
> |
98 |
> # sed -ne '/PATCH_URI="/,/"/p' < ./gcc.cygport |
99 |
> PATCH_URI=" |
100 |
> 0001-share-mingw-fset-stack-executable-with-cygwin.patch |
101 |
> ... |
102 |
> " |
103 |
> |
104 |
> # $(sed -ne '/PATCH_URI="/,/"/p' < ./gcc.cygport) |
105 |
> -bash: PATCH_URI=": command not found |
106 |
> |
107 |
> # eval "$(sed -ne '/PATCH_URI="/,/"/p' < ./gcc.cygport)" |
108 |
> |
109 |
> # declare -p PATCH_URI |
110 |
> declare -- PATCH_URI=" |
111 |
> 0001-share-mingw-fset-stack-executable-with-cygwin.patch |
112 |
> ... |
113 |
> " |
114 |
> |
115 |
|
116 |
It's not very hard if you try to find another solution to the problem |
117 |
rather than trying to force your solution to work without eval. |
118 |
|
119 |
For example: |
120 |
|
121 |
local patches=() |
122 |
readarray -t patches < <(sed -e '1,/PATCH_URI="/d;/"/,$d' < gcc.cygport) |
123 |
|
124 |
-- |
125 |
Best regards, |
126 |
Michał Górny |