Bug#471513: Please add an example hook for using gcc snapshot easily
Loïc Minier
lool at dooz.org
Sat Jan 2 16:25:09 UTC 2010
Hi
On Tue, Mar 18, 2008, Kumar Appaiah wrote:
> Please consider adding an example hook for use with gcc-snapshot build
> testing. I have attached an example which does the needful for gcc,
> g++ and gfortran (which I needed), which you may use to base the
> example.
Thanks; I think that's a good idea; I have some concerns with the
implementation though:
> #!/bin/bash
> aptitude -R -y install gcc-snapshot
This assumes aptitude is installed, but it might not be; consider using
apt-get instead. I suggest you look at other sample hooks in pbuilder
e.g. the lintian one.
> cat > /usr/local/bin/gcc-snapshot <<EOF
Adding files not tracked by dpkg in the chroot isn't optimal; also,
can't the gcc-snapshot package provide this wrapper instead? It
certainly seems cumbersome to have to create such things for every use
of gcc-snapshot IMO:
> #!/bin/sh
> LD_LIBRARY_PATH=/usr/lib/gcc-snapshot/lib:$LD_LIBRARY_PATH
> PATH=/usr/lib/gcc-snapshot/bin:$PATH
> gcc "\$@"
> EOF
Note that this will add "." to LD_LIBRARY_PATH; you should check
whether LD_LIBRARY_PATH is set before appending/prepending to it. e.g.
LD_LIBRARY_PATH="foo${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
> chmod 755 /usr/local/bin/gcc-snapshot
> cat > /usr/local/bin/g++-snapshot <<EOF
> #!/bin/sh
> LD_LIBRARY_PATH=/usr/lib/gcc-snapshot/lib:$LD_LIBRARY_PATH
> PATH=/usr/lib/gcc-snapshot/bin:$PATH
> g++ "\$@"
> EOF
> chmod 755 /usr/local/bin/g++-snapshot
> cat > /usr/local/bin/gfortran-snapshot <<EOF
> #!/bin/sh
> LD_LIBRARY_PATH=/usr/lib/gcc-snapshot/lib:$LD_LIBRARY_PATH
> PATH=/usr/lib/gcc-snapshot/bin:$PATH
> g++ "\$@"
> EOF
> chmod 755 /usr/local/bin/gfortran-snapshot
You might want to avoid repetition by wrapping that in a function.
> rm -f /usr/bin/gcc /usr/bin/g++ /usr/bin/gfortran
> ln -s /usr/local/bin/gcc-snapshot /usr/bin/gcc
> ln -s /usr/local/bin/g++-snapshot /usr/bin/g++
> ln -s /usr/local/bin/gfortran-snapshot /usr/bin/gfortran
> #/bin/bash < /dev/tty > /dev/tty
Instead of rm + ln, you could ln -sf, but again I find it bad style to
replace dpkg-owned files with your changes. You could use dpkg-divert,
or simply install the above as /usr/local/bin/gcc instead of diverting
/usr/bin/gcc.
Thanks!
--
Loïc Minier
More information about the Pbuilder-maint
mailing list