Blob Blame History Raw
%bcond_without pam
%global _hardened_build 1

Summary:	Job spooling tools
Name:		at
Version:	3.1.13
Release:	22%{?dist}.2
# http://packages.debian.org/changelogs/pool/main/a/at/current/copyright
# + install-sh is MIT license with changes under Public Domain
License:	GPLv3+ and GPLv2+ and ISC and MIT and Public Domain
Group:		System Environment/Daemons
URL:		http://ftp.debian.org/debian/pool/main/a/at

Source:		http://ftp.debian.org/debian/pool/main/a/at/at_%{version}.orig.tar.gz
# git upstream source git://git.debian.org/git/collab-maint/at.git
Source1:	pam_atd
Source2:	atd.init
Source3:	atd.sysconf
Source5:	atd.systemd

Patch1:		at-3.1.13-makefile.patch
Patch2:		at-3.1.12-opt_V.patch
Patch3:		at-3.1.12-shell.patch
Patch4:		at-3.1.13-nitpicks.patch
Patch5:		at-3.1.13-pam.patch
Patch6:		at-3.1.13-selinux.patch
Patch7:		at-3.1.12-nowrap.patch
Patch8:		at-3.1.12-fix_no_export.patch 
Patch9:         at-3.1.13-mailwithhostname.patch
Patch10:        at-3.1.13-usePOSIXtimers.patch
Patch11:        at-3.1.13-help.patch
Patch12:        at-3.1.10-filter-environment.patch
Patch13:	at-3.1.13-fclose-error.patch
Patch14:	at-3.1.13-clear-nonjobs.patch
Patch15:	at-3.1.13-utc-dst.patch
Patch17:	at-3.1.13-aborted-jobs.patch

BuildRequires: fileutils /etc/init.d
BuildRequires: flex flex-static bison autoconf
BuildRequires: libselinux-devel >= 1.27.9
BuildRequires: perl(Test::Harness)
BuildRequires: perl(Test::More)

%if %{with pam}
BuildRequires: pam-devel
%endif
Conflicts: crontabs <= 1.5
# No, I'm not kidding
BuildRequires: smtpdaemon

Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units

%description
At and batch read commands from standard input or from a specified
file. At allows you to specify that a command will be run at a
particular time. Batch will execute commands when the system load
levels drop to a particular level. Both commands use user's shell.

You should install the at package if you need a utility for
time-oriented job control. Note: If it is a recurring job that will
need to be repeated at the same time every day/week, etc. you should
use crontab instead.

%package sysvinit
Summary:	SysV init script for at
Group:		System Environment/Base
Requires:	%{name} = %{version}-%{release}
Requires(post): /sbin/chkconfig

%description sysvinit
SysV style init script for at. It needs to be installed only if systemd
is not used as the system init process.

%prep
%setup -q
cp %{SOURCE1} .
%patch1 -p1 -b .make
%patch2 -p1 -b .opt_V
%patch3 -p1 -b .shell
%patch4 -p1 -b .nit
%patch5 -p1 -b .pam
%patch6 -p1 -b .selinux
%patch7 -p1 -b .nowrap
%patch8 -p1 -b .export
%patch9 -p1 -b .mail
%patch10 -p1 -b .posix
%patch11 -p1 -b .help
%patch12 -p1 -b .filter-environment
%patch13 -p1 -b .fclose
%patch14 -p1 -b .clear-nonjobs
%patch15 -p1 -b .dst
%patch17 -p1 -b .aborted-jobs

%build
# patch9 touches configure.in
autoconf
# clean old pregenerated files
rm -f lex.yy.* y.tab.*
%configure --with-atspool=%{_localstatedir}/spool/at/spool \
	--with-jobdir=%{_localstatedir}/spool/at \
	--with-daemon_username=root  \
	--with-daemon_groupname=root \
	--with-selinux \
%if %{with pam}
	--with-pam
%endif

make

%install
make install \
	DAEMON_USERNAME=`id -nu`\
	DAEMON_GROUPNAME=`id -ng` \
	DESTDIR=%{buildroot}\
	sbindir=%{buildroot}%{_prefix}/sbin\
	bindir=%{buildroot}%{_bindir}\
	prefix=%{buildroot}%{_prefix}\
	exec_prefix=%{buildroot}%{_prefix}\
	docdir=%{buildroot}/usr/doc\
	mandir=%{buildroot}%{_mandir}\
	etcdir=%{buildroot}%{_sysconfdir} \
	ATJOB_DIR=%{buildroot}%{_localstatedir}/spool/at \
	ATSPOOL_DIR=%{buildroot}%{_localstatedir}/spool/at/spool \
	INSTALL_ROOT_USER=`id -nu` \
	INSTALL_ROOT_GROUP=`id -nu`;

echo > %{buildroot}%{_sysconfdir}/at.deny
mkdir docs
cp  %{buildroot}/%{_prefix}/doc/at/* docs/

mkdir -p %{buildroot}%{_sysconfdir}/pam.d
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/pam.d/atd

mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d
install -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/rc.d/init.d/atd

mkdir -p %{buildroot}/etc/sysconfig
install -m 644 %{SOURCE3} %{buildroot}/etc/sysconfig/atd

# install systemd initscript
mkdir -p %{buildroot}/%{_unitdir}/
install -m 644 %{SOURCE5} %{buildroot}/%{_unitdir}/atd.service

# remove unpackaged files from the buildroot
rm -r  %{buildroot}%{_prefix}/doc

%check
make test

%post
touch %{_localstatedir}/spool/at/.SEQ
chmod 600 %{_localstatedir}/spool/at/.SEQ
chown daemon:daemon %{_localstatedir}/spool/at/.SEQ
%systemd_post atd.service

%preun
%systemd_preun atd.service

%postun
%systemd_postun_with_restart atd.service

%triggerun -- at < 3.1.12-6
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply atd
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save atd

# The package is allowed to autostart:
/bin/systemctl enable atd.service >/dev/null 2>&1

/sbin/chkconfig --del atd >/dev/null 2>&1 || :
/bin/systemctl try-restart atd.service >/dev/null 2>&1 || :
/bin/systemctl daemon-reload >/dev/null 2>&1 || :

%triggerpostun -n at-sysvinit -- at < 3.1.12-9
/sbin/chkconfig --add atd >/dev/null 2>&1 || :

%files
%doc docs/*
%attr(0644,root,root)		%config(noreplace) %{_sysconfdir}/at.deny
%attr(0644,root,root)		%config(noreplace) %{_sysconfdir}/sysconfig/atd
%attr(0700,daemon,daemon)	%dir %{_localstatedir}/spool/at
%attr(0600,daemon,daemon)	%verify(not md5 size mtime) %ghost %{_localstatedir}/spool/at/.SEQ
%attr(0700,daemon,daemon)	%dir %{_localstatedir}/spool/at/spool
%attr(0644,root,root)		%config(noreplace) %{_sysconfdir}/pam.d/atd
%{_sbindir}/atrun
%attr(0755,root,root)		%{_sbindir}/atd
%{_mandir}/man*/*
%{_bindir}/batch
%{_bindir}/atrm
%{_bindir}/atq
%attr(4755,root,root)		%{_bindir}/at
%attr(0644,root,root)		/%{_unitdir}/atd.service

%files sysvinit
%attr(0755,root,root)		%{_initrddir}/atd

%changelog
* Wed Dec 20 2017 Tomáš Mráz <tmraz@redhat.com> - 3.1.13-22.2
- fix handling of the aborted jobs (due to possibly
  temporary conditions) and avoid flooding the syslog

* Mon May 23 2016 Tomáš Mráz <tmraz@redhat.com> - 3.1.13-22
- SIGPIPE should not be ignored in atd (#1338039)

* Wed Apr 20 2016 Tomáš Mráz <tmraz@redhat.com> - 3.1.13-21
- correct the DST correction when using UTC time specification (#1328832)
- clear non-job files from at dir and test for write error on fclose
  to fix bogus syslog messages

* Mon Jun 22 2015 Tomáš Mráz <tmraz@redhat.com> - 3.1.13-20
- build the package with hardening flags (PIE, full RELRO)

* Fri Oct  3 2014 Tomáš Mráz <tmraz@redhat.com> - 3.1.13-18
- filter environment variables not acceptable in bash input

* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 3.1.13-17
- Mass rebuild 2014-01-24

* Thu Jan 09 2014 Marcela Mašláňová <mmaslano@redhat.com> - 3.1.13-16
- the correct solution is remove smp_flags, they don't work properly on ppc with
  the option mpower7
- Related: rhbz#1048745

* Mon Jan 06 2014 Marcela Mašláňová <mmaslano@redhat.com> - 3.1.13-15
- remove old changelogs
- ppc fail to rebuild package
- Resolves: rhbz#1048745

* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 3.1.13-14
- Mass rebuild 2013-12-27

* Thu Jul 11 2013 Marcela Mašláňová <mmaslano@redhat.com> - 3.1.13-13
- rebuild with ? in dist
- Resolves: rhbz#983255

* Mon Feb 11 2013 Peter Robinson <pbrobinson@fedoraproject.org> 3.1.13-12
- Fix patch to fix FTBFS with gcc 4.8

* Wed Nov 14 2012 Marcela Mašláňová <mmaslano@redhat.com> - 3.1.13-11
- fix license field again

* Thu Nov  1 2012 Marcela Mašláňová <mmaslano@redhat.com> - 3.1.13-10
- fix license field
- fix systemd macros in scriptlets part of the specfile
- fix selinux patch to apply without fuzz=2

* Fri Jul 27 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.13-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Tue Apr 17 2012 Marcela Mašláňová <mmaslano@redhat.com> - 3.1.13-8
- at-3.1.13-mailwithhostname.patch in email mention also hostname address
- at-3.1.13-usePOSIXtimers.patch use POSIX timers, so we won't need
  pm-utils hack anymore
- at-3.1.13-help.patch update usage
- systemd-user-sessions.service is used in unit file, so the atd should be
  started after almost all services are up and running
- 812682 pam support work with new systemd defaults

* Thu Jan 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.1.13-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild