Skip to content

Instantly share code, notes, and snippets.

@jamesdavidson
Last active March 25, 2020 03:31
Show Gist options
  • Save jamesdavidson/b6a325fa1f66c797f0bb89b2f53563b1 to your computer and use it in GitHub Desktop.
Save jamesdavidson/b6a325fa1f66c797f0bb89b2f53563b1 to your computer and use it in GitHub Desktop.
RPM packaging a command-line JMX client for use on CentOS Linux.
%global version 0.10.3
%global release 1
%global jar %{name}-%{version}.jar
%define _optdir /opt
Name: cmdline-jmxclient
Version: %{version}
Release: %{release}%{?dist}
Summary: Command-line JMX client
License: LGPL-2.1
URL: http://crawler.archive.org/cmdline-jmxclient/
%description
A command-line JMX client (RMI to a remote JMX Agent).
%prep
make %{jar}
%install
rm -rf %{buildroot}
install -d %{buildroot}%{_optdir}/%{name}
install -p -m 0644 %{jar} %{buildroot}%{_optdir}/%{name}/%{jar}
%clean
rm -rf %{buildroot}
%files
%dir %attr(0755, root, root) %{_optdir}/%{name}
%attr(0644, root, root) %{_optdir}/%{name}/%{jar}
%changelog
* Wed Feb 13 2019 James Davidson <[email protected]> - 0.10.3-1
- Initial RPM release
PACKAGE = cmdline-jmxclient
PACKAGE_VERSION = 0.10.3
JAR = $(PACKAGE)-$(PACKAGE_VERSION).jar
EXTRA_DIST = Makefile
RPM_TOPDIR := $(HOME)/rpmbuild
$(JAR):
curl -s -o $(JAR) http://crawler.archive.org/cmdline-jmxclient/$(JAR)
rpm: $(JAR)
mkdir -v -p $(RPM_TOPDIR)/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
cp -v $(PACKAGE).spec $(RPM_TOPDIR)/SPECS/$(PACKAGE).spec
cp -v $(JAR) $(EXTRA_DIST) $(RPM_TOPDIR)/BUILD/
rpmbuild -ba $(RPM_TOPDIR)/SPECS/$(PACKAGE).spec
cp -v $(RPM_TOPDIR)/RPMS/x86_64/$(PACKAGE)-* .
rpmclean:
rm -vf $(RPM_TOPDIR)/SPECS/$(PACKAGE).spec
rm -vf $(RPM_TOPDIR)/BUILD/$(JAR)
rm -vf $(RPM_TOPDIR)/RPMS/x86_64/$(PACKAGE)-*
.PHONY = rpm rpmclean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment