From 1dd680b16d6242f18c648c32c99d1d4d1d9520e0 Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 24 Oct 2012 19:45:59 +0000 Subject: [PATCH] Update RPM spec file from build.opensuse.org (marcindulak) git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2055 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/contribs/rpm/SOURCES/davmail-init | 4 +- src/contribs/rpm/SPECS/davmail.spec | 125 ++++++++++++++++++++------ 2 files changed, 100 insertions(+), 29 deletions(-) diff --git a/src/contribs/rpm/SOURCES/davmail-init b/src/contribs/rpm/SOURCES/davmail-init index 6bf99140..de645365 100644 --- a/src/contribs/rpm/SOURCES/davmail-init +++ b/src/contribs/rpm/SOURCES/davmail-init @@ -35,7 +35,7 @@ test -d $DAVMAIL_HOME || exit 5 LOGFILE=/var/log/davmail.log PIDFILE=/var/run/davmail.pid -LOCKFILE=/var/lock/subsys/davmail +LOCKFILE=/var/run/davmail.lock start() { echo -n $"Starting DavMail gateway: " @@ -47,7 +47,7 @@ start() { RETVAL=1 return fi - runuser - davmail -s /bin/sh -c "exec nohup $DAVMAIL_HOME/davmail $DAVMAIL_CONF >> $LOGFILE 2>&1 &" + su - davmail -s /bin/sh -c "exec nohup $DAVMAIL_HOME/davmail $DAVMAIL_CONF >> $LOGFILE 2>&1 &" RETVAL=$? if [ $RETVAL -eq 0 ] then diff --git a/src/contribs/rpm/SPECS/davmail.spec b/src/contribs/rpm/SPECS/davmail.spec index 2eb570e3..e87aa069 100644 --- a/src/contribs/rpm/SPECS/davmail.spec +++ b/src/contribs/rpm/SPECS/davmail.spec @@ -1,7 +1,11 @@ -%define davrel 3.8.5 -%define davsvn 1480 +# do not hard-code ids https://sourceforge.net/mailarchive/message.php?msg_id=27249602 +%{?!davmail_uid: %define davmail_uid 213} +%{?!davmail_gid: %define davmail_gid 213} + +%{?!davrel: %define davrel 4.0.0} +%{?!davsvn: %define davsvn 2016} %define davver %{davrel}-%{davsvn} -%ifarch i686 +%ifarch i386 i586 i686 %define davarch x86 %endif %ifarch x86_64 @@ -15,15 +19,23 @@ Release: 1%{?dist} License: GPL Group: Applications/Internet BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -BuildRequires: ant >= 1.7.1, ant-antlr, desktop-file-utils -Requires(pre): chkconfig, coreutils, initscripts, shadow-utils -Requires: logrotate, jre +BuildRequires: ant >= 1.7.1, ant-nodeps >= 1.7.1, ant-antlr, desktop-file-utils +BuildRequires: java-devel >= 1.6.0 +Requires: coreutils +Requires: filesystem +Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd +Requires(post): coreutils, filesystem, /sbin/chkconfig +Requires(preun): /sbin/service, coreutils, /sbin/chkconfig, /usr/sbin/userdel, /usr/sbin/groupdel +Requires(postun): /sbin/service +Requires: /etc/init.d, logrotate, jre = 1.6.0 + +%define davmaildotproperties davmail.properties Source0: %{name}-src-%{davver}.tgz Source1: davmail.sh Source2: davmail-logrotate Source3: davmail-init -Source4: davmail.properties +Source4: %{davmaildotproperties} Source5: davmail.desktop Source6: davmail-wrapper @@ -39,14 +51,21 @@ window and full calendar support with attendees free/busy display. %setup -q -n %{name}-src-%{davver} %build -export JAVA_HOME=/etc/alternatives/java_sdk -ant +# JAVA_HOME points to the JDK root directory: ${JAVA_HOME}/{bin,lib} +jre=`rpm -q --whatprovides jre` +jexec=`rpm -ql ${jre} | grep "jexec"` +lib=`dirname ${jexec}` # level up +jre=`dirname ${lib}` # level up +java_home=`dirname ${jre}` # level up +export JAVA_HOME=${java_home} +# we have java 1.6 +ant -Dant.java.version=1.6 %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{_bindir} mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d -mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/init.d mkdir -p $RPM_BUILD_ROOT/%{_datadir}/applications mkdir -p $RPM_BUILD_ROOT/%{_datadir}/pixmaps mkdir -p $RPM_BUILD_ROOT/%{_datadir}/davmail/lib @@ -56,9 +75,10 @@ mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log # Init scripts, icons, configurations install -m 0775 %{SOURCE1} $RPM_BUILD_ROOT/%{_bindir}/davmail install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/davmail -install -m 0775 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/davmail +install -m 0775 %{SOURCE3} $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/davmail install -m 0644 %{SOURCE4} $RPM_BUILD_ROOT/%{_sysconfdir} -desktop-file-install --dir $RPM_BUILD_ROOT/%{_datadir}/applications/ %{SOURCE5} +# https://fedoraproject.org/wiki/TomCallaway/DesktopFileVendor +desktop-file-install --dir $RPM_BUILD_ROOT/%{_datadir}/applications/ %{SOURCE5} --vendor="" install -m 0775 %{SOURCE6} $RPM_BUILD_ROOT/%{_localstatedir}/lib/davmail/davmail # Actual DavMail files @@ -73,44 +93,95 @@ install -m 0664 dist/*.jar $RPM_BUILD_ROOT/%{_datadir}/davmail/ rm -rf $RPM_BUILD_ROOT %pre -/usr/sbin/groupadd -r davmail > /dev/null 2>&1 || : -/usr/sbin/useradd -r -s /sbin/nologin -d /var/lib/davmail -M \ - -g davmail davmail > /dev/null 2>&1 || : +# do not hard-code ids https://sourceforge.net/mailarchive/message.php?msg_id=27249602 +#/usr/sbin/groupadd -g %{davmail_gid} -f -r davmail > /dev/null 2>&1 || : +#/usr/sbin/useradd -u %{davmail_uid} -r -s /sbin/nologin -d /var/lib/davmail -M \ +# -g davmail davmail > /dev/null 2>&1 || : +/usr/sbin/groupadd -f -r davmail > /dev/null 2>&1 || : +/usr/sbin/useradd -r -s /sbin/nologin -d /var/lib/davmail -M \ + -g davmail davmail > /dev/null 2>&1 || : %post -if [ ! -f /var/log/davmail.log ] -then - /bin/touch /var/log/davmail.log +file=/var/log/davmail.log +if [ ! -f ${file} ] + then + /bin/touch ${file} fi -/bin/chown davmail:davmail /var/log/davmail.log -/bin/chmod 0640 /var/log/davmail.log +/bin/chown davmail:davmail ${file} +/bin/chmod 0640 ${file} + +# proper service handling http://en.opensuse.org/openSUSE:Cron_rename +%{?fillup_and_insserv: +%{fillup_and_insserv -y davmail} +} +%{!?fillup_and_insserv: +# undefined /sbin/chkconfig --add davmail #/sbin/chkconfig davmail on +} %preun if [ "$1" = "0" ]; then - /sbin/service davmail stop > /dev/null 2>&1 || : - /bin/rm -f /var/lib/davmail/pid > /dev/null 2>&1 || : - /sbin/chkconfig davmail off - /sbin/chkconfig --del davmail + /sbin/service davmail stop > /dev/null 2>&1 || : + /bin/rm -f /var/lib/davmail/pid > /dev/null 2>&1 || : + %{?stop_on_removal: + %{stop_on_removal davmail} + } + %{!?stop_on_removal: + # undefined + /sbin/chkconfig davmail off + /sbin/chkconfig --del davmail + } + /usr/sbin/userdel davmail + if [ ! `grep davmail /etc/group` = "" ]; then + /usr/sbin/groupdel davmail + fi fi %postun if [ $1 -ge 1 ]; then - /sbin/service davmail condrestart > /dev/null 2>&1 || : + %{?restart_on_update: + %{restart_on_update davmail} + %insserv_cleanup + } + %{!?restart_on_update: + # undefined + /sbin/service davmail condrestart > /dev/null 2>&1 || : + } fi %files %defattr (-,root,root,-) %{_bindir}/* -%{_sysconfdir}/rc.d/init.d/davmail +%{_sysconfdir}/init.d/davmail %{_sysconfdir}/logrotate.d/davmail -%{_sysconfdir}/davmail.properties +%config(noreplace) %{_sysconfdir}/%{davmaildotproperties} %{_datadir}/applications/* %{_datadir}/pixmaps/* %{_datadir}/davmail/ %attr(0775,davmail,davmail) %{_localstatedir}/lib/davmail %changelog +* Fri Dec 09 2011 Marcin Dulak +- use /var/run/davmail.lock instead of /var/lock/subsys/davmail + http://en.opensuse.org/openSUSE:Packaging_checks#subsys-unsupported + +* Fri Dec 09 2011 Marcin Dulak +- fixed https://bugzilla.novell.com/show_bug.cgi?id=734592 + +* Wed Apr 20 2011 Marcin Dulak +- proper service handling on openSUSE http://en.opensuse.org/openSUSE:Cron_rename + +* Thu Mar 24 2011 Marcin Dulak +- do not hard-code gid/uid: https://sourceforge.net/mailarchive/message.php?msg_id=27249602 + +* Fri Mar 18 2011 Marcin Dulak +- fixed incorrect JAVA_HOME +- added i386 i586 arch +- uses {davmail_gid} and {davmail_uid} of default 213 +- uses /etc/init.d for compatibility with other dists +- BuildRequires and Requires compatible with openSUSE 11.4 +- removed runlevels 2 4 from davmail-init: https://bugzilla.novell.com/show_bug.cgi?id=675870 + * Mon Oct 18 2010 Marko Myllynen - Initial version