|
# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
|
|
#
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
# Please add additional copyright information _after_ the line containing
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
|
|
#
|
|
# ROCK Linux: rock-src/package/base/linux/linux.conf
|
|
# ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version. A copy of the GNU General Public
|
|
# License can be found at Documentation/COPYING.
|
|
#
|
|
# Many people helped and are helping developing ROCK Linux. Please
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
|
|
# file for details.
|
|
#
|
|
# --- ROCK-COPYRIGHT-NOTE-END ---
|
|
|
|
pkg_linux_mode=image
|
|
pkg_linux_cross=""
|
|
|
|
case "$xpkg-" in
|
|
*-header-*)
|
|
pkg_linux_mode=header ;;
|
|
*-source-*)
|
|
unset splitdesc_dev
|
|
pkg_linux_mode=source ;;
|
|
esac
|
|
|
|
echo_status "Preparing to build a linux kernel $pkg_linux_mode package."
|
|
|
|
case "$xpkg" in
|
|
*-cross-*)
|
|
pkg_linux_cross="${xpkg#**-cross-}"
|
|
if [ $pkg_linux_mode = header ]; then
|
|
echo_status "Preparing to build a linux kernel $pkg_linux_cross cross-headers package."
|
|
else
|
|
echo_error "Building linux kernel cross packages isn't supported yet."
|
|
exit 1
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
|
|
treever=${xpkg/linux/}
|
|
treever=${treever/-*/}
|
|
|
|
[ "$vanilla_ver" ] || vanilla_ver="$ver"
|
|
srctar="linux-${vanilla_ver}.tar.bz2"
|
|
|
|
lx_extraversion=""
|
|
lx_kernelrelease=""
|
|
|
|
if [ -z "$pkg_linux_cross" ]
|
|
then
|
|
lx_cpu=$( echo "$arch_machine" | \
|
|
sed -e s/x86$/i386/ -e s/powerpc/ppc/ \
|
|
-e s/hppa/parisc/ -e s/i.86/i386/ \
|
|
-e s/sun4u/sparc64/ -e s/arm.*/arm/ \
|
|
-e s/sa110/arm/ -e s/s390x/s390/ \
|
|
-e s/parisc64/parisc/ )
|
|
|
|
if [ $arch = sparc -a "$ROCKCFG_SPARC_64BIT_KERNEL" = 1 ] ; then
|
|
lx_cpu=sparc64 ;
|
|
KCC=sparc64-unknown-linux-gnu-gcc
|
|
archprefix=sparc64-unknown-linux-gnu-
|
|
fi
|
|
else
|
|
lx_cpu=$( echo "$pkg_linux_cross" | \
|
|
sed -e s/x86$/i386/ -e s/powerpc/ppc/ \
|
|
-e s/hppa/parisc/ -e s/i.86/i386/ \
|
|
-e s/sun4u/sparc64/ -e s/arm.*/arm/ \
|
|
-e s/sa110/arm/ -e s/s390x/s390/ \
|
|
-e s/mips.*/mips/ -e s/parisc64/parisc/ )
|
|
fi
|
|
|
|
MAKE="$MAKE ARCH=$lx_cpu CROSS_COMPILE=$archprefix KCC=$KCC"
|
|
|
|
# correct the abolute path for patchfiles supplied in the .desc file
|
|
for x in $patchfiles ; do
|
|
if [ ! -e "$x" -a -n "${x##*/*}" ] ; then
|
|
var_remove patchfiles " " "$x"
|
|
var_append patchfiles " " "$archdir/$x"
|
|
fi
|
|
done
|
|
|
|
# add kernel specific patchfiles
|
|
for x in $confdir/linux$treever/*.patch; do
|
|
var_append patchfiles " " "$x"
|
|
done
|
|
|
|
# add hppa patch if needed
|
|
if [[ "$arch" == hppa && "$vanillaver" == 2.6* ]]; then
|
|
var_insert patchfiles " " "$archdir/patch-2.6.*-pa*.bz2"
|
|
fi
|
|
|
|
auto_config ()
|
|
{
|
|
if [ -f $base/architecture/$arch/kernel$treever.conf.sh ] ; then
|
|
echo " using: architecture/$arch/kernel$treever.conf.sh"
|
|
. $base/architecture/$arch/kernel$treever.conf.sh > .config
|
|
elif [ -f $base/architecture/$arch/kernel$treever.conf.m4 ] ; then
|
|
echo " using: architecture/$arch/kernel$treever.conf.m4"
|
|
m4 -I $base/architecture/$arch -I $base/architecture/share \
|
|
$base/architecture/$arch/kernel$treever.conf.m4 > .config
|
|
elif [ -f $base/architecture/$arch/kernel$treever.conf ] ; then
|
|
echo " using: architecture/$arch/kernel$treever.conf"
|
|
cp $base/architecture/$arch/kernel$treever.conf .config
|
|
elif [ -f $base/architecture/$arch/kernel.conf.sh ] ; then
|
|
echo " using: architecture/$arch/kernel.conf.sh"
|
|
. $base/architecture/$arch/kernel.conf.sh > .config
|
|
elif [ -f $base/architecture/$arch/kernel.conf.m4 ] ; then
|
|
echo " using: architecture/$arch/kernel.conf.m4"
|
|
m4 -I $base/architecture/$arch -I $base/architecture/share \
|
|
$base/architecture/$arch/kernel.conf.m4 > .config
|
|
elif [ -f $base/architecture/$arch/kernel.conf ] ; then
|
|
echo " using: architecture/$arch/kernel.conf"
|
|
cp $base/architecture/$arch/kernel.conf .config
|
|
else
|
|
echo " using: no rock kernel config found"
|
|
cp arch/$lx_cpu/defconfig .config
|
|
fi
|
|
|
|
echo " merging (system default): 'arch/$lx_cpu/defconfig'"
|
|
grep '^CONF.*=y' arch/$lx_cpu/defconfig | cut -f1 -d= | \
|
|
while read tag ; do egrep -q "(^| )$tag[= ]" .config || echo "$tag=y"
|
|
done >> .config ; cp .config .config.1
|
|
|
|
# all modules needs to be first so modules can be disabled by i.e.
|
|
# the targets later
|
|
echo "Enabling all modules ..."
|
|
yes '' | eval $MAKE no2modconfig > /dev/null ; cp .config .config.2
|
|
|
|
if [ -f $base/target/$target/kernel$treever.conf.sh ] ; then
|
|
confscripts="$base/target/$target/kernel$treever.conf.sh $confscripts"
|
|
elif [ -f $base/target/$target/kernel.conf.sh ] ; then
|
|
confscripts="$base/target/$target/kernel.conf.sh $confscripts"
|
|
fi
|
|
|
|
for x in $confscripts ; do
|
|
echo " running: $x"
|
|
. $x .config
|
|
done
|
|
cp .config .config.3
|
|
|
|
# merge various text/plain config files
|
|
for x in $base/config/$config/linux.cfg \
|
|
$base/target/$target/kernel.conf \
|
|
$base/target/$target/kernel$treever.conf ; do
|
|
if [ -f $x ] ; then
|
|
echo " merging: '$x'"
|
|
tag="$(sed '/CONFIG_/ ! d; s,.*CONFIG_\([^ =]*\).*,\1,' \
|
|
$x | tr '\n' '|')"
|
|
egrep -v "\bCONFIG_($tag)\b" < .config > .config.4
|
|
sed 's,\(CONFIG_.*\)=n,# \1 is not set,' \
|
|
$x >> .config.4
|
|
cp .config.4 .config
|
|
fi
|
|
done
|
|
|
|
# create a valid .config
|
|
yes '' | eval $MAKE oldconfig > /dev/null ; cp .config .config.5
|
|
|
|
# last disable broken stuff
|
|
rm -f /tmp/$$.sed
|
|
list="CONFIG_THIS_DOES_NOT_EXIST"
|
|
for x in $pkg_linux_brokenfiles ; do
|
|
if [ -f "$x" ] ; then
|
|
echo "Disable broken file: $x"
|
|
list="$list `tr ' ' '\t' < $x | cut -f1 | grep '^CONFIG_'`"
|
|
fi
|
|
done
|
|
for x in $list ; do
|
|
echo "s,^$x=.\$,# $x is not set,;" >> /tmp/$$.sed
|
|
done
|
|
|
|
sed -f /tmp/$$.sed < .config > .config.6
|
|
cp .config.6 .config ; rm -f /tmp/$$.sed
|
|
|
|
# create a valid .config (dependencies might need to be disabled)
|
|
yes '' | eval $MAKE oldconfig > /dev/null
|
|
|
|
# save final config
|
|
cp .config .config_modules
|
|
|
|
echo "Creating config without modules ...."
|
|
sed "s,\(CONFIG_.*\)=m,# \1 is not set," .config > .config_new
|
|
mv .config_new .config
|
|
# create a valid .config (dependencies might need to be disabled)
|
|
yes '' | eval $MAKE oldconfig > /dev/null
|
|
mv .config .config_nomods
|
|
|
|
# which .config to use?
|
|
if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = "modules" ] ; then
|
|
cp .config_modules .config
|
|
else
|
|
cp .config_nomods .config
|
|
fi
|
|
}
|
|
|
|
lx_grabextraversion () {
|
|
local ev
|
|
ev=$( sed -n -e 's,^[ \t]*EXTRAVERSION[ \t]*=[ \t]*\([^ \t]*\),\1,p' Makefile | tail -n 1 )
|
|
if [ "$ev" ]; then
|
|
lx_extraversion="${lx_extraversion}$ev"
|
|
# keep intact but commented since the second EXTRAVERSION
|
|
# definition, and clean the first.
|
|
sed -e 's,^\([ \t]*EXTRAVERSION[ \t]*=.*\),#\1,g' \
|
|
-e 's,^#\(EXTRAVERSION =\).*,\1,' \
|
|
Makefile > Makefile.new
|
|
mv Makefile.new Makefile
|
|
fi
|
|
}
|
|
|
|
lx_injectextraversion () {
|
|
lx_extraversion="${lx_extraversion}-rock"
|
|
|
|
# inject final EXTRAVERSION into Makefile
|
|
sed -i -e "s,^\([ \t]*EXTRAVERSION[ \t]*\)=.*,\1= ${lx_extraversion},g" Makefile
|
|
|
|
# update version.h - we only do this, because some other freaky
|
|
# projects like rsbac change EXTRAVERSION in other Makefiles ...
|
|
rerun=""; eval $MAKE include/linux/version.h | grep -q "is up to date" && rerun=1
|
|
if [ "$rerun" ] ; then
|
|
echo "WARNING: Your system's timer resolution is too low ..."
|
|
sleep 1 ; touch Makefile
|
|
eval $MAKE include/linux/version.h
|
|
fi
|
|
|
|
# get kernel_release
|
|
lx_kernelrelease="$( echo -e "#include <linux/version.h>\nUTS_RELEASE" \
|
|
> conftest.c && \
|
|
gcc -E -I./include conftest.c | tail -n 1 \
|
|
| cut -d '"' -f 2 && rm -f conftest.c )"
|
|
}
|
|
|
|
lx_config ()
|
|
{
|
|
echo "Generic linux source patching and configuration ..."
|
|
|
|
# grab extraversion from vanilla
|
|
lx_grabextraversion
|
|
|
|
hook_eval prepatch
|
|
apply_patchfiles "lx_grabextraversion"
|
|
hook_eval postpatch
|
|
|
|
echo "Redefining some VERSION flags ..."
|
|
lx_injectextraversion
|
|
|
|
if [[ $treever = 24* ]] ; then
|
|
echo "Create symlinks and a few headers for <$lx_cpu> ... "
|
|
eval $MAKE symlinks
|
|
cp $confdir/autoconf.h include/linux/
|
|
touch include/linux/modversions.h
|
|
fi
|
|
|
|
if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
|
|
echo "Using \$base/config/\$config.$swpid/linux.cfg."
|
|
echo "Since automatic generation is disabled ..."
|
|
cp -v $base/config/$config.$swpid/linux.cfg .config
|
|
else
|
|
echo "Automatically creating default configuration ...."
|
|
auto_config
|
|
fi
|
|
|
|
echo "... configuration finished!"
|
|
|
|
if [[ $treever != 24* ]] ; then
|
|
echo "Create symlinks and a few headers for <$lx_cpu> ... "
|
|
eval $MAKE include/asm
|
|
yes '' | eval $MAKE oldconfig > /dev/null
|
|
fi
|
|
|
|
echo "Clean up the *.orig and *~ files ... "
|
|
rm -f .config.old `find -name '*.orig' -o -name '*~'`
|
|
|
|
echo "Generic linux source configuration finished."
|
|
}
|
|
|
|
pkg_linux_brokenfiles="$base/architecture/$arch/kernel-disable.lst \
|
|
$base/architecture/$arch/kernel$treever-disable.lst \
|
|
$confdir/linux$treever/disable-broken.lst $pkg_linux_brokenfiles"
|
|
|
|
main_lx_src() {
|
|
echo "Extracting the Linux Kernel Sources [$vanilla_ver] ... "
|
|
tar $taropt $archdir/$srctar
|
|
cd linux-$vanilla_ver
|
|
|
|
echo "Correcting user and permissions ..."
|
|
chown -R root:root . ; chmod -R u=rwX,go=rX .
|
|
|
|
echo "Configuring kernel source ..."
|
|
lx_config
|
|
|
|
echo "Copying to $root/usr/src/linux-${lx_kernelrelease} ..."
|
|
cd $root/usr/src
|
|
rm -rf linux-${lx_kernelrelease}
|
|
cp -r $builddir/linux-$vanilla_ver linux-${lx_kernelrelease}
|
|
|
|
if [ "${xpkg%-source}" = "$ROCKCFG_PKG_LINUX_HEADERS" ] ; then
|
|
rm -f linux
|
|
ln -svf linux-${lx_kernelrelease} $root/usr/src/linux
|
|
fi
|
|
|
|
echo "Copying kernel patches ... "
|
|
rm -rf linux$treever-patches ; mkdir -p linux$treever-patches
|
|
echo "This directory contains all the stuff used by ROCK Linux" > linux$treever-patches/README
|
|
echo "to build the Kernel (in addition to the official Kernel Sources)." >> linux$treever-patches/README
|
|
cp -v $patchfiles linux$treever-patches/
|
|
|
|
cd linux-${lx_kernelrelease}
|
|
|
|
if [ "$ROCKCFG_PKG_LINUX_CONFIG_STYLE" = none ] ; then
|
|
# create a valid .config (new settings may be available etc.)
|
|
yes '' | eval $MAKE oldconfig > /dev/null
|
|
else
|
|
cp -v .config_nomods ../linux$treever-patches/config_nomods.txt
|
|
cp -v .config_modules ../linux$treever-patches/config_modules.txt
|
|
fi
|
|
|
|
# can fail in stage 0-1 ...
|
|
if [ $stagelevel -gt 1 ] && [[ $treever = 24* ]] ; then
|
|
echo "Creating dependencies (e.g. for versioned symbols) ..."
|
|
eval $MAKE dep-files
|
|
fi
|
|
if [ $stagelevel -gt 1 ] && [[ $treever = 26* ]] ; then
|
|
echo "Creating scripts/* because external modules need it ..."
|
|
eval $MAKE scripts/
|
|
fi
|
|
|
|
echo "Clean up the *.orig and *~ files ... "
|
|
find -name '*.orig' -o -name '*~' | xargs rm -f
|
|
rm -f .config.old .config.[1-9]
|
|
}
|
|
|
|
main_lx_header() {
|
|
echo "Extracting the Linux Kernel Sources [$ver] ... "
|
|
tar $taropt $archdir/$srctar
|
|
cd linux-$vanilla_ver
|
|
|
|
# patch and configure
|
|
lx_config
|
|
|
|
if [ -z "$pkg_linux_cross" ]; then
|
|
incdir="$root/$prefix/include/"
|
|
else
|
|
incdir="$root/$prefix/$pkg_linux_cross-unknown-linux-gnu/include"
|
|
fi
|
|
|
|
# install the header files - and do some post-processing for sparc
|
|
rm -rf $incdir/{asm,asm-generic,linux,asm-sparc,asm-sparc64}
|
|
mkdir -p $incdir
|
|
if [ "$lx_cpu" != sparc -a "$lx_cpu" != sparc64 ]
|
|
then
|
|
mkdir -p $incdir/asm
|
|
cp -rv include/asm/* $incdir/asm/
|
|
cp -rv include/{asm-generic,linux} $incdir/
|
|
else
|
|
# we can only generate this files when we have a cross compiler
|
|
# which is stage 1 and above ...
|
|
if [ $stagelevel -gt 0 -a $treever != 26 ] ; then
|
|
# build two generated headers first ...
|
|
make ARCH=sparc CROSS_COMPILE=$archprefix KCC=$KCC \
|
|
arch/sparc/kernel/Makefile check_asm
|
|
[ $lx_cpu = sparc64 ] && \
|
|
make ARCH=sparc64 CROSS_COMPILE=$archprefix KCC=sparc64-unknown-linux-gnu-gcc \
|
|
arch/sparc64/kernel/Makefile check_asm
|
|
fi
|
|
|
|
cp -rv include/{asm-{sparc{,64},generic},linux} $incdir/
|
|
cp -v $confdir/generate-asm . ; chmod +x ./generate-asm
|
|
./generate-asm $incdir
|
|
fi
|
|
}
|
|
|
|
main_lx() {
|
|
lx_config
|
|
|
|
# we need to rerun the oldconfig since the used .config
|
|
# might not match the one used in the last oldconfig run
|
|
# (e.g. the nomods is run last - and normally the module
|
|
# one is used)
|
|
yes '' | eval $MAKE oldconfig > /dev/null
|
|
|
|
if [[ $treever = 24* ]] ; then
|
|
echo "Creating dependencies ..."
|
|
eval $MAKE -j 1 dep
|
|
fi
|
|
|
|
echo "Cleanup kernel ..."
|
|
eval $MAKE -j 1 clean > /dev/null
|
|
|
|
echo "Building the kernel ..."
|
|
[ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ] && default=1
|
|
case "$lx_cpu" in
|
|
i386)
|
|
eval $MAKE bzImage
|
|
cp -vf arch/i386/boot/bzImage $root/boot/vmlinuz_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
cp -vf arch/i386/boot/bzImage $root/boot/vmlinuz
|
|
;;
|
|
x86_64)
|
|
eval $MAKE bzImage
|
|
cp -vf arch/x86_64/boot/bzImage $root/boot/vmlinuz_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
cp -vf arch/x86_64/boot/bzImage $root/boot/vmlinuz
|
|
;;
|
|
alpha)
|
|
eval $MAKE vmlinux
|
|
gzip < vmlinux > $root/boot/vmlinux_${lx_kernelrelease}.gz
|
|
[ "$default" ] && \
|
|
cp -vf $root/boot/vmlinux_$ver-rock.gz $root/boot/vmlinux.gz
|
|
;;
|
|
mips)
|
|
eval $MAKE vmlinux
|
|
$BUILDCC arch/mips/boot/elf2ecoff.c -o elf2ecoff
|
|
./elf2ecoff vmlinux vmlinux.ecoff
|
|
cp -vf vmlinux.ecoff $root/boot/vmlinux_${lx_kernelrelease}.ecoff
|
|
[ "$default" ] && \
|
|
cp -vf vmlinux.ecoff $root/boot/
|
|
;;
|
|
ppc)
|
|
eval $MAKE vmlinux
|
|
cp -vf vmlinux $root/boot/vmlinux_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
cp -vf vmlinux $root/boot/vmlinux
|
|
eval $MAKE zImage
|
|
for x in arch/ppc/boot/images/zImage.* ; do
|
|
cp -v $x $root/boot/${x/arch\/ppc\/boot\/images\//}-$ver
|
|
done
|
|
;;
|
|
sparc)
|
|
if [ "$treever" = 24 ] ; then
|
|
eval $MAKE vmlinux
|
|
else
|
|
eval $MAKE image
|
|
fi
|
|
|
|
cp -vf vmlinux $root/boot/vmlinux32_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
gzip -9 < vmlinux > $root/boot/vmlinux32.gz
|
|
;;
|
|
sparc64)
|
|
eval $MAKE vmlinux
|
|
cp -vf vmlinux $root/boot/vmlinux64_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
gzip -9 < vmlinux > $root/boot/vmlinux64.gz
|
|
;;
|
|
um)
|
|
eval $MAKE linux
|
|
cp -vf linux $root/boot/linux_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
cp -vf linux $root/boot/linux
|
|
;;
|
|
*)
|
|
eval $MAKE vmlinux
|
|
cp -vf vmlinux $root/boot/vmlinux_${lx_kernelrelease}
|
|
[ "$default" ] && \
|
|
cp -vf vmlinux $root/boot/vmlinux
|
|
;;
|
|
esac
|
|
cp -vf .config $root/boot/kconfig_${lx_kernelrelease}
|
|
cp -vf System.map $root/boot/System.map_${lx_kernelrelease}
|
|
[ "$default" ] && cp -vf System.map $root/boot/System.map
|
|
|
|
echo "Building the modules ..."
|
|
eval $MAKE modules
|
|
echo "Installing the modules ..."
|
|
if [ $stagelevel -le 1 ] ; then
|
|
eval $MAKE modules_install \
|
|
INSTALL_MOD_PATH=$root DEPMOD=/bin/true
|
|
else
|
|
eval $MAKE modules_install DEPMOD=/bin/true
|
|
echo "Running 'depmod -a -q -F /boot/System.map ${lx_kernelrelease}' .."
|
|
depmod -a -q -F /boot/System.map_${lx_kernelrelease} ${lx_kernelrelease}
|
|
for x in /lib/modules/${lx_kernelrelease}/modules.*
|
|
do [ -f $x ] && add_flist $x; done
|
|
fi
|
|
|
|
# fix /lib/modules/${ver}/build symlink
|
|
rm -f $root/lib/modules/${lx_kernelrelease}/build
|
|
ln -sf ../../../usr/src/linux-${lx_kernelrelease} \
|
|
$root/lib/modules/${lx_kernelrelease}/build
|
|
|
|
if [ "$default" ] ; then
|
|
cp $confdir/mkinitrd.sh $root/sbin/mkinitrd
|
|
chmod +x $root/sbin/mkinitrd
|
|
|
|
if [ -z "$root" ]; then
|
|
mkinitrd empty ${lx_kernelrelease}
|
|
rm -f /boot/initrd.img
|
|
ln -s initrd-${lx_kernelrelease}.img /boot/initrd.img
|
|
fi
|
|
fi
|
|
}
|
|
|
|
case "$pkg_linux_mode" in
|
|
source)
|
|
autoextract=0
|
|
createdocs=0
|
|
custmain="main_lx_src"
|
|
;;
|
|
header)
|
|
autoextract=0
|
|
createdocs=0
|
|
custmain="main_lx_header"
|
|
;;
|
|
image)
|
|
custmain="main_lx"
|
|
autopatch=0
|
|
;;
|
|
esac
|
|
|