www.digitalmars.com         C & C++   DMDScript  

D.gnu - setup-gcc.sh

reply "eles" <eles eles.com> writes:
Hello,

  What is the purpose of this code in setup-gcc.sh?


test -h "$d_gccsrc/gcc/d" && rm "$d_gccsrc/gcc/d"
test -d "$d_gccsrc/libphobos" && rm -r "$d_gccsrc/libphobos"
if test -e "$d_gccsrc/gcc/d" -o -e "$d_gccsrc/libphobos"; then
     echo "error: cannot update gcc source, please remove D 
sources by hand."
     exit 1
fi

For example, the line

test -h "$d_gccsrc/gcc/d" && rm "$d_gccsrc/gcc/d"

should return 0 if $d_gccsrc/gcc/d both exists and is a symlink. 
The command fails if any of the two is not true, and the intended 
purpose is to remove the original D sources from the gcc package 
(that is, when the "d" folder exists, but is *not* a symlink).

However, if the "d" folder exists and is *not* a symlink, the 
exit code of "test" will be 1, that is the command will *not* 
succeed.

In that case, the "rm" part will not be executed, which destroys 
the purpose of it.

Do I miss something?


More, why testing for symlink-ness in the first place? Existing 
sources (or symlink towards them) should be deleted and, then, 
newly-provided sources should be provided, that's all. What if an 
existing symlink exists, but points to an outdated D source?
Jun 07 2013
next sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
Slightly different question about setup-gcc.sh.

If you run it on the gcc-4.8.1 sources, having run it previously, you get the
following error message:

	Reversed (or previously applied) patch detected!  Assume -R? [n]

... what's the correct response here? :-)
Jun 07 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
On 7 June 2013 13:55, Joseph Rushton Wakeling
<joseph.wakeling webdrake.net> wrote:
 Slightly different question about setup-gcc.sh.

 If you run it on the gcc-4.8.1 sources, having run it previously, you get the
 following error message:

         Reversed (or previously applied) patch detected!  Assume -R? [n]

 ... what's the correct response here? :-)
You should run setup-gcc.sh with --update. That skips applying the patches (again) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Jun 07 2013
prev sibling next sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 06/07/2013 04:05 PM, Iain Buclaw wrote:
 You should run setup-gcc.sh with --update.  That skips applying the
 patches (again)
Cool, thanks. :-)
Jun 07 2013
prev sibling parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 7 June 2013 13:26, eles <eles eles.com> wrote:
 Hello,

  What is the purpose of this code in setup-gcc.sh?


 test -h "$d_gccsrc/gcc/d" && rm "$d_gccsrc/gcc/d"
 test -d "$d_gccsrc/libphobos" && rm -r "$d_gccsrc/libphobos"
 if test -e "$d_gccsrc/gcc/d" -o -e "$d_gccsrc/libphobos"; then
     echo "error: cannot update gcc source, please remove D sources by hand."
     exit 1
 fi

 For example, the line

 test -h "$d_gccsrc/gcc/d" && rm "$d_gccsrc/gcc/d"

 should return 0 if $d_gccsrc/gcc/d both exists and is a symlink. The command
 fails if any of the two is not true, and the intended purpose is to remove
 the original D sources from the gcc package (that is, when the "d" folder
 exists, but is *not* a symlink).

 However, if the "d" folder exists and is *not* a symlink, the exit code of
 "test" will be 1, that is the command will *not* succeed.

 In that case, the "rm" part will not be executed, which destroys the purpose
 of it.

 Do I miss something?


 More, why testing for symlink-ness in the first place? Existing sources (or
 symlink towards them) should be deleted and, then, newly-provided sources
 should be provided, that's all. What if an existing symlink exists, but
 points to an outdated D source?
The gcc/d folder is symlinked to the gdc sources, so any updates in gdc will reflect in the gcc/d tree. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Jun 07 2013
parent reply "eles" <eles eles.com> writes:
On Friday, 7 June 2013 at 14:07:27 UTC, Iain Buclaw wrote:
 On 7 June 2013 13:26, eles <eles eles.com> wrote:

 The gcc/d folder is symlinked to the gdc sources, so any 
 updates in
 gdc will reflect in the gcc/d tree.
I think there is a confusion. The code that I quoted used to workk with gcc-4.8 (4.8.0) source package of Debian/ubuntu, since it did *not* include a src/gcc/d/ subfolder and a src/libphobos/ subfolder. Things changed when the package was updated to gcc-4.8.1, as the changelog show it: http://ftp-master.metadata.debian.org/changelogs//main/g/gcc-4.8/gcc-4.8_4.8.1-2_changelog "* Build D and libphobos packages from this source package." That makes the gcc-4.8 (4.8.1) package to include a src/libphobos and a src/gcc/d folders. The code that I quoted in the beginning will fail with asking to manually remove the d sources form the gcc tree. The setup-gcc.sh should be modified accordingly: it does not try to remove the folders libphobos/ and gcc/d, still complains about their presence afterwards. BTW, what version of gdc does the gcc-4.8 (4.8.1) package ships with?
Jun 07 2013
parent reply Iain Buclaw <ibuclaw ubuntu.com> writes:
On 7 June 2013 16:28, eles <eles eles.com> wrote:
 On Friday, 7 June 2013 at 14:07:27 UTC, Iain Buclaw wrote:
 On 7 June 2013 13:26, eles <eles eles.com> wrote:

 The gcc/d folder is symlinked to the gdc sources, so any updates in
 gdc will reflect in the gcc/d tree.
I think there is a confusion. The code that I quoted used to workk with gcc-4.8 (4.8.0) source package of Debian/ubuntu, since it did *not* include a src/gcc/d/ subfolder and a src/libphobos/ subfolder.
Me and Matthias did this deliberately to make maintenance easier.
 Things changed when the package was updated to gcc-4.8.1, as the changelog
 show it:

 http://ftp-master.metadata.debian.org/changelogs//main/g/gcc-4.8/gcc-4.8_4.8.1-2_changelog

 "* Build D and libphobos packages from this source package."

 That makes the gcc-4.8 (4.8.1) package to include a src/libphobos and a
 src/gcc/d folders. The code that I quoted in the beginning will fail with
 asking to manually remove the d sources form the gcc tree.

 The setup-gcc.sh should be modified accordingly: it does not try to remove
 the folders libphobos/ and gcc/d, still complains about their presence
 afterwards.
So you must remove these by hand. If it doesn't give that error to you, let me know. =)
 BTW, what version of gdc does the gcc-4.8 (4.8.1) package ships with?
It is the current development snapshot as of 1st June 2013... or there abouts. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
Jun 07 2013
parent "eles" <eles eles.com> writes:
On Friday, 7 June 2013 at 16:07:46 UTC, Iain Buclaw wrote:
 On 7 June 2013 16:28, eles <eles eles.com> wrote:
 On Friday, 7 June 2013 at 14:07:27 UTC, Iain Buclaw wrote:
 On 7 June 2013 13:26, eles <eles eles.com> wrote:
So you must remove these by hand. If it doesn't give that error to you, let me know. =)
Shouldn't be better to replace those lines: test -h "$d_gccsrc/gcc/d" && rm "$d_gccsrc/gcc/d" test -d "$d_gccsrc/libphobos" && rm -r "$d_gccsrc/libphobos" with: rm -rf "$d_gccsrc/gcc/d" rm -rf "$d_gccsrc/libphobos" ?
Jun 07 2013