Skip to content

Commit

Permalink
Linux: Create davmail user/group per new conventions in RPM 4.19, mer…
Browse files Browse the repository at this point in the history
…ge changes from #356

git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@3586 3d1905a2-6b24-0410-a738-b14d5a86fcbd
  • Loading branch information
mguessan committed Jul 6, 2024
1 parent 0ffbfe1 commit cfd1c09
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions davmail-user.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#Type Name ID GECOS Home directory Shell
g davmail -
u davmail - "davmail" /var/lib/davmail -
4 changes: 4 additions & 0 deletions davmail.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-------------------------------------------------------------------
Thu May 23 2024 Tristan Miller <psychonaut@nothingisreal.com>
- Change to using systemd-sysusers

-------------------------------------------------------------------
Sat Mar 30 2024 Mickael Guessant <mguessan@free.fr>
- update to 6.2.2
Expand Down
28 changes: 25 additions & 3 deletions davmail.spec
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ BuildRequires: openjfx

Requires: coreutils
Requires: filesystem
Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd
Requires(post): coreutils, filesystem
Requires(preun): /sbin/service, coreutils, /usr/sbin/userdel, /usr/sbin/groupdel
Requires(postun): /sbin/service
%if %systemd_macros
Requires(preun): /sbin/service, coreutils
BuildRequires: sysuser-tools
%sysusers_requires
%else
Requires(preun): /sbin/service, coreutils, /usr/sbin/userdel, /usr/sbin/groupdel
Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd
%endif

%{?fedora:Requires: java}
%if 0%{?el7} || 0%{?el8}
Expand All @@ -69,6 +75,7 @@ Requires: eclipse-swt
%endif

Source0: %{name}-src-%{version}.tgz
Source1: %{name}-user.conf

%description
A POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange gateway allowing
Expand Down Expand Up @@ -104,6 +111,10 @@ rm lib/swt*
# we have java 8
ant -Dant.java.version=1.8 prepare-dist

%if %systemd_macros
%sysusers_generate_pre %{SOURCE1} davmail %{name}-user.conf
%endif

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_bindir}
Expand Down Expand Up @@ -145,12 +156,20 @@ mkdir -p $RPM_BUILD_ROOT%{_datadir}/metainfo
install -m 0644 src/appstream/org.davmail.DavMail.appdata.xml $RPM_BUILD_ROOT%{_datadir}/metainfo
%endif

%pre
%if %systemd_macros
mkdir -p %{buildroot}%{_sysusersdir}
install -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/
%else
/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 || :
%endif

%if %systemd_macros
%pre -f davmail.pre
%service_add_pre davmail.service
%else
%pre
%endif

%post
Expand Down Expand Up @@ -226,6 +245,9 @@ fi
%files
%defattr (-,root,root,-)
%{_bindir}/*
%if %systemd_macros
%{_sysusersdir}/%{name}-user.conf
%endif

%if %systemd_support
%{_unitdir}/davmail.service
Expand Down

0 comments on commit cfd1c09

Please sign in to comment.