• rpm封装包,只用于记录自己过程,不适合初学者看,请看参考链接


    参考http://www.worldhello.net/2011/04/02/2405.html

    http://www.ibm.com/developerworks/cn/linux/management/package/rpm/part1/

    http://www.ibm.com/developerworks/cn/linux/management/package/rpm/part2/

    http://www.ibm.com/developerworks/cn/linux/management/package/rpm/part3/

    1、创建目录结构

    [root@nodea rpmbuild]# rpm --showrc|grep _topdir
    -14: _builddir %{_topdir}/BUILD
    -14: _buildrootdir %{_topdir}/BUILDROOT
    -14: _rpmdir %{_topdir}/RPMS
    -14: _sourcedir %{_topdir}/SOURCES
    -14: _specdir %{_topdir}/SPECS
    -14: _srcrpmdir %{_topdir}/SRPMS
    -14: _topdir %{getenv:HOME}/rpmbuild

    [root@nodea rpmbuild]# echo $HOME
    /root

    得知目录结构是/root/rpmbuild/、/root/rpmbuild/BUILD、 /root/rpmbuild/BUILDROOT /root/rpmbuild/RPMS /root/rpmbuild/SOURCES /root/rpmbuild/SPECS /root/rpmbuild/SRPMS

    /root/rpmbuild/BUILD是将tar.gz文件解压后,暂时存储的路径,并在这路惊下调用Make

    /root/rpmbuild/BUILDROOT是rpm打包前的存储路径

    /root/rpmbuild/RPMS 是rpm打包成果的路径

    /root/rpmbuild/SOURCES 是源码存放的路径

    /root/rpmbuild/SPECS 是打包脚本存放的路径

    /root/rpmbuild/SRPMS (暂时没用到过)

    2、资源的准备

    项目名称为PlaybackService,目录结构为

    [root@nodea PlaybackService-0.1]# ls
    PlaybackService So config.ini config.mk jw.conf makefile

    在So中存放工程中要用到的动态库

    [root@nodea So]# ls
    config.ini libThreadPool.so libmyodbc5.so
    libChannelMgr.so libUnitCommandClient.so libmysqlclient.so.18
    libDBPM.so libjrtp-3.7.1.so libodbc.so.1
    libPMData.so libjrtp_adp.so libodbcinst.so.1
    libPMNEW.so libjthread-1.2.1.so libpcl.so
    libSendStream.so libjwrtp.so libxmlformattedoutputc.so
    libTcpClient.so liblog4cplus-1.1.so.6

    修改原有的makefile文件,在其Install项目中添加

    51 mkdir -p $(RPM_INSTALL_ROOT)/usr/local/bin/JW/
    52 mkdir -p $(RPM_INSTALL_ROOT)/usr/local/bin/JW/lib/
    53 cp ./So/* $(RPM_INSTALL_ROOT)/usr/local/bin/JW/lib/
    54 cp ./config.ini $(RPM_INSTALL_ROOT)/usr/local/bin/JW/
    55 cp ./jw.conf $(RPM_INSTALL_ROOT)/usr/local/bin/JW/
    56 install -m 755 ../Bin/debug/PlaybackService $(RPM_INSTALL_ROOT)/usr /local/bin/JW/

    此处代码将被rpm的脚本调用,主要任务是将需要打包的资源拷贝到/root/rpmbuild/BUILDROOT相应的目录中,准备用于封装rpm包。

    3、在/root/rpmbuild/SPECS存放打包的脚本:PlaybackService.spce

    其代码为:

    1 Summary: hello world rpm package
    2 Name: PlaybackService
    3 Version: 0.1
    4 Release: 1
    5 Source: PlaybackService-0.1.tar.gz
    6 License: GPL
    7 Packager: amoblin
    8 Group: Application
    9 URL: http://www.gzjpg.com/
    10
    11 %description
    12 This is a software for making your city more beautiful!
    13
    14 %pre
    15 echo This is PlaybackService Install
    16 echo -----------------Welcome------------------
    17
    18
    19 %prep
    20 %setup -q
    21
    22 %post
    23 export LD_LIBRARY_PATH=/usr/local/bin/JW/lib
    24 cd /usr/local/bin/JW
    25 mv /usr/local/bin/JW/jw.conf /etc/ld.so.conf.d/
    26 sleep 1
    27 ldconfig
    28 echo Install Success
    29
    30 %build
    31 make
    32
    33 %install
    34 RPM_INSTALL_ROOT=$RPM_BUILD_ROOT make install
    35
    36 %clean
    37 rm -rf $RPM_BUILD_ROOT
    38
    39 %files
    40 %defattr(-,root,root)
    41 /usr/local/bin/JW/

    3、操作过程

    去到/root/rpmbuild/SOURCES

    tar zcvf PlaybackService-0.1.tar.gz  PlaybackService/

    去到/root/rpmbuild/SPECS

    rpmbuild -bb PlaybackService.spec

    4、验证

    将/root/rpmbuild/RPMS下的PlaybackService-0.1-1.x86_64.rpm拷贝到其他机器上

    运行rpm -i PlaybackService-0.1-1.x86_64.rpm

  • 相关阅读:
    DBA常用脚本 二、性能监控
    ORA01012:not logged on的解决办法
    线性布局LinearLayout
    Android Handler.postDelayed()方法
    java String.valueOf()
    布局管理器ViewGroup
    UE3的数据绑定笔记
    概念、实现和沟通
    DirectX11的Shader Reflect的几个问题(2012222更新)
    测试livewriter
  • 原文地址:https://www.cnblogs.com/linmzh/p/3183999.html
Copyright © 2020-2023  润新知