这活真恶心。瞎忙还没意义。

编译libhdfs提示找不到xml2

错误提示

CMake Error at cmake-3.10.3/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):  
 Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)

用的cmake版本是3.10.

编译机是docker容器。本地测试好使

试着安装库依赖
yum install -y libxml2-devel

依旧不好使。我在其他环境的docker机器上测试cmake 3 cmake2都没问题

试着看cmakeerr log

看到了错误日志 发现 dladdr 连接错误,加上链接ldl修了半天才发现方向不对

手动指定 LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR目录到bootstrap,cmake命令家伙是哪个

-DLIBXML2_INCLUDE_DIR=/usr/include/libxml2/ -DLIBXML2_LIBRARY=/usr/lib64/

,但是编译不过

回到开头

安装的日志是这样的

--> Running transaction check  
---> Package libxml2-devel.x86_64 0:2.9.1-6.3 will be installed  
--> Processing Dependency: libxml2 = 2.9.1-6.3 for package: libxml2-devel-2.9.1-6.3.x86_64  
--> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-6.3.x86_64  
--> Running transaction check  
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated  
--> Processing Dependency: libxml2 = 2.9.1-6.el7_2.3 for package: libxml2-python-2.9.1-6.el7_2.3.x86_64  
---> Package libxml2.x86_64 0:2.9.1-6.3 will be an update  
---> Package xz-devel.x86_64 0:5.2.2-1.el7 will be installed  
--> Running transaction check  
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be updated  
---> Package libxml2-python.x86_64 0:2.9.1-6.3.h3 will be an update  
--> Processing Dependency: libxml2 = 2.9.1-6.3.h3 for package: libxml2-python-2.9.1-6.3.h3.x86_64  
--> Running transaction check  
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated  
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated  
---> Package libxml2.x86_64 0:2.9.1-6.3 will be an update  
--> Processing Dependency: libxml2 = 2.9.1-6.3 for package: libxml2-devel-2.9.1-6.3.x86_64  
---> Package libxml2.x86_64 0:2.9.1-6.3.h3 will be an update  
--> Finished Dependency Resolution  
 You could try using --skip-broken to work around the problem  
 You could try running: rpm -Va --nofiles --nodigest  

卧槽,没装成功。妈的

加上–skip-broken还是不行

错误冲突实际上是这样的

Error: Package: libxml2-devel-2.9.1-6.3.x86_64 (current)  
          Requires: libxml2 = 2.9.1-6.3  
          Installed: libxml2-2.9.1-6.3.h3.x86_64 (@stable)  
               libxml2 = 2.9.1-6.3.h3  
          Available: libxml2-2.9.1-6.el7_2.3.i686 (base)  
               libxml2 = 2.9.1-6.el7_2.3  
          Available: libxml2-2.9.1-6.3.x86_64 (current)  
               libxml2 = 2.9.1-6.3 

试着删掉libxml2提示 yum is protecte,换另外的删除方法

rpm -e --nodeps libxml2

但是会报错

 There was a problem importing one of the Python modules  
 required to run yum. The error leading to this problem was:  
   
    libxml2.so.2: cannot open shared object file: No such file or directory  
   
 Please install a package which provides this module, or  
 verify that the module is installed correctly.  
   
 It's possible that the above module doesn't match the  
 current version of Python, which is:  
 2.7.5 (default, Nov  6 2016, 00:28:07)   
 [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]  
   
 If you cannot solve this problem yourself, please go to   
 the yum faq at:

yum完全就不工作了。

唉。我最后自带了一个xml源码包自己编。

RPM打包

我只是想把编好的二进制和相关lib库打包后放到rpm里。网上搜了一天。各种从头开始。各种源码开始编。一点意义都没有。

rpmbuild打包就有三种模式,ba bb bs。还有各种奇怪的宏。还有各种make install流程。很容易就陷入这些没用的细节中。我根本都不需要的。最终我使用了bs。就当我打包源码包了。

另外rpmbuild默认目录是root,还需要指定

rpmbuild --define '_topdir ./rpmbuild' -bs rpmbuild/SPECS/rpm.spec

另外,解压rpm

rpm2cpio xxx.rpm | cpio -div

又遇到了个问题,要求目录。只能从二进制打包,又浪费一上午

照着这个文档看了半天 http://kuanghy.github.io/2015/11/13/rpmbuild

我的步骤里总会删掉buildroot,原来还需要install流程里加二进制。

最后发一个我的模板

Name:  xx
Version:	1.0
Release:	1%{?dist}
Summary: xx binary
#Group:		
License: WTF	
 
%install
mkdir -p  %{buildroot}/dir/dir/somedir/
cp -a %(pwd)/your.tar.gz %{buildroot}/dir/dir/somedir/
echo "install done"

%files
%defattr (-,root,root,-)
/dir/

然后打包,bb是二进制打包,之前用的bs 源码打包

rpmbuild --define '_topdir ./rpmbuild' --buildroot=$(pwd)/rpmbuild/BUILDROOT -bb rpm.spec

ref

  1. 找不到iddr https://github.com/ContinuumIO/libhdfs3-downstream/issues/9 严重误导我。没有没啥影响。

  2. https://www.mail-archive.com/dev@hawq.incubator.apache.org/msg04104.html 严重误导

  3. https://stackoverflow.com/questions/12993460/why-am-i-getting-undefined-reference-to-dladdr-even-with-ldl-for-this-simpl 严重误导。不是同一个场景。

  4. https://github.com/libical/libical/issues/248 这个链接让我误以为装了glibc2-devel就能找到xml2了。没仔细读就用,误导

  5. https://gitlab.kitware.com/cmake/cmake/issues/18078 这个给了我一点思路,我可以定义这两个变量

  6. https://trac.macports.org/ticket/55386 误导

  7. https://stackoverflow.com/questions/15799047/trying-to-remove-yum-which-is-protected-in-centos 删除包

  8. https://serverfault.com/questions/742160/conflicts-in-files-when-installing-libxml2

  9. https://www.centos.org/forums/viewtopic.php?t=68202 这个和我遇到的问题差不多,但是是arm机器

  10. https://forums.cpanel.net/threads/requires-libxml2-update-error.636661/ 真正的原因,但没说解决办法

  11. https://stackoverflow.com/questions/416983/why-is-topdir-set-to-its-default-value-when-rpmbuild-called-from-tcl rpmbuild更改目录的办法

  12. 网上一大堆rpm详解封装。都是翻译的外国的文章。说不到重点。比如

    1. https://blog.csdn.net/Nedved_L/article/details/78548101
    2. https://blog.csdn.net/u012373815/article/details/73257754
    3. https://www.iarno.cn/2019/04/22/RPM%E6%89%93%E5%8C%85/ 这个是写得好的。不过我也没用上
    4. https://stackoverflow.com/questions/42773687/creating-rpm-spec-file-from-compiled-binary-files 没啥用
  • https://stackoverflow.com/questions/39743808/cannot-make-rpm-from-spec-file-file-not-found-errors 这个有点用

contact