#! /bin/sh # grab_patch_kernel: # download and patch/merge a given kernel version # do_patchdir: # patch the package: # Apply all of patchdir/ (in alpha/numeric order) to the package. # User must make sure that the patches are numbered/sorted in the # required order. do_patchdir() { kernel_id="$1" src_dir="$2" patchdir="$3" cd $src_dir for patchfile in $patchdir/* ; do echo "Applying patch: $patchfile..." if [ ${patchfile%.gz} != $patchfile ]; then cat_cmd="zcat" elif [ ${patchfile%.bz2} != $patchfile ]; then cat_cmd="bzcat" else cat_cmd="cat" fi if [ -f $patchfile ]; then $cat_cmd $patchfile | patch -p1 sts=$? elif [ -f $patchdir/$patchfile ]; then $cat_cmd $patchdir/$patchfile | patch -p1 sts=$? else echo "Error: did not find patch: $patchfile" return -5 fi if [ $sts -ne 0 ]; then echo "Error: patch $patchfile failed." return -10 fi done return 0 } . run_profile.txt . $base_dir/plans/commands/common.fns [ -f /etc/crucible.cfg ] && source /etc/crucible.cfg [ -f $ETC_DIR/global.cfg ] && source $ETC_DIR/global.cfg if [ "$SRC_DIR" == "" ]; then SRC_DIR="/usr/local/src" fi kernel_info # gives kernel_id, kernel_label SUT=`hostname -s` out_dir=$run_dir/logs/$SUT [ -d $out_dir ] || mkdir -p $out_dir sut_type=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/arm.*/arm/ \ -e s/s390.*/s390/ -e s/sa110/arm/ -e s/ppc64/powerpc/ -e s/parisc64/parisc/` if [ -e "$all_suts_dir/$SUT/profile.txt" ]; then sut_type=`grep ^sut_type= $all_suts_dir/$SUT/profile.txt | cut -d '=' -f 2` fi karch=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc/ -e s/arm.*/arm/ \ -e s/s390.*/s390/ -e s/sa110/arm/ -e s/ppc64/powerpc/ -e s/parisc64/parisc/` pwd=`/bin/pwd` src_dir="$SRC_DIR/linux-$kernel_id" # clear out src_dir for no collisions echo "clear out: $src_dir" [ -d $src_dir ] && rm -rf $src_dir # use "$ETC_DIR/grab-kernel.rc" file and run 'grab-kernel $version $SRC_DIR' echo "now run: grab_kernel '$kernel_id' '$SRC_DIR'" grab_kernel "$kernel_id" "$SRC_DIR" if [ "$patchdir" != "" ]; then do_patchdir "$kernel_id" "$src_dir" "$patchdir" sts=$? if [ $sts -ne 0 ]; then echo "applying patchdir failed" exit 99 else echo "applying patchdir done" fi else echo "no patchdir to apply" fi cd $pwd