File jboss6.spec of Package jboss6

# spec file for package jboss 6
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# 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

%if 0%{?suse_version} < 1500
%define _fillupdir /var/adm/fillup-templates

%define real_name	jboss
%define prefix		/srv/jboss/%{version}

Name:           jboss6
Summary:        JBoss Applicationserver 6.1.0.
License:        LGPL-2.1
Group:          Productivity/Networking/Web/Servers
Version:        6.1.0
Release:        1
Source0:        jboss-as-distribution-%{version}
Source1:        %{name}.sysinit
Source2:        %{name}.sysconfig
Source3:        %{name}.systemd
Source99:       jboss6.rpmlintrc
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

PreReq: 		%fillup_prereq

# manual requires only
AutoReqProv:           off
Requires:              jre >= 1.7.0

# needed for brp-check-bytecode-version (jar, fastjar would do as well)  
BuildRequires:  unzip
BuildRequires:  -post-build-checks

The open source Java Applicationserver.

%setup -q -n %{real_name}-%{version}.Final
# rpmlint script-without-shebang
chmod -x bin/README-service.txt
chmod -x bin/run.conf
chmod -x bin/

echo "no build process needed" 

# suppress bytecode version error

%{__mkdir_p} %{buildroot}%{prefix}
for D in bin client common docs lib server
  cp -a $D %{buildroot}%{prefix}

# install missing dir log
install -d -m755 %{buildroot}%{prefix}/log

# remove unneeded .bat files
rm %{buildroot}/%{prefix}/bin/*.bat

# sysinit
install -d -m755 $RPM_BUILD_ROOT/usr/sbin/
install -D -m644 %{SOURCE3} $RPM_BUILD_ROOT/usr/lib/systemd/system/%{name}.service
install -D -m755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/init.d/%{name} 
install -D -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_fillupdir}/sysconfig.%{name}
ln -snf %{_sysconfdir}/init.d/%{name} $RPM_BUILD_ROOT/usr/sbin/rc%{name}

# generate config-files list
find -type f | grep '\.xml' | grep common | sed -e 's:\./:/:g' | sed -e 's:^:%config(noreplace) %{prefix}:g' >> FILELIST.common.config
find -type f | grep '\.xml' | grep server | sed -e 's:\./:/:g' | sed -e 's:^:%config(noreplace) %{prefix}:g' >> FILELIST.server.config
echo "%defattr(0660,jboss,daemon)" > FILELIST.config
cat FILELIST.common.config FILELIST.server.config >> FILELIST.config

# add user and group
if ! getent group jboss >/dev/null; then
	groupadd  -r jboss
if ! getent passwd jboss >/dev/null; then
  useradd -r -g daemon -d /srv/jboss -c "JBoss Application Server" jboss -s /sbin/nologin
%service_add_pre %{name}.service

%service_add_post %{name}.service

# systemd
%service_del_preun %{name}.service
# init.d
%stop_on_removal %{name}

# systemd
%service_del_postun %{name}.service
# init.d
%restart_on_update %{name}

%files -f FILELIST.config
%doc docs README.txt LICENSE.txt copyright.txt jar-versions.xml
%dir %{prefix}
%config(noreplace) %{prefix}/bin/run.conf
%config(noreplace) %{prefix}/server/default/conf/*xml
# configs
%config(noreplace) %{prefix}/server/default/conf/props/*properties
%config(noreplace) %{prefix}/server/default/deploy/*xml
%config(noreplace) %{prefix}/server/default/deploy/hornetq/*xml
%config(noreplace) %{prefix}/server/default/deployers/jbossws.deployer/META-INF/*xml