yum-utils工具集详解

Yum-utils 剖析

功能简介:

管理repository及扩展包的工具 (主要是针对repository)

准备:

1.安装createrepo ,可以通过如下命令实现

yum install createrepo

  1. rpm包放在/media

命令简介

一、 debuginfo-install :

安装debuginfo 包及其依赖

选项:

-h, --help

-t, --tolerant :

允许有错误

-C :

从cache 中运行,且不更新cache

-c [config file ] :

配置文件位置

-R [minutes] :

命令行等待的最长时间

-d [debug level] :

debugging output level

--showduplicates :

show duplicates, in repos, in list/search commands 显示重复

-e [error level] :

error output level

-q, --quiet :

quiet operation

-v, --verbose :

verbose operation (详细)

-y : answer yes for all questions

--version : show Yum version and exit

--installroot=[path]

set install root

--enablerepo=[repo]

enable one or more repositories (wildcards allowed)

--disablerepo=[repo]

disable one or more repositories (wildcards allowed)

-x [package], --exclude=[package]

exclude package(s) by name or glob

--disableexcludes=[repo]

disable exclude from main, for a repo or for everything

--obsoletes :

enable obsoletes processing during updates

--noplugins :

disable Yum plugins (插件)

--nogpgcheck :

disable gpg signature checking

--disableplugin=[plugin]

disable plugins by name

--enableplugin=[plugin]

enable plugins by name

--skip-broken :

skip packages with depsolving problems

--color=COLOR :

control whether color is used

  1. package-cleanup: 清除重复包、孤儿包、及明显的包依赖问题
    GENERAL OPTIONS:
    -c :
    使用-c 后面指定的配置文件,默认是 /et/yum.conf
    -h : 帮助
    -q , --quiet :
    Print out nothing unecessary
    -v , --version :
    报告程序版本同时退出
    -y :
    响应任何请求
    --leaves :
    列出local RPM database 中的叶子节点。即没有软件包依赖叶节点。
    --orphans:
    列出从当前软件仓库库中无法安装的包
    --oldkernels:
    删除老的 kernel 及kernel-devel 包
    --problems :
    列出local RPM database 中的赖问题
    --dupes :
    扫描local RPM database 中重复的包
    --cleandupes :
    扫描本地rpm数据库中重复的包并清除老版本的rpm包

leaves options :

--all:列出所有的节点,包括不是本库中的

--leaf-regex :

指定某rpm包为叶子节点

--exclude-bin:

除了在bin 目录中出现的包,其他的包都列出来

oldkernels options:

--count :

保持对系统内核软件包的数量,默认为2

--keepdevel :

删除内核时不删除kernel-devel

例子:

  1. 列出所有存在问题的依赖
    package-cleanup --problems
  2. 列出不属于任何repository的包
    package-cleanup --orphans
  3. 删除旧版本的kernel ,并保存3个包,保留kernel-devel
    package-cleanup --oldkernels --count=3 --keepdevel
    4.列出在bin目录下没有文件且以 perl 或者 python开头的叶子节点包
    package-cleanup --leaves --exclude-bin --leaf-regex="^(perl)|(python)"

结果为:

#package-cleanup --leaves --exclude-bin --leaf-regex="^(perl)|(python)"

Loaded plugins: fastestmirror

perl-Crypt-SSLeay-0.57-16.el6.x86_64

perl-XML-Dumper-0.81-6.el6.noarch

perl-XML-Grove-0.46alpha-40.el6.noarch

perl-core-5.10.1-115.el6.x86_64

三、repo-graph: 以点格式输出一个完整的软件包依赖关系列表

格式:

repo-graph [options]

options:

--repoid=REPOID :

指定使用哪个软件仓库

-c CONFIFILE :

config file location

四、 repo-rss : 一个RSS feed 生成一个或多个资料库

格式:

repo-rss [options] repoid1 repoid2

选项:

-h :

-f :

指定RSS生成的文件名,默认是repo-rss.xml

-l :

RSS feed 的URL, 默认是 http://yum.baseurl.org/

-t TITLE :

指定RSS feed的标题, 默认是RSS "Repository - Recent Packages".

-d DESCRIPTION: :

Default is "Most recent packages in Repositories".

-r DAYS :

指定的天数,默认是3

--tempcache :

使用yum缓存启用一个临时目录(由非root用户默认启用)

-g :

Generate one feed per package group

-a ARCHES :

arches to use -- can be listed more than once

-c CONFIG :

config file

五、 repoclosure : 读取元数据资料库,检查依赖关系,并显示未解决的依赖列表

options:

-h:

-c CONFIG, --config=CONFIG

config file to use (defaults to /etc/yum.conf)

-a ARCH, --arch=ARCH check packages of the given archs, can be specified

multiple times (default: current arch)

--basearch=BASEARCH :

set the basearch for yum to run as

-b, --builddeps :

check build dependencies only (needs source repos enabled)

-r REPOID, --repoid=REPOID :

specify repo ids to query, can be specified multiple

times (default is all enabled)

-t, --tempcache :

Use a temp dir for storing/accessing yum-cache

-q, --quiet :

quiet (no output to stderr)

-n, --newest :

check only the newest packages in the repos

--repofrompath=REPOFROMPATH

specify repoid & paths of additional repositories -

unique repoid and complete path required, can be

specified multiple times.

Example.

--repofrompath=myrepo,/path/to/repo

-p PKG, --pkg=PKG :

check closure for this package only

-g GROUP, --group=GROUP

check closure for packages in this group only

六、repodiff : 比较一个或多个资料库的差异并返回一个显示增加,删除,改变的包的列表

格式:

repodiff --old=old_repo_baseurl --new=new_repo_baseurl

options:

--version :

show program's version number and exit

-h, --help show this help message and exit

-n NEW, --new=NEW :

new baseurl[s] for repos

-o OLD, --old=OLD :

old baseurl[s] for repos

-q, --quiet :

-a ARCHLIST, --archlist=ARCHLIST

In addition to src.rpms, any arch you want to include

-s, --size :

Output size changes for any new->old packages

--simple :

output simple format

七、 repomanage :

manage a directory of rpm packages, returns lists of newest or oldest packages in a directory for easy piping to xargs or similar programs.

管理rpm包的目录,在目录返回最新或最古老的软件包列表

格式:

repomanage [--old] [--new] path

options:

-h, --help

-o, --old :

print the older packages

-n, --new :

print the newest packages

-s, --space :

space separated output, not newline

-k KEEP, --keep=KEEP :

newest N packages to keep -defaults to 1

-c , nocheck:

do not check package payload signatures/digests

八、 repoquery : 查询yum库,并得到他们的额外信息

格式:

repoquery [options] <item...>

repoquery -a [options]

CENERAL OPTION

--querytags : 列出有效的queryformat标签并退出
-v :报告程序版本并推出
--repoid=<repo>
-q: 为了兼容,不做任何事
--quiet :错误输出没有警告
--verbose :输出详细资料
-C:从缓存中yum
--tempcache :使用私有的cache代替main YUM cache
-c <config file>, --config=<config file>  : 指定配置文件,默认是/etc/yum.conf

Package Query options:

-i, --info:  as  rpm -qi
-l , --list : 列出包中的文件
-R, --requires :  
      列出包的依赖
--resolve  :
      When used with --requires, resolve capabilities to originating packages.
--provides :
    list capabilities package provides  
    列出该rpm包提供了哪些包
--obsoletes :
    list capabilities obsoleted by package  (过时包)
    列出该rpm包废弃了哪些包
--conflicts :
    list capabilities conflicting with package
    列出哪些包和该包冲突了
--changelog :
    list package changlog
    列出包的changelog
--location :
    show a location where the package could be downloaded from.
    显示包的下载地址
-s, --source :
    show package source RPM name.
    显示包的source  rpm包名
--groupmember  PACKAGE :
    list the repodata groups  (yumgroups.xml)  belongs  to (if any)
--nvr :
    use  name-version-release output format (rpm query default)
以name-version-release 形式输出包名
--nevra :
    use  name-epoch:version-release.architecture  output format (default)
    以 name-epoch:version-release.architecture 形式输出包名
--envra :
    use epoch:name-version-release.architecture output format (easier to parse than nevra)
    以 epoch:name-version-release.architecture 形式输出包名
--qf=FORMAT, --queryformat=FORMAT:
    specify custom output format for queries
    以某一特定形式输出

PACKAGE SELECTION OPTIONS:

-a :

query all availabel packages

-f, --file FILE :

query package owning FILE.

--whatobsoletes CAPABILITY:

query all packages that obsolete CAPABLITY

--whatconflicts CAPABILITY

query all packages that confict with CAPABILITY (冲突)

--whatprovides CAPABILITY

query all packages that provied CAPABILITY

--whatrequires CAPABILITY :

query all packages that require CAPABILITY

--alldeps:

when used with --whatrequires, use both automatic and manual dependencies for the query

--archlist=ARCH1 [,ARCH2...]

特定架构的包

--pkgnarrow=WHAT

limit what packages are considered for the query .Valid values for WHAT are: installed, available, recent, updates, extras, all and repository (default).

--show-dupes

query all versions of package. By default only newest packages are considered.

GROUP QUERY OPTIONS;

-i, --info:

show general information about group

-l, --list:

list packages belonging to (required by) group

--grouppkgs=WHAT:
    Specify what type of packages are queried from groups. Valid values for WHAT are all, mandatory, default, optional

--requires:
    list groups required by group

GROUP SELECTION OPTIONS:

-a : query all available groups

-g: query groups instead of packages

例子:

  1. 列出所有包名中 有perl 的包

    repoquery 'perl'

  2. 列出所有依赖openssl 的包

    repoquery --whatrequires --alldeps openssl

  3. List all package names and the repository they come from, nicely formatted:

    repoquery -a --qf "%-20{repoid} %{name}"

  4. List name and summary of all available updates (if any), nicely formatted:

    repoquery -a --pkgnarrow=updates --qf "%{name}:\n%{summary}\n"

  5. List optional packages in base group:

    repoquery -g --grouppkgs=optional -l base

  6. List build requirements from 'anaconda' source rpm:

    repoquery --requires anaconda.src

  7. List packages which BuildRequire gail-devel

    repoquery --archlist=src --whatrequires gail- devel

九、reposync: 同步远程yum仓库,使用yum来获取软件包到本地目录

格式:

reposync [options]

options:

-h, --help

-c CONFIG, --config=CONFIG:

config file to use (defaults to /etc/yum.conf)

-a ARCH, --arch=ARCH :

act as if running the specified arch (default: current arch, note: does not override $releasever)

--source:

also download .src.rpm files

-r REPOID, --repoid=REPOID

specify repo ids to query , can be specified multiple times (default is all enabled)

-t, --tempcache

Use a temp dir for storing/accessing yum-cache.

-p DESTDIR, --download_path=DESTDIR

path to download packages to : defaults to current directory

-g, --gpgcheck

remove packages that fail GPG signature checking after downloading .

-u, --urls :

just list urls of what would be downloaded, don't download.

-n, --newest-only:

Download only newest packages per-repo

-q, --quiet

output as little information as possible .

例子:

1.Sync all packages from the 'updates' repo to the current directory:

reposync --repoid=updates

2.Sync only the newest packages from the 'updates' repo to the current directory:

reposync -n --repoid=updates

  1. Sync packages from the 'updates' and 'extras' repos to the current directory:

reposync --repoid=updates --repoid=extras

4.Sync all packages from the 'updates' repo to the repos directory:

reposync -p repos --repoid=updates

  1. repotrack: 跟踪包及其依赖,并将该包及其依赖下载

    -r REPOID, --repoid=REPOID : 查询指定的repo id ,可以被指定多次

    -a ARCH, --arch=ARCH 修改包的arch

    -t, --tempcache :用一个临时的目录存储yum-cache

    -p DESTDIR , --download_path=DESTDIR :包的下载到的地址

    -u, --urls : 列出下载包的url,但是并不下载

    -n, --newest :下载并将原来的包换成最新的包

    -q, --quiet : 尽可能少的输出

  2. yum-builddep :安装某个包的依赖

    yum-builddep [options] package1 [package2] [package...]

    options:

    -t, --tolerant :允许有错误

    -C:

    -c [config file ] config file location

    -R [minutes] 命令行等待最长时间

    -d [debug level] debugging output level

    --showduplicates : 显示重复

    -e [error level] : error output level

    -q, --quiet quite operation

    -v, --verbose : 详细的操作

    -y : answer yes for all questions

    --version : show yum version and exit

    --installroot-[path] : set install root

    --enablerepo=[repo]

    enable one or more repositories (wildcards allowed)

    --disablerepo=[repo]

    disabel one or more repositories (wildcards allowed)

    -x [package], --exclude=[package]

    exclude package(s)by name or glob

    --disableexcludes=[repo]

    disable exclude from main, for a repo or for everything

    --obsoletes :

    enable obsoletes processing during updates

    --noplugins :

    disable plugins by name

    --nogpgcheck :

    disable gpg signature checking

    --disableplugin=[plugin]

    disable plugins by name

    --enableplugin=[plugin]

    enable plugins by name

    --skip-broken :

    skip packages with depsolving problems

    --color=COLOR

    control whether color is used

    例子:

    下载并安装kernel 需要的所有的RPM包

    yum-builddep kernel

  3. yum-complete-transaction : 发现不完整包或者因yum中止而导致的包不完整,把其补充完整

    格式:

    yum-complete-transaction [options]

    CENERAL OPTIONS:

    --cleanup-only :

    do not complete the transaction just clean up

    清除不完全的包

    -t , --tolerant :
    be tolerant of errors
    -C : run entirely from cache , don't update cache
    -c [config file ] :
    config file location
    -R [minutes]:
    maximum command wait time
    -d [debug level]:
    debugging output level
    --showduplicates :

  4. yumdownloader : 从rpm仓库中下载rpm源码包
    格式:
    yumdownloader [options] package1 [package2...]
    GENERAL OPTIONS :
    -h, --help
    --destdir DIR
    specify a destination directory for the download. Defaults to the current directory
    指定下载程序rpm包存放目录
    --urls :
    Instead of downloading RPMS, list the URLs that would be downloaded .
    列出要下载包的url

    --resolve:
    when dowloading RPMs, resolve dependencies and also download the required packages.
    下载rpm 包时解决依赖问题,并下载相关的包
    --source :
    下载源码包

例子:

  1. 下载kernel RPM 包到 /var/tmp
    yumdownloader --destdir /var/tmp kernel
  2. 列出 kernel 和 kernel-smp RPM 包的url
    yumdownloader --urls kernel kernel-smp

                        版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/xiaoxiao_22/article/details/7044583

相关推荐
热爱嵌入式的小许3 小时前
Linux基础项目开发1:量产工具——显示系统
linux·运维·服务器·韦东山量产工具
韩楚风7 小时前
【linux 多进程并发】linux进程状态与生命周期各阶段转换,进程状态查看分析,助力高性能优化
linux·服务器·性能优化·架构·gnu
陈苏同学7 小时前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
Ambition_LAO7 小时前
解决:进入 WSL(Windows Subsystem for Linux)以及将 PyCharm 2024 连接到 WSL
linux·pycharm
Pythonliu77 小时前
茴香豆 + Qwen-7B-Chat-Int8
linux·运维·服务器
你疯了抱抱我8 小时前
【RockyLinux 9.4】安装 NVIDIA 驱动,改变分辨率,避坑版本。(CentOS 系列也能用)
linux·运维·centos
追风赶月、8 小时前
【Linux】进程地址空间(初步了解)
linux
栎栎学编程8 小时前
Linux中环境变量
linux
挥剑决浮云 -8 小时前
Linux 之 安装软件、GCC编译器、Linux 操作系统基础
linux·服务器·c语言·c++·经验分享·笔记
小O_好好学9 小时前
CentOS 7文件系统
linux·运维·centos