File hddtemp.spec of Package hddtemp

# norootforbuild

%global beta    beta15
%global migfile %{_var}/run/systemd-migr_%{name}-%{version}-%{release}.%{_arch}

Name:           hddtemp
Version:        0.3
Release:        0.22.%{beta}%{?dist}
Summary:        Hard disk temperature tool

License:        GPLv2+
URL:            http://savannah.nongnu.org/projects/hddtemp/
Source0:        %{name}-%{version}-%{beta}.tar.bz2
Source1:        hddtemp.db
Source2:        %{name}.service
Source3:        %{name}.sysconfig
Source4:        %{name}.pam
Source5:        %{name}.consoleapp
Patch0:         %{name}-db.patch
Patch1:         hddtemp_0.3-beta15-48.diff.gz
# https://bugzilla.redhat.com/show_bug.cgi?id=717479
# https://bugzilla.redhat.com/show_bug.cgi?id=710055
Patch2:         %{name}-0.3-beta15-autodetect-717479.patch
# Debian patchset -48 forgets to add de to po/LINGUAS (maintainer notified)
Patch3:         %{name}-0.3-beta15-linguas-de.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-buildroot

BuildRequires:  gettext, perl, gawk, gcc

%if 0%{?suse_version}
Group:          System/Monitoring
BuildRequires:  net-tools
BuildRequires:  systemd
%endif

%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
Group:          Applications/System
BuildRequires:  systemd-units, systemd-sysv
Requires:       %{_bindir}/consolehelper
Requires(pre):  chkconfig
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
%endif


%description
hddtemp is a tool that gives you the temperature of your hard drive by
reading S.M.A.R.T. information.


%prep
%setup -q -n %{name}-%{version}-%{beta}

cp -p %{SOURCE1} ./hddtemp.db
%patch0 -p0
%patch1 -p1
%patch2 -p1
%patch3 -p1
sed -i -e s/Celius/Celsius/g po/*.po*
sed -i -e 's|/etc/hddtemp.db|/usr/share/misc/hddtemp.db|' doc/hddtemp.8

chmod -x contribs/analyze/*
rm COPYING ; cp -p GPL-2 COPYING
cp -p debian/changelog changelog.debian


%build
%configure --disable-dependency-tracking
make %{?_smp_mflags}


%install
%makeinstall
install -Dpm 644 hddtemp.db $RPM_BUILD_ROOT/usr/share/misc/hddtemp.db
install -Dpm 644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/hddtemp.service
install -Dpm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/hddtemp
install -dm 755 $RPM_BUILD_ROOT%{_bindir}
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
ln -s consolehelper $RPM_BUILD_ROOT%{_bindir}/hddtemp
install -Dpm 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/pam.d/hddtemp
install -Dpm 644 %{SOURCE5} \
    $RPM_BUILD_ROOT%{_sysconfdir}/security/console.apps/hddtemp
%endif
%find_lang %{name}


%pre
rm -f %{migfile} &>/dev/null
if [ $1 -gt 1 ] && [ ! -e %{_unitdir}/hddtemp.service ] && \
   [ -e %{_initddir}/hddtemp ] ; then
    systemd-sysv-convert --save hddtemp &>/dev/null
    chkconfig --del hddtemp &>/dev/null
    touch %{migfile} &>/dev/null || :
fi

%post
[ $1 -eq 1 ] && systemctl daemon-reload &>/dev/null || :

%preun
if [ $1 -eq 0 ] ; then
    systemctl --no-reload disable hddtemp.service &>/dev/null
    systemctl stop hddtemp.service &>/dev/null || :
fi

%postun
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
systemctl daemon-reload &>/dev/null
[ $1 -gt 0 ] && systemctl try-restart hddtemp.service &>/dev/null || :
%endif

%triggerpostun -- %{name}
if [ $1 -gt 0 ] && [ -e %{migfile} ] ; then
    systemctl status hddtemp.service
    systemctl daemon-reload &>/dev/null
    systemctl status hddtemp.service
    systemctl try-restart hddtemp.service &>/dev/null
    systemctl status hddtemp.service
fi
rm -f %{migfile} &>/dev/null || :


%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc ChangeLog changelog.debian COPYING README TODO contribs/
%config(noreplace) %{_sysconfdir}/sysconfig/hddtemp
%{_unitdir}/hddtemp.service
%{_sbindir}/hddtemp
%config(noreplace) /usr/share/misc/hddtemp.db
%{_mandir}/man8/hddtemp.8*
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
%config(noreplace) %{_sysconfdir}/pam.d/hddtemp
%config(noreplace) %{_sysconfdir}/security/console.apps/hddtemp
%endif

%changelog
* Mon Nov 28 2011 Agnelo de la Crotche <agnelo@unixversal.com>
- systemd compatible version ported from Fedora

* Thu Aug 18 2011 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.22.beta15
- Migrate to systemd, patch to glob usual device names w/o arguments (#717479).
- Update Debian patch set to 0.3-beta15-48, ship its changelog in docs.

* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3-0.21.beta15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Sun Feb 14 2010 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.20.beta15
- Patch to fix ix86 build if sys/ucontext.h is pulled in by signal.h (#564857).

* Thu Aug 20 2009 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.19.beta15
- Try to start daemon for all disks if none are specified in sysconfig.
- Update URLs.

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3-0.18.beta15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3-0.17.beta15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Wed Oct  1 2008 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.16.beta15
- Sync with Debian's 0.3-beta15-45 for a fix for undesired spin-ups with
  most current drives (#464912).

* Sat Feb  9 2008 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.15.beta15
- Sync with Debian's 0.3-beta15-38.
- Update drive database to 2007-09-14.
- Trim pre-2006 changelog entries.

* Wed Sep  5 2007 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.14.beta15
- Adjust server chkconfig start/stop priorities to start before gkrellmd,
  other cosmetic init script tweaks.
- Mark hddtemp.db as %%config(noreplace).

* Mon Aug  6 2007 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.13.beta15
- License: GPLv2+

* Tue Jul 10 2007 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.12.beta15
- Improve init script LSB compliance.

* Tue Jan  9 2007 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.11.beta15
- SATA sense fix (#221100, Jens Axboe).

* Sun Dec 31 2006 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.10.beta15
- Apply patches from Debian containing bunch of hddtemp.db updates and
  guess mode improvements for drives not in the database.

* Wed Aug 30 2006 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.9.beta15
- Rebuild.

* Wed May  3 2006 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.8.beta15
- 0.3-beta15, drive database 2006-04-26.
- Specfile cleanups.

* Wed Feb  8 2006 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.8.beta14
- Update drive database to 2006-02-07.

* Wed Jan 18 2006 Ville Skytt <ville.skytta@iki.fi> - 0.3-0.7.beta14
- Update drive database to 2006-01-18.
- Init script is not a config file.
- Mark console.perms snippet as noreplace.
openSUSE Build Service is sponsored by