Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Build RPM package on Linux

  sonic0002        2013-03-22 12:44:29       5,941        0    

1. Check the OS version and core version

#uname -a

#more /etc/redhat-release

2. Create relative directories

/usr/src/redhat/SOURCES    //Store source codes, patches, icons etc

/usr/src/redhat/SPECS        //Store specs about the process of building RPM packages

/usr/src/redhat/BUILD     //File after uncompressed are stored here

/usr/src/redhat/RPMS     //Store the binary files built with rpmbuild

/usr/src/redhat/SRPMS   //Store source code package built with rpmbuild

 

#mkdir -p /usr/src/redhat/

#cd /usr/src/redhat/

#mkdir SOURCES SPECS BUILD RPMS SRPMS

3. Download Nginx source package

Download source package to SOURCES directory and do not uncompress it.

#wget http://nginx.org/download/nginx-1.3.9.tar.gz

4. Create spec files

Since spec file is written using spec language, please take note about the syntax of spec.

#cd /usr/src/redhat/SPECS/

#cat < nginx.spec > EOC

Summary:  High Performance Web Server

Name:  nginx

Version:  1.3.9

Release:  el5

License:  GPL

Group:  Applications/Server

Source:  http://nginx.org/download/nginx-1.3.9.tar.gz

URL:  http://nginx.org/

Distribution:  Linux

Packager:  JingSheng <jingsheng1@staff.sina.com.cn>

%description

nginx  [engine x] is a HTTP and reverse proxy server

%prep

useradd  nginx -s /sbin/nologin

rm -rf  $RPM_BUILD_DIR/nginx-1.3.9

zcat  $RPM_SOURCE_DIR/nginx-1.3.9.tar.gz | tar -xvf -

%build

cd  $RPM_BUILD_DIR/nginx-1.3.9

./configure  --user=nginx --group=nginx --prefix=/usr/local/nginx/ --with-http_stub_status_module  --with-http_ssl_module

make

%install

cd  $RPM_BUILD_DIR/nginx-1.3.9

make  install

%preun

if [ -z  "`ps aux | grep nginx | grep -v grep`" ];then

killall  nginx >/dev/null

exit 0

fi

%files

/usr/local/ngin

Line begin with # is comment, rpm will ignore it.

Summary : Simple description of the software

Name : Define name of RPM

Version : Software version

Release : Release version

License : Which license it uses

Group : Type of software

Source : The download address of the source

URL : Website about the source code

Description : Detail introduction of the software, can have multiple lines

%prep: Processes before the software is compiled

%build : Start build the software such as make

%install : Start to install the software such as make install

%files : Specify which files should be packaged such as /usr/local/nginx/

%qrerun : Define actions to be taken before software uninstall. For example kill the process

5. Start RPM build

Before build RPM package, you need to download the build tool first.

#yum install -y gcc rpm-build pcre-devel

Start to build the RPM package

# rpmbuild-bb nginx.spec

Source : http://cloudbbs.org/forum.php?mod=viewthread&tid=13065

 

LINUX  BUILD  RPM 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.