sed -i '/####add parameter start/r /opt/custom_build_tool/rpmbuild-gcov' /usr/bin/rpmbuild
old_gcc=/usr/bin/gcc
old_gplus=/usr/bin/g++
old_rpmbuild=/usr/bin/rpmbuild
old_cplus=/usr/bin/c++
cat <<END1 > ${old_rpmbuild}-gcov
#!/bin/sh -x
${old_rpmbuild} "\$@"
ret=\$?
if [ \$ret -eq 0 ]; then
source /opt/custom_build_tool/upload.sh
echo "Gcov version has been compiledddddddddddddddddddddddddddd"
else
if file /usr/bin/gcc | grep ELF; then
exit \$ret
else
/usr/bin/gmv ${old_gcc}_gcov $old_gcc
/usr/bin/gmv ${old_gplus}_gcov $old_gplus
if [ -d /home/abuild/rpmbuild/BUILD ]; then
rm -rf /home/abuild/rpmbuild/BUILD
rm -rf /home/abuild/rpmbuild/BUILDROOT
else
rm -rf /root/rpmbuild/BUILD
rm -rf /root/rpmbuild/BUILDROOT
fi
${old_rpmbuild} "\$@"
ret=\$?
if [ \$ret -eq 0 ]; then
source /opt/custom_build_tool/upload.sh
else
exit \$ret
fi
fi
fi
END1
chmod 755 ${old_rpmbuild}-gcov
# add gcc args
mv $old_gcc $old_gcc"_gcov"
cat <<END1 > $old_gcc
#!/bin/sh -x
echo "\$@" | grep conftest &>/tmp/tmp.tmp
ret=\$?
if [ \$ret -eq 0 ]; then
${old_gcc}_gcov "\$@"
else
${old_gcc}_gcov %{?_with_gcov_args} "\$@"
fi
END1
chmod 755 $old_gcc $old_gcc"_gcov"
# add gplus args
if [ -f $old_gplus ]; then
mv $old_gplus $old_gplus"_gcov"
cat <<END1 > $old_gplus
#!/bin/sh -x
echo "\$@" | grep conftest &>/tmp/tmp.tmp
ret=\$?
if [ \$ret -eq 0 ]; then
${old_gplus}_gcov "\$@"
else
${old_gplus}_gcov %{?_with_gcov_args} "\$@"
fi
END1
chmod 755 $old_gplus $old_gplus"_gcov"
fi
# add cplus args
if [ -f $old_cplus ]; then
mv $old_cplus $old_cplus"_gcov"
cat <<END1 > $old_cplus
#!/bin/sh
echo "\$@" | grep conftest &>/tmp/tmp.tmp
ret=\$?
if [ \$ret -eq 0 ]; then
${old_cplus}_gcov "\$@"
else
${old_cplus}_gcov %{?_with_gcov_args} "\$@"
fi
END1
chmod 755 $old_cplus $old_cplus"_gcov"
fi
%endif
%if %{with_ub}
%post uploadbuild
sed -i '/####add parameter start/r /opt/custom_build_tool/rpmbuild-ub' /usr/bin/rpmbuild
bin_rpmbuild=/usr/bin/rpmbuild
cmd_rpmbuild=/usr/bin/rpmbuild-ub
cat <<END1 > ${cmd_rpmbuild}
#!/bin/sh -x
${bin_rpmbuild} "\$@"
ret=\$?
if [ \$ret -ne 0 ]; then
exit \$ret
fi
source /opt/custom_build_tool/upload_build.sh
END1
chmod 755 ${cmd_rpmbuild}
%endif
%if %{with_san}
%post san
cp -a /usr/bin/mv /usr/bin/gmv
chmod 4777 /usr/bin/gmv
sed -i '/####add parameter start/r /opt/custom_build_tool/rpmbuild-san' /usr/bin/rpmbuild
old_gcc=/usr/bin/gcc
old_gplus=/usr/bin/g++
old_rpmbuild=/usr/bin/rpmbuild
old_cplus=/usr/bin/c++
ulimit -v unlimited
ulimit -a
sed '2 i export ASAN_OPTIONS=abort_on_error=0:disable_coredump=0:detect_leaks=0\nexport LD_PRELOAD=/usr/lib64/libasan.so.4' -i /usr/lib/rpm/find-debuginfo.sh
head /usr/lib/rpm/find-debuginfo.sh
sed -i "$ a* hard as unlimited\n* soft as unlimited" /etc/security/limits.conf