Linux下软件部署安装管理----rpmbuild打包rpm包部署安装
来源:微信公众号「编程学习基地」
文章目录
- 1.安装rpmbuild
- 2.rpm包制作
- 打包rpm包
- 3.rpm包安装
- 4.rpm包卸载
1.安装rpmbuild
yum install rpmbuild
yum install rpmdevtools
创建rpm包管理路径,生成rpm相关目录
RPM打包的时候需要编译源码,还需要把编译好的配置文件,二进制命令文件之类的东西按照安装好的样子放到合适的位置,还要根据需要对RPM的包进行测试,这些都需要先有一个“工作空间”。rpmbuild命令使用一套标准化的“工作空间”:
[root@ ~]# rpmdev-setuptree
[root@ ~]# ls
rpmbuild
[root@iZbp1gjp1hwnsngz9ayrlnZ ~]# cd rpmbuild/
[root@iZbp1gjp1hwnsngz9ayrlnZ rpmbuild]# ls
BUILD RPMS SOURCES SPECS SRPMS
rpmdev-setuptree这个命令就是安装rpmdevtools带来的。
手动创建
如果没有安装rpmdevtools的话,其实用mkdir命令创建这些文件夹也是可以的。
#使用下面的目录手动目录
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
2.rpm包制作
下载源码
这里直接下载官方例子的源码,是个压缩包
wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
mv hello-2.10.tar.gz /root/rpmbuild/SOURCES/
编辑SPEC文件
vim soft.spec
模板如下
Name: hello
Version: 2.1
Release: 1%{?dist}
Summary: The "Hello World" program from GNU
Summary(zh_CN): GNU "Hello World" 程序
License: GPLv3+
URL: http://ftp.gnu.org/gnu/hello
Source0: http://ftp.gnu.org/gnu/hello/%{name}-%{version}.tar.gz%description
The "Hello World" program, done with all bells and whistles of a proper FOSS
project, including configuration, build, internationalization, help files, etc.%description -l zh_CN
"Hello World" 程序, 包含 FOSS 项目所需的所有部分, 包括配置, 构建, 国际化, 帮助文件等.%prep
%setup -q%build
%configure
make %{?_smp_mflags}%install
make install DESTDIR=%{buildroot}%files
%doc%changelog
* Sun Dec 4 2016 Your Name <youremail@xxx.xxx> - 2.10-1
- Update to 2.10
* Sat Dec 3 2016 Your Name <youremail@xxx.xxx> - 2.9-1
- Update to 2.9
本示例最终的完整SPEC
Name: hello
Version: 2.10
Release: 1%{?dist}
Summary: The "Hello World" program from GNU
Summary(zh_CN): GNU "Hello World" 程序
License: GPLv3+
URL: http://ftp.gnu.org/gnu/hello
Source0: http://ftp.gnu.org/gnu/hello/%{name}-%{version}.tar.gzBuildRequires: gettext
Requires(post): info
Requires(preun): info%description
The "Hello World" program, done with all bells and whistles of a proper FOSS
project, including configuration, build, internationalization, help files, etc.%description -l zh_CN
"Hello World" 程序, 包含 FOSS 项目所需的所有部分, 包括配置, 构建, 国际化, 帮助文件等.%prep
%setup -q%build
%configure
make %{?_smp_mflags}%install
make install DESTDIR=%{buildroot}
%find_lang %{name}
rm -f %{buildroot}/%{_infodir}/dir%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :%preun
if [ $1 = 0 ] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi%files -f %{name}.lang
%doc AUTHORS ChangeLog NEWS README THANKS TODO
%license COPYING
%{_mandir}/man1/hello.1.*
%{_infodir}/hello.info.*
%{_bindir}/hello%changelog
* Sun Dec 4 2016 Your Name <youremail@xxx.xxx> - 2.10-1
- Update to 2.10
* Sat Dec 3 2016 Your Name <youremail@xxx.xxx> - 2.9-1
- Update to 2.9
打包rpm包
rpmbuild -ba soft.spec
看一下打包好的rpm包
tree /root/rpmbuild/*RPMS
/root/rpmbuild/RPMS
└── x86_64├── hello-2.10-1.el7.x86_64.rpm└── hello-debuginfo-2.10-1.el7.x86_64.rpm
/root/rpmbuild/SRPMS
└── hello-2.10-1.el7.src.rpm
3.rpm包安装
rpm -ivh xxx.rpm --nodeps --force
– nodeps
Linux下软件部署安装管理----rpmbuild打包rpm包部署安装相关推荐
- 安装jdk步骤rpm_jenkins rpm包方式安装
war包方式安装jenkins已经说过java openjdk的安装和注意事项,这里不做赘述 前提:确保 java的jdk或者jre已安装 #]java -version #]whereis java ...
- Centos7 安装GPU驱动(rpm包方式安装) 亲测,出坑 NVIDIA-SMI has failed because it couldn’t communicate...
删除驱动 查看安装的nvidia模块命令 rpm -qa|grep -i nvid|sort 删除找到的模块 yum remove kmod-nvidia-* 一.查看支持CUDA的GPU列表 :ls ...
- centos6/7 yum安装mysql客户端和rpm包方式安装方式
查看操作系统版本 cat /etc/redhat-release 这个命令就会查看该操作系统上是否已经安装了mysql数据 rpm -qa | grep mysql [root@larry ~]# r ...
- 项目打包rpm包(rpmbuild)
这里以python项目为例,通过rpmbuild工具打包成rpm包,并进行安装验证 rpmbuild打包 rpm流程 构建rpmbuild打包目录 rpmbuild 默认变量配置文件 将我们的pyth ...
- linux用卸载软件管理,Linux下软件的安装卸载管理
一.Linux应用程序组成 1. 普通执行程序文件,保存在"/usr/bin"目录中 2. 服务器执行程序文件和管理程序文件,保存在"/usr/sbin"目录中 ...
- linux下软件的安装[转]
linux下软件的安装 先来看看Linux软件扩展名.软件后缀为.rpm最初是Red Hat Linux提供的一种包封装格式,现在许多Linux发行版本都使用:后缀为.deb是Debain Linux ...
- Linux下软件的安装与卸载
在Windows下安装软件时,只需运行软件的安装程序(setup.install等)或者用zip等解压缩软件解开即可安装,运行反安装程序(uninstall.unware."卸载" ...
- 【转】Linux下软件安装的几种方式
转自Linux下软件安装的几种方式 Linux 系统的/usr目录 Linux 软件安装到哪里合适,目录详解 Linux 的软件安装目录是也是有讲究的,理解这一点,在对系统管理是有益的 /usr:系统 ...
- linux下软件更新,Linux安装软件每次靠百度,这次花了些时间,终于算是搞明白了...
Linux下安装命令虽然经常使用,但也仅仅是会使用,每次再用时依然的百度 .于是就花了些时间整理了一番,以便于更好地理解. 1.安装流程介绍 在Linux下安装软件,其实也是遵循着和Windows一样 ...
- Linux下软件的安装与卸载方法
第一章 linux下安装软件,如何知道软件安装位置 注:一般的软件的默认安装目录在/usr/local或者/opt里,可以到那里去找找. 指令名称:whereis 功能介绍:在特定目录中查找符合条 ...
最新文章
- 工业物联网为“两化融合”带来巨大推力
- 爬虫神器xpath的用法(一)
- 无限“递归”的python程序
- codeforces 483B Friends and Presents 解题报告
- 工作106:crul哈哈概念
- STM32f103——ILI9341
- MATLAB(四)在高等数学中的应用
- Java 平台有哪几个版本?
- Win7系统打印机删除不掉的解决方法
- 最近公司需要监测网络PING写了一个脚本
- 微信程序短视频去水印源码 开源产品未加密未授权相关文章
- Delphi XE不生成__history目录
- Leader:这样的 Bug 你也写的出来???
- C#:合并EXCEL文件工作表列
- 沟通表达的实用技巧和练习方法
- 深度Deepin20 安装软件的依赖问题(sudo apt --fix-broken install)
- 【参透浏览器原理】1—— 为什么明明浏览器只打开了一个页面,却出现了多个进程
- 9139 位艺人在 Python 面前不值一提 # Python 爬虫小课 5-9
- 网页三栏布局常用方法
- 从CSDN博客到出书,我的新书《SQL编程思想》是这样诞生的