How to make RPM package under CentOS? How to make RPM package under CentOS


Talk about rpm to many compiler installation friends, RPM installation is a fool installation.

Ha ha, in fact, RPM is a very effective centralized deployment solution.

Yum + rpm is a very fast and convenient large-scale deployment scheme.

The following is a brief introduction to the production of RPM

Take cronlog as an example

First download the cronlog source package.

Open the source package, tar xzvf cronlog-1.6.2 tar.gz

Find cronolog.spec This file is a configuration file for customizing how to generate RPM packages

vim cronolog.spec
%define name cronolog
%define version 1.6.2
%define release 1
%define group System Networking/Daemons
Summary:        a flexible log file rotation program for Apache
Name:           %{name}
Version:        %{version}
Release:        %{release}
Copyright:      Apache license
Group:          %{group}
Packager:       Andrew Ford <[email protected]>
BuildRoot:      /tmp/%{name}-root
"cronolog" is a simple program that reads log messages from its input
and writes them to a set of output files, the names of which are
constructed using template and the current date and time.  The
template uses the same format specifiers as the Unix date command
(which are the same as the standard C strftime library function).
%setup -n %{name}-%{version}
mkdir -p $RPM_BUILD_ROOT/usr/share/doc/%{name}-${RPM_PACKAGE_VERSION} -m 755
make prefix=$RPM_BUILD_ROOT/usr mandir=$RPM_BUILD_ROOT/usr/share/man install
install -m 644 README $RPM_BUILD_ROOT/usr/share/doc/%name-${RPM_PACKAGE_VERSION}
#install -m 644 $RPM_SOURCE_DIR/doc/cronolog.1m $RPM_BUILD_ROOT/usr/man/man1/cronolog.1
#install -m 755 $RPM_SOURCE_DIR/src/cronolog $RPM_BUILD_ROOT/usr/sbin/cronolog
#strip  $RPM_BUILD_ROOT/usr/sbin/* || echo Ignored strip on a non-binary file
#%attr(-,root,root) /usr/share/doc/%{name}-%{version}/README
%attr(-,root,root) /usr/sbin/cronolog
%attr(-,root,root) /usr/sbin/cronosplit
#%files man
%attr(644,root,root) /usr/share/man/man1/*.1*

Copy the code, then copy the source package to / usr / SRC / RedHat / sources/

cp cronolog-1.6.2.tar.gz /usr/src/redhat/SOURCES/

Execute, rpmbuild – BA cronolog.spec

The RPM package is generated^_^

ls -l /usr/src/redhat/RPMS/i386/