File amanda.spec of Package amanda

#
# spec file for package amanda
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


#
%if 0%{?suse_version} <= 1110
    %define amanda_group disk
%else
    %define amanda_group amanda
%endif

Name:           amanda
Version:        3.3.0
Release:        0

PreReq:         pwdutils permissions

BuildRequires:  automake
BuildRequires:  cups-client
BuildRequires:  dump
BuildRequires:  gawk
BuildRequires:  glib2-devel
BuildRequires:  gnuplot
BuildRequires:  krb5-devel
BuildRequires:  libsmbclient
BuildRequires:  libsmbclient-devel
BuildRequires:  libxslt
BuildRequires:  mailx
BuildRequires:  mtx
BuildRequires:  perl-base
BuildRequires:  popt-devel
BuildRequires:  procps
BuildRequires:  readline-devel
BuildRequires:  samba-client
BuildRequires:  sendmail

Requires:       dump /usr/bin/smbclient
Requires:       perl = %{perl_version}
Group:          Productivity/Archiving/Backup
License:        GPL-2.0+ ; MIT
Url:            http://www.amanda.org/
Summary:        Network Disk Archiver

Source:         %{name}-%{version}.tar.bz2
#amanda-SuSE.tar.bz2 contain init scripts, config examples
Source1:        %{name}-SuSE.tar.bz2
Source2:        amanda-howto-collection.pdf.tar.bz2

Patch3:         amanda-2.6.1p1-shellbang.patch
Patch4:         amanda-2.6.1p1-return_val.patch
Patch6:         amanda-2.6.1p1-avoid-perl-provides.patch
Patch7:         amanda-3.3.0-g_queue.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This is a release of Amanda, the Advanced Maryland Automatic Network
Disk Archiver.	Amanda is a backup system designed to archive many
computers on a network to a single large-capacity tape drive.

%prep
%setup -q -a 1 -a 2
rm -r patches
%patch3
%patch4
%patch6 -p1
%patch7 -p1

%build
./autogen

CFLAGS="$RPM_OPT_FLAGS -U BUILD_DATE -U BUILD_MACH -fno-strict-aliasing -fPIC -fPIE" \
CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fPIC -fPIE" \
LDFLAGS="-pie" \
	./configure --mandir=%{_mandir} \
          --with-bsdtcp-security --with-bsdudp-security \
          --with-ssh-security --with-rsh-security --with-krb5-security \
          --prefix=%{_prefix} \
          --infodir=%{_infodir} \
          --sysconfdir=%{_sysconfdir} \
          --libdir=%{_libdir} \
          --libexecdir=/usr/lib \
          --localstatedir=/var/lib \
          --with-index-server=localhost \
          --with-gnutar-listdir=/var/lib/amanda/gnutar-lists \
          --with-smbclient=%{_prefix}/bin/smbclient \
          --with-amperldir=%{perl_vendorlib} \
          --with-user=amanda \
          --with-group=%{amanda_group} \
          --with-gnutar=/bin/tar \
          --disable-libtool \
          --with-amandahosts \
          --disable-installperms
make %{?_smp_mflags}

%install
make DESTDIR=$RPM_BUILD_ROOT/ install
install -d $RPM_BUILD_ROOT/%{_sysconfdir}/amanda \
           $RPM_BUILD_ROOT/var/lib/amanda/index \
           $RPM_BUILD_ROOT/var/lib/amanda/gnutar-lists \
           $RPM_BUILD_ROOT/var/lib/amanda/disklist \
           $RPM_BUILD_ROOT/var/lib/amanda/DailySet1 \
           $RPM_BUILD_ROOT/var/lib/amanda/lbl-templ \
           $RPM_BUILD_ROOT/%{_docdir}/%{name} \
           $RPM_BUILD_ROOT/%{_sysconfdir}/xinetd.d
install NEWS README README.SuSE example/{amanda.conf,chg-multi.conf,disklist} $RPM_BUILD_ROOT/%{_docdir}/%{name}
chmod 644 $RPM_BUILD_ROOT/%{_docdir}/%{name}/* \
          $RPM_BUILD_ROOT/%{_mandir}/*/*
cp -a SuSE/* $RPM_BUILD_ROOT
#we must change group name for amanada user in xinit'd scripts for 11.1 and lower
%if 0%{?suse_version} <= 1110
    %__sed -i 's|amanda|disk|' $RPM_BUILD_ROOT/etc/xinetd.d/am*
%endif
# pdf doc
cp amanda-howto-collection.pdf $RPM_BUILD_ROOT/%{_docdir}/%{name}/
# label templates
cp -a example/*.ps $RPM_BUILD_ROOT/var/lib/amanda/lbl-templ
# contain docs,examples which are already included
rm -rf $RPM_BUILD_ROOT/usr/share/amanda
# bnc#412636
touch $RPM_BUILD_ROOT//usr/lib/amanda/exclude.gtar
# delete all static linking remnats
find $RPM_BUILD_ROOT \( -name "*.a" -o -name "*.la" \) -delete
# create a list of binaries to be checked externally
cat << EOF > $RPM_BUILD_ROOT/usr/lib/amanda/suidlist
/usr/sbin/amcheck
/usr/lib/amanda/calcsize
/usr/lib/amanda/rundump
/usr/lib/amanda/planner
/usr/lib/amanda/runtar
/usr/lib/amanda/dumper
/usr/lib/amanda/killpgrp
EOF

%pre
# since 11.2 we use group "tape" instead of "disk" for tape devices /dev/nst*,
# so we must check group for "amanda" user
%if 0%{?suse_version} > 1110
    # create primary group for amanda user
    /usr/sbin/groupadd -r amanda 2>/dev/null || :
    # if user already exists and has effective group "disk", we have to change this group
    # to "amanda" group and also add supplementary "tape" group see bnc#523006
    # else - move amanda to group amanda unconditionally (ignore failures if amanda doesn't exist)
    /usr/bin/id -n -g amanda 2>&1 | grep "disk" >/dev/null \
        && /usr/sbin/usermod -g amanda -G tape amanda \
        || /usr/sbin/usermod -g amanda amanda 2>&1 \
        || :
    # this is ugly but just simple add user with "tape" and "amanda" groups regardless of existing user
    /usr/sbin/useradd -r -o -g amanda -G tape -u 37 -s /bin/bash \
        -c "Amanda admin" -d /var/lib/amanda amanda >/dev/null 2>&1 || :
%else
    # in <= 11.1 use old disk group for amanda user
    /usr/sbin/useradd -r -o -g disk -u 37 -s /bin/bash \
        -c "Amanda admin" -d /var/lib/amanda amanda >/dev/null 2>&1 || :
%endif

%post
%run_permissions
%verifyscript
%verify_permissions -f /usr/lib/amanda/suidlist

%files
%defattr(-,root,root)
%doc %attr(644,root,root) amanda-howto-collection.pdf ChangeLog NEWS AUTHORS COPYRIGHT README ReleaseNotes
%doc %attr(755,root,root) %dir %{_docdir}/%{name}
%doc %{_mandir}/man*/*
%config /usr/lib/amanda/exclude.gtar
%attr(755,root,root) %dir /usr/lib/amanda
%attr(664,amanda,%{amanda_group}) %config(noreplace) %{_sysconfdir}/dumpdates
%attr(664,amanda,%{amanda_group}) %config(noreplace) %{_sysconfdir}/amandates
%attr(755,amanda,%{amanda_group}) %dir %{_sysconfdir}/amanda
%attr(755,amanda,%{amanda_group}) %dir %{_sysconfdir}/amanda/example
%attr(755,amanda,%{amanda_group}) %dir /var/lib/amanda/
%attr(755,amanda,%{amanda_group}) %dir /var/lib/amanda/disklist
%attr(755,amanda,%{amanda_group}) %dir /var/lib/amanda/gnutar-lists/
%attr(755,amanda,%{amanda_group}) %dir /var/lib/amanda/index/
%attr(755,amanda,%{amanda_group}) %dir /var/lib/amanda/DailySet1
%attr(755,amanda,%{amanda_group}) %dir /var/lib/amanda/lbl-templ
%attr(644,amanda,%{amanda_group}) /var/lib/amanda/lbl-templ/*
%config %attr(644,amanda,%{amanda_group}) /var/lib/amanda/.bashrc
%config %attr(644,amanda,%{amanda_group}) /var/lib/amanda/.profile
# bnc#412636 file permissions of .amandahosts should be 600
%config %attr(600,amanda,%{amanda_group}) /var/lib/amanda/.amandahosts
%config %attr(644,amanda,%{amanda_group}) %{_sysconfdir}/amanda/example/amanda.conf
%config %attr(644,amanda,%{amanda_group}) %{_sysconfdir}/amanda/example/disklist
%config(noreplace) %{_sysconfdir}/xinetd.d/*
# perl scripts
%dir %{perl_vendorlib}/Amanda/
%dir %{perl_vendorlib}/Amanda/Application
%dir %{perl_vendorlib}/Amanda/Changer
%dir %{perl_vendorlib}/Amanda/Config
%dir %{perl_vendorlib}/Amanda/Curinfo
%dir %{perl_vendorlib}/Amanda/DB
%dir %{perl_vendorlib}/Amanda/Interactivity
%dir %{perl_vendorlib}/Amanda/IPC
%dir %{perl_vendorlib}/Amanda/Recovery
%dir %{perl_vendorlib}/Amanda/Report
%dir %{perl_vendorlib}/Amanda/Taper
%dir %{perl_vendorlib}/Amanda/Taper/Scan
%dir %{perl_vendorlib}/auto/Amanda/
%dir %{perl_vendorlib}/auto/Amanda/Application
%dir %{perl_vendorlib}/auto/Amanda/Archive
%dir %{perl_vendorlib}/auto/Amanda/Cmdline
%dir %{perl_vendorlib}/auto/Amanda/Config
%dir %{perl_vendorlib}/auto/Amanda/Debug
%dir %{perl_vendorlib}/auto/Amanda/Device
%dir %{perl_vendorlib}/auto/Amanda/Disklist
%dir %{perl_vendorlib}/auto/Amanda/Feature
%dir %{perl_vendorlib}/auto/Amanda/Header
%dir %{perl_vendorlib}/auto/Amanda/IPC
%dir %{perl_vendorlib}/auto/Amanda/IPC/Binary
%dir %{perl_vendorlib}/auto/Amanda/Logfile
%dir %{perl_vendorlib}/auto/Amanda/MainLoop
%dir %{perl_vendorlib}/auto/Amanda/NDMP
%dir %{perl_vendorlib}/auto/Amanda/Tapelist
%dir %{perl_vendorlib}/auto/Amanda/Tests
%dir %{perl_vendorlib}/auto/Amanda/Util
%dir %{perl_vendorlib}/auto/Amanda/Xfer
%dir %{perl_vendorlib}/auto/Amanda/XferServer
%{perl_vendorlib}/Amanda/*/*/*.pm
%{perl_vendorlib}/Amanda/*/*.pm
%{perl_vendorlib}/Amanda/*.pm
%{perl_vendorlib}/auto/Amanda/*/*.so
%{perl_vendorlib}/auto/Amanda/*/*/*.so
%defattr(755,amanda,%{amanda_group})
%{_sbindir}/amadmin
%{_sbindir}/amcheckdb
%{_sbindir}/amcleanup
%{_sbindir}/amdump
%{_sbindir}/amflush
%{_sbindir}/amgetconf
%{_sbindir}/amlabel
%{_sbindir}/amoverview
%{_sbindir}/amplot
%verify(not mode) %attr(0750,root,%{amanda_group}) %{_sbindir}/amcheck
%attr(0750,amanda,%{amanda_group}) %{_sbindir}/amrecover
%{_sbindir}/amreport
%{_sbindir}/amrestore
%{_sbindir}/amrmtape
%{_sbindir}/amstatus
%{_sbindir}/amtape
%{_sbindir}/amtapetype
%{_sbindir}/amtoc
%{_sbindir}/amcrypt-ossl
%{_sbindir}/amcrypt-ossl-asym
%{_sbindir}/amoldrecover
%{_sbindir}/amgpgcrypt
%{_sbindir}/amaespipe
%{_sbindir}/amcrypt
%{_sbindir}/amfetchdump
%{_sbindir}/amaddclient
%{_sbindir}/amarchiver
%{_sbindir}/amcheckdump
%{_sbindir}/amcryptsimple
%{_sbindir}/amdevcheck
%{_sbindir}/amdump_client
%{_sbindir}/amserverconfig
%{_sbindir}/amservice
%{_sbindir}/amvault
%defattr(644,amanda,%{amanda_group})
/usr/lib/amanda/suidlist
/usr/lib/amanda/amcat.awk
/usr/lib/amanda/amplot.awk
/usr/lib/amanda/amplot.g
/usr/lib/amanda/amplot.gp
%defattr(755,amanda,%{amanda_group})
/usr/lib/amanda/amandad
/usr/lib/amanda/amdumpd
/usr/lib/amanda/amidxtaped
/usr/lib/amanda/amindexd
/usr/lib/amanda/amtrmidx
/usr/lib/amanda/chg-disk
/usr/lib/amanda/chg-manual
/usr/lib/amanda/chg-multi
/usr/lib/amanda/chg-zd-mtx
/usr/lib/amanda/driver
/usr/lib/amanda/amcheck-device
/usr/lib/amanda/amcleanupdisk
/usr/lib/amanda/amlogroll
/usr/lib/amanda/amndmjob
/usr/lib/amanda/amtrmlog
/usr/lib/amanda/patch-system
/usr/lib/amanda/selfcheck
/usr/lib/amanda/sendbackup
/usr/lib/amanda/sendsize
/usr/lib/amanda/taper
/usr/lib/amanda/chunker
/usr/lib/amanda/noop
/usr/lib/amanda/ndmjob
/usr/lib/amanda/amanda-sh-lib.sh
/usr/lib/amanda/teecount
/usr/lib/amanda/chg-lib.sh
%verify(not mode) %attr(0750,root,%{amanda_group})/usr/lib/amanda/calcsize
%verify(not mode) %attr(0750,root,%{amanda_group})/usr/lib/amanda/dumper
%verify(not mode) %attr(0750,root,%{amanda_group})/usr/lib/amanda/killpgrp
%verify(not mode) %attr(0750,root,%{amanda_group})/usr/lib/amanda/planner
%verify(not mode) %attr(0750,root,%{amanda_group})/usr/lib/amanda/rundump
%verify(not mode) %attr(0750,root,%{amanda_group})/usr/lib/amanda/runtar
%dir /usr/lib/amanda/application/
/usr/lib/amanda/application/*
# include shared libs
%dir %{_libdir}/amanda/
%{_libdir}/amanda/lib*

%changelog
openSUSE Build Service is sponsored by