CentOS the RPM package with the TAR source package

Source: Internet
Author: User
Tags redis rpmbuild

The company has a demand for encryption redis, there is a profile option Requirepass can set the password, but the company felt can be modified by the configuration file to disable the password, feel insecure, and then directly modify the source code (mandatory set Requirepass as a fixed password), The RPM package is perfectly safe.

1. Download the Redis source package

Http://redis.googlecode.com/files/redis-2.6.14.tar.gz

2. Modify the source code compilation

Tar zxvf redis-2.6.14.tar.gz

CD redis-2.6.14

Vim src/config.c

331 lines to delete, move to the Else statement after the end, whether it is not empty set Requirepass

Server.requirepass = Zstrdup ("123456"); #加到426行

Save exit, then compile

Make

\CP src/redis-server/usr/local/bin/
\CP src/redis-cli/usr/local/bin/

3. Make RPM Package

MV Redis-2.6.14.tar.gz/usr/src/redhat/sources

cd/usr/src/redhat/specs/

Vim Redis.spec

Summary:the-Package
Name:redis
version:2.6.14
Release:2
Vendor:zhangrenfang@gmail.com
License:share
Group:applications/text
Source:redis-2.6.14.tar.gz
%description
My Test Redis Crypto
%prep
Tar-zxvf/usr/src/redhat/sources/redis-2.6.14.tar.gz
%build
cd/usr/src/redhat/build/redis-2.6.14
Make
%clean
rm-rf/usr/src/redhat/build/redis-2.6.14
%files
%defattr (-,root,root)
/usr/local/bin/redis-cli
/usr/local/bin/redis-server

[Root@localhost specs]# Rpmbuild-ba Redis.spec

If there is no error in the operation, it is generated,/usr/src/redhat/srpms/redis-2.6.14-2.src.rpm and/usr/src/redhat/rpms/x86_64/redis-2.6.14-2.x86_64.rpm

Rpm-qpi redis-2.6.14-2.x86_64.rpm can view information about the package


Relocations: If Non-null, indicates that the package can be installed to the new directory. When installing the package, use--relocate=/usr/loca/=/home/cyx/to modify the installation location of the package.

It may not work, however, because the package is binary, and the absolute path may be used when the program compiles.

RPM package production is generated by Rpmbuild. Rpmbuild used a few directories:

Build RPMS SOURCES SPECS Srpms

Directory of Build:build Procedure execution

RPMS: Location of the last generated RPM package

SOURCES: Source file location

Specs:spec the location of the file, Rpmbuild to build the package using the description information of the spec file

Srpms: Source code RPM Package Location

Spec files are key files that instruct Rpmbuild to generate packages. Put it under the specs directory:

----------------------------------Example------------------------------------------------------------------

[root@v092019 specs]# Cat Nginx-0.8.54.spec

Name:nginx Package Name

summary:nginx-server! Summary

version:0.8.54 Version

Release:1 Issue

Group:taobao.com Organization

License:gpl License

url:http://www.nginx.com/official website

The directory of the Buildroot:%{_tmppath}/%{name}-%{version}-%{release}-root build, which will build a binary here

The name of the source:%{name}-%{version}.tar.gz source file, placed in the SOU The RCEs directory

Prefix:%{_prefix} Prefix, which has this value, when the package is generated there is relocations.

Packager:nginx Bag Name

%description The following is a description of the package

Nginx-httpd-server

%prep Here's the prep work.

%setup-q Here we use the built-in command to solve the open source code package to the build directory.

%build Start building packages, corresponding to configure and make, in the build directory

Cflags= "-g"./configure

Make-j ' Cat/proc/cpuinfo | grep Processor | Wc-l '

%install Install package to BuildRoot

Make destdir= $RPM _build_root install

%files Finally, package the file into the RPM package, where you specify the files, permissions, and owners to be packaged, and the directory here is relative to the BuildRoot directory, but starts with '/'.

%defattr (755,daemon,daemon)

/usr/local/%{name}

%pre Perform the action here before installing the package with the RPM command

Echo Nginx,preinstall

%post Perform the action here after installing with the RPM command

Echo Nginx,afterinstall,done

%preun Perform the action here before uninstalling

Echo Nginx,uninstall

%postun Perform the action here after uninstalling

Echo Nginx,uninstall,done

---------------------------------------------End-----------------------------------------------------------------


So we can customize our RPM package.

Reference Link: http://zhumeng8337797.blog.163.com/blog/static/100768914201110185456104/

Related Article

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.