#========================================== # $Id: kernel-macros,v 1.7 2005/07/14 16:55:50 mouse Exp $ #========================================== %kgcc gcc-2.96 %kgcc_package gcc2.96 %patches %_usrsrc/kernel/patches %patches_dir %buildroot%patches %kernel_src %_usrsrc/kernel/sources %kernel_srcdir %buildroot%kernel_src %base_arch %(echo %_target_cpu | sed 's/^\\(i.86\\|pentium4\\|athlon\\|k6\\)$/i386/') %_patch_list %nil %set_patch_list() %global _patch_list %* %add_patch_list() %global _patch_list %_patch_list %* %get_patch_list() %_patch_list %format_patch_list %(rpmquery --queryformat '\\n\\t%%{NAME}-%%{VERSION}-%%{RELEASE}' %get_patch_list) %_src_list %nil %source() \ Source%1: %2 \ %global _src_list %_src_list %{?3:%3/}%(f="%2"; printf "%s" "${f##*/}") \ %nil %__touch /bin/touch # Standard way for applying patches %apply_patches() \ function in_the_patch_list() \ { \ for p in %_patch_list ; do \ [ $p = $1 ] && return 0 \ done \ return 1 \ } \ function apply_patchset() \ { \ echo -e "----- Applying patchset $1 ------" \ [ -f patches/APPLIED_$1 ] && echo "Already applied, ignoring... $1" && return 0 \ if [ -f "%patches/apply/$1" ] ; then \ echo "Call %patches/apply/$1" \ /bin/sh %patches/apply/$1 %patches $1 %kversion $2 || return 1 \ else \ apply_recursive %patches/$1 %kversion $2 || return 1 \ fi \ %__touch ./patches/APPLIED_$1 \ } \ function apply_recursive() \ { \ local patchset \ local i \ for i in `ls -1 $1` ; do \ [ -s $1/$i ] || continue \ if [ -f $1/dont_apply_to_${2}_$i ] ; then \ echo "Denied for the kernel version $2 ..." \ continue \ fi \ if [ -d $1/$i ] ; then \ patchset="${i##??_}" \ if [ "$patchset" = "common" ] ; then \ echo "Applying common patches ..." \ apply_recursive "$1/$i" "$2" "$3" || return 1 \ continue \ fi \ if [ "$patchset" = "$3" ] ; then \ echo "Applying only for the label $3" \ apply_recursive "$1/$i" "$2" "$3" || return 1 \ continue \ fi \ if [ -z "${patchset##apply_to_*}" ] ; then \ if [ "$patchset" = "apply_to_$2" ] ; then \ echo "Applying only for the kernel version $2 ..." \ apply_recursive "$1/$i" "$2" "$3" || return 1 \ fi \ continue \ fi \ if [ -z "${patchset##not_*}" ] ; then \ patchset="${patchset##not_}" \ if in_the_patch_list $patchset ; then \ echo "Skipping patches incompatible with $patchset" \ else \ echo "Applying patches for kernels without $patchset" \ apply_recursive "$1/$i" "$2" "$3" || return 1 \ fi \ continue \ fi \ if in_the_patch_list $patchset ; then \ apply_patchset $patchset "$3" || return 1 \ if [ -f patches/APPLIED_$patchset ] ; then \ apply_recursive "$1/$i" "$2" "$3" || return 1; \ fi \ fi \ continue \ fi \ echo "Applying patch $i ..." \ %__cat $1/$i | patch -p1 -b || return 1 \ done \ } \ set +x \ [ -d './patches' ] || %__mkdir './patches' \ for f in %_patch_list ; do \ apply_patchset $f %1 || exit 1 \ done \ %nil # Standard way for installing patches %install_patches \ %__mkdir_p %patches_dir/%patch_name \ for i in %_src_list ; do \ %__install -p -D -m644 %_sourcedir/"${i##*/}" %patches_dir/%patch_name/"$i" \ done \ %nil # Standard %%post script for kernel-image-* packages %post_kernel_image /sbin/installkernel # Standard %%preun script for kernel-image-* packages %preun_kernel_image /sbin/modprobe loop > /dev/null 2>&1 ||: \ /sbin/installkernel --remove # Standard %%post script for kernel-headers-* packages %post_kernel_headers [ -x %_sbindir/adjust_kernel_headers ] && %_sbindir/adjust_kernel_headers ||: # Standard %%postun script for kernel-headers-* packages %postun_kernel_headers [ -x %_sbindir/adjust_kernel_headers ] && %_sbindir/adjust_kernel_headers ||: # Standard %%post script for kernel-modules-* packages %post_kernel_modules() [ -n "$DURING_INSTALL" ] || \ /sbin/depmod -a -F /boot/System.map-%1 %1 \ %nil # Standard %%postun script for kernel-modules-* packages %postun_kernel_modules() [ -n "$DURING_INSTALL" ] || \ [ ! -f /boot/System.map-%1 ] || \ /sbin/depmod -a -F /boot/System.map-%1 %1 \ %nil # Kernel per-arch configuration %_kernel_config_offset 10000 %_kernel_arches %nil %set_kernel_arches() %global _kernel_arches %* \ %( \ echo "ExclusiveArch: %*" \ n=%_kernel_config_offset \ for arch in %_kernel_arches; do \ echo "Source$n: config-%kernel_base_version-%flavour.$arch" \ n=$(($n+1)) \ done \ ) %get_kernel_config() %{expand:%%SOURCE%( \ n=%_kernel_config_offset \ for arch in %_kernel_arches; do \ if [ "$arch" = "%1" ]; then \ echo $n \ exit \ fi \ n=$((n+1)) \ done \ echo "__No_such_architecture__%{1}" \ )} #========================================== #local variables: #mode: rpm-spec #fill-column: 80 #end: