LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File otrs.spec of Package otrs (Project network:otrs)

#
# spec file for package otrs
#
# 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 http://bugs.opensuse.org/
#


%define otrs_ver 3.3.6
%define itsm_ver 3.3.6
%define itsm_min 3.3
%define otrs_root /srv
%define otrsdoc_dir_files AUTHORS* CHANGES* COPYING* CREDITS README* UPGRADING.SuSE doc
%define otrsdocs CHANGES* doc

Name:           otrs
Summary:        The Open Ticket Request System
License:        AGPL-3.0
Group:          Productivity/Networking/Email/Utilities
Version:        %{otrs_ver}
Release:        0
Url:            http://otrs.org/
AutoReqProv:    off
Source:         ftp://ftp.otrs.org/pub/otrs/%{name}-%{otrs_ver}.tar.bz2
Source1:        itsm-%{itsm_ver}.tar.bz2
Source2:        %{name}.rpmlintrc
Source11:       sysconfig.%{name}
Source12:       %{name}.README.en
Source13:       %{name}.README.de
Source14:       itsm.README.en
Source15:       itsm.README.de
Source16:       ZZZAuto.pm
Source17:       UPGRADING.SuSE
Source20:       %{name}.init
Source21:       %{name}-scheduler.init
#atch0:         %{name}-3.1.1-init.patch
Patch1:         %{name}-httpd_conf.patch
Patch2:         %{name}-perm.patch
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         %insserv_prereq %fillup_prereq 
PreReq:         coreutils mktemp net-tools pwdutils
PreReq:         grep sed
PreReq:         apache2
BuildRequires:  pwdutils
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
%endif
#
Requires:       apache2-mod_perl
Requires:       fetchmail
Requires:       mysql
Requires:       mysql-client
Requires:       perl
Requires:       procmail
Requires:       perl(DBD::mysql)
Requires:       perl(DBI)
Requires:       perl(Digest::MD5)
Requires:       perl(GD)
Requires:       perl(GD::Graph)
Requires:       perl(GD::Text)
Requires:       perl(LWP::UserAgent)
Requires:       perl(List::Util::XS)
Requires:       perl(Net::DNS) >= 0.60
Requires:       perl(PDF::API2)
Requires:       perl(YAML::XS)
#
Recommends:     perl(Crypt::SSLeay)
Recommends:     perl(Encode::HanExtra)
Recommends:     perl(IO::Socket::SSL)
Recommends:     perl(JSON::XS)
Recommends:     perl(Mail::IMAPClient) >= 3.22
Recommends:     perl(Net::SSL)
Recommends:     perl(SOAP::Lite)
#
Suggests:       perl(Net::LDAP)
Suggests:       perl(Text::CSV_XS)

%if "%_vendor" == "suse"
	%define	VENDOR SUSE
%else
	%define	VENDOR %_vendor
%endif

%description
OTRS is an Open source Ticket Request System with many features to manage
customer telephone calls and e-mails. It is distributed under the GNU
AFFERO General Public License (AGPL) and tested on Linux, Solaris, AIX,
Windows, FreeBSD, OpenBSD and Mac OS 10.x. Do you receive many e-mails and
want to answer them with a team of agents? You're going to love OTRS!

Feature list: see README

Authors list: see CREDITS

%package doc
Summary:        OTRS Documentation
Group:          Documentation/Other

%description doc
This package contains the README, Changes and docs for OTRS

Authors list: see CREDITS

%package -n otrs-itsm
Summary:        ITIL (R) focused IT service management
Group:          Productivity/Networking/Email/Utilities
Version:        %{itsm_ver}
Release:        0
Requires:       %{name} >= %{otrs_ver}
Provides:       OTRS::ITSM
Provides:       itsm = %{itsm_ver}

%description itsm
OTRS::ITSM implements ITIL (R) focused IT service management.

You need a OTRS %{otrs_ver} (http://otrs.org/) installation.

Make sure your database accepts packages over 5 MB in size. A MySQL database
for example accepts packages up to 1 MB by default. In this case, the value for
max_allowed_packet must be increased. The recommended maximum size accepted is
20 MB.

for INSTALL see INSTALL-%{itsm_min}.ITSM
please see README.itsm for further details, which comes with otrs package

Required OTRS::ITSM modules can be found under %{otrs_root}/%{name}/itsm

Authors list: see CREDITS

%prep
%setup -q -n %{name}-%{otrs_ver} -a 1
#patch0
%patch1
%patch2
##### rpmlint
#### incorrect-fsf-address
### http://www.fsf.org/about/contact/
for sdir in bin scripts; do
  find ./${sdir} -type f -exec perl -p -i -e 's|^# Foundation.*|# Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA|' {} \;
done

find -name ".cvsignore" -type f | xargs rm -fv
find -name ".htaccess" -type f | xargs rm -fv
%__rm -f UPGRADING.md
%__cp %{S:17} .
pushd Kernel/Config/Files
%__cp %{S:16} .
%__sed -i -e "s,@OTRS_ROOT@,%{otrs_root},g"\
 ZZZAuto.pm ../../../scripts/apache2-httpd.include.conf
popd

# fix old otrs_root (/opt)
%__sed -i -e "s,/opt/%{name},%{otrs_root}/%{name},g" \
  bin/otrs.SetPermissions.pl \
  Kernel/Config/Files/Framework.xml \
  Kernel/Config/Defaults.pm \
  Kernel/Config.pm.dist \
  README.md \
  scripts/apache2-perl-startup.pl \
  scripts/restore.pl

## rpmlint:
# wrong-file-end-of-line-encoding
%{__perl} -p -i -e "s|\r\n|\n|" itsm-%{itsm_ver}/INSTALL-%{itsm_min}.ITSM

%build
%{_sbindir}/groupadd -g 88 -r %{name} 2>/dev/null || :
%{_sbindir}/useradd -c "OTRS User" -d %{otrs_root}/%{name} -G %{name},www -g %{name} \
  -u 88 -r -s /bin/false %{name} 2>/dev/null || :
# copy config file
%__cp -a Kernel/Config.pm.dist Kernel/Config.pm
cd Kernel/Config/
for file in *.dist
do
  %__cp -a $file `basename $file .dist`
done
cd ../../
# copy all crontab dist files
for file in var/cron/*.dist
do
%__mv $file var/cron/`basename $file .dist`
done
%__rm INSTALL.md
#%__rm INSTALL{.md,.RedHat,.SuSE}
#%__mv INSTALL.SuSE INSTALL

%install
export DESTROOT="%{otrs_root}/%{name}/"
%__install -d ${RPM_BUILD_ROOT}${DESTROOT}
%__install -d ${RPM_BUILD_ROOT}%{_sbindir}
%__cp -a . ${RPM_BUILD_ROOT}/${DESTROOT}
for configFile in .fetchmailrc .mailfilter .procmailrc; do
  touch ${RPM_BUILD_ROOT}/${DESTROOT}/${configFile}
done
touch $RPM_BUILD_ROOT${DESTROOT}var/log/TicketCounter.log

# add ghost file 'otrs.NagiosCheck.pl'
# otherwise module 'SystemMonitoring' won't install
touch ${RPM_BUILD_ROOT}${DESTROOT}/bin/%{name}.NagiosCheck.pl
# otherwise module 'Survey' won't install
touch ${RPM_BUILD_ROOT}${DESTROOT}/bin/%{name}.SurveyTriggerSendRequests.pl

# install README
for lang in en de; do
  %__cp -p "${RPM_SOURCE_DIR}/%{name}.README.${lang}" "README.%{VENDOR}.${lang}"
  %__cp -p "${RPM_SOURCE_DIR}/itsm.README.${lang}" "README.itsm.%{VENDOR}.${lang}"
done

# fix @OTRS_ROOT@ in itsm.README.* 
for r in $(ls -1 README.itsm.*); do
  %__sed -i -e "s,@OTRS_ROOT@,%{otrs_root},g" $r
done

# remove files that are part of the docdir
pushd ${RPM_BUILD_ROOT}/${DESTROOT}
%__rm -rf %{otrsdoc_dir_files}
%__install -d doc
popd

# remove unneeded files from scripts
pushd ${RPM_BUILD_ROOT}/${DESTROOT}/scripts
%__rm -rf apache{,2}*.conf auto_build* auto_docbuild.sh otrs-scheduler-* redhat-* suse-* *.spec test/* tool
popd

# install permissions file
#__install -D -m0644 %{S:3} ${RPM_BUILD_ROOT}/etc/permissions.d/%{name}

# install sysconfig file and init script
%__install -D -m0644 ${RPM_SOURCE_DIR}/sysconfig.%{name} $RPM_BUILD_ROOT/%{_var}/adm/fillup-templates/sysconfig.%{name}
%__install -D -m0755 %{S:20} ${RPM_BUILD_ROOT}/etc/init.d/%{name}
%__ln_s -f ../../etc/init.d/%{name} ${RPM_BUILD_ROOT}/%{_sbindir}/rc%{name}
%__install -D -m0755 %{S:21} ${RPM_BUILD_ROOT}/etc/init.d/%{name}-scheduler
%__ln_s -f ../../etc/init.d/%{name}-scheduler ${RPM_BUILD_ROOT}/%{_sbindir}/rc%{name}-scheduler
## FIXME - nochown patch obsolete, cause script complete changed
#${RPM_BUILD_ROOT}%{otrs_root}/%{name}/bin/SetPermissions.sh ${RPM_BUILD_ROOT}%{otrs_root}/%{name} %{name} wwwrun %{name} www echo

otrs_apache_conf="scripts/apache2-httpd.include.conf"
%__install -D -m0644 ${otrs_apache_conf} ${RPM_BUILD_ROOT}/etc/apache2/conf.d/%{name}.conf

# OTRS::ITSM
# rename itsm-%{itsm_ver} to itsm
pushd ${RPM_BUILD_ROOT}/${DESTROOT}
%__mv itsm-%{itsm_ver} itsm
popd

%if 0%{?suse_version} > 1020
%fdupes ${RPM_BUILD_ROOT}/%{otrs_root}/%{name}/var
%fdupes ${RPM_BUILD_ROOT}/%{otrs_root}/%{name}/Kernel/cpan-lib
%endif

%preun
%stop_on_removal otrs
:

%pre
# on `rpm -ivh` PARAM is 1
# on `rpm -Uvh` PARAM is 2
if [ -z  "`%{_bindir}/getent group %{name} 2>/dev/null`" ]; then
  %{_sbindir}/groupadd -g 88 -r %{name} 2>/dev/null
else
  if [ `%{_bindir}/id -g %{name}` != 88 ]; then
    %{_sbindir}/groupmod -g 88 %{name} 2>/dev/null
  fi
fi 
if [ -z "`%{_bindir}/getent passwd %{name} 2>/dev/null`" ]; then
  %{_sbindir}/useradd -c "OTRS User" -d %{otrs_root}/%{name} -G %{name},www -g %{name} -u 88 -r -s /bin/false %{name} 2>/dev/null
else
  if [ `%{_bindir}/id -u %{name}` != 88 ]; then
    %{_sbindir}/usermod -c "OTRS User" -d %{otrs_root}/%{name} -G %{name},www -g %{name} -u 88 %{name} 2>/dev/null
  fi
fi

%post
# fill otrs sysconfig file
%{fillup_and_insserv -f otrs-scheduler}
%{fillup_and_insserv otrs}
%if 0%{?suse_version}
  /usr/sbin/a2enmod perl >/dev/null
%endif
# Update ?
if [ ${FIRST_ARG:-0} -gt 1 ]; then
  # OTRS_ROOT changed from /opt to /srv
  if [ -f /opt/%{name}/Kernel/Config.pm.rpmsave ]; then
    %__mv /opt/%{name}/Kernel/Config.pm.rpmsave %{otrs_root}/%{name}/Kernel/
  fi
  %{_sbindir}/usermod -d %{otrs_root}/%{name} %{name}
  #update sysconfig
  %__sed -i -e "s,/opt/%{name},%{otrs_root}/%{name},g" /etc/sysconfig/%{name}
fi
# if rpm is not in update mode
if ! [ ${FIRST_ARG:-0} -gt 1 ]; then
	if [ -z "${YAST_IS_RUNNING}" ]; then
		for lang in LC_ALL LC_MESSAGE LANG; do
			test "${!lang}" && break
		done
		echo
		case "${!lang}" in
			de_*)
				echo "Hinweise zur Erstkonfiguration von OTRS finden Sie in"
				echo "/usr/share/doc/packages/otrs/README.%{VENDOR}.de"
				;;
			*)
				echo "About the initial setup of OTRS, please read"
				echo "/usr/share/doc/packages/otrs/README.%{VENDOR}.en"
				;;
		esac
		echo
	fi
fi
exit 0

%postun
%restart_on_update otrs-scheduler
%restart_on_update otrs
%restart_on_update apache2
%insserv_cleanup

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc AUTHORS.md COPYING* README{.md,.database.md,.webserver.md} README.SUSE.* UPGRADING.SuSE
%dir /etc/apache2
%dir /etc/apache2/conf.d
%config(noreplace) /etc/apache2/conf.d/%{name}.conf
/etc/init.d/%{name}
/usr/sbin/rc%{name}
/etc/init.d/%{name}-scheduler
/usr/sbin/rc%{name}-scheduler
#config /etc/permissions.d/%{name}
%{_var}/adm/fillup-templates/sysconfig.%{name}

###############
## {root,www}
###############
%defattr(0770,root,www,0775)
# bin
%{otrs_root}/%{name}/bin
#exclude %{otrs_root}/%{name}/bin/%{name}.DeleteSessionIDs.pl
#exclude %{otrs_root}/%{name}/bin/%{name}.UnlockTickets.pl
%exclude %{otrs_root}/%{name}/bin/%{name}.GetConfig.pl
%exclude %{otrs_root}/%{name}/bin/%{name}.SetPermissions.pl
#%attr(0700,%{name},%{name}) %{otrs_root}/%{name}/bin/%{name}.DeleteSessionIDs.pl
#%attr(0700,%{name},%{name}) %{otrs_root}/%{name}/bin/%{name}.UnlockTickets.pl
#%attr(0700,%{name},%{name}) %{otrs_root}/%{name}/bin/%{name}.GetConfig.pl
# add ghost file 'otrs.NagiosCheck.pl'
# otherwise module 'SystemMonitoring' won't install
%attr(0750,wwwrun,www) %{otrs_root}/%{name}/bin/%{name}.NagiosCheck.pl
# otherwise module 'Survey' won't install
%attr(0750,wwwrun,www) %{otrs_root}/%{name}/bin/%{name}.SurveyTriggerSendRequests.pl

###############
## {otrs,otrs}
###############

# otrs HOME
%defattr(-,%{name},%{name})
%dir %{otrs_root}/%{name}
%ghost %config(noreplace) %{otrs_root}/%{name}/.fetchmailrc
%ghost %config(noreplace) %{otrs_root}/%{name}/.mailfilter
%ghost %config(noreplace) %{otrs_root}/%{name}/.procmailrc
%{otrs_root}/%{name}/.fetchmailrc.dist
%{otrs_root}/%{name}/.mailfilter.dist
%{otrs_root}/%{name}/.procmailrc.dist
%{otrs_root}/%{name}/ARCHIVE
%{otrs_root}/%{name}/RELEASE

# scripts
%{otrs_root}/%{name}/scripts/*.pl
#%{otrs_root}/%{name}/scripts/*.pm
%{otrs_root}/%{name}/scripts/*.sql
%{otrs_root}/%{name}/scripts/database
%{otrs_root}/%{name}/scripts/tools

#%defattr(0755,wwwrun,%{name},0755)
# var/httpd
%dir %{otrs_root}/%{name}/var/httpd

###############
## {otrs,www}
###############
%defattr(0744,%{name},www,0775)
# doc and scripts
%dir %{otrs_root}/%{name}/doc
%dir %{otrs_root}/%{name}/scripts
%dir %{otrs_root}/%{name}/scripts/test

# var
%dir %{otrs_root}/%{name}/var
%{otrs_root}/%{name}/var/logo-%{name}.png

# var/cron
%dir %{otrs_root}/%{name}/var/cron
%config(noreplace) %{otrs_root}/%{name}/var/cron/*

# var/{packages,spool}
%{otrs_root}/%{name}/var/packages
#%dir %{otrs_root}/%{name}/var/spool

# var/{article,log,tmp}
#defattr(0644,%{name},www,2775)
#%dir %{otrs_root}/%{name}/var/article
%ghost %config(noreplace) %attr(660,%{name},www) %{otrs_root}/%{name}/var/log/TicketCounter.log

#%defattr(0644,%{name},www,2775)
#%dir %{otrs_root}/%{name}/var/tmp
%defattr(0660,%{name},www,2775)
%dir %{otrs_root}/%{name}/var/log

#%dir %{otrs_root}/%{name}/var/httpd/htdocs/js
#%dir %{otrs_root}/%{name}/var/httpd/htdocs/js/js-cache

#%{otrs_root}/%{name}/var/httpd/htdocs/skins/Agent/default
#%{otrs_root}/%{name}/var/httpd/htdocs/skins/Customer/default

###############
## {wwwrun,www}
###############

%defattr(0644,wwwrun,www,0755)
# var/tmp/Cache
#dir %{otrs_root}/%{name}/var/tmp/Cache

# var/fonts
%{otrs_root}/%{name}/var/fonts

# var/httpd/htdocs
%{otrs_root}/%{name}/var/httpd/htdocs

# var/{session,stats}
#%dir %{otrs_root}/%{name}/var/sessions
%dir %{otrs_root}/%{name}/var/stats
%{otrs_root}/%{name}/var/stats/*

# Custom DIR
#defattr(0644,wwwrun,www,0755)
%dir %{otrs_root}/%{name}/Custom
%{otrs_root}/%{name}/Custom/README

# Kernel DIR
#defattr(0644,wwwrun,www,0755)
%dir %{otrs_root}/%{name}/Kernel
%config(noreplace) %attr(0640,wwwrun,www) %{otrs_root}/%{name}/Kernel/Config.pm
%{otrs_root}/%{name}/Kernel/Config.pm.dist
%dir %{otrs_root}/%{name}/Kernel/Config
%{otrs_root}/%{name}/Kernel/Config/Defaults.pm
%config(noreplace) %{otrs_root}/%{name}/Kernel/Config/GenericAgent.pm
%{otrs_root}/%{name}/Kernel/Config/GenericAgent.pm.*
# as otrs user: perl scripts/DBUpdate-to-3.2.pl needs
%attr(2775,wwwrun,www) %dir %{otrs_root}/%{name}/Kernel/Config/Files
#{otrs_root}/%{name}/Kernel/Config/Files/Deprecated.xml
%{otrs_root}/%{name}/Kernel/Config/Files/Framework.xml
%{otrs_root}/%{name}/Kernel/Config/Files/GenericInterface.xml
%{otrs_root}/%{name}/Kernel/Config/Files/ProcessManagement.xml
%{otrs_root}/%{name}/Kernel/Config/Files/Scheduler.xml
%{otrs_root}/%{name}/Kernel/Config/Files/Ticket.xml
%{otrs_root}/%{name}/Kernel/GenericInterface
%{otrs_root}/%{name}/Kernel/cpan-lib
%{otrs_root}/%{name}/Kernel/Language.pm
%dir %{otrs_root}/%{name}/Kernel/Language
%config(noreplace) %{otrs_root}/%{name}/Kernel/Language/*.pm
%{otrs_root}/%{name}/Kernel/Modules/
%config(noreplace) %{otrs_root}/%{name}/Kernel/Output/HTML/Standard/*.dtl
%config(noreplace) %{otrs_root}/%{name}/Kernel/Output/HTML/Standard/ProcessManagement/*.dtl
#config(noreplace) %{otrs_root}/%{name}/Kernel/Output/HTML/Lite/*.dtl
%dir %{otrs_root}/%{name}/Kernel/Output
%dir %{otrs_root}/%{name}/Kernel/Output/HTML
#dir %{otrs_root}/%{name}/Kernel/Output/HTML/Lite
%dir %{otrs_root}/%{name}/Kernel/Output/HTML/Standard
%dir %{otrs_root}/%{name}/Kernel/Output/HTML/Standard/ProcessManagement
%{otrs_root}/%{name}/Kernel/Output/HTML/*.pm
%{otrs_root}/%{name}/Kernel/Scheduler.pm
%{otrs_root}/%{name}/Kernel/Scheduler
%{otrs_root}/%{name}/Kernel/System/

%files doc
%defattr(644,root,root,755)
%doc %{otrsdocs}

%files itsm
%defattr(-,root,root)
%doc COPYING*
%doc README.itsm*
%doc itsm-%{itsm_ver}/INSTALL-%{itsm_min}.ITSM
%defattr(0644,wwwrun,www,0755)
%{otrs_root}/%{name}/itsm
%config %attr(0664,wwwrun,www) %{otrs_root}/%{name}/Kernel/Config/Files/ZZZAuto.pm

%changelog