- 安装依赖
shell
[root@20240423-instance4 ~]# yum install rpmdevtools
2.初始化目录
shell
[root@20240423-instance4 ~]# rpmdev-setuptree
[root@20240423-instance4 ~]# tree rpmbuild/
rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
5 directories, 0 files
3.编写SPEC文件
shell
%define __jar_repack 0
Name: jtlas-server
Version: 1.0.0
Release: 1
Summary: JD.Cloud jtlas service back end server.
License: Apache 2.0
Group: JD.Cloud/Applications
Prefix: /export
Source0: %{name}-%{version}-SNAPSHOT.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
Jtlas Service backend acts as a service for querying metadata from a warehouse.
%prep
%setup -n %{name}
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/export/App/%{name}
cp -r * $RPM_BUILD_ROOT/export/App/%{name}
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
%post
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/export/App/%{name}
4.资源包文件打包
shell
[root@20240423-instance4 rpmbuild]# rpmbuild -ba SPECS/jtals-server.spec