kafka的自定义安装路径RPM包制作
# 编写SPEC
cat kafka.spec
BuildArch: noarch
Name: kafka_2.11
Version: 2.1.0
Release: 1
License: Apache License v2.0
Group: Development/Libraries
Summary: This is a Kafka RPM installation package
URL: www.ksyun.com
Source0: %{name}-%{version}.tar.gz
Source1: kafka.service
BuildRoot: %{_topdir}/BUILDROOT
Requires: /bin/sh
Requires: /usr/bin/env
#Requires: rpmlib(CompressedFileNames) <= 3.0.4-1
#Requires: rpmlib(FileDigests) <= 4.6.0-1
#Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: sh-utils
#Requires: rpmlib(PayloadIsXz) <= 5.2-1
#suggest
#enhance
%description
This is a Kafka RPM installation package
%prep
%setup -q
#tar -zxf %{sources}
%install
#mkdir -p $RPM_BUILD_ROOT/usr/%{stack_name}/%{stack_version}/atlas
#mkdir -p $RPM_BUILD_ROOT/usr/%{stack_name}/%{stack_version}/etc/atlas/conf.dist
#
#cp -rp %{_builddir}/%{name}-%{version}/* $RPM_BUILD_ROOT/usr/%{stack_name}/%{stack_version}/atlas
#cp -rp %{_builddir}/%{name}-%{version}/conf/* $RPM_BUILD_ROOT/usr/%{stack_name}/%{stack_version}/etc/atlas/conf.dist
mkdir -m 0755 -p $RPM_BUILD_ROOT/data/apps/kafka
mkdir -m 0755 -p $RPM_BUILD_ROOT/usr/lib/systemd/system
cp -rp %{_builddir}/kafka_2.11-2.1.0 $RPM_BUILD_ROOT/data/apps/kafka/kafka_2.11-2.1.0
if [ ! -f "/usr/lib/systemd/system/kafka.service" ]; then
%{__install} -p -D %{SOURCE1} $RPM_BUILD_ROOT/usr/lib/systemd/system/kafka.service
fi
%post -p /bin/sh
#if [ ! -e "/etc/atlas/conf" ]; then
# rm -f /etc/atlas/conf
# mkdir -p /etc/atlas/conf
# cp -rp /usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/* /etc/atlas/conf
#fi
#/usr/bin/hdp-select --rpm-mode set atlas-server 3.0.1.0-187
#/usr/bin/hdp-select --rpm-mode set atlas-client 3.0.1.0-187
#cp -rp %{Source1} $RPM_BUILD_ROOT/usr/lib/systemd/system/kafka.service
%files
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/bin"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/models"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/models/0000-Area0"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/models/1000-Hadoop"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/models/1000-Hadoop/patches"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/models/2000-RDBMS"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/models/3000-Cloud"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/server"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/server/webapp"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/atlas/tools/migration-exporter"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/atlas-application.properties"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/atlas-env.sh"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/atlas-log4j.xml"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/atlas-simple-authz-policy.json"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/hbase"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/hbase/hbase-site.xml.template"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/currency.xml"
#%dir %attr(0755, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/lang"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/lang/stopwords_en.txt"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/protwords.txt"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/schema.xml"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/solrconfig.xml"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/stopwords.txt"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/solr/synonyms.txt"
#%attr(0644, root, root) "/usr/hdp/3.0.1.0-187/etc/atlas/conf.dist/users-credentials.properties"
#
#%defattr(-,root,root)
/data/apps/kafka
/usr/lib/systemd/system/kafka.service
%defattr(-,root,root)
#######################
#### FILES SECTION ####
#######################
%changelog
%preun
rm -rf /usr/lib/systemd/system/kafka.service
rm -rf /data/apps/kafka
# Build-RPM安装包
rpmbuild -bb kafka.spec
ll ../RPMS/noarch/
-rw-r--r-- 1 root root 60979828 Feb 23 11:29 kafka_2.11-2.1.0-1.noarch.rpm