File rear116.spec of Package rear116.100

#
# spec file for package rear116
#
# Copyright (c) 2014 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/
#


%bcond_without	use_mkisofs

Name:           rear116
Version:        1.16
Release:        0
# Automatic version upgrades are not possible in practice.
# The user must explicitly specify his intended version.
# When users have a working disaster recovery procedure, they should not upgrade
# (see "Version upgrades" at http://en.opensuse.org/SDB:Disaster_Recovery).
# Users who already use it and like to upgrade, must re-validate that their
# particular disaster recovery procedure still works.
# For one product (e.g. SLE11 or SLE12) we provide several versions in parallel
# so that users where version N does not support their particular needs
# can upgrade to version M but on the other hand users who have a working
# disaster recovery procedure with version N do not need to upgrade.
# Therefore the package name contains the version and all packages conflict with each other
# to avoid that an installed version gets accidentally replaced with another version:
Provides:       rear = %{version}
Conflicts:      rear < %{version}
Conflicts:      rear > %{version}
Summary:        Relax-and-Recover (abbreviated rear) is a Linux Disaster Recovery framework
License:        GPL-2.0+
Group:          Productivity/Archiving/Backup
Url:            http://relax-and-recover.org/
# as GitHub stopped with download section we need to go back to Sourceforge for downloads
Source0:        http://sourceforge.net/projects/rear/files/rear/%{version}/rear-%{version}.tar.gz
# Source1 rear-release-notes.txt-1.16 was created by calling
# w3m -dump -cols 78 http://relax-and-recover.org/documentation/release-notes-1-16 >rear-release-notes.txt-1.16
# because rear-1.16.tar.gz does not contain an up to date doc/rear-release-notes.txt file:
Source1:        rear-release-notes.txt-1.16
# Source2 SLE12-btrfs-example.conf is a working example for SLE12 with default btrfs subvolumes
# that gets installed as /usr/share/rear/conf/SLE12-btrfs-example.conf
Source2:        SLE12-btrfs-example.conf
# Source3 SLE11-ext3-example.conf is a working example for SLE11 with default ext3 filesystem
# that gets installed as /usr/share/rear/conf/SLE11-ext3-example.conf
Source3:        SLE11-ext3-example.conf
# Source99 rear116-rpmlintrc filters false positives rpmlint warning messages, see
# https://en.opensuse.org/openSUSE:Packaging_checks#Building_Packages_despite_of_errors
Source99:       rear116-rpmlintrc
# Patch1 traditional_style_for_bash_3.diff replaces bash 4.x syntax with traditional style for bash 3.x:
Patch1:         traditional_style_for_bash_3.diff
# Patch2 adaptions_for_btrfs_for_SLE12.diff changes btrfs handling as needed for SLE12 in particular
# - adds an explicit '-f' to "mkfs -t btrfs" that needs it (same as mkfs.xfs)
#   to force an overwrite when an existing filesystem is detected
#   otherwise "rear recover" fails with an error (bnc#878870)
# - avoids https://bugzilla.novell.com/show_bug.cgi?id=878058
#   by disabling code that seems to have been made for Fedora 19 but does not work for SLE12
#   but a btrfs expert should check whether or not this is a proper fix
# - adds preliminary support to recover normal btrfs subvolumes (i.e. no btrfs snapshot subvolumes)
#   see https://bugzilla.novell.com/show_bug.cgi?id=879111
#   where again a btrfs expert should check whether or not this is a proper fix
Patch2:         adaptions_for_btrfs_for_SLE12.diff
# Patch3 avoid_unary_operator_expected_error.diff uses $BACKUP_TYPE in double quotes
# to avoid the error message: "[: ==: unary operator expected":
Patch3:         avoid_unary_operator_expected_error.diff
# Patch4 skip_sysconfig_kernel_if_not_exist.diff skips etc/sysconfig/kernel stuff in
# /usr/share/rear/finalize/SUSE_LINUX/i386/17_rebuild_initramfs.sh
# when there is no etc/sysconfig/kernel so that it works for SLE12
# because since SLE12 RC3 /etc/sysconfig/kernel does no longer exist,
# see https://bugzilla.novell.com/show_bug.cgi?id=895084
# and https://bugzilla.novell.com/show_bug.cgi?id=896038
Patch4:         skip_sysconfig_kernel_if_not_exist.diff
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# LSB RPM Requires:
# Begin of "Requires: lsb" cleanup:
# Rear upstream has "Requires: lsb" but that requires much too much,
# see https://bugzilla.novell.com/show_bug.cgi?id=807747#c4
# "A distribution is LSB Certified or LSB compliant if and only if
#  the distribution provides all requirements as outlined in the
#  specification."
# Accordingly SUSE's lsb RPM requires tons of stuff that is not
# needed by Rear (in particular various graphical libraries,
# sound stuff, printing stuff, and so on).
# Therefore "Requires: lsb" is replaced by explicitly listing the RPM packages
# that are mandatory (in particular when a binary is called in a script) for Rear (as RPM Requires)
# plus what seems to be optional (nice to have) for Rear (as RPM Recommends)
# minus library packages because needed libraries should be automatically required.
# I <jsmeix@suse.de> think requiring RPM packages instead of binaries is better
# because it keeps the list shorter which is hopefully easier to maintain and
# the requirements are on a more higher level which is hopefully more unsusceptible against
# minor changes in what exact binaries names are actually called by Rear.
# To test if a binary is called by a Rear script the following was done (example for /usr/bin/bc):
#   BIN="bc"
#   for f in $( find /usr/share/rear/ )
#   do grep "\<$BIN\> " $f 2>/dev/null | grep -v '^[[:space:]]*#'
#   done
# What is not tested to find out if a binary is called by a Rear script is "eval" stuff,
# something like STRING=<result of whatever calls> ; eval $STRING
# Usually Rear calls "eval echo ..." or "eval "${EXTERNAL_whatever[@]}"
# except in /usr/share/rear/finalize/default/88_check_for_mount_by_id.sh that calls
#   eval "$(scsi_id ...
# where the only scsi_id that I could find is /usr/lib/udev/scsi_id
# which belongs to udev and I assume that udev is installed in any case
# so that there is no explicit RPM Requires for udev in Rear.
# What is also not tested to find out what Rear actually needs is
# which files (not only binaries) Rear needs to build up its recovery system
# (in particular tools for partitioning, creating filesystems, and bootloader installation).
# I assume what Rear needs to build up the system-specific recovery system is installed
# (e.g. if the ext4 filesystem is used, I assume mkfs.ext4 is installed)
# so that there are no explicit RPM Requires needed for that in Rear.
# The following list was derived from the RPM Requires of SUSE's lsb package
# (its last RPM changelog entry dated "Tue Oct  1 07:01:56 UTC 2013") as follows:
#   for r in $( grep ^Requires: lsb.spec | tr -s ' ' | cut -d ' ' -f2 )
#   do rpm -q --whatprovides $r
#   done | sort -u
# which results the following list where only what is needed for Rear is activated:
#   Mesa-9.2.3-61.9.1.i586
#   Mesa-libGL1-9.2.3-61.9.1.i586
#   at-3.1.13-5.4.1.i586
Requires:       bash
Requires:       bc
Requires:       binutils
Requires:       coreutils
Requires:       cpio
#   cronie-1.4.8-50.1.2.i586
#   cups-client-1.5.4-140.1.i586
Requires:       diffutils
#   ed-1.9-2.1.2.i586
Requires:       file
Requires:       findutils
#   fontconfig-2.11.0-1.1.i586
#   foomatic-filters-4.0.12-5.1.1.i586
Requires:       gawk
#   gettext-runtime-0.18.3.1-1.1.i586
#   ghostscript-9.10-45.4.i586
# Rear calls getent in /usr/share/rear/rescue/default/90_clone_users_and_groups.sh
Requires:       glibc
#   glibc-i18ndata-2.18-4.11.1.noarch
Requires:       grep
Requires:       gzip
#   libGLU1-9.0.0-7.1.2.i586
#   libXt6-1.1.4-2.1.2.i586
#   libXtst6-1.2.2-2.1.2.i586
#   libasound2-1.0.27.2-3.5.1.i586
#   libatk-1_0-0-2.10.0-1.1.i586
#   libglib-2_0-0-2.38.2-8.2.i586
#   libgtk-2_0-0-2.24.22-2.1.i586
#   libjpeg62-62.0.0-24.1.3.i586
#   libpango-1_0-0-1.36.1-4.2.i586
#   libpng12-0-1.2.50-6.1.2.i586
#   libqt4-4.8.5-5.6.1.i586
#   libqt4-sql-4.8.5-5.6.1.i586
#   libqt4-x11-4.8.5-5.6.1.i586
#   libxml2-tools-2.9.1-2.1.2.i586
# Rear calls "lsb_release" in /usr/share/rear/lib/config-functions.sh
Requires:       lsb-release
#   m4-1.4.16-14.1.2.i586
#   mailx-12.5-14.1.3.i586
#   make-3.82-160.2.1.i586
#   man-2.6.3-9.1.3.i586
#   mozilla-nss-3.15.3.1-8.1.i586
Requires:       net-tools
#   patch-2.7.1-4.1.2.i586
#   pax-3.4-155.1.2.i586
Requires:       perl-base
#   postfix-2.9.6-7.4.1.i586
Requires:       procps
#   psmisc-22.20-5.1.2.i586
#   python-2.7.5-8.3.1.i586
#   python3-3.3.2-5.1.3.i586
#   qt3-3.3.8c-128.1.2.i586
Requires:       rsync
Requires:       sed
#   shadow-4.1.5.1-8.1.2.i586
#   systemd-sysvinit-208-15.1.i586
#   sysvinit-tools-2.88+-89.1.2.i586
Requires:       tar
#   time-1.7-3.1.2.i586
Requires:       util-linux
#   xdg-utils-20121008-2.2.1.noarch
# End of "Requires: lsb" cleanup.
# Non-LSB RPM Requires:
# all RPM based systems seem to have this and call it the same
Requires:       ethtool
Requires:       iproute2
Requires:       iputils
%if 0%{?suse_version} >= 1230
Requires:       %{_sbindir}/agetty
%else
Requires:       /sbin/mingetty
%endif
%if %{with use_mkisofs}
Requires:       %{_bindir}/mkisofs
%else
Requires:       %{_bindir}/genisoimage
%endif
# recent SUSE versions have an extra nfs-client package
Requires:       nfs-client
# Rear calls openssl in /usr/share/rear/rescue/default/50_ssh.sh
Requires:       openssl
# openSUSE from 11.1 and SLES from 11 uses rpcbind instead of portmap
Requires:       rpcbind
Requires:       syslinux

%description
Relax-and-Recover (abbreviated rear) is a highly modular
disaster recovery framework for GNU/Linux based systems,
but can be easily extended to other UNIX alike systems.
The disaster recovery information (and maybe the backups)
can be stored via the network, local on hard disks or
USB devices, DVD/CD-R, tape, etc. The result is also a
bootable image that is capable of booting via PXE,
DVD/CD and USB media.

Relax-and-Recover integrates with other backup software
and provides integrated bare metal disaster recovery
abilities to the compatible backup software.

Warning for users who like to upgrade Relax-and-Recover:
Users who already use it must re-validate that their
particular disaster recovery procedure still works.
See in particular "Version upgrades" at
http://en.opensuse.org/SDB:Disaster_Recovery

Therefore SUSE provides Relax-and-Recover as RPM packages
where the RPM package name contains the version and all
those RPM packages conflict with each other to avoid
that the installed Relax-and-Recover gets accidentally
replaced with another version. The user must explicitly
specify his intended Relax-and-Recover version.

Additionally when you already use Relax-and-Recover and
you upgrade software that is related to the basic system
(e.g. kernel, storage, bootloader, init, networking) or
you do other changes in your basic system, you must also
re-validate that your particular disaster recovery
procedure still works for you.

%prep
%setup -q -n rear-%{version}
# Patch1 traditional_style_for_bash_3.diff replaces bash 4.x syntax with traditional style for bash 3.x
# in any case because rear should be the same on any platform
# (up to openSUSE:11.1 and SLE11 we have bash 3.x and since openSUSE:11.2 we have bash 4.x):
%patch1 -p1
# Patch2 adaptions_for_btrfs_for_SLE12.diff changes btrfs handling as needed for SLE12 in particular
# - adds an explicit '-f' to "mkfs -t btrfs" that needs it (same as mkfs.xfs)
#   to force an overwrite when an existing filesystem is detected
#   otherwise "rear recover" fails with an error (bnc#878870)
# - avoids https://bugzilla.novell.com/show_bug.cgi?id=878058
#   by disabling code that seems to have been made for Fedora 19 but does not work for SLE12
#   but a btrfs expert should check whether or not this is a proper fix
# - adds preliminary support to recover normal btrfs subvolumes (i.e. no btrfs snapshot subvolumes)
#   see https://bugzilla.novell.com/show_bug.cgi?id=879111
#   where again a btrfs expert should check whether or not this is a proper fix
%patch2
# Patch3 avoid_unary_operator_expected_error.diff uses $BACKUP_TYPE in double quotes
# to avoid the error message: "[: ==: unary operator expected":
%patch3
# Patch4 skip_sysconfig_kernel_if_not_exist.diff skips etc/sysconfig/kernel stuff in
# /usr/share/rear/finalize/SUSE_LINUX/i386/17_rebuild_initramfs.sh
# when there is no etc/sysconfig/kernel so that it works for SLE12
# because since SLE12 RC3 /etc/sysconfig/kernel does no longer exist,
# see https://bugzilla.novell.com/show_bug.cgi?id=895084
# and https://bugzilla.novell.com/show_bug.cgi?id=896038
%patch4
# add a specific os.conf to not depend on LSB dependencies
# (otherwise it calls "lsb_release" in /usr/share/rear/lib/config-functions.sh)
# for the suse_version values see the listing at
# http://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto
# in particular see there the "Note" that reads
# "sles_version is no longer set in SLES 11. Use suse_version == 1110 instead.":
%if 0%{?suse_version} == 1110
# SLE 11
OS_VERSION="11"
%endif
%if 0%{?suse_version} == 1140
# openSUSE 11.4
OS_VERSION="11.4"
%endif
%if 0%{?suse_version} == 1210
# openSUSE 12.1
OS_VERSION="12.1"
%endif
%if 0%{?suse_version} == 1220
# openSUSE 12.2
OS_VERSION="12.2"
%endif
%if 0%{?suse_version} == 1230
# openSUSE 12.3
OS_VERSION="12.3"
%endif
%if 0%{?suse_version} == 1310
# openSUSE 13.1
OS_VERSION="13.1"
%endif
%if 0%{?suse_version} == 1315
# SLE 12
OS_VERSION="12"
%endif
%if 0%{?suse_version} == 1320
# openSUSE 13.2
OS_VERSION="13.2"
%endif
echo -e "OS_VENDOR=SUSE_LINUX\nOS_VERSION=$OS_VERSION" >etc/rear/os.conf
# replace outdated doc/rear-release-notes.txt from rear-1.16.tar.gz
# with the up to date rear-release-notes.txt-1.16 in Source1:
cp %{SOURCE1} doc/rear-release-notes.txt

%build
# no code to compile - all bash scripts
# but at least test if the syntax is o.k.
# currently "make validate" does not work because '-n 1' is missing for xargs
# so that the commands from "make validate" are run here with 'xargs -n 1':
find etc/ usr/share/rear/conf/ -name '*.conf' | xargs -n 1 bash -n
bash -n usr/sbin/rear
find . -name '*.sh' | xargs -n 1 bash -n

%install
make install DESTDIR="%{buildroot}"
# "make install" only installs the man page but not the other documentation
# and the 'doc' RPM macro in the files section would install the documentation
# into a /usr/share/doc/packages/rear116 directory (using the RPM package name)
# but the documentation should be installed into the fixed
# upstream-compliant /usr/share/doc/packages/rear directory
# so that the documentation is hereby explicitly installed as needed:
install -d %{buildroot}%{_defaultdocdir}/rear/
cp -r AUTHORS COPYING README doc/*.txt doc/user-guide/ doc/mappings/ %{buildroot}%{_defaultdocdir}/rear
# Source2 SLE12-btrfs-example.conf is a working example for SLE12 with default btrfs subvolumes
# that gets installed as /usr/share/rear/conf/SLE12-btrfs-example.conf
install -m 644 %{SOURCE2} %{buildroot}%{_datadir}/rear/conf/SLE12-btrfs-example.conf
# Source3 SLE11-ext3-example.conf is a working example for SLE11 with default ext3 filesystem
# that gets installed as /usr/share/rear/conf/SLE11-ext3-example.conf
install -m 644 %{SOURCE3} %{buildroot}%{_datadir}/rear/conf/SLE11-ext3-example.conf

%files
%defattr(-,root,root,-)
%doc %{_defaultdocdir}/rear/
%doc %{_mandir}/man8/rear.8*
%config(noreplace) %{_sysconfdir}/rear/
%config(noreplace) %{_datadir}/rear/
%{_localstatedir}/lib/rear/
%{_sbindir}/rear

%changelog
openSUSE Build Service is sponsored by