diff --git a/.gitignore b/.gitignore index 8464542..c5373d7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /xtide-2.14.tar.bz2 /harmonics-dwf-20141224-free.tar.bz2 /harmonics-dwf-20151227-free.tar.bz2 +/systemd-patch.tar.gz diff --git a/sources b/sources index fac00cb..250729e 100644 --- a/sources +++ b/sources @@ -1,2 +1,3 @@ 0f50833e6f686eca16dcb33c1719cf6c xtide-2.14.tar.bz2 1c1adf4c8a7d69547f296f783914de5d harmonics-dwf-20151227-free.tar.bz2 +bb71524254f7ded08348d6e1e2268a47 systemd-patch.tar.gz diff --git a/xtide.spec b/xtide.spec index 7b1b3d0..b288008 100644 --- a/xtide.spec +++ b/xtide.spec @@ -8,7 +8,7 @@ %endif -%define fedorarel 6.1 +%define fedorarel 7 %define rel %{?betatag:0.}%{fedorarel}%{?betatag:.%(echo %betatag | sed -e 's|-||g')} @@ -21,6 +21,10 @@ Release: %{rel}%{?dist} URL: http://www.flaterco.com/xtide/ Source0: ftp://ftp.flaterco.com/xtide/%{name}-%{version}%{?betatag:-%betatag}.tar.bz2 +# Upstream systemd patches +Source1: systemd-patch.tar.gz +# Upstream service file +Source2: xttpd.service Source14: xtide-get_harmonics-data.sh Source20: %{name}.desktop @@ -35,11 +39,8 @@ Source30: xtide-README.fedora #Source40: Harminics-USpart-recreate-sh.tar.bz2 #Source41: harmonics-dwf-%{dwfdate}-dump-US.tar.bz2 Source42: ftp://ftp.flaterco.com/xtide/harmonics-dwf-%{dwfdate}-free.tar.bz2 -# The following files need discussion with the upstream -Source50: xttpd.service # new systemd ( >= 37.4? ) needs pidfile -Patch0: xtide-2.14-rcscript-pidfile-with-server-change.patch -Patch1: xtide-2.14-server-write-pid.patch +Patch0: xtide-2.12.1-rcscript-pidfile.patch License: GPLv3+ Group: Applications/Engineering @@ -54,6 +55,9 @@ BuildRequires: libtcd-devel BuildRequires: gpsd-devel >= 3 %if %{?use_systemd_unit} BuildRequires: systemd-devel +# By SOURCE1 +BuildRequires: automake +BuildRequires: autoconf %endif Requires: wvs-data @@ -125,15 +129,33 @@ tideEditor. Please read README.fedora for Fedora specific issue. %prep -%setup -q -n %{name}-%{version}%{?betatag:-%{betatag}} -a 42 +%setup -q -n %{name}-%{version}%{?betatag:-%{betatag}} -a 1 -a 42 + +# Systemd stuff +# copy sources in SOURCE1 to the proper directory +cp -a systemd-patch/xtide-stuff/* . +sed -i systemd-patch/systemd-stuff/xttpd.socket \ + -e 's|ListenStream=80|ListenStream=8080|' +sed -i systemd-patch/systemd-stuff/xttpdenv \ + -e 's|HFILE_PATH=/usr/local/share/xtide|HFILE_PATH=%{_datadir}/%{name}-harmonics|' \ + -e 's|^XTTPD_FEEDBACK=.*$|XTTPD_FEEDBACK=xtide-owner@fedoraproject.org|' + +cp -p %{SOURCE2} . +sed -i xttpd.service \ + -e 's|^EnvironmentFile=.*$|EnvironmentFile=-%{_sysconfdir}/sysconfig/xttpd.service.conf|' + +# Systemd stuff +# Needed by Source1 +sed -i configure.ac \ + -e '\@AM_INIT_AUTOMAKE@s|-Werror||' +autoreconf -fi # Dstr -> Dstr.h grep -rl 'include.*' . | while read f ; do sed -i.name -e 's|\(include.*\)|\1|' $f done -%patch1 -p1 -b .pid_server -%patch0 -p1 -b .pid_rc +%patch0 -p1 -b .pid # Embed version sed -i.ver \ @@ -151,6 +173,11 @@ export CFLAGS="%{optflags} -DJGFeatures" export CXXFLAGS="%{optflags} -DJGFeatures" %configure \ +%if %{use_systemd_unit} + --enable-systemd \ +%else + --disable-systemd \ +%endif %if 0 --enable-moon-age \ %endif @@ -170,7 +197,9 @@ echo "%{_datadir}/wvs-data/" >> %{name}.conf install %{__mkdir_p} $RPM_BUILD_ROOT%{_sbindir} +%if ! 0%{?use_systemd_unit} %{__mkdir_p} $RPM_BUILD_ROOT%{_libexecdir} +%endif # xttpd treatment # xttpd is wrapped @@ -179,28 +208,34 @@ echo "%{_datadir}/wvs-data/" >> %{name}.conf %{__install} -c -p -m 755 xtide-get_harmonics-data.sh \ $RPM_BUILD_ROOT%{_sbindir} +%if ! 0%{?use_systemd_unit} %{__mv} $RPM_BUILD_ROOT%{_sbindir}/xttpd $RPM_BUILD_ROOT%{_libexecdir} %{__install} -c -p -m 755 scripts/Fedora/xttpd-wrapper.sh \ $RPM_BUILD_ROOT%{_sbindir}/xttpd +%endif # ensure xttpd binary installation directory (original # wrapper script is hardcorded) %{__sed} -i -e 's|/usr/libexec|%{_libexecdir}|' \ $RPM_BUILD_ROOT%{_sbindir}/xttpd -# Create pid directory for xttpd -# and create tmpfile.d file -%{__mkdir_p} ${RPM_BUILD_ROOT}%{_localstatedir}/run/xttpd -%{__mkdir_p} ${RPM_BUILD_ROOT}%{_prefix}/lib/tmpfiles.d -%{__cat} > ${RPM_BUILD_ROOT}%{_prefix}/lib/tmpfiles.d/xttpd.conf </dev/null || : @@ -303,7 +339,7 @@ exit 0 %preun %if 0%{?use_systemd_unit} -%systemd_preun xttpd.service +%systemd_preun xttpd.socket xttpd.service %else if [ $1 = 0 ] ; then /sbin/service xttpd stop &>/dev/null @@ -343,7 +379,9 @@ exit 0 %files %defattr(-,root,root,-) -%doc AUTHORS COPYING README README-QUICK +%doc AUTHORS README README-QUICK +%doc scripts/DOS/.xtide.xml +%license COPYING # xtide %{_mandir}/man1/*tide.1* @@ -354,20 +392,31 @@ exit 0 %{_bindir}/*tide # xttpd +%if 0%{?use_systemd_unit} +%config(noreplace) %{_sysconfdir}/sysconfig/xttpd.service.conf +%config(noreplace) %{_sysconfdir}/sysconfig/xttpd.socket +%else %config(noreplace) %{_sysconfdir}/sysconfig/xttpd -%attr(0750,xttpd,xttpd) %dir %{_localstatedir}/run/xttpd -%{_prefix}/lib/tmpfiles.d/xttpd.conf +%endif %if 0%{?use_systemd_unit} %{_unitdir}/xttpd.service +%{_unitdir}/xttpd.socket %else %{_initddir}/xttpd %endif %{_sbindir}/xttpd +%if ! 0%{?use_systemd_unit} %{_libexecdir}/xttpd +%endif %{_datadir}/man/man8/xttpd.8* %changelog +* Sun Jan 3 2016 Mamoru TASAKA - 2.14.3-7 +- Use systemd patches provided by the upstream +- Make xttpd.socket (provided by the upstream) be symlink from + %%_sysconfdir + * Thu Dec 31 2015 Mamoru TASAKA - 2.14.3-6 - Switch to use systemd unit on F-24+ diff --git a/xttpd.service b/xttpd.service index fbbf976..8787e70 100644 --- a/xttpd.service +++ b/xttpd.service @@ -1,13 +1,16 @@ [Unit] Description=Harmonic tide clock and tide predictor (web server) Documentation=man:xttpd(8) -After=network.target +Wants=xttpd.socket [Service] -Type=forking -PIDFile=/var/run/xttpd/xttpd.pid +User=xttpd +Group=xttpd +WorkingDirectory=~ +Type=simple EnvironmentFile=-/etc/sysconfig/xttpd -ExecStart=/usr/sbin/xttpd $PORT XTTPD_FEEDBACK=$XTTPD_FEEDBACK HOME=$HOME +ExecStart=/usr/sbin/xttpd +NotifyAccess=main [Install] WantedBy=multi-user.target