歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux系統程序包管理工具-RPM

Linux系統程序包管理工具-RPM

日期:2017/3/1 12:20:55   编辑:關於Linux
一、rpm是什麼 RPM 是RPM Package Manager(RPM軟件包管理器)的縮寫,這一文件格式名稱雖然打上了RedHat的標志,但是其原始設計理念是開放式的。RPM包管理器(RPM)是一個強大的命令行驅動的包管理系統能夠安裝、卸載、驗證、查詢和更新計算機軟件包。每個軟件包包括存檔的文件連同包和它的版本信息,描述等。還有一個庫API,允許高級開發人員來管理 二、程序的組成部分 程序的組成部分: 編譯之前:源代碼 編譯文件: 二進制程序 庫文件 配置文件 幫助文件(手冊、文檔) 二進制程序:/bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin, /opt/bin, /opt/sbin 庫文件:/lib, /lib64, /usr/lib, /usr/lib64, /usr/local/lib, /usr/local/lib64 配置文件:/etc, /etc/DIR, /usr/local/{etc,conf} 幫助文件:/usr/share/man, /usr/share/doc, /usr/local/share/man 注意:有些特殊的應用程序可能會將可執行文件放置在libexec目錄; 三、rpm包命名格式: rpm包命名格式: appname-VERSION-RELEASE.ARCH.rpm VERSION: major:主版本號 minor:此版本號 release:發行號 RELEASE:包自身的修訂號:有時候還會包含適用於os信息:比如bash-4.3.2-2.centos.x86_64.rpm ARCH:適用的平台 x86:i386,i486,i586,i686 x86_64,adm64:x86 64bits powerpc:ppc noarch:跟平台無關 四、分包機制 想象一種場景:testapp有30種功能,其中有10種常用,有6次常用,余下的14種極少用;所以rpm包制作者會把一個程序的每個功能制作成一個rpm包,他們都依賴主包。 例如: 核心包,主包:命名與原項目名稱一致; bash-4.3.2-2.centos6.x86_64.rpm 子包(支包):命令為源項目名稱後附加分支包中的文件提供的功能組成; bash-devel-4.3.2-2.centos6.x86_64.rpm 程序包的獲取路徑: 1、系統的發行光盤鏡像或官方站點(或站點鏡像服務器) 掛載光盤: mount -r /dev/cdrom /media/cdrom 官方站點,鏡像: mirrors.sohu.com mirrors.163.com mirrors.aliyun.com 2、程序包的官方站點 3、第三方組織:epel 4、搜索引擎 http://rpmfind.net http://rpm.pbone.net http://pkgs.org 建議:安裝之前要驗正的其合法性 來源合法 包的完整性 五、centos系統上的程序rpm包管理 安裝、升級、卸載、查詢、校驗 5.1 安裝 rpm {-i|--install} [install-options] PACKAGE_FILE1.. -i:安裝 # rpm -i zsh-4.3.10-7.el6.x86_64.rpm # rpm -q zsh#rpm -q為查詢次包是否安裝,在後面的查詢中會講到。 zsh-4.3.10-7.el6.x86_64 -h:hash, 以#來表示安裝進度 # rpm -ih zsh-4.3.10-7.el6.x86_64.rpm ########################################### [100%] ########################################### [100%] -v,--verbose:顯示安裝過程中的詳細信息 # rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] 1:zsh########################################### [100%] -vv:顯示更多的詳細信息 # rpm -ivvh zsh-4.3.10-7.el6.x86_64.rpm 安裝時常用的組合:-ivh,-ivvh --test:不執行真正的安裝過程,而僅報告依賴關系及沖突 # rpm -ivh --test zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] 程序包之間存在依賴關系 由眾多目的單一的小程序組成:結果程序包之間存在相關性; --nodeps:忽略依賴關系:副作用:安裝成功,但未必能夠成功運行 # rpm -ivh php-5.3.3-38.el6.x86_64.rpm error: Failed dependencies: php-cli(x86-64) = 5.3.3-38.el6 is needed by php-5.3.3-38.el6.x86_64 php-common(x86-64) = 5.3.3-38.el6 is needed by php-5.3.3-38.el6.x86_64 # rpm -ivh --nodeps php-5.3.3-38.el6.x86_64.rpm Preparing...########################################### [100%] 1:php########################################### [100%] --replacepkgs:覆蓋安裝:重新安裝並覆蓋原有的文件 # rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] package zsh-4.3.10-7.el6.x86_64 is already installed # rpm -ivh --replacepkgs zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] 1:zsh########################################### [100%] --force:強制安裝 # rpm -ivh zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] package zsh-4.3.10-7.el6.x86_64 is already installed # rpm -ivh --force zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] 1:zsh########################################### [100%] 5.2 升級 -U:升級或安裝 # rpm -q zsh zsh-4.3.10-7.el6.x86_64 # rpm -Uvh --nodeps zsh-5.1.1-3.fc24.x86_64.rpm warning: zsh-5.1.1-3.fc24.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 81b46521: NOKEY Preparing...########################################### [100%] 1:zsh########################################### [100%] # 此處使用--nodeps的原因是這個版本需要很多依賴關系,所以忽略依賴關系,在生產環境中升級需要安裝依賴關系後在升級。 -F:升級 組合:-Uvh,-Fvh --test --nodeps --force --oldpackage:降級到舊版本; # rpm -q zsh zsh-5.1.1-3.fc24.x86_64 # rpm -Uvh --oldpackage /misc/cd/Packages/zsh-4.3.10-7.el6.x86_64.rpm Preparing...########################################### [100%] 1:zsh########################################### [100%] # rpm -q zsh zsh-4.3.10-7.el6.x86_64 注意:一定不要對內核升級:Linux允許多內核共存,所以可以直接安裝多個不同版本內核; 注意:如果程序包的配置文件安裝後曾被修改,升級時,新版本的文件不會覆蓋老版本的配置文件,而把新版本的配置文件重命名(加後綴.rpmnew)後保存 5.3 卸載 rpm {-e|--erase} [--allmatches] [--nodeps] [--test] 簡單用法:rpm -e PACKAGE_NAME... # rpm -q zsh zsh-4.3.10-7.el6.x86_64 # rpm -e zsh # rpm -q zsh package zsh is not installed --nodeps:忽略依賴關系; --test: 測試卸載;dry-run模式; --allmatches: 如果一個程序包同時安裝多個版本,則此選項一次全部卸載之; 注意:如果程序包的配置文件安裝後曾被修改,卸載時,此文件通常不會被刪除,而是被重命名(加後綴.rpmsave)後留存; 5.4 查詢 rpm {-q|--query} [select-options] [query-options] [select-options] 1、查詢某包或某些包是否安裝: rpm -q PACKAGE_NAME # rpm -q zsh zsh-5.1.1-3.fc24.x86_64 2、查詢已經安裝的所有包 rpm -qa PACKAGE_NAME # rpm -qa zsh zsh-5.1.1-3.fc24.x86_64 # 或者,grep後面支持正則表達式過濾 # rpm -qa |grep "zhs" 3、查詢某文件是由哪個包安裝生成: rpm -qf /PATH/TO/SOMEFILE # rpm -qf /etc/fstab setup-2.8.14-20.el6_4.1.noarch # rpm -qf /etc/httpd/conf/httpd.conf httpd-2.2.15-39.el6.centos.x86_64 4、查詢尚未安裝的包文件的相關信息 -p # rpm -qpi PACKAGE_NAME # rpm -qpi gcc-4.4.7-11.el6.x86_64.rpm Name: gcc Relocations: (not relocatable) Version : 4.4.7 Vendor: CentOS Release : 11.el6Build Date: 2014年10月15日 星期三 08時24分47秒 Install Date: (not installed) Build Host: c6b9.bsys.dev.centos.org Group : Development/Languages Source RPM: gcc-4.4.7-11.el6.src.rpm Size: 19495803 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions Signature : RSA/SHA1, 2014年10月18日 星期六 04時02分58秒, Key ID 0946fca2c105b9de Packager: CentOS BuildSystem <http://bugs.centos.org> URL : http://gcc.gnu.org Summary : Various compilers (C, C++, Objective-C, Java, ...) Description : The gcc package contains the GNU Compiler Collection version 4.4. You'll need this package in order to compile C code. [query-options]: 1、查詢某包的簡要說明信息: rpm -qi PACKAGE_NAME # rpm -qi zsh Name: zsh Relocations: (not relocatable) Version : 5.1.1 Vendor: Fedora Project Release : 3.fc24Build Date: 2015年11月05日 星期四 21時41分02秒 Install Date: 2015年11月19日 星期四 15時20分55秒 Build Host: buildvm-26.phx2.fedoraproject.org Group : System Environment/Shells Source RPM: zsh-5.1.1-3.fc24.src.rpm Size: 6474662 License: MIT Signature : RSA/8, 2015年11月05日 星期四 21時56分22秒, Key ID 73bde98381b46521 Packager: Fedora Project URL : http://zsh.sourceforge.net/ Summary : Powerful interactive shell Description : The zsh shell is a command interpreter usable as an interactive login shell and as a shell script command processor. Zsh resembles the ksh shell (the Korn shell), but includes many enhancements. Zsh supports command line editing, built-in spelling correction, programmable command completion, shell functions (with autoloading), a history mechanism, and more. 2、查詢某包安裝後生成了哪些文件列表; rpm -ql PACKAGE_NAME # rpm -ql zsh|less /etc/skel/.zshrc /etc/zlogin /etc/zlogout /etc/zprofile /etc/zshenv /etc/zshrc /usr/bin/zsh /usr/lib64/zsh /usr/lib64/zsh/5.1.1 /usr/lib64/zsh/5.1.1/zsh /usr/lib64/zsh/5.1.1/zsh/attr.so /usr/lib64/zsh/5.1.1/zsh/cap.so ...... 3、查詢某包安裝後生成的配置文件路徑 rpm -qc PACKAGE_NAME # rpm -qc zsh /etc/skel/.zshrc /etc/zlogin /etc/zlogout /etc/zprofile /etc/zshenv /etc/zshrc 4、查詢某包安裝後生成的所有幫助文件 rpm -qd PACKAGE_NAME # rpm -qd zsh /usr/share/doc/zsh/BUGS /usr/share/doc/zsh/CONTRIBUTORS /usr/share/doc/zsh/FAQ /usr/share/doc/zsh/FEATURES /usr/share/doc/zsh/LICENCE /usr/share/doc/zsh/MACHINES /usr/share/doc/zsh/NEWS /usr/share/doc/zsh/README /usr/share/doc/zsh/completion-style-guide /usr/share/doc/zsh/zsh-development-guide /usr/share/doc/zsh/zshprompt.pl /usr/share/info/zsh.info-1.gz /usr/share/info/zsh.info-2.gz /usr/share/info/zsh.info-3.gz /usr/share/info/zsh.info-4.gz /usr/share/info/zsh.info-5.gz .... 5、查看某包制作時隨版本變化的changelog信息;
rpm-q --changelog PACKAGE_NAME

# rpm -q --changelog zsh
* 四 11月 05 2015 Kamil Dudka <[email protected]> - 5.1.1-3
- make loading of module's dependencies work again (#1277996)

* 四 10月 08 2015 Kamil Dudka <[email protected]> - 5.1.1-2
- fix crash in ksh mode with -n and $HOME (#1269883)

* 一 9月 14 2015 Kamil Dudka <[email protected]> - 5.1.1-1
- Update to latest upstream release: Zsh 5.1.1

* 一 8月 31 2015 Kamil Dudka <[email protected]> - 5.1-1
- Update to latest upstream release: Zsh 5.1
- remove outdated workarounds in %check

* 四 7月 30 2015 Kamil Dudka <[email protected]> - 5.0.8-6
- fix handling of command substitution in math context

* 三 7月 22 2015 Kamil Dudka <[email protected]> - 5.0.8-5
- prevent infinite recursion in ihungetc() (#1245712)

* 二 7月 07 2015 Kamil Dudka <[email protected]> - 5.0.8-4
- backport completion for dnf (#1239337)

* 四 7月 02 2015 Kamil Dudka <[email protected]> - 5.0.8-3
- backport completion-related upstream fixes (#1238544)

* 五 6月 19 2015 Fedora Release Engineering <[email protected]> - 5.0.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* 三 6月 03 2015 Kamil Dudka <[email protected]> - 5.0.8-1
- Update to latest upstream release: Zsh 5.0.8

* 五 5月 22 2015 Kamil Dudka <[email protected]> - 5.0.7-8
- fix SIGSEGV of the syntax check in ksh emulation mode (#1222867)

* 一 4月 20 2015 Kamil Dudka <[email protected]> - 5.0.7-7
- fix SIGSEGV when handling heredocs and keyboard interrupt (#972624)
- queue signals when manipulating global state to avoid deadlock

* 日 1月 25 2015 Kamil Dudka <[email protected]> - 5.0.7-6
- use correct allocation function in the new 'cd' code (#1183238)

* 五 1月 23 2015 Kamil Dudka <[email protected]> - 5.0.7-5
- suppress a warning about closing an already closed file descriptor (#1184002)
- improve handling of NULL in the 'cd' built-in (#1183238)

* 三 11月 19 2014 Kamil Dudka <[email protected]> - 5.0.7-4
- update documentation of POSIX_JOBS in the zshoptions.1 man page (#1162198)

* 二 11月 18 2014 Kamil Dudka <[email protected]> - 5.0.7-3
- replace an incorrect comment in /etc/zshenv (#1164313)

* 一 11月 10 2014 Kamil Dudka <[email protected]> - 5.0.7-2
- make the wait built-in work for already exited processes (#1162198)

* 三 10月 08 2014 Dominic Hopf <[email protected]> - 5.0.7-1
- Update to latest upstream release: Zsh 5.0.7

* 四 8月 28 2014 Dominic Hopf <[email protected]> - 5.0.6-1
- Update to latest upstream release: Zsh 5.0.6

* 一 8月 18 2014 Fedora Release Engineering <[email protected]> - 5.0.5-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* 四 7月 17 2014 Dominic Hopf <[email protected]> - 5.0.5-7
- apply upstream patch which fixes CPU load issue (RHBZ#1120424)

* 三 7月 09 2014 Adam Jackson <[email protected]> 5.0.5-6
- Fix missing 'fi' in %post

* 四 7月 03 2014 Dominic Hopf <[email protected]> - 5.0.5-5
- improve handling of /etc/shells

* 三 7月 02 2014 Dominic Hopf <[email protected]> - 5.0.5-4
- fix FTBFS issue (RHBZ#1106713)
- remove individual _bindir setting; install to /usr/bin/ (RHBZ#1034060)
- require info package instead of /sbin/install-info binary

* 六 6月 07 2014 Fedora Release Engineering <[email protected]> - 5.0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* 二 4月 08 2014 Dominic Hopf <[email protected]> - 5.0.5-1
- Update to latest upstream release: Zsh 5.0.5

* 四 1月 16 2014 James Antill <[email protected]> - 5.0.2-8
- Remove unneeded build require on tetex.

* 六 10月 26 2013 Dominic Hopf <[email protected]> - 5.0.2-7
- Require hostname package instead of /bin/hostname

* 二 10月 22 2013 Dominic Hopf <[email protected]> - 5.0.2-6
- remove systemd completion, it delivers it's own now (RHBZ#1022039)

* 四 8月 01 2013 Dominic Hopf <[email protected]> - 5.0.2-5
- update systemd completion (adds machinectl command)

* 二 6月 25 2013 Dominic Hopf <[email protected]> - 5.0.2-4
- up-to-date systemd completion (#949003)
- apply patch for building for aarch64 (#926864)

* 一 4月 15 2013 James Antill <[email protected]> - 5.0.2-3
- Fix the changelog dates.
- Fix the texi itemx bug.
- Resolves: bug#927863

* 五 2月 15 2013 Fedora Release Engineering <[email protected]> - 5.0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* 二 1月 08 2013 Dominic Hopf <[email protected]> - 5.0.2-1
- Update to new upstream version: Zsh 5.0.2

* 三 11月 21 2012 Dominic Hopf <[email protected]> - 5.0.0-1
- Update to new upstream version: Zsh 5.0.0

* 日 7月 22 2012 Fedora Release Engineering <[email protected]> - 4.3.17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* 日 3月 04 2012 Dominic Hopf <[email protected]> - 4.3.17-1
- Update to new upstream version: Zsh 4.3.17

* 六 1月 14 2012 Fedora Release Engineering <[email protected]> - 4.3.15-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* 六 12月 24 2011 Dominic Hopf <[email protected]> - 4.3.15-1
- Update to new upstream version: Zsh 4.3.15

* 六 12月 17 2011 Dominic Hopf <[email protected]> - 4.3.14-2
- change the License field to MIT (RHBZ#768548)

* 六 12月 10 2011 Dominic Hopf <[email protected]> - 4.3.14-1
- Update to new upstream version: Zsh 4.3.14

* 六 12月 03 2011 Dominic Hopf <[email protected]> - 4.3.13-1
- Update to new upstream version: Zsh 4.3.13

* 六 8月 13 2011 Dominic Hopf <[email protected]> - 4.3.12-1
- Update to new upstream version: Zsh 4.3.12

* 二 2月 08 2011 Fedora Release Engineering <[email protected]> - 4.3.11-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* 四 1月 20 2011 Christopher Ailon <[email protected]> - 4.3.11-1
- Rebase to upstream version 4.3.11

* 二 12月 07 2010 Toshio Kuratomi <[email protected]> - 4.3.10-6
- Rebuild for FTBFS https://bugzilla.redhat.com/show_bug.cgi?id=631197
- Remove deprecated PreReq, the packages aren't needed at runtime and they're
  already in Requires(post,preun,etc): lines.

* 一 3月 22 2010 James Antill <[email protected]> - 4.3.10-5
- Add pathmunge to our /etc/zshrc, for profile.d compat.
- Resolves: bug#548960

* 五 8月 07 2009 James Antill <[email protected]> - 4.3.10-4
- Allow --excludedocs command to work!
- Resolves: bug#515986

* 一 7月 27 2009 Fedora Release Engineering <[email protected]> - 4.3.10-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* 一 7月 20 2009 James Antill <[email protected]> - 4.3.10-1
- Import new upstream 4.3.10

* 三 6月 10 2009 Karsten Hopp <[email protected]> 4.3.9-4.1
- skip D02glob test on s390, too

* 一 3月 02 2009 James Antill <[email protected]> - 4.3.9-4
- Remove D02glob testcase on ppc/ppc64, and hope noone cares

* 三 2月 25 2009 Fedora Release Engineering <[email protected]> - 4.3.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

6、查詢某包提供的capabilities; rpm -q --provides PACKAGE_NAME; # rpm -q --provides zsh /bin/zsh config(zsh) = 5.1.1-3.fc24 zsh = 5.1.1-3.fc24 zsh(x86-64) = 5.1.1-3.fc24 7、查詢某包所依賴的capabilities;
rpm -q --requires PACKAGE_NAME


# rpm -q --requires zsh
/bin/sh  
/bin/sh  
/bin/sh  
/bin/sh  
/bin/zsh  
config(zsh) = 5.1.1-3.fc24
coreutils  
grep  
grep  
info  
info  
libc.so.6()(64bit)  
libc.so.6(GLIBC_2.11)(64bit)  
libc.so.6(GLIBC_2.14)(64bit)  
libc.so.6(GLIBC_2.15)(64bit)  
libc.so.6(GLIBC_2.2.5)(64bit)  
libc.so.6(GLIBC_2.3)(64bit)  
libc.so.6(GLIBC_2.3.4)(64bit)  
libc.so.6(GLIBC_2.4)(64bit)  
libc.so.6(GLIBC_2.7)(64bit)  
libdl.so.2()(64bit)  
libdl.so.2(GLIBC_2.2.5)(64bit)  
libm.so.6()(64bit)  
libm.so.6(GLIBC_2.2.5)(64bit)  
libncursesw.so.6()(64bit)  
librt.so.1()(64bit)  
librt.so.1(GLIBC_2.2.5)(64bit)  
libtinfo.so.6()(64bit)  
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
rtld(GNU_HASH)

8、查詢某包安裝或卸載時執行腳本;
rpm -q --scripts PACKAGE_NAME

# rpm -q --scripts zsh
\postinstall scriptlet (using /bin/sh):
if [ "$1" = 1 ]; then
  if [ ! -f /etc/shells ] ; then
echo "/usr/bin/zsh" > /etc/shells
echo "/bin/zsh" >> /etc/shells
  else
grep -q "^/usr/bin/zsh$" /etc/shells || echo "/usr/bin/zsh" >> /etc/shells
grep -q "^/bin/zsh$" /etc/shells || echo "/bin/zsh" >> /etc/shells
  fi
fi

if [ -f /usr/share/info/zsh.info.gz ]; then
# This is needed so that --excludedocs works.
/sbin/install-info /usr/share/info/zsh.info.gz /usr/share/info/dir \
  --entry="* zsh: (zsh).An enhanced bourne shell."
fi
preuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ] ; then
if [ -f /usr/share/info/zsh.info.gz ]; then
# This is needed so that --excludedocs works.
/sbin/install-info --delete /usr/share/info/zsh.info.gz /usr/share/info/dir \
  --entry="* zsh: (zsh).An enhanced bourne shell."
fi
fi
postuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ] && [ -f /etc/shells ] ; then
  sed -i '\!^/usr/bin/zsh$!d' /etc/shells
  sed -i '\!^/bin/zsh$!d' /etc/shells
fi

腳本有四類: preinstall:安裝過程開始之前執行的腳本; postinstall:安裝過程後執行的腳本; preuninstall:卸載前執行的腳本; postuninstall:卸載過程完成之後執行的腳本; 5.5 校驗 查詢包安裝之後生成的文件是否發生了改變 rpm {-V|--verify} [select-options] [verify-options] # rpm -V zsh S.5....T. c /etc/zshrc 常見用法:rpm -V PACKAGE_NAME S file Size differs M Mode differs (includes permissions and file type) 5 digest (formerly MD5 sum) differs D Device major/minor number mismatch L readLink(2) path mismatch U User ownership differs G Group ownership differs T mTime differs P caPabilities differ 程序包的合法性驗正: 來源合法: 由我們信任的制作者提供 依賴於:制作者的數字簽名;簽名是作者使用自己的私鑰加密程序包的特性碼進行的; 內容合法: 包未被二次修改;完整性校驗成功 依賴於:制作者提供的程序特征碼; 驗正方式:安裝者用同樣的特征碼提取算法提取程序包的特征碼,並與原作者提供的相比較; 驗正其光盤中程序包的來源及完整性: rpm --import /path/to/RPM-GPG-KEY-FILE 例如:# rpm --import RPM-GPG-KEY-CentOS-6 驗正:rpm {-K|--checksig} PACKAGE_FILE # rpm --import /misc/cd/RPM-GPG-KEY-CentOS-6 # rpm -K zsh-4.3.10-7.el6.x86_64.rpm zsh-4.3.10-7.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK # rpm -K php-5.3.3-38.el6.x86_64.rpm php-5.3.3-38.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK --nosignature: 不檢查來源合法性 --nodigest: 不檢查完整性 rpm管理器數據庫:/var/lib/rpm 重建數據庫: rpm {--initdb|--rebuilddb} [-v] [--dbpath DIRECTORY] --initdb: 初始化數據庫,即數據庫完全不存時,可新建之; 例如: 我刪除__db.001、__db.002、__db.003、__db.004
# rm -rf /var/lib/rpm/__db.00{1..4}
# ll /var/lib/rpm/
總用量 57208
-rw-r--r--. 1 root root  5083136 11月 19 15:32 Basenames
-rw-r--r--. 1 root root12288 11月 10 15:20 Conflictname
-rw-r--r--. 1 root root  1044480 11月 19 15:32 Dirnames
-rw-r--r--. 1 root root  5263360 11月 19 15:32 Filedigests
-rw-r--r--. 1 root root20480 11月 19 15:32 Group
-rw-r--r--. 1 root root20480 11月 19 15:32 Installtid
-rw-r--r--. 1 root root49152 11月 19 15:32 Name
-rw-r--r--. 1 root root24576 11月 19 15:07 Obsoletename
-rw-r--r--. 1 root root 46825472 11月 19 15:32 Packages
-rw-r--r--. 1 root root  1343488 11月 19 15:32 Providename
-rw-r--r--. 1 root root   696320 11月 19 15:32 Provideversion
-rw-r--r--. 1 root root12288 11月 16 15:07 Pubkeys
-rw-r--r--. 1 root root   446464 11月 19 15:32 Requirename
-rw-r--r--. 1 root root   253952 11月 19 15:32 Requireversion
-rw-r--r--. 1 root root90112 11月 19 15:32 Sha1header
-rw-r--r--. 1 root root86016 11月 19 15:32 Sigmd5
-rw-r--r--. 1 root root12288 11月 10 15:20 Triggername
# rpm --initdb /var/lib/rpm/
# ll /var/lib/rpm/
總用量 58048
-rw-r--r--. 1 root root  5083136 11月 19 15:32 Basenames
-rw-r--r--. 1 root root12288 11月 10 15:20 Conflictname
-rw-r--r--  1 root root24576 11月 19 15:38 __db.001
-rw-r--r--  1 root root   229376 11月 19 15:38 __db.002
-rw-r--r--  1 root root  1318912 11月 19 15:38 __db.003
-rw-r--r--  1 root root   753664 11月 19 15:38 __db.004
-rw-r--r--. 1 root root  1044480 11月 19 15:32 Dirnames
-rw-r--r--. 1 root root  5263360 11月 19 15:32 Filedigests
-rw-r--r--. 1 root root20480 11月 19 15:32 Group
-rw-r--r--. 1 root root20480 11月 19 15:32 Installtid
-rw-r--r--. 1 root root49152 11月 19 15:32 Name
-rw-r--r--. 1 root root24576 11月 19 15:07 Obsoletename
-rw-r--r--. 1 root root 46825472 11月 19 15:32 Packages
-rw-r--r--. 1 root root  1343488 11月 19 15:32 Providename
-rw-r--r--. 1 root root   696320 11月 19 15:32 Provideversion
-rw-r--r--. 1 root root12288 11月 16 15:07 Pubkeys
-rw-r--r--. 1 root root   446464 11月 19 15:32 Requirename
-rw-r--r--. 1 root root   253952 11月 19 15:32 Requireversion
-rw-r--r--. 1 root root90112 11月 19 15:32 Sha1header
-rw-r--r--. 1 root root86016 11月 19 15:32 Sigmd5
-rw-r--r--. 1 root root12288 11月 10 15:20 Triggername

--rebuilddb: 無論當前數據存在與否,都會直接重建此庫; 總結: 基本管理:安裝、升級、卸載、查詢和校驗; 合法性驗正; 數據庫管理;
Copyright © Linux教程網 All Rights Reserved