2020-01-13 10:27:00 -05:00

88 lines
2.3 KiB
Bash

#!/bin/bash
# Author: yhon
# Copyright Huawei Technologies Co., Ltd. 2010-2018. All rights reserved.
set -e
cpath=/opt/custom_build_tool
build_dir=$(rpm --eval %{_builddir})
#if find /home/abuild/rpmbuild/RPMS/ -name "*.rpm" |egrep 'i386$|i586.rpm$|i686.rpm$' &> /dev/null; then
# echo "xdfgcov: Don't need i386 i586 i686"
# exit 0
#fi
ip="10.175.100.158"
user="root"
password="huawei"
http_dir="/srv/www/htdocs/gcov"
project=$(rpm --eval %{_project})
repo=$(rpm --eval %{_repository})
arch=$(rpm --eval %{_build_cpu})
release_dir="${http_dir}/${project}/${repo}/${arch}"
cd "${build_dir}"
if ! find ./ | grep 'gcno$' &> /dev/null; then
echo "xdf: No gcno file!!!"
exit 0
fi
module=$(find ./ | grep 'gcno$' | head -1 | awk -F '/' '{print $2}')
if [ -z "${module}" ]; then
echo "xdf: has some problem"
exit 1
#exit 0
fi
tar_name=${module}
if find /home/abuild/rpmbuild/RPMS/ | grep mirro ; then
tar_name="${module}-mirror"
mv "${module}" "${tar_name}"
module="${module}-mirror"
fi
if find /home/abuild/rpmbuild/RPMS/ | grep openvswitch | grep kmod ; then
tar_name="${module}-kmod"
fi
tar --exclude *.o --exclude *.so -czf "${tar_name}".tar.gz "${module}"
#chmod 777 /opt/custom_build_tool/client-tool-linux
/opt/custom_build_tool/client-tool-linux "$ip"#4123#cmdwait["mkdir -p $release_dir"]
/opt/custom_build_tool/client-tool-linux "$ip"#4123#sendfile["${module}.tar.gz,$release_dir/${module}.tar.gz"]
cd -
exit 0
echo "xdf: cp gcno and src to $release_dir"
SSH_CMD="mkdir -p $release_dir"
sh "$cpath"/sshcmd.sh -c "$SSH_CMD" -m "$ip" -u "$user" -p "$password"
if [ $? -ne 0 ]; then
echo "Failed in sshcmd.sh on mkdir -p $release_dir"
exit 1
#exit 0
fi
if find ./ | grep 'gcno$' &> /dev/null; then
echo "xdf: No gcno file!!!"
exit 0
fi
cd $build_dir
MODULE=$(find ./ | grep 'gcno$' | head -1 | awk -F '/' '{print $2}')
if [ -z "${MODULE}" ]; then
echo "xdf: has some problem"
exit 1
#exit 0
fi
tar --exclude *.o --exclude *.so -czf "${MODULE}".tar.gz "${MODULE}"
cd -
echo "xdf: $build_dir/$MODULE gcov done"
sh "$cpath"/sshscp.sh -p "$password" -s "$build_dir/${MODULE}.tar.gz" -d "root@$ip:$release_dir" -r
if [ $? -ne 0 ]; then
echo "Failed in sshscp.sh $build_dir/$MODULE"
exit 1
#exit 0
fi
echo "xdf:Gcov successful"
exit 0