|
|
#!/bin/bash # --- 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 - 2006 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=""
# do not replicate docs createdocs=0
forcefpic=0
prefix=usr set_confopt
case "$xpkg-" in *-source-*) unset splitdesc_dev pkg_linux_mode=source ;; *-src-*) abort "If you want to build a source package, use '${xpkg//src/source}'.";; *-headers-cross-*) pkg_linux_mode=headers pkg_linux_cross="${xpkg#*-cross-}" echo_status "Preparing to build a cross-binutils package for $pkg_binutils_cross." prefix="$prefix/${pkg_linux_cross}-unknown-linux-gnu" set_confopt ;; *-headers-*) pkg_linux_mode=headers ;; esac
echo_status "Preparing to build a linux kernel $pkg_linux_mode package."
treever=${xpkg/linux/} treever=${treever/-*/}
vanilla_ver="$ver" # vanilla_ver=$( echo ${vanilla_ver} | cut -d. -f-3 ) 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/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/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 () { case "$arch" in powerpc) defconfig="configs/common_defconfig" ;; *) defconfig="defconfig" ;; esac
for x in $base/architecture/$arch/kernel{$treever,}.conf{.sh,.m4,} \ arch/$lx_cpu/$defconfig do if [ -f $x ] ; then echo " using: $x" case "${x##*.}" in m4) m4 -I $base/architecture/$arch \ -I $base/architecture/share \ $x > .config ;; sh) . $x > .config ;; *) cp $x .config ;; esac break fi done
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
for x in $base/target/$target/kernel{$treever,}.conf.sh ; do if [ -f $x ] ; then confscripts="$x $confscripts" break fi done
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{,$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 }
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/linux.cfg." echo "Since automatic generation is disabled ..." cp -v $base/config/$config/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
# get kernel_release if [ $treever == 24 ] ; then 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 )" else make include/config/kernel.release lx_kernelrelease="$( < include/config/kernel.release )" fi
lx_cleanup
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"
lx_source() { echo "Extracting the Linux Kernel Sources [$vanilla_ver] ... " tar $taropt $archdir/$srctar cd linux-$vanilla_ver
# if [ -e $archdir/patch-${ver}.bz2 ] ; then # echo "Patching up to $ver ..." # bzcat $archdir/patch-${ver}.bz2 | patch $patchopt # fi
echo "Correcting ownership and permissions ..." chown -R 0:0 . ; chmod -R u=rwX,go=rX . }
lx_cleanup() { echo "Clean up the *.orig and *~ files ... " find -name '*.orig' -o -name '*~' | xargs rm -f rm -f .config.old .config.[1-9] }
main_lx_src() { lx_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_DEFAULT" ] ; 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 to" echo "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-2 ... if [ $stagelevel -ge 3 ] && [[ $treever = 24* ]] ; then echo "Creating dependencies (e.g. for versioned symbols) ..." eval $MAKE dep-files fi if [ $stagelevel -ge 3 ] && [[ $treever = 26* ]] ; then echo "Creating scripts/* because external modules need it ..." eval $MAKE scripts/ fi lx_cleanup }
main_lx() { lx_source 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 ..." case "$lx_cpu" in i386|x86_64) eval $MAKE bzImage cp -vf arch/$lx_cpu/boot/bzImage $root/boot/vmlinuz_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinuz_${lx_kernelrelease} $root/boot/vmlinuz fi ;; alpha) eval $MAKE vmlinux gzip < vmlinux > $root/boot/vmlinux_${lx_kernelrelease}.gz if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinuz_${lx_kernelrelease}.gz $root/boot/vmlinuz.gz fi ;; arm) eval $MAKE zImage cp -vf arch/arm/boot/zImage $root/boot/zImage_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf zImage_${lx_kernelrelease} $root/boot/zImage fi ;; 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 if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinux_${lx_kernelrelease}.ecoff $root/boot/vmlinux.ecoff fi ;; ppc) eval $MAKE vmlinux cp -vf vmlinux $root/boot/vmlinux_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinux_${lx_kernelrelease} $root/boot/vmlinux fi eval $MAKE zImage for x in arch/ppc/boot/images/zImage.* ; do y=$( echo $x | sed 's,.*/zImage\.,,'; ) cp -v $x $root/boot/zImage_${lx_kernelrelease}.$y if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf zImage_${lx_kernelrelease}.$y $root/boot/zImage.$y fi done ;; sparc) # sparc doesn't seem to support gzipped kernel images if [ "$treever" = 24 ] ; then eval $MAKE vmlinux cp -a vmlinux $root/boot/vmlinux32_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinux32_${lx_kernelrelease} $root/boot/vmlinux32 fi else eval $MAKE image cp -a arch/sparc/boot/image $root/boot/image_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf image_${lx_kernelrelease} $root/boot/image fi fi ;; sparc64) eval $MAKE vmlinux gzip -9 < vmlinux > $root/boot/vmlinux64_${lx_kernelrelease}.gz if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinux64_${lx_kernelrelease}.gz $root/boot/vmlinux64.gz fi ;; um) eval $MAKE linux cp -vf linux $root/boot/linux_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf linux_${lx_kernelrelease} $root/boot/linux fi ;; *) eval $MAKE vmlinux cp -vf vmlinux $root/boot/vmlinux_${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf vmlinux_${lx_kernelrelease} $root/boot/vmlinux fi ;; esac cp -vf .config $root/boot/kconfig_${lx_kernelrelease} cp -vf System.map $root/boot/System.map-${lx_kernelrelease} if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf System.map-${lx_kernelrelease} $root/boot/System.map fi
# only build modules if enabled in the kernel config, # otherwise a build error will occur if [ "`egrep "^CONFIG_MODULES=[ym]" .config`" ] ; then echo "Building the modules ..." eval $MAKE modules echo "Installing the modules ..." if [ $stagelevel -le 2 ] ; then eval $MAKE modules_install \ INSTALL_MOD_PATH=$root DEPMOD=/bin/true else eval $MAKE modules_install DEPMOD=/bin/true fi echo "Running 'depmod -a -F ${root}/boot/System.map -b ${root:-/} ${lx_kernelrelease}' .." depmod -a -F ${root}/boot/System.map-${lx_kernelrelease} \ -b ${root:-/} ${lx_kernelrelease} for x in ${root}/lib/modules/${lx_kernelrelease}/modules.* do [ -f $x ] && add_flist $x; done else echo "No module support configured for this kernel ..." mkdir -p $root/lib/modules/${lx_kernelrelease} fi
# fix /lib/modules/${ver}/{build,source} symlinks rm -f $root/lib/modules/${lx_kernelrelease}/build rm -f $root/lib/modules/${lx_kernelrelease}/source ln -sf ../../../usr/src/linux-${lx_kernelrelease} \ $root/lib/modules/${lx_kernelrelease}/build ln -sf ../../../usr/src/linux-${lx_kernelrelease} \ $root/lib/modules/${lx_kernelrelease}/source
# just create a symlink to the default initrd image here; the file # pointed to will be created by the rockinitrd postinstall script if [ "$xpkg" = "$ROCKCFG_PKG_LINUX_DEFAULT" ]; then ln -svf initrd-${lx_kernelrelease}.img $root/boot/initrd.img fi }
main_lx_headers() { lx_source
$MAKE mrproper $MAKE headers_check $MAKE INSTALL_HDR_PATH=dest headers_install
for x in $confdir/linux26-hdrs/*.patch; do [ -f $x ] || continue echo "Applying linux userspace headers patch $x.." ( cd dest/include && patch -p1 --no-backup-if-mismatch < $x; ) done
mkdir -p $CLFS/$prefix/include rm -rf dest/include/scsi cp -rv dest/include/* $CLFS/$prefix/include }
autoextract=0 case "$pkg_linux_mode" in source) createdocs=0 custmain="main_lx_src" ;; image) custmain="main_lx" ;; headers) custmain="main_lx_headers" ;; esac
# ignore pseudo-deps to other modules var_append flistrfilter "|" ".*lib/modules/.*/.*"
|