[实践OK] rpmbuild打包错误:*** ERROR: No build ID note found in ******,以及Httpsqs是否真的支持Libevent1.4.13? 不指定

jackxiang 2017-6-23 00:10 | |
背景:在打RPMBUILD一个张宴兄弟的httpsqs结合Libevent1.4.13的包的时候,出现错误,本来他写的是Libevent2.0,顾问在微信问了张宴兄弟下他本人说1.4.13也是也没有啥问题的,就要问了:为何要降级,因为Memcached也需要这个Libevent的低版本的,没办法,Httpsqs所以来的Libevnet也跟着降吧。出现问题:ERROR: No build ID note found in

BuildRequires: gcc,gcc-c++,make,tokyocabinet = 1.4.48,libevent >= 1.4.13
Requires: tokyocabinet = 1.4.48,libevent >= 1.4.13



还不够,得加这一行,因为不加会提示:
AutoReqProv:   no
Rpmbuild自己会自动依赖一些so动态链接库的东西,给关掉:

rpm -ihv /home/test/rpmbuild/RPMS/x86_64/httpsqs-1.7-170522172954.el6.x86_64.rpm
error: Failed dependencies:
        libevent-2.0.so.5()(64bit) is needed by httpsqs-1.7-170522172954.el6.x86_64


问题依旧:
service httpsqs start
Starting httpsqs: /usr/local/httpsqs/httpsqs: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
                                                           [FAILED]

反查一个源码,如下:
tar -zxvf httpsqs-1.7.tar.gz
httpsqs-1.7/
httpsqs-1.7/httpsqs.c
httpsqs-1.7/prename.h
httpsqs-1.7/prename.c
httpsqs-1.7/Makefile
httpsqs-1.7/.Makefile.swp
httpsqs-1.7/httpsqs   (这个文件应该是一个二进制文件,去了编译不过去,报错)

gcc -o httpsqs httpsqs.c prename.c -Wl,-rpath,/usr/local/libevent/lib/:/usr/local/tokyocabinet/lib/ -L/usr/local/libevent/lib/ -levent -L/usr/local/tokyocabinet/lib/ -ltokyocabinet -I/usr/local/libevent/include/ -I/usr/local/tokyocabinet/include/ -lz -lbz2 -lrt -lpthread -lm -lc -O2 -g
httpsqs.c: In function 'httpsqs_handler':
httpsqs.c:350: error: 'struct evhttp_request' has no member named 'uri_elems'
make: *** [httpsqs] Error 1
error: Bad exit status from /home/test/rpmbuild/tmp/rpm-tmp.OyM3VG (%build)
果然:
grep -r "libevent-2.0" ./
Binary file ./httpsqs matches

[root@  httpsqs]# stat httpsqs
  File: `httpsqs'
  Size: 20184           Blocks: 40         IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 1066707     Links: 1
Access: (4755/-rwsr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-05-22 17:58:26.000000000 +0800
Modify: 2017-05-22 17:58:26.000000000 +0800
Change: 2017-05-22 17:58:50.635000020 +0800
[root@  httpsqs]# ldd httpsqs
        linux-vdso.so.1 =>  (0x00007ffd27464000)
        libevent-2.0.so.5 => not found
        libtokyocabinet.so.9 => /usr/local/tokyocabinet/lib/libtokyocabinet.so.9 (0x00007fed13df0000)
        libz.so.1 => /lib64/libz.so.1 (0x0000003cf6c00000)
        libbz2.so.1 => /lib64/libbz2.so.1 (0x0000003cfc000000)
        librt.so.1 => /lib64/librt.so.1 (0x0000003cf7c00000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003cf7400000)
        libm.so.6 => /lib64/libm.so.6 (0x0000003cf8000000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003cf7000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003cf6800000)
但是编译是从这儿编译的:
rpm -qa|grep libevent
libevent-devel-1.4.13-4.el6.x86_64
libevent-1.4.13-4.el6.x86_64
libevent-doc-1.4.13-4.el6.noarch
libevent-headers-1.4.13-4.el6.noarch
难怪了,原来写二进制里面了:^@^@^@^@^@^@^@^@libevent-2.0.so.5^@__gmon_start__^@_Jv_RegisterClass
稍微深入到源码看一下:

rpm2cpio libevent-2.0.22-170116172306.el6.x86_64.rpm |cpio -div
/usr/local/libevent/include/event2/http_struct.h

httpsqs.c:350: error: ‘struct evhttp_request’ has no member named ‘uri_elems’

struct evhttp_request{#57行到123行都是这个结构体的,而这个uri_elems定义在在98行。
  struct evhttp_uri *uri_elems;   /* uri elements */
}

张宴兄弟的源码里文件之httpsqs.c:350行:
350         httpsqs_query_part = evhttp_uri_get_query(req->uri_elems);

而旧的版本没有这个http_struct.h文件及结构体,如下:
rpm -ql libevent-headers-1.4.13-4.el6.noarch
/usr/include/evdns.h
/usr/include/event-config.h
/usr/include/event.h
/usr/include/evhttp.h
/usr/include/evrpc.h
/usr/include/evutil.h

所以,张宴兄弟的说法不成立。


还不放心,看一下源码包,不看RPM包,有可能RPM包没有打进来?
http://pkgs.fedoraproject.org/repo/pkgs/libevent/libevent-1.4.13-stable.tar.gz/
DownLoad:http://pkgs.fedoraproject.org/repo/pkgs/libevent/libevent-1.4.13-stable.tar.gz/0b3ea18c634072d12b3c1ee734263664/libevent-1.4.13-stable.tar.gz
解压后,再用Editplus查找:uri_elems,并没有找到这个结构体变量,如下:
-- 在文件中查找: uri_elems in E:\download\libevent-1.4.13-stable excl *.* --
找到 0 个事件 (在 0 个文件中)。
输出完成 (耗时 0 秒)

So,张宴兄弟长时间没有看这块代码,应该是记错了!!!



在Fedora14中打rpm包,是没有/usr/src/redhat这个目录的,而是要建立~/rpmbuild目录,并建立SOURCES、SPECS、RPMS等相应目录。其它步骤相同。
但是在rpmbuild -ba时,遇到如下错误:
*** ERROR: No build ID note found in /home/wuyang/rpmbuild/BUILDROOT/******
error: Bad exit status from /var/tmp/rpm-tmp.BPd1OI (%install)


gcc -o httpsqs httpsqs.c prename.c -Wl,-rpath,/usr/local/libevent/lib/:/usr/local/tokyocabinet/lib/ -L/usr/local/libevent/lib/ -levent -L/usr/local/tokyocabinet/lib/ -ltokyocabinet -I/usr/local/libevent/include/ -I/usr/local/tokyocabinet/include/ -lz -lbz2 -lrt -lpthread -lm -lc -O2 -g
修改为:
gcc -o httpsqs httpsqs.c prename.c -Wl,-rpath,/usr/lib64:/usr/local/tokyocabinet/lib/ -L/usr/lib64 -levent -L/usr/local/tokyocabinet/lib/ -ltokyocabinet -I/usr/include/ -I/usr/local/tokyocabinet/include/ -lz -lbz2 -lrt -lpthread -lm -lc -O2 -g
[root@yum_rpmbuild-centos6_bj_sjs_10_71_183_1** httpsqs-1.7]# gcc -o httpsqs httpsqs.c prename.c -Wl,-rpath,/usr/lib64:/usr/local/tokyocabinet/lib/ -L/usr/lib64 -levent -L/usr/local/tokyocabinet/lib/ -ltokyocabinet -I/usr/include/ -I/usr/local/tokyocabinet/include/ -lz -lbz2 -lrt -lpthread -lm -lc -O2 -g
httpsqs.c: In function ‘httpsqs_handler’:
httpsqs.c:350: error: ‘struct evhttp_request’ has no member named ‘uri_elems’

rpm -ql libevent-1.4.13-4.el6.x86_64
/usr/lib64/libevent-1.4.so.2
/usr/lib64/libevent-1.4.so.2.1.3
/usr/lib64/libevent_core-1.4.so.2
/usr/lib64/libevent_core-1.4.so.2.1.3
/usr/lib64/libevent_extra-1.4.so.2
/usr/lib64/libevent_extra-1.4.so.2.1.3
/usr/share/doc/libevent-1.4.13
/usr/share/doc/libevent-1.4.13/README
rpm -ql libevent-devel-1.4.13-4.el6.x86_64
/usr/bin/event_rpcgen.py
/usr/lib64/libevent.a
/usr/lib64/libevent.so
/usr/lib64/libevent_core.a
/usr/lib64/libevent_core.so
/usr/lib64/libevent_extra.a
/usr/lib64/libevent_extra.so
/usr/share/man/man3/evdns.3.gz
/usr/share/man/man3/event.3.gz
rpm -ql libevent-headers-1.4.13-4.el6.noarch
/usr/include/evdns.h
/usr/include/event-config.h
/usr/include/event.h
/usr/include/evhttp.h
/usr/include/evrpc.h
/usr/include/evutil.h




解决方法是在.spec文件中任意位置添加如下参数:
%define __debug_install_post   \
   %{_rpmconfigdir}/find-debuginfo.sh %{?_find_debuginfo_opts} "%{_builddir}/%{?buildsubdir}"\
%{nil}

重新打包,即可。
另外最后生成的rpm包是在/RPMS/i686中

来自:http://blog.csdn.net/onlyou930/article/details/6995645

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/9218/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]