[Operation and maintenance] rpm package production

Record the process of Xiaobai making rpm;

Documentation related to fedora's official website: RPM Guide

SPEC common paths and macro variables in RPM: SPEC common paths and macro variables in RPM

c instance:  c instance

Build an rpm instance with a single file: Build an rpm instance with a single file

The basic things will not be introduced, and go straight to the topic;

The task that needs to be done is

Make several related applications required by the environment into an rpm package to facilitate the installation of the later environment: Of course, the related applications here are configured in advance and do not need to be changed. Some other environment variables may need to be configured.

Direct spec file:

Name: georelation #Corresponding to the name of the source file
Version: 1.0 #Corresponding to the version of the source file
Release:	1%{?dist}
Summary:	geo relation files

Group:		vastio
License:	GPL
URL:		www.vastio.com
Source0: source files under georelation-1.0.tar.gz #SOURCE
BuildArch:      x86_64	
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) #默认
AutoReqProv: no #No need to load dependencies

%description
geo relation install

%global debug_package %{nil} #关闭debug package

%prep
%setup -q #Unzip the source file


%build
%install
rm -rf $RPM_BUILD_ROOT
install -d -m 0755 $RPM_BUILD_ROOT/opt #Create a directory
install -d -m 0755 $RPM_BUILD_ROOT/usr/local #Create directory
cp -pr %_topdir/BUILD/%{name}-%{version}/elasticsearch-6.1.2/ $RPM_BUILD_ROOT/opt/ #Move the files under BUILD to BUILDROOT to prepare rpm packages
cp -pr %_topdir/BUILD/%{name}-%{version}/es-loader/ $RPM_BUILD_ROOT/opt/
cp -pr %_topdir/BUILD/%{name}-%{version}/data/ $RPM_BUILD_ROOT/opt/
cp -pr %_topdir/BUILD/%{name}-%{version}/geoserver-9090/ $RPM_BUILD_ROOT/opt/
cp -pr %_topdir/BUILD/%{name}-%{version}/python3 $RPM_BUILD_ROOT/usr/local/

exit 0 #Because the source file contains python, preventing the compilation of python files

%clean
rm -rf $RPM_BUILD_ROOT #Empty the BUILDROOT directory

%files
%defattr(-,root,root,-) #file, user, group, directory
/opt/elasticsearch-6.1.2/ #Decide which files to install
/opt/es-loader/
/ opt / date /
/opt/geoserver-9090/
/usr/local/python3/


%changelog


Related commands:

rpmbuild -bc / -bp / -bb / -ba xxx.spec  

rpm -ivh xxx.rpm //Install rpm
rpm -e xxx.rpm //Uninstall rpm
rpm -q xxx.rpm //whether to install the rpm








Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324909291&siteId=291194637
Recommended