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' squashfs.spec
#  rpmbuild -ba --target x86_64 --define 'kernel 2.6.9-42.0.2.EL' squashfs.spec
#
# or only for UP kernel
#
#  rpmbuild -ba --target i686   --define 'kernel 2.6.9-42.0.2.EL' --define 'buildsmp 0' squashfs.spec
#  rpmbuild -ba --target x86_64 --define 'kernel 2.6.9-42.0.2.EL' --define 'buildsmp 0' squashfs.spec
#
#
# for the running kernel:
#
#  rpmbuild -ba --target i686   squashfs.spec
#  rpmbuild -ba --target x86_64 squashfs.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 squashfs
%define kmdl_name kernel-module-%{pkg_name}-%{kernel}

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

%define kernel_patch_version    2.6.10
# this is for 3.1-r2
%define squashfs_release        2           
%define squashfs_version        3.1

Summary:        A Read-Only File System with Efficient Compression
Name:           %{pkg_name}
Version:        %{squashfs_version}.%{squashfs_release}
Release:        1.sl4.psi
Epoch:          0
Packager:       Urs Beyerle <urs.beyerle@psi.ch>
License:        GPL
Group:          System Environment/Kernel
Source0:        %{name}%{squashfs_version}-r%{squashfs_release}.tar.gz
URL:            http://squashfs.sourceforge.net/
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
Squashfs is a compressed read-only filesystem for Linux. 
Squashfs is intended for general read-only filesystem use.
This package contains the userland utilities to create and read
squashfs images.

Kernel modules for squashfs 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 -n %{name}%{squashfs_version}-r%{squashfs_release}
# %patch

# turn patch into plain sources :-/
patch -f -p2 < linux-%{kernel_patch_version}/squashfs3.1-patch || true
mv linux squashfs/.
echo '#define CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE 3' >> squashfs/squashfs.h

%build

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

### build the squashfs-tools
make -C squashfs-tools \
        CFLAGS="-I. -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $RPM_OPT_FLAGS"

### prepare source
rm -rf obj
mkdir obj
cp -r squashfs obj
cd obj/squashfs
# point to right header files
sed -i 's|#include <linux/squashfs_fs.h>|#include "linux/squashfs_fs.h"|' *.c
sed -i 's|#include <linux/squashfs_fs_sb.h>|#include "linux/squashfs_fs_sb.h"|' *.c
sed -i 's|#include <linux/squashfs_fs_i.h>|#include "linux/squashfs_fs_i.h"|' *.c
sed -i 's|#include <linux/squashfs_fs.h>|#include "squashfs_fs.h"|' linux/*.h
sed -i 's|#include <linux/squashfs_fs_sb.h>|#include "squashfs_fs_sb.h"|' linux/*.h
sed -i 's|#include <linux/squashfs_fs_i.h>|#include "squashfs_fs_i.h"|' linux/*.h

export CONFIG_SQUASHFS=m
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=kernel/fs

### UP kernel module
make -C %{kernel_src_path} M=$PWD clean
rm -f *.o *.ko
make -C %{kernel_src_path} M=$PWD modules
mkdir -p $RPM_BUILD_ROOT/%{kernel_moduledir}/kernel/fs/squashfs
cp -a squashfs.ko $RPM_BUILD_ROOT/%{kernel_moduledir}/kernel/fs/squashfs/

### SMP kernel module
%if %{buildsmp}
make -C %{kernel_smp_src_path} M=$PWD clean
rm -f *.o *.ko
make -C %{kernel_smp_src_path} M=$PWD modules
mkdir -p $RPM_BUILD_ROOT/%{kernel_smp_moduledir}/kernel/fs/squashfs
cp -a squashfs.ko $RPM_BUILD_ROOT/%{kernel_smp_moduledir}/kernel/fs/squashfs/
%endif


%install
mkdir -p $RPM_BUILD_ROOT/usr/bin
cp -p squashfs-tools/*squashfs $RPM_BUILD_ROOT/usr/bin

%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 README README-3.1 PERFORMANCE.README COPYING CHANGES ACKNOWLEDGEMENTS INSTALL
/usr/bin/mksquashfs
/usr/bin/unsquashfs

%files -n %{kmdl_name}
%defattr(-,root,root,-)
%{kernel_moduledir}/kernel/fs/squashfs

%if %{buildsmp}
%files -n %{kmdl_name}smp
%defattr(-,root,root,-)
%{kernel_smp_moduledir}/kernel/fs/squashfs
%endif

%changelog
* Sun Oct 15 2006 Urs Beyerle <urs.beyerle@psi.ch>  3.1.r2-1.sl4.psi
- #include <linux/squash...> -> #include "squash..."
- #define CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE 3 (the default)
- no patching of do_mounts, so no initrd support
- build for RHEL kernel 2.6.9