Files
Linux/Docs/Yum打包Rpm文件.md
2026-09-17 22:29:26 +08:00

74 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本文作者:丁辉
# Yum打包Rpm文件
> 拿 vim 举例
## 方法一
1. 安装工具
```bash
yum install -y yum-plugin-downloadonly
```
2. 下载
```bash
yum install -y --downloadonly --downloaddir=. vim
```
3. 安装
```bash
rpm -ivh *.rpm --force --nodeps
```
## 方法二
> 只下载保存rpm文件包, 离线环境也可以用
1. 创建目录
```bash
mkdir /root/vim/
```
2. 下载
> 安装工具
>
> ```bash
> yum install yum-utils -y
> ```
>
>
```bash
yumdownloader --resolve --destdir=/root/vim/ vim
```
**参数解释**
## 各参数含义
| 参数 | 含义 |
| :----------------- | :----------------------------------------------------------: |
| `--enablerepo=` | 临时启用某个仓库。有些默认仓库可能是禁用的,启用来查找包。 |
| `--resolve` | 解析并下载依赖。不仅下载RPM包本身,还会自动解析它的所有依赖包并一并下载到目标目录,避免离线安装时缺依赖。 |
| `--destdir=/root/` | 指定下载文件的存放目录为 `/root/`。如果不指定,默认下载到当前工作目录。 |
3. 安装
```bash
cd /root/vim/ && rpm -ivh *.rpm --force --nodeps
```
或
```bash
yum localinstall -y *.rpm
```