最近着实被恶心到了,开始统计所有第三方库的版本信息,公司十几个项目都要看,要吐了。
然后就想有没有什么简单的方法呢,工具化。
日志格式大概是这样的:
1065 17:02:19 (cd /home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/curl-7.74.0; chmod 777 configure; rm -f include/curl/curlbuild.h;./configure --without-libidn --without-zlib --without-librtmp --disable-manual --with-ssl=/home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/openssl-1.1.1n --disable-ldap --disable-rtsp --disable-dict --disable-file --disable-ftp --disable-gopher --disable-imap --disable-pop3 --disable-smtp --disabl e-telnet --disable-tftp --disable-libcurl-option --enable-shared=no CPPFLAGS="-I/home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/openssl-1.1.1n/include" LDFLAGS="-L/home/jenkins/workspace/Backend/Platform/Lync/LyncGW/build/Lyncgw/../Vendors/openssl-1.1.1n";make;)
想了想,我们只要看vendors后面的值,所以来一发小工具还是可以的
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const string key = "Vendors";
void show(std::string str)
{
std::size_t found = str.find(key);
while (found!=std::string::npos)
{
found += key.size();//to key last
found ++;//to next val
auto found_end =str.find_first_of("/",found);//to next split char
if(found_end == std::string::npos)
break;
if(found_end - found > 2)
std::cout<<str.substr(found,found_end - found)<<std::endl;
found = str.find(key, found_end + 1);
}
}
int main(int argc, char** argv)
{
fstream f("a");
while(!f.eof())
{
std::string str;
f>>str;
/* cout<<"file data"<<tmp<<endl; */
show(str);
}
return 1;
}
最后就是我们熟悉的管道命令
./a.out |sort|uniq