RPM介绍
最初只有.tar.gz的打包的源码文件,用户必须编译每个他想在GNU/Linux上运行的软件。用户们急需系统提供一种方法来管理这些安装在机器上的软件,当Debian诞生时,这样一个管理工具也就应运而生,它被命名为dpkg。从而著名的“package”概念第一次出现在GNU/Linux系统中,后来Red Hat才开发自己的“rpm-RedHat Packeges Manager”包管理系统,但是其原始设计理念是开放式的,包括OpenLinux、S.u.S.E.以及Turbo Linux等Linux的分发版本都有采用,可以算是公认的行业标准了。
包的组成:
二进制文件、库文件、配置文件、帮助文件
包文件组成(每个包独有):
RPM包内的文件
RPM的元数据,如名称、版本、依赖性、描述等
安装或卸载时运行的脚本
程序包的来源:
获取包的途径:
1)系统发布的光盘或官方的服务器
CentOS镜像:
https://www.centos.org/download/
http://mirrors.aliyun.com
http://mirrors.sohu.com
http://mirrors.163.com
2)项目官方站点
3)第三方组织:
Fedora-EPEL:
Extra Packages for Enterprise Linux
Rpmforge:RHEL推荐,包很全
搜索引擎:
http://pkgs.org
http://rpmfind.net
http://rpm.pbone.net
https://sourceforge.net/
4)自己制作
注意:第三方包建议要检查其合法性,来源合法性,程序包的完整性
包命名:
源码包命名:
name-VERSION.tar.gz|bz2|xz
VERSION: major.minor.release
源码包命名示例:mariadb-10.5.5.tar.gz
RPM包命名
name-VERSION-release.arch.rpm
示例:bash-4.2.46-19.el7.x86_64.rpm
VERSION:major,minor.release
release:release.OS
常见arch:
x86:i386,i486,i586,i686
x86_64:x64,x86_64,amd64
powerpc:ppc
和平台无关:noarch
rpm常见用法
安装、卸载、升级、查询、校验、数据库维护。
安装
-i 安装package
-v --verbose
provide more detailed output
-h --hash
print hash marks as package installs
–test
don’t install, but tell if it would work or not
–nodeps
do not verify package dependencies
–replacepkgs
reinstall if the package is already present
–replacefiles
ignore file confilcts between packages
–noscripts
–nopre 安装前脚本
–nopost 安装后脚本
–nopreun 卸载前脚本
–nopostun 卸载后脚本
Dont’t execute the scriptlet of the same name.The --noscripts
option is equivalent to --nopre --nopost --nopreun --nopostun and turns off the execution of the corresponding %pre,%post,%preun,and %postun scriptlet(s).
升级
-F|–freshen
This will upgrade packages,but only ones for which an earlier version is installed .
-U|–upgrade
This upgrades or installs the package currently installed to a newer version. This is the same as install, except all other version(s) of the package are removed after the new package is installed.
查询
-a,–all
Query all installed packages.
-f,–file
Query package owning FILE
-p
Query an (uninstalled) package PACKAGE FILE.
-c,–configfiles
List only configuration files
-i
Display package information,including name,version,and description.
-l,–list
List files in package.
-d, --docfiles list all documentation files
–scripts
List the package specific scriptlet(s) that are used as part of the installation and uninstallation processes.
卸载
包校验
-V
S file Size differs
M Mode differs (includes permissions and file type)
5 digest differs
D Device major/minor number mismatch
L readLink(2) patch mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ
–import 倒入校验文件
-K 检查包的完整性和签名
其他选项
--changelog list change logs this package rpm -q --changelog openssh |grep "cve"
#查询openssh安装包修复的CVE漏洞`
–scripts list install/erase scriptlets from package(s)