File mkcdrec.spec of Package mkcdrec

%define _prefix /var/opt/mkcdrec
%define _boot_arch x86

Name: mkcdrec
Version: 1.4
Release: 1%{?dist}
Summary: Make CD-ROM Recovery (mkCDrec) disaster recovery tool-set

Group: Productivity/Archiving/Backup
License: GPLv2+
URL: http://mkcdrec.sourceforge.net/
Source0: %{name}-%{version}.tar.gz
##Source1: busybox-1.01.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Prefix: %{_prefix}

%if %{_boot_arch}==ia64
Requires: chkconfig fileutils cdrecord mkisofs tar ash mtools rsync
Requires: kernel >= 2.0.0, util-linux >= 2.11, parted >= 1.6
BuildRequires: gcc >= 2.96
%endif
%if %{_boot_arch}==x86_64
Requires: fileutils cdrecord mkisofs tar ash rsync syslinux
Requires: kernel >= 2.0.0, util-linux >= 2.11
BuildRequires: gcc >= 2.96
%endif
%if %{_boot_arch}==x86
Requires: coreutils fileutils cdrecord mkisofs tar ash syslinux rsync
Requires: kernel >= 2.0.0, util-linux >= 2.11
BuildRequires: syslinux >= 1.60, gcc >= 2.96
%endif


%description
mkCDrec (Make CDROM Recovery) makes a bootable (El Torito) disaster recovery
image, including backups of the Linux system to one or more CD-ROM(s)
(multi-volume sets). Otherwise, the backups can be stored on another disk,
NFS disk, or (remote) tape. After a disk crash or system intrusion, the system
can be booted from the CD-ROM and one can restore the complete system as 
it was. It also features disk cloning, which allows one to restore a disk
to another disk (the destination disk does not have to be of the same size,
as it calculates the partition layout itself). Currently, ext2, ext3, minix, 
msdos, fat, vfat, reiserfs, xfs and jfs filesystems are supported.
One Button Disaster Recovery (OBDR) is also supported as recovery method.


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


%build
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
%if 0%{?mdkversion}
# no-error needed for mandriva which has format-security on
CFLAGS="$CFLAGS -Wno-error=format-security"
%endif
export CFLAGS
make %{?_smp_mflags} -f Makefile.%{_boot_arch} build V=1

%install
rm -rf $RPM_BUILD_ROOT
find . -name CVS | xargs rm -Rfv

mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/busybox/applets
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/bin
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/contributions
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/modules
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/scripts/messages
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/doc
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/usr
mkdir -m 755 -p $RPM_BUILD_ROOT%{_prefix}/etc
mkdir -m 755 -p $RPM_BUILD_ROOT%{_mandir}/man8

for fname in busybox*/busybox busybox*/busybox.links  ; do
	install -m 755 $fname $RPM_BUILD_ROOT%{_prefix}/busybox
done
install -m 755 busybox*/applets/install.sh $RPM_BUILD_ROOT%{_prefix}/busybox/applets

for fname in  cutstream*/cutstream \
	pastestream*/pastestream mediacheck/checkisomd5 mediacheck/implantisomd5
do
	install -s -m 755 $fname $RPM_BUILD_ROOT%{_prefix}/bin
done

for fname in contributions/*.sh contributions/mkcdrec; do
	install -m 755 $fname $RPM_BUILD_ROOT%{_prefix}/contributions
done

for fname in scripts/messages/*; do
	install -m 644 $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done

for fname in `find scripts -type f`; do
	install -m 755 $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done

for fname in modules/*; do
	install -m 755 $fname $RPM_BUILD_ROOT%{_prefix}/modules
done

for fname in `find etc -type d`; do
	install -d -m 755  $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done
for fname in `find etc -type f`; do
	install -m 644  $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done

for fname in `find usr -type d`; do
	install -d -m 755  $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done
for fname in `find usr -type f`; do
	install -m 644  $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done
for fname in `find usr/bin -type f`; do
	install -m 755  $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done

for fname in `find . -type f -maxdepth 1`; do
	install -m 755  $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done

for fname in doc/autorun.inf doc/README doc/CD-Rom.ico; do
	install -m 644 $fname $RPM_BUILD_ROOT%{_prefix}/$fname
done

install -m 644 doc/mkcdrec.8 $RPM_BUILD_ROOT%{_mandir}/man8

test -f $RPM_BUILD_ROOT%{_mandir}/man8/mkcdrec.8.gz || {
	gzip -f -c $RPM_BUILD_ROOT%{_mandir}/man8/mkcdrec.8 > \
	$RPM_BUILD_ROOT%{_mandir}/man8/mkcdrec.8.gz && \
	rm -f $RPM_BUILD_ROOT%{_mandir}/man8/mkcdrec.8
	}

for file in \
	$RPM_BUILD_ROOT%{_prefix}/.cvsignore \
	$RPM_BUILD_ROOT%{_prefix}/COPYING \
	$RPM_BUILD_ROOT%{_prefix}/Changelog \
	$RPM_BUILD_ROOT%{_prefix}/README \
; do rm -f $file ; done

# fix up script permissions
cd ${RPM_BUILD_ROOT}%{_prefix} && \
	chmod 755 usr/share/udhcpc/default.renew usr/share/udhcpc/default.script \
		usr/share/udhcpc/default.deconfig usr/share/udhcpc/default.bound \
		etc/rc.d/rc.sysinit etc/rc.d/rc.udev.boot

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc Changelog README COPYING
%doc %{_prefix}/doc
%config(noreplace) %{_prefix}/Config.sh
%{_prefix}
%{_prefix}/VERSION
%{_prefix}/.config.bb
%{_prefix}/busybox
%{_prefix}/bin
%{_prefix}/contributions
%{_prefix}/scripts
%{_prefix}/modules
%{_prefix}/etc
%{_prefix}/usr
%{_prefix}/linuxrc
%{_prefix}/linuxrc_find_and_prep_root
%{_prefix}/linuxrc_post
%{_prefix}/linuxrc_pre
%{_prefix}/Makefile
%{_prefix}/Makefile.new-powermac
%{_prefix}/Makefile.x86
%{_prefix}/Makefile.sparc
%{_prefix}/Makefile.ia64
%{_prefix}/Makefile.x86_64
%{_mandir}/man8

%post
install -m 750 %{_prefix}/contributions/mkcdrec /usr/sbin/mkcdrec

%postun
# rm the mkcdrec wrapper
rm -f /usr/sbin/mkcdrec


%changelog
* Fri Feb 18 2011 Gratien D'haese <gdha at sourceforge.net> - 1.2-1
- spec file reworked so make it compile on older distros

* Thu Mar 25 2010 Gratien D'haese <gdha at sourceforge.net> - 1.0.0-1
- rework the spec file