源码编译RPM安装包
发表于 · 归类于
技术 · 阅读完需 5 分钟 ·
阅读量 报告错误
(1)编译最新版本Nginx
安装rpm-build软件包
yum -y install rpm-build
生成rpmbuild目录结构
rpmbuild -ba nginx.spec
将源码软件复制到SOURCES目录
cd /root/rpmbuild/SOURCES/ && wget https://nginx.org/download/nginx-1.24.0.tar.gz
创建并修改SPEC配置文件
vim /root/rpmbuild/SPECS/nginx.spec
Name:nginx
Version:1.24.0
Release:1
Summary:nginx is a web server
Group:nginx
License:GPL
URL:nginx.org
Source0:nginx-1.24.0.tar.gz
Source1:nginx
#BuildRequires:
#Requires:
%description
this is web server
%prep
%setup -q
%build
./configure
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
install -p -D -m 0755 %{SOURCE1} %{buildroot}/etc/init.d/nginx
%files
%doc
/usr/local/nginx/*
/etc/init.d/nginx
%changelog
以下3行代码的目的是将~/rpmbuild/SOURCES/nginx
文件生成为系统的/etc/init.d/nginx
文件,也可对原文件覆盖
Source1:nginx
install -p -D -m 0755 %{SOURCE1} %{buildroot}/etc/init.d/nginx
/etc/init.d/nginx
编译过程
rpmbuild -ba rpmbuild/SPECS/nginx.spec
查看编译文件
ll /root/rpmbuild/RPMS/x86_64/
查看包信息
测试安装结果
rpm -ivh /root/rpmbuild/RPMS/x86_64/nginx-1.24.0-1.x86_64.rpm
设置软链
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
设置启动
vim /etc/init.d/nginx
(2)编译最新版本Ruby
./configure --prefix=/usr/local/ruby
rpm -ivh 包名 --nodeps --force
失败了
(3)把文件打包到rpm包中
Name:webfiles
Version:1.1.2
Release:1%{?dist}
Summary:this is a file package
Group:gihub
License:GPL
URL:github.cn
#Source0:bbb
Source1:aaa
Source2:index.html
Source3:0602.html
Source4:folder
#BuildRequires:
#Requires:
%description
this is files
#%prep
#%setup -q
#%build
%install
install -p -D -m 0755 %{SOURCE1} %{buildroot}/webfiles/nginx2
install -p -D -m 0755 %{SOURCE2} %{buildroot}/webfiles/index.html
install -p -D -m 0755 %{SOURCE3} %{buildroot}/webfiles/0602.html
mkdir %{buildroot}/webfiles/folder/ #不会自动创建文件夹,要先创建文件夹
install -p -D -m 0755 %{SOURCE4}/* %{buildroot}/webfiles/folder
#cp -ar %{SOURCE4}/* %{buildroot}/webfiles/folder/ #或者用这行代码
%files
/webfiles/folder
%doc
/webfiles/nginx2
/webfiles/index.html
/webfiles/0602.html
#/webfiles/folder
%changelog