將定製RPM包加入內部Yum Server

#####################################################
## 若有轉載,請務必保留本文連接及版權信息
## 歡迎廣大運維同仁一塊兒交流linux/unix網站運維技術!
##QQ:335623998
##E-mail:335623998@qq.com

##博客: http://dreamway.blog.51cto.com/ html

##weibohttp://weibo.com/zhaixiangpan linux

#####################################################
如何定製RPM包
前言:此文以生產案例應用經過HAProxy1.4.22源碼包爲例定製生成rpm包,並加入內部YUM Server倉庫,便於之後的軟件包安裝
1 、製做RPM包linux系統環境
   
   
   
   
  1. # cat /etc/redhat-release   git

  2. CentOS release 5.8 (Final)  github

  3. # uname -r  sql

  4. 2.6.18-308.el5  數據庫

  5. # uname -m  vim

  6. x86_64 數組

2 、構建前的準備
建立rpmbuild所需的目錄結構,一般安裝好的Cent0S5.8系統已經建立好目錄結構,以下:
   
   
   
   
  1. # ls /usr/src  服務器

  2. debug kernels redhat  cookie

  3. # ls /usr/src/redhat/  

  4. BUILD RPMS SOURCES SPECS SRPMS

root 用戶製做RPM包使用/usr/src/redhat/下的目錄便可
若是使用普通用戶,則手工建立好目錄便可,命令以下
   
   
   
   
  1. # mkdir -p  /home/zxp/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

目錄說明
BUILD:   用於編譯軟件包時,源碼的臨時存放空間。
RPMS:   製做好的二進制包的輸出位置。
SOURCES:  源碼的位置。
SPECS:   spec文件存放的位置。
SRPMS:   製做好的源碼RPM包的輸出位置,該包安裝時仍須要先編譯。
3 、SPEC文件詳解
構建一個標準的 RPM 包,就須要在目錄SPECS下建立.spec文件,裏面包含即將被安裝的軟件的全部詳細信息。而後對這個文本在系統中執行rpmbuild命令,系統會按照.spec內容設置的步驟自動生成最終的 RPM 包。
3.1 SPEC 文件 語法詳解(以HAProxy爲例)
   
   
   
   
  1. # cat haproxy.spec  

  2. Summary: HA-Proxy is a TCP/HTTP reverse proxy for high availability environments       #軟件摘要信息  

  3. Name: haproxy       #軟件名稱  

  4. Version: 1.4.22     #軟件版本

  5. Release: 20130106_hexun_as5  #軟件分支版本

  6. License: GPL                 #軟件版權

  7. Group: System Environment/Daemons  #軟件所屬分類

  8. URL: http://haproxy.1wt.eu/       #軟件主頁

  9. Source0: http://haproxy.1wt.eu/download/1.4/src/%{name}-%{version}.tar.gz #源碼位置

  10. BuildRoot: %{_tmppath}/%{name}-%{version}-root  #安裝目錄

  11. BuildRequires: pcre-devel               #編譯依賴軟件包

  12. Requires: /sbin/chkconfig, /sbin/service #安裝依賴軟件包

  13. %description  #軟件詳細的描述信息

  14. HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high  

  15. availability environments. Indeed, it can:  

  16. - route HTTP requests depending on statically assigned cookies  

  17. - spread the load among several servers while assuring server persistence  

  18.  through the use of HTTP cookies  

  19. - switch to backup servers in the event a main one fails  

  20. - accept connections to special ports dedicated to service monitoring  

  21. - stop accepting connections without breaking existing ones  

  22. - add/modify/delete HTTP headers both ways  

  23. - block requests matching a particular pattern  

  24. It needs very little resource. Its event-driven architecture allows it to easily  

  25. handle thousands of simultaneous connections on hundreds of instances without  

  26. risking the system's stability.  

  27. # %prep定義了構建前要作的準備,一般是%setup定義如何解包

  28. %prep        

  29. %setup -q  

  30. # We don't want any perl dependecies in this RPM:  

  31. %define __perl_requires /bin/true #定義不使用perl依賴關係

  32. %build #編譯源碼命令,一般是./configure && make,根據具體包安裝方法而定

  33. %{__make} ARCH=%{_target_cpu} TARGET=linux26  

  34. %install  #安裝階段  

  35. [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}  

  36. %{__install} -d %{buildroot}%{_sbindir}  

  37. %{__install} -d %{buildroot}%{_sysconfdir}/rc.d/init.d  

  38. %{__install} -d %{buildroot}%{_sysconfdir}/%{name}  

  39. %{__install} -d %{buildroot}%{_mandir}/man1/  

  40. %{__install} -s %{name} %{buildroot}%{_sbindir}/  

  41. %{__install} -c -m 644 examples/%{name}.cfg %{buildroot}%{_sysconfdir}/%{name}/  

  42. %{__install} -c -m 755 examples/%{name}.init %{buildroot}%{_sysconfdir}/rc.d/init.d/%{name}  

  43. %{__install} -c -m 755 doc/%{name}.1 %{buildroot}%{_mandir}/man1/  

  44. %clean  #清理BUILD目錄階段

  45. [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}  

  46. %post   #安裝後製定的腳本

  47. /sbin/chkconfig --add %{name}

  48. %preun #卸載前執行的腳本

  49. if [ $1 = 0 ]; then

  50.  /sbin/service %{name} stop >/dev/null 2>&1 || :  

  51.  /sbin/chkconfig --del %{name}

  52. fi  

  53. %postun  #卸載後執行的腳本

  54. if [ "$1" -ge "1" ]; then

  55.  /sbin/service %{name} condrestart >/dev/null 2>&1 || :  

  56. fi  

  57. %files  #文件列表,主要是設置安裝rpm包後的文件、目錄屬性

  58. %defattr(-,root,root)  #定義默認屬性

  59. %doc CHANGELOG TODO examples/*.cfg doc/haproxy-en.txt doc/haproxy-fr.txt doc/architecture.txt doc/configuration.txt #指定軟件文檔

  60. %doc %{_mandir}/man1/%{name}.1*          #指定man幫助文檔  

  61. %attr(0755,root,root) %{_sbindir}/%{name}  #單獨指定目錄屬性  

  62. %dir %{_sysconfdir}/%{name}               #定義軟件安裝目錄  

  63. %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.cfg   #單獨指定文件屬性  

  64. %attr(0755,root,root) %config %{_sysconfdir}/rc.d/init.d/%{name} #單獨指定文件屬性

  65. %changelog   #軟件升級日誌

  66. * Tue Aug 14 2012 Willy Tarreau <w@1wt.eu>  

  67. - updated to 1.4.22  

  68. …………略………………  

  69. * Thu Oct 16 2003 Simon Matter <simon.matter@invoca.ch>  

  70. - initial build  

3 、獲取spec文件方法(三種方法)
3.1 方法1: 經過src.rpm包獲取
下載&安裝相應的src.rpm包
   
   
   
   
  1. # cd SRPMS/  

  2. # wget http://1wt.eu/tools/haproxy/src/devel/haproxy-1.2.3-1.src.rpm  

  3. # rpm -ivh haproxy-1.2.3-1.src.rpm  

  4.   1:haproxy                ########################################### [100%]  

 這裏的「安裝」是指把xxx.src.rpm中的tar.gz、patches、xxx.spec等文件分別輸出到/usr/src/redhat/的SOURCES、SPECS等子目錄中
查看生成的文件
   
   
   
   
  1. # ls /usr/src/redhat/{SOURCES,SPECS}  

  2. /usr/src/redhat/SOURCES:  

  3. haproxy-1.2.3.tar.gz  

  4. /usr/src/redhat/SPECS:  

  5. haproxy.spec  

找到spec文件,進行備份、修改
   
   
   
   
  1. # cd /usr/src/redhat/SPECS  

  2. # cd /usr/src/redhat/SPECS  

  3. # cp haproxy.spec haproxy.spec_bak$(date +%F)  

  4. # ls  

  5. haproxy.spec  haproxy.spec_bak2013-01-06  

3.2 方法2: 新建spec文件
再目錄SPECS下,建立一個新的spec文件,根據spec文件語法規範編寫,這個難度較高,適用於本身開發的軟件。
3.3 方法3: 從源碼包中獲取已有spec文件 推薦的方法
   
   
   
   
  1. # tar zxf haproxy-1.4.22.tar.gz  

  2. # cd haproxy-1.4.22  

  3. # ll haproxy.spec    

  4. -rw-rw-r-- 1 root root 7442 Aug 14 15:09 haproxy.spec  

  5. #cd haproxy-1.4.22/examples/  

  6. # ls  

  7. haproxy.spec  

將spec放入目錄SPECS
   
   
   
   
  1. # cp haproxy.spec  /usr/src/redhat/SPECS/

備份
   
   
   
   
  1. # cp haproxy.spec  haproxy.spec.$(date +%F)

本文采用此方法獲取spec
4 、編輯spec
   
   
   
   
  1. # pwd /usr/src/redhat/SPECS  

  2. # vim haproxy.spec  

修改先後內容對比(後面爲原文件)
   
   
   
   
  1. [root@study02 SPECS]# diff haproxy.spec haproxy.spec.2013-01-07  

  2. 4c4  

  3. < Release: 20130106_hexun_as5  

  4. ---

  5. > Release: 1  

  6. 36c36  

  7. < %{__make} ARCH=%{_target_cpu} TARGET=linux26  

  8. ---

  9. > %{__make} USE_PCRE=1 DEBUG="" ARCH=%{_target_cpu} TARGET=linux26  

5 、下載HAProxy源碼包
下載源碼包並放入SOURCES目錄中
   
   
   
   
  1. # pwd  

  2. /usr/src/redhat/SOURCES  

  3. # wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.22.tar.gz  

  4. # ls haproxy-1.4.22.tar.gz  

6 、建立RPM 包
經過rpmbuild命令來解析SPEC文件生成對應的RPM包
6.1 確認rpmbuild 已經安裝
   
   
   
   
  1. # yum install rpm-build -y

6.2 安裝依賴包
在build rpm包的系統上安裝pcre-devel
   
   
   
   
  1. # yum -y  install pcre-devel

6.3 開始build rpm:
   
   
   
   
  1. # rpmbuild  -v -ba SPECS/haproxy.spec

6.4 看到以下內容即建立過程,紅色內容爲build包位置
   
   
   
   
  1. Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.44698  

  2. + umask 022  

  3. + cd /usr/src/redhat/BUILD  

  4. + LANG=C  

  5. + export LANG  

  6. + unset DISPLAY  

  7. + cd /usr/src/redhat/BUILD  

  8. + rm -rf haproxy-1.4.22  

  9. + /bin/gzip -dc /usr/src/redhat/SOURCES/haproxy-1.4.22.tar.gz  

  10. + tar -xf -  

  11. + STATUS=0  

  12. …………略………………  

  13. Wrote: /usr/src/redhat/SRPMS/haproxy-1.4.22-20130106_hexun_as5.src.rpm  

  14. Wrote: /usr/src/redhat/RPMS/x86_64/haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm  

  15. Wrote: /usr/src/redhat/RPMS/x86_64/haproxy-debuginfo-1.4.22-20130106_hexun_as5.x86_64.rpm  

  16. Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.75459  

  17. + umask 022  

  18. + cd /usr/src/redhat/BUILD  

  19. + cd haproxy-1.4.22  

  20. + '[' /var/tmp/haproxy-1.4.22-root '!=' / ']'

  21. + /bin/rm -rf /var/tmp/haproxy-1.4.22-root  

  22. + exit 0  #注意輸出status爲0 即建立過程錯誤

7 、檢驗RPM包
7.1 使用 Mock 和 Koji 去測試 RPM 包
7.2 列出RPM軟件包內的文件信息
   
   
   
   
  1. # rpm -qpl   /usr/src/redhat/RPMS/x86_64/haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm  

  2. /etc/haproxy  

  3. /etc/haproxy/haproxy.cfg  

  4. /etc/rc.d/init.d/haproxy  

  5. /usr/sbin/haproxy  

  6. /usr/share/doc/haproxy-1.4.22  

  7. /usr/share/doc/haproxy-1.4.22/CHANGELOG  

  8. /usr/share/doc/haproxy-1.4.22/TODO  

  9. /usr/share/doc/haproxy-1.4.22/acl-content-sw.cfg  

  10. /usr/share/doc/haproxy-1.4.22/architecture.txt  

  11. /usr/share/doc/haproxy-1.4.22/auth.cfg  

  12. /usr/share/doc/haproxy-1.4.22/build.cfg  

  13. /usr/share/doc/haproxy-1.4.22/configuration.txt  

  14. /usr/share/doc/haproxy-1.4.22/content-sw-sample.cfg  

  15. /usr/share/doc/haproxy-1.4.22/cttproxy-src.cfg  

  16. /usr/share/doc/haproxy-1.4.22/examples.cfg  

  17. /usr/share/doc/haproxy-1.4.22/haproxy-en.txt  

  18. /usr/share/doc/haproxy-1.4.22/haproxy-fr.txt  

  19. /usr/share/doc/haproxy-1.4.22/haproxy.cfg  

  20. /usr/share/doc/haproxy-1.4.22/option-http_proxy.cfg  

  21. /usr/share/doc/haproxy-1.4.22/tarpit.cfg  

  22. /usr/share/doc/haproxy-1.4.22/test-section-kw.cfg  

  23. /usr/share/doc/haproxy-1.4.22/url-switching.cfg  

  24. /usr/share/man/man1/haproxy.1.gz

7.3 列出RPM軟件包的描述信息
   
   
   
   
  1. # rpm -qpi   /usr/src/redhat/RPMS/x86_64/haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm  

  2. Name        : haproxy                      Relocations: (not relocatable)  

  3. Version     : 1.4.22                            Vendor: (none)  

  4. Release     : 20130106_hexun_as5            Build Date: Mon 07 Jan 2013 09:36:21 AM CST  

  5. Install Date: (not installed)               Build Host: study02  

  6. Group       : System Environment/Daemons    Source RPM: haproxy-1.4.22-20130106_hexun_as5.src.rpm  

  7. Size        : 1275757                          License: GPL  

  8. Signature   : (none)  

  9. URL         : http://haproxy.1wt.eu/  

  10. Summary     : HA-Proxy is a TCP/HTTP reverse proxy for high availability environments  

  11. Description :  

  12. HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high  

  13. availability environments. Indeed, it can:  

  14. - route HTTP requests depending on statically assigned cookies  

  15. - spread the load among several servers while assuring server persistence  

  16. through the use of HTTP cookies  

  17. - switch to backup servers in the event a main one fails  

  18. - accept connections to special ports dedicated to service monitoring  

  19. - stop accepting connections without breaking existing ones  

  20. - add/modify/delete HTTP headers both ways  

  21. - block requests matching a particular pattern  

  22. It needs very little resource. Its event-driven architecture allows it to easily  

  23. handle thousands of simultaneous connections on hundreds of instances without  

  24. risking the system's stability.  

7.4 rpm方式 安裝驗證
   
   
   
   
  1. [root@study01 tools]# rpm -ivh haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm  

  2. Preparing...                ########################################### [100%]  

  3.   1:haproxy                ########################################### [100%]  

  4. [root@study01 tools]# ls  

  5. haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm  

  6. [root@study01 tools]# ls /etc/haproxy/ #安裝目錄及主配置文件

  7. haproxy.cfg  

  8. [root@study01 tools]# ll /etc/rc.d/init.d/haproxy  #服務啓動文件

  9. -rwxr-xr-x 1 root root 2553 Jan 7 09:36 /etc/rc.d/init.d/haproxy  

  10. [root@study01 tools]# ll /etc/init.d/haproxy  

  11. -rwxr-xr-x 1 root root 2553 Jan 7 09:36 /etc/init.d/haproxy  

  12. [root@study01 tools]# rpm -qf /etc/init.d/haproxy  #查看軟件所屬軟件包

  13. haproxy-1.4.22-20130106_hexun_as5  

至此定製RPM包已經制做完畢,接下來咱們就能夠把經常使用的應用軟件源碼包都製做爲rpm包放入yum倉庫,之後部署軟件就很便捷了。

8、將定製的RPM加入yum倉庫
所需工具createrepo 、yum-arch
詳見很早之前寫的yum server搭建文章
CentOS基於 http服務 搭建yum 源 服務器 http://bbs.linuxtone.org/thread-4439-1-1.html
8.1 在yum server上配置
  
  
  
  
  1. [root@hxinstall 5ASU8]# cd /opt/ftp/pub/os/Linux/Centos/x86_64/Centos5.8/  

  2. [root@hxinstall Centos5.8]# ls  

  3. dvd install  

  4. # cd RPMS.hexun/  

  5. # ls  

  6. haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm  

8.2 建立repodata 數據庫
包含rpm 包的詳細信息,依賴關係等
  
  
  
  
  1. [root@hxinstall RPMS.hexun]# createrepo /opt/ftp/pub/os/Linux/Centos/x86_64/Centos5.8/RPMS.hexun  

  2. 1/1 - haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm                                

  3. Saving Primary metadata  

  4. Saving file lists metadata  

  5. Saving other metadata  

8.3 RPM 包分析
在目錄下產生 heaers 目錄
  
  
  
  
  1. # yum-arch -l /opt/ftp/pub/os/Linux/Centos/x86_64/Centos5.8/RPMS.hexun  

  2. # ls  

  3. haproxy-1.4.22-20130106_hexun_as5.x86_64.rpm headers repodata  

注意:
每添加新的軟件包,都須要執行此兩個命令使其生效。
8.4 yum 客戶端安裝定製版HAProxy
8.4.1 配置yum
添加定製軟件包yum倉庫
  
  
  
  
  1. cat << EOF >>  /etc/yum.repos.d/CentOS-Base.repo  

  2. [hexun]  

  3. name= hexun rpm  

  4. baseurl=http://10.0.251.154/pub/os/Linux/Centos/x86_64/Centos5.8/RPMS.hexun  

  5. gpgcheck=0  

  6. EOF  

8.4.2 YUM安裝自定製HAProxy 軟件包

       
       
       
       
  1. # yum clean all

  2. # yum  install  haproxy -y  

  3. Loaded plugins: fastestmirror  

  4. Determining fastest mirrors  

  5. ……略…………  

  6. hexun                                                       |  951 B     00:00      

  7. hexun/primary                                               | 1.2 kB     00:00      

  8. hexun                                                                          1/1  

  9. Setting up Install Process  

  10. Resolving Dependencies  

  11. --> Running transaction check

  12. ---> Package haproxy.x86_64 0:1.4.22-20130106_hexun_as5 set to be updated

  13. ………略………  

  14. Running Transaction

  15.  Installing     : haproxy                                                     1/1  

  16. Installed:  #yum已經安裝成功

  17.  haproxy.x86_64 0:1.4.22-20130106_hexun_as5

8.4.3 卸載定製版軟件包
  
  
  
  
  1. # yum  remove  haproxy   -y    

  2. Loaded plugins: fastestmirror  

  3. Setting up Remove Process  

  4. Resolving Dependencies  

  5. --> Running transaction check

  6. ---> Package haproxy.x86_64 0:1.4.22-20130106_hexun_as5 set to be erased

  7. --> Finished Dependency Resolution

  8. Dependencies Resolved  

  9. ===================================================================================  

  10. Package       Arch         Version                          Repository       Size

  11. ===================================================================================  

  12. Removing:  

  13. haproxy       x86_64       1.4.22-20130106_hexun_as5        installed       1.2 M  

  14. Transaction Summary  

  15. ===================================================================================  

  16. Remove        1 Package(s)  

  17. Reinstall     0 Package(s)  

  18. Downgrade     0 Package(s)  

  19. Downloading Packages:  

  20. Running rpm_check_debug  

  21. Running Transaction Test  

  22. Finished Transaction Test  

  23. Transaction Test Succeeded  

  24. Running Transaction

  25.  Erasing        : haproxy                                                     1/1  

  26. Removed:  #已經成功卸載  

  27.  haproxy.x86_64 0:1.4.22-20130106_hexun_as5  

  28. Complete!  

9 、製做RPM報錯記錄
9.1 build 包報錯找不到源碼包
  
  
  
  
  1. # rpmbuild -v -ba SPECS/haproxy.spec  

  2. error: File /usr/src/redhat/SOURCES/haproxy-1.4.22.tar.gz: No such file or directory  

解決:將對應版本源碼包放入對應目錄
  
  
  
  
  1. # cd /usr/src/redhat/SOURCES/  

  2. [root@study02 SOURCES]# wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.22.tar.gz  

9.2 build 時報依賴關係錯誤
  
  
  
  
  1. # rpmbuild -v -ba SPECS/haproxy.spec                                

  2. error: Failed build dependencies:  

  3.        pcre-devel is needed by haproxy-1.4.22-20130106_hexun_as5.x86_64  

解決:在build rpm包的系統上安裝pcre-devel
  
  
  
  
  1. # yum -y install pcre-devel      

10 、製做RPM包涉及到的命令用法
10.1 命令rpmbuild
用法:
  
  
  
  
  1. Usage: rpmbuild [ <specfile> | <tarball> | <source package> ]  

經常使用參數:
-bb 只編譯二進制rpm包
-bs 只編譯源碼rpm包(src.rpm)
-ba 同時編譯二進制和源碼rpm包(src.rpm)
-bp 執行到%prep段,解開tar包而後把全部的補丁文件合併而生成一個完整的具最新功能的源文件
10.2 命令rpm
rpm 命令之前的linux版本較經常使用,可是解決軟件包依賴關係就比較麻煩,不如yum便捷。
用法:
  
  
  
  
  1. Usage: rpm [OPTION...]  

經常使用的rpm參數組合:

  
  
  
  
  1. (1)rpm -qx file_name, x={f,i,l,a,p...}, file_name能夠是命令名、動態庫名稱、配置文件名等等。  

  2. 使用此命令的前提:相應的rpm包已經安裝。  

  3. rpm -qf file:查詢文件file是哪一個rpm包中的;rpm -qf `which your_cmd`, rpm -qf `locate file_name`  

  4. rpm -qi rpm_name:查看指定rpm包安裝的詳細信息;  

  5. rpm -ql installed_rpm_name:列出已經安裝的rpm包中包含了哪些文件及他們的安裝路徑。如rpm -ql iptraf  

  6. 用如下選項與 -q 連用來指明要查詢哪些軟件包的信息。這些選項被稱之爲「軟件包指定選項」:  

  7. -a 查詢全部已安裝的軟件包。  

  8. -f <file> 將查詢包含有文件 <file>的軟件包。  

  9. -p <packagefile> 查詢軟件包文件名爲 <packagefile>的包。  

  10. 有幾種方式來指定查詢軟件包時所顯示的信息。 如下選項可經過讀取rpm包頭部的辦法顯示rpm包的信息,這樣的選項被稱做「信息選擇選項」:  

  11. -i 顯示軟件包信息,如描述、發行號、大小、編譯日期、安裝日期、硬件平臺、以及其它一些各種信息。  

  12. -l 列出軟件包中包含的文件。(列出已經安裝的rpm包中包含了哪些文件及他們的安裝路徑)  

  13. -s 顯示軟件包中全部文件的狀態。  

  14. -d 列出被標註爲文檔的文件 (如,man 手冊、 info 信息、README,等等) 。  

  15. -c 列出被標註爲配置文件的文件。這些文件是須要在安裝完畢後加以定製的,如 (sendmail.cf, passwd, inittab, 等) 。  

  16. 若是要在執行上述選項的同時,顯示文件列表, 能夠同時使用 -v 命令行選項,就能得出與 ls -l 格式相似的輸出。  

  17. (2)查看未安裝的rpm/src.rpm包中包含的文件列表  

  18. - 在本地暫時只能使用(4)中提供的方法;  

  19. - 經過rpmfind.net等網站進行查詢;  

  20. (3)rpm -ivh xxx.rpm:從新安裝;(和-Uvh相比,建議用-ivh)  

  21. rpm -ivh --relocate /=/tmp/test/ xxx.rpm

  22. (4)rpm2cpio xxx.rpm/xxx.src.rpm:將rpm解壓爲cpio歸檔;  

  23. rpm2cpio xxx.rpm/xxx.src.rpm | cpio -idmv (rpm2cpio xxx.rpm | cpio --extract --make-directories)

  24. 參數-i(或--extract)表示提取文件; v表示指示執行進程;-d(或--make-directory)表示根據包中文件原來的路徑創建目錄;m表示保持文件的更新時間。

10.3 命令 yum
目前yum命令在安裝軟件包時很經常使用,這裏再也不一一列舉用法參數。
經常使用命令可參考 http://bbs.linuxtone.org/thread-4439-1-1.html
11 、參考資料
RPM 打包技術與典型 SPEC 文件分析
經常使用的rpm參數組合
RPM 使用筆記
How to create an RPM package/zh-cn
Fedora 新軟件維護者指南
相關文章
相關標籤/搜索