File keycloak.spec of Package keycloak
#
# spec file for package keycloak
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define debug_package %{nil}
%define __jar_repack %{nil}
%define jboss_home %{_libdir}/jboss
%if ! %{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
Name: keycloak
Version: 24.0.2
Release: 0
Summary: Keycloak is an open source identity and access management solution.
License: Apache-2.0
URL: https://www.keycloak.org/
Source0: https://github.com/%{name}/%{name}/releases/download/%{version}/%{name}-%{version}.tar.gz
Source1: keycloak.service
Source2: keycloak.sysconfig
Source3: LICENSE
BuildRequires: fdupes
BuildRequires: systemd-rpm-macros
BuildRequires: zip
Requires: java-headless
Requires: sysconfig
Requires(post): %fillup_prereq
Requires(pre): shadow
ExclusiveArch: x86_64
%{?systemd_requires}
%description
Keycloak is an open source Identity and Access Management solution aimed at
modern applications and services. It makes it easy to secure applications and
services with little to no code.
%prep
%setup -q -T -c
cp %{SOURCE3} .
%build
%install
install -d %{buildroot}%{jboss_home}/%{name}
tar --strip-components=1 -C %{buildroot}%{jboss_home}/%{name} -xvf %{SOURCE0}
%fdupes -s %{buildroot}%{jboss_home}/%{name}
install -D %{SOURCE1} %{buildroot}/%{_unitdir}/%{name}.service
# fillup_only will take care of that
install -c -D -m 600 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.%{name}
mkdir -p %{buildroot}%{_sharedstatedir}/%{name}
%pre
%service_add_pre %{name}.service
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \
-c "%{name} user" %{name}
exit 0
%post
%service_add_post %{name}.service
%fillup_only %{name}
%preun
%service_del_preun %{name}.service
%postun
case "$1" in
0)
# This is an uninstallation.
getent passwd %{name} >/dev/null && userdel %{name}
getent group %{name} >/dev/null && groupdel %{name}
;;
1)
# This is an upgrade.
;;
esac
%service_del_postun %{name}.service
%files
%dir %attr(-, %{name}, %{name}) %{jboss_home}
%attr(-, %{name}, %{name}) %{jboss_home}/%{name}
%attr(644, root, root) %{_unitdir}/%{name}.service
%{_fillupdir}/sysconfig.%{name}
%license LICENSE
%dir %attr(-, %{name}, %{name}) %{_sharedstatedir}/%{name}
%changelog