The work flow to create RPM package and install the Apache ActiveMQ open source message broker.
sudo dnf install -y rpmdevtools rpmlint
- rpmdevtools: core tools for RPM
- rpmlint: check the RPM spec file for erroes
rpmdev-setuptree
tree
rpmbuild/
├── BUILD
├── RPMS
├── SOURCES
├── SPECS
└── SRPMS
wget https://archive.apache.org/dist/activemq/5.16.0/apache-activemq-5.16.0-bin.tar.gz
-O rpm/SOURCES/apache-activemq-5.16.0-bin.tar.gz
rpmdev-newspec activemq.spec
vi rpmbuild/SPECS/activemq.spec
and paste there:
Name: activemq
Version: 1
Release: 1%{?dist}
Summary: An RPM installing standalone activeMQ
Source0: activemq-5.16.0.tar.gz
Requires: gzip
License: MIT
%description
An RPM for installing activemq v5.16.0 without affecting host PATH.
%prep
%build
%install
[ -d %{buildroot}/ActiveMQ ] && rm -rf %{buildroot}/ActiveMQ
mkdir %{buildroot}/ActiveMQ/
cp $RPM_SOURCE_DIR/activemq-5.16.0.tar.gz %{buildroot}/ActiveMQ/
%post
tar xvf /ActiveMQ/activemq-5.16.0.tar.gz -C /ActiveMQ/
/ActiveMQ/apache-activemq-5.16.0/bin/activemq start
%preun
/ActiveMQ/apache-activemq-5.16.0/bin/activemq stop
%files
/ActiveMQ/
add java-sdk to rpmbuild/SOURCE folder:
wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz
config AMQ to work with dedicated java sdk:
tar -xzf rpmbuild/SOURCE/activemq-5.16.0.tar.gz -C /tmp/activemq-5.16.0
vim /tmp/activemq-5.16.0/bin/env
// Change
// #JAVA_HOME=''
// to
// JAVA_HOME="ActiveMQ/openjdk-11.0.2_linux-x64_bin/bin/java"
tar -czf /tmp/activemq-5.16.0.tar.gz /tmp/activemq-5.16.0
Name: activemq_ojdk11
Version: 1
Release: 1%{?dist}
Summary: An RPM installing standalone activeMQ
Source0: openjdk-11.0.2_linux-x64_bin.tar.gz
Source1: activemq-5.16.0.tar.gz
Requires: gzip
License: GPL
%description
An RPM for installing activemq v5.16.0 which also installs open jdk v11.0.2 without affecting host PATH.
%prep
%build
%install
[ -d %{buildroot}/ActiveMQ ] && rm -rf %{buildroot}/ActiveMQ
mkdir %{buildroot}/ActiveMQ/
cp $RPM_SOURCE_DIR/openjdk-11.0.2_linux-x64_bin.tar.gz %{buildroot}/ActiveMQ/
cp $RPM_SOURCE_DIR/activemq-5.16.0.tar.gz %{buildroot}/ActiveMQ/
%post
pwd
tar xvf /ActiveMQ/openjdk-11.0.2_linux-x64_bin.tar.gz -C /ActiveMQ/
tar xvf /ActiveMQ/activemq-5.16.0.tar.gz -C /ActiveMQ/
/ActiveMQ/apache-activemq-5.16.3/bin/activemq start
%preun
/ActiveMQ/apache-activemq-5.16.0/bin/activemq stop
%files
/ActiveMQ/
%changelog
* Wed Dec 1 2021 root
-
rpmlint ~/rpmbuild/SPECS/activemq.spec
rpmbuild -bb ~/rpmbuild/SPECS/activemq.spec