Create an rpm package in Centos

Source: Internet
Author: User

There are many friends who talk about RPM compilation and installation. RPM installation is a dumb installation.
In fact, RPM is a very effective centralized deployment solution.
Yum + RPM is a fast and convenient large-scale deployment solution.
The following describes how to create an rpm:
Taking cronolog as an example:
First download the source code package of cronolog.
Undo source package, tar xzvf cronolog-1.6.2.tar.gz
Find cronolog. spec. This file is a configuration file that customizes how to generate an RPM package.

vim cronolog.spec%define name cronolog%define version 1.6.2%define release 1%define group System Networking/DaemonsSummary:        a flexible log file rotation program for ApacheName:           %{name}Version:        %{version}Release:        %{release}Copyright:      Apache licenseGroup:          %{group}Packager:       Andrew Ford <A.Ford@ford-mason.co.uk>URL:            http://www.ford-mason.co.uk/resources/cronolog/Source:         http://www.ford-mason.co.uk/resources/cronolog/cronolog-%version.tar.gzBuildRoot:      /tmp/%{name}-root%description"cronolog" is a simple program that reads log messages from its inputand writes them to a set of output files, the names of which areconstructed using template and the current date and time.  Thetemplate uses the same format specifiers as the Unix date command(which are the same as the standard C strftime library function).%changelog%prep%setup -n %{name}-%{version}%build./configuremake %installrm -rf $RPM_BUILD_ROOTmkdir -p $RPM_BUILD_ROOT/usr/share/doc/%{name}-${RPM_PACKAGE_VERSION} -m 755make prefix=$RPM_BUILD_ROOT/usr mandir=$RPM_BUILD_ROOT/usr/share/man installinstall -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%post%preun%postun%cleanrm -rf $RPM_BUILD_ROOT%files#%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*%doc README

Copy the code and copy the source code package to/usr/src/redhat/SOURCES/
Cronolog-1.6.2.tar.gz/usr/src/redhat/SOURCES/
Run rpmbuild-ba cronolog. spec
In this way, the RPM package is generated, ^ _ ^
Ls-l/usr/src/redhat/RPMS/i386/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.