I'm attaching a proposed hook script. Will this work for you?
#!/bin/bash # Force use of clang instead of GCC. function setup_clang() { local GCC_VERSION=$(readlink /usr/bin/gcc | sed 's/^gcc\-//')
apt-get -y "${APTGETOPT[@]}" install clang echo -e "\e[33mReplace gcc, g++ & cpp by clang\e[m" for compiler in gcc-"$GCC_VERSION" cpp-"$GCC_VERSION" g++-"$GCC_VERSION"; do rm /usr/bin/$compiler && ln -s /usr/bin/clang /usr/bin/$compiler done echo -e "\e[33mCheck if gcc, g++ & cpp are actually clang\e[m" usr/bin/gcc --version| grep clang > /dev/null || exit 1 } setup_clang
At Sat, 23 Feb 2013 22:39:04 +0900, Hideki Yamane wrote: > > diff -Nru pbuilder-0.213/bash_completion.d/pbuilder > pbuilder-0.213+nmu1/bash_completion.d/pbuilder > --- pbuilder-0.213/bash_completion.d/pbuilder 2012-03-25 14:53:45.000000000 > +0900 > +++ pbuilder-0.213+nmu1/bash_completion.d/pbuilder 2013-02-11 > 14:21:58.000000000 +0900 > @@ -60,7 +60,7 @@ > --aptconfdir --timeout --override-config --binary-arch \ > --preserve-buildplace --bindmounts --debug --twice > --autocleanaptcache \ > --compressprog --debootstrapopts --save-after-login > --save-after-exec \ > - --debootstrap' \ > + --debootstrap --with-clang' \ > -- "$cur" ) ) > if [[ $prev = @(--aptcache|--hookdir) ]]; then > # Optionally provide a directory > diff -Nru pbuilder-0.213/debian/changelog pbuilder-0.213+nmu1/debian/changelog > --- pbuilder-0.213/debian/changelog 2012-10-08 08:30:05.000000000 +0900 > +++ pbuilder-0.213+nmu1/debian/changelog 2013-02-11 15:01:07.000000000 > +0900 > @@ -1,3 +1,13 @@ > +pbuilder (0.213+nmu1) UNRELEASED; urgency=low > + > + [ Hideki Yamane ] > + * Non-maintainer upload. > + * add "--with-clang" option to build your package with clang. > + It would replace GCC by default(Thanks Luca Falavigna > <dktrkr...@debian.org>), > + also you can specify it any version with GCC_VERSION environment > variable. > + > + -- Hideki Yamane <henr...@debian.org> Mon, 11 Feb 2013 14:22:38 +0900 > + > pbuilder (0.213) unstable; urgency=low > > [ Beatrice Torracca ] > diff -Nru pbuilder-0.213/pbuilder-buildpackage > pbuilder-0.213+nmu1/pbuilder-buildpackage > --- pbuilder-0.213/pbuilder-buildpackage 2012-03-13 17:25:15.000000000 > +0900 > +++ pbuilder-0.213+nmu1/pbuilder-buildpackage 2013-02-11 15:18:41.000000000 > +0900 > @@ -97,6 +97,9 @@ > executehooks "D" > trap saveaptcache_umountproc_cleanbuildplace_trap exit sighup sigpipe > checkbuilddep "$PACKAGENAME" > +if [ "$CLANG" = "yes" ]; then > + setup_clang > +fi > save_aptcache > trap umountproc_cleanbuildplace_trap exit sighup sigpipe > > diff -Nru pbuilder-0.213/pbuilder-buildpackage-funcs > pbuilder-0.213+nmu1/pbuilder-buildpackage-funcs > --- pbuilder-0.213/pbuilder-buildpackage-funcs 2012-03-31 > 13:51:11.000000000 +0900 > +++ pbuilder-0.213+nmu1/pbuilder-buildpackage-funcs 2013-02-11 > 16:44:51.000000000 +0900 > @@ -112,3 +112,22 @@ > export CCACHE_DIR="$CCACHEDIR" > fi > } > + > +function setup_clang() { > + # set appropriate GCC version. > + if [ -z $GCC_VERSION ]; then > + GCC_VERSION=$(readlink /usr/bin/gcc | sed 's/^gcc\-//') > + fi > + > + $CHROOTEXEC usr/bin/apt-get -y "${APTGETOPT[@]}" install clang > + > + echo -e "\e[33mReplace gcc, g++ & cpp by clang\e[m" > + for compiler in gcc-"$GCC_VERSION" cpp-"$GCC_VERSION" g++-"$GCC_VERSION" > + do > + $CHROOTEXEC rm /usr/bin/$compiler && > + $CHROOTEXEC ln -s /usr/bin/clang /usr/bin/$compiler > + done > + > + echo -e "\e[33mCheck if gcc, g++ & cpp are actually clang\e[m" > + $CHROOTEXEC usr/bin/gcc --version| grep clang > /dev/null || exit 1 > +} > diff -Nru pbuilder-0.213/pbuilder-checkparams > pbuilder-0.213+nmu1/pbuilder-checkparams > --- pbuilder-0.213/pbuilder-checkparams 2012-03-09 07:54:41.000000000 > +0900 > +++ pbuilder-0.213+nmu1/pbuilder-checkparams 2013-02-11 14:20:54.000000000 > +0900 > @@ -260,6 +260,10 @@ > TWICE="yes" > shift; > ;; > + --with-clang) > + CLANG="yes" > + shift; > + ;; > --) # end of processing for this > shift; > break; > diff -Nru pbuilder-0.213/pbuilder-modules pbuilder-0.213+nmu1/pbuilder-modules > --- pbuilder-0.213/pbuilder-modules 2012-03-31 13:50:46.000000000 +0900 > +++ pbuilder-0.213+nmu1/pbuilder-modules 2013-02-11 14:51:33.000000000 > +0900 > @@ -79,6 +79,7 @@ > --debootstrapopts [debootstrap options] > --save-after-login/--save-after-exec > --debootstrap [debootstrap|cdebootstrap] > + --with-clang > > pdebuild-specific pbuilder-options: > --pbuilderroot [command to obtain root privilege for pbuilder] > diff -Nru pbuilder-0.213/pbuilder.8 pbuilder-0.213+nmu1/pbuilder.8 > --- pbuilder-0.213/pbuilder.8 2012-03-09 07:54:41.000000000 +0900 > +++ pbuilder-0.213+nmu1/pbuilder.8 2013-02-11 14:35:27.000000000 +0900 > @@ -534,6 +534,10 @@ > properly. The resulting packages are the ones from the second build. > > .TP > +.BI "\-\-with\-clang" > +Build the package with clang, instead of gcc. > + > +.TP > .BI "\-\-preserve\-buildplace" > Do not clean the > .B "\-\-buildplace"