Subversion Repositories livecd

Rev

Rev 36 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

# -------------------------------------------------------------------------------------------
#
# How to build for SMP and UP kernel
#
#  rpmbuild -ba --target i686   --define 'kernel 2.6.9-42.0.2.EL' unionfs.spec
#  rpmbuild -ba --target x86_64 --define 'kernel 2.6.9-42.0.2.EL' unionfs.spec
#
# or only for UP kernel
#
#  rpmbuild -ba --target i686   --define 'kernel 2.6.9-42.0.2.EL' --define 'buildsmp 0' unionfs.spec
#  rpmbuild -ba --target x86_64 --define 'kernel 2.6.9-42.0.2.EL' --define 'buildsmp 0' unionfs.spec
#
#
# for the running kernel:
#
#  rpmbuild -ba --target i686   unionfs.spec
#  rpmbuild -ba --target x86_64 unionfs.spec
#
# -------------------------------------------------------------------------------------------

%{!?buildsmp:%define buildsmp 1}

%{?!kernel:%define kernel %(rpm -q kernel-devel | tail -1 | sed -e 's|kernel-devel-||')}

%define kversion %(echo "%{kernel}" | sed -e 's|-.*||')
%define krelease %(echo "%{kernel}" | sed -e 's|.*-||')

%define kernel_src_path %{_usrsrc}/kernels/%{kernel}-%{_target_cpu}
%define kernel_smp_src_path %{_usrsrc}/kernels/%{kernel}-smp-%{_target_cpu}

%define kernel_moduledir /lib/modules/%{kernel}
%define kernel_smp_moduledir /lib/modules/%{kernel}smp

%define pkg_name unionfs
%define kmdl_name kernel-module-%{pkg_name}-%{kernel}

# -------------------------------------------------------------------------------------------

Summary:        A Stackable Unification File System
Name:           %{pkg_name}
Version:        1.1.5
Release:        2.sl4.psi
Epoch:          0
Packager:       Urs Beyerle <urs.beyerle@psi.ch>
License:        GPL
Group:          System Environment/Kernel
Source0:        ftp://ftp.fsl.cs.sunysb.edu/pub/unionfs/%{name}-%{version}.tar.gz
URL:            http://www.am-utils.org/project-unionfs.html
Patch0:         unionfs-1.1.5-rhel4.patch
Patch1:         unionfs-1.1.5-kernel-2.6.9-42.0.2.EL.patch
Patch2:         unionfs-1.1.5-Makefile.patch
Patch3:         unionfs-1.1.5-copyup-security.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Requires:       kernel-module-%{pkg_name} >= %{version}-%{release}
BuildRequires:  kernel-devel = %{kernel}, 
%if %{buildsmp}
BuildRequires:  kernel-smp-devel = %{kernel}
%endif

%description
This project builds a stackable unification file system, which 
can appear to merge the contents of several directories (branches), 
while keeping their physical content separate. Unionfs is useful 
for unified source tree management, merged contents of split 
CD-ROM, merged separate software package directories, data grids, 
and more. Unionfs allows any mix of read-only and read-write 
branches, as well as insertion and deletion of branches anywhere 
in the fan-out. To maintain unix semantics, Unionfs handles 
elimination of duplicates, partial-error conditions, and more. 
Unionfs is part of the larger FiST project.

Kernel modules for unionfs are in kernel-module-%{pkg_name} rpms.

%package -n     %{kmdl_name}
Summary:        kernel modules for %{name}.
Group:          System Environment/Kernel
License:        GPL
Provides:       kernel-module-%{pkg_name} = %{epoch}:%{version}-%{release}
Requires:       %{pkg_name}

%description -n %{kmdl_name}
Kernel modules for %{name}.

%if %{buildsmp}

%package -n     %{kmdl_name}smp
Summary:        smp kernel modules for %{name}.
Group:          System Environment/Kernel
License:        GPL
Provides:       kernel-module-%{pkg_name} = %{epoch}:%{version}-%{release}
Requires:       %{pkg_name}

%description -n %{kmdl_name}smp
SMP kernel modules for %{name}.

%endif

%prep
%setup -q

%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

%build
echo -e "\nDriver version: %{version}\nKernel version: %{kernel}\n"

### build statically linked unionctl
make clean
cp -a Makefile Makefile.ori
sed -i "s|^CC.*=.*gcc|CC      = gcc -static|" Makefile
make unionctl
cp -a unionctl unionctl.static
mv -f Makefile.ori Makefile

### UP kernel
make clean
KVERS="%{kernel}" PREFIX=${RPM_BUILD_ROOT}%{_prefix} make

INST_MODLIB="${RPM_BUILD_ROOT}/lib/modules/%{kernel}/kernel"
mkdir -p "${INST_MODLIB}/fs/unionfs"
install -p -m 744 unionfs.ko "${INST_MODLIB}/fs/unionfs/"

### SMP kernel
%if %{buildsmp}

make clean
KVERS="%{kernel}smp" PREFIX=${RPM_BUILD_ROOT}%{_prefix} make

INST_MODLIB="${RPM_BUILD_ROOT}/lib/modules/%{kernel}smp/kernel"
mkdir -p "${INST_MODLIB}/fs/unionfs"
install -p -m 744 unionfs.ko "${INST_MODLIB}/fs/unionfs/"

%endif

%install
# "make install-utils" does not work - we do it manually
# PREFIX=${RPM_BUILD_ROOT}/%{_prefix} make install-utils

mkdir -p ${RPM_BUILD_ROOT}/%{_prefix}/sbin
mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}/man4
mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}/man8

cp unionctl ${RPM_BUILD_ROOT}/%{_prefix}/sbin
cp unionctl.static ${RPM_BUILD_ROOT}/%{_prefix}/sbin
cp uniondbg ${RPM_BUILD_ROOT}/%{_prefix}/sbin
cp unionimap ${RPM_BUILD_ROOT}/%{_prefix}/sbin

cp man/unionfs.4 ${RPM_BUILD_ROOT}/%{_mandir}/man4
cp man/unionctl.8 ${RPM_BUILD_ROOT}/%{_mandir}/man8
cp man/uniondbg.8 ${RPM_BUILD_ROOT}/%{_mandir}/man8

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

%postun -n %{kmdl_name}
depmod -a %{kernel} >/dev/null 2>&1 || :        

%post -n %{kmdl_name}
depmod -a %{kernel} >/dev/null 2>&1 || :

%if %{buildsmp}
%postun -n %{kmdl_name}smp
depmod -a %{kernel}smp >/dev/null 2>&1 || :

%post -n %{kmdl_name}smp
depmod -a %{kernel}smp >/dev/null 2>&1 || :
%endif

%files 
%defattr(-,root,root,-)
%doc AUTHORS BUGS ChangeLog COPYING INSTALL NEWS README
%{_prefix}/sbin/*
%{_mandir}/man4/*
%{_mandir}/man8/*

%files -n %{kmdl_name}
%defattr(-,root,root,-)
/lib/modules/%{kernel}/kernel/fs/unionfs

%if %{buildsmp}
%files -n %{kmdl_name}smp
%defattr(-,root,root,-)
/lib/modules/%{kernel}smp/kernel/fs/unionfs
%endif

%changelog
* Mon Oct 16 2006 Urs Beyerle <urs.beyerle@psi.ch>  1.1.5-2.sl4.psi
- add unionctl.static (statically linked unionctl), needed for LiveCD

* Thu Aug 31 2006 Urs Beyerle <urs.beyerle@psi.ch>  1.1.5-1.sl4.psi
- inital build.