rpmbuild 编译
rpmbuild 是用于 将源码包 编译成rpm包
安装rpmbuild 程序
yum -y install rpm-build
不建议用管理员做
[root@linuxidc 桌面]# useradd linuxidc
[root@linuxidc 桌面]# su – linuxidc
[linuxidc@linuxidc ~]$ rpm --eval %configure 查看 rpm默认环境下的宏的
编写一个spec 的文件
vim httpd.spec
Name: httpd 名字
Version: 2.2.25 版本号
Release: 1%{?dist} 软件包释出号
Summary: apache 2.2.25 server 描述信息
Group: Amusements/Graphics 软件包组类型
License: GPL
URL: http://www.tarena.com
Source0: httpd-2.2.25.tar.gz
BuildRoot: %(mktemp -ud%{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: gcc,gcc-c++,openssl-devel
#Requires:
%description
this is a web server
%prep
%setup -q
%build
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite\
--enable-ssl --enable-cgi --enable-charset-lite \
--enable-suexec --with-suexec-caller=daemon \
--with-suexec-docroot=/usr/local/apache/htdocs
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%clean
rm -rf %{buildroot}
make clean
%files
%defattr(-,root,root,-)
%config /usr/local/apache/conf/*
%doc /usr/local/apache/man/*
%doc /usr/local/apache/manual/*
/usr/local/apache/bin/*
/usr/local/apache/build/*
/usr/local/apache/cgi-bin/*
/usr/local/apache/error/*
/usr/local/apache/htdocs/*
/usr/local/apache/icons/*
/usr/local/apache/lib/*
%dir /usr/local/apache/logs
/usr/local/apache/include/*
/usr/local/apache/modules/*
%post
cp /usr/local/apache/bin/apachectl/etc/init.d/apache
sed -i '2a # chkconfig: 35 85 25 '/etc/init.d/apache
sed -i '3a # description: this is webserver ' /etc/init.d/apache
chkconfig --add apache
%postun
%postun
chkconfig --del apahce
rm -rf /etc/init.d/apache
%changelog
* Mon Jan 27 2014 localhost <[email protected]>
- First compile
- httpd-2.2.25
13,1
group 可以自己定义但最好使用系统预定义组的组名
vim /usr/share/doc/rpm-4.8.0/GROUPS
[linuxidc@linuxidc ~]$ rpmbuild httpd.spec
[linuxidc@linuxidc ~]$ ls
httpd-2.2.25.tar.gz httpd.spec rpmbuild
[linuxidc@linuxidc ~]$ cp httpd-2.2.25.tar.gzrpmbuild/SOURCES/ && chmod 644 rpmbuild/SOURCES/httpd-2.2.25.tar.gz
[linuxidc@linuxidc ~]$ cp httpd.specrpmbuild/SPECS/
[linuxidc@linuxidc ~]$ rpmbuild -barpmbuild/SPECS/httpd.spec 开始编译
[linuxidc@linuxidc ~]$ ls rpmbuild/RPMS/x86_64/
httpd-2.2.25-1.el6.x86_64.rpm
[linuxidc@linuxidc ~]$ ls rpmbuild/RPMS/x86_64/
httpd-2.2.25-1.el6.x86_64.rpm
[linuxidc@linuxidc ~]$ ls rpmbuild/RPMS/x86_64/
httpd-2.2.25-1.el6.x86_64.rpm
表示成功
建议编译前先自己安装下源码包在进行rpmbuild编译