File: [Development] / xfs-cmds / xfsmisc / Attic / update_26_xfs (download)
Revision 1.1, Fri Oct 13 17:25:28 2006 UTC (11 years ago) by tes.longdrop.melbourne.sgi.com
Branch: MAIN
Script used to update 2.6.x-xfs with a newer 2.6 kernel and kdb versions
Merge of master-melb:xfs-cmds:27193a by kenmcd.
Script used to update 2.6.x-xfs with a newer 2.6 kernel and kdb versions
|
#!/bin/sh
#
# Update the 2.6 ism workarea with a 2.6 kernel src tree
# ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.gz 50Mb
#
# NEED to update kernel_version and kdb prefixes/suffixes
#
tmp=/tmp/$$
here=`pwd`
prog=`basename $0`
status=1
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
kernel_version=2.6.18
kdb_prefix="kdb-v4.4-${kernel_version}-"
kdb_suffix="-2.bz2"
kdb_glob="${kdb_prefix}{i386,ia64,common,x86_64}${kdb_suffix}"
kdb_ftp_host=oss.sgi.com
kdb_ftp_dir=/projects/kdb/download/latest
patches="split-patches"
tmp_linux_dir=/tmp/$USER.linux_src.$$
cat <<EOF >$tmp.skip
xfs
dmapi
patches
split-patches
*.out.$USER
\.pc
final.*
\.modheader
\.workarea
\.census
census
census,v
*\.prj
*\.prcs_aux
EOF
_usage()
{
cat << EOF
Usage: $prog workarea mainline-2.6
workarea ptools 2.6.x-xfs workarea
mainline-2.6 fresh 2.6 mainline src tree or
.tar or .tar.gz or .tar.bz2 file
(won't delete this tree on exit)
EOF
exit 1
}
_kdb_all_there()
{
for file in ${kdb_prefix}{i386,ia64,common,x86_64}${kdb_suffix}
do
[ ! -e $file ] && return 1
done
return 0
}
_fixup_new_kdb_patches()
{
cd $ism/$patches
if _kdb_all_there
then
echo "All kdb patches already present in 2.6 workarea"
p_state `p_list -c`
return
fi
set -x
echo kdb* >/dev/null && p_delete kdb*
ftp -aiv "$kdb_ftp_host:$kdb_ftp_dir/$kdb_glob"
echo kdb* >/dev/null && p_fetal -kb kdb*
p_state `p_list -c`
set -
}
# apply to current 2.6 mainline tree
_apply_custom_patches()
{
cd $kernel_src
if [ -d kdb ]
then
echo "kdb subdir exists assuming kernel already patched"
else
echo "apply kdb patches..."
for p in $ism/$patches/${kdb_prefix}{i386,ia64,common,x86_64}${kdb_suffix}
do
bzcat $p | patch -p1
done
fi
if grep -iq dmapi MAINTAINERS
then
echo "DMAPI in MAINTAINERS assuming dmapi patch already applied"
else
echo "apply dmapi patches using quilt (in case of failure)..."
mkdir $kernel_src/patches
cd $kernel_src
quilt import $ism/$patches/dmapi-enable
quilt push
fi
}
_new_files()
{
lsdiff -s $1 | grep '^+' | cut -c3-
}
_deleted_files()
{
lsdiff -s $1 | grep '^-' | cut -c3-
}
_modified_files()
{
lsdiff -s $1 | grep '^!' | cut -c3-
}
_process_args()
{
[ $# -ne 2 ] && _usage
# process ism/workarea argument
ism=$1
if [ ! -d $ism ]
then
echo "$prog: $ism is not a directory"
_usage
fi
if [ ! -s $ism/.workarea ]
then
echo "$prog: can't find $ism/.workarea"
_usage
fi
# process linux kernel source argument
kernel_src=$2
if [ ! -e $kernel_src ]
then
echo "$prog: $kerenel_src does not exist"
_usage
fi
# extra handling for kernel src archives
if [ ! -d $kernel_src ]
then
echo "Making $tmp_linux_dir (will leave behind)"
mkdir $tmp_linux_dir
cd $tmp_linux_dir
echo "$prog: $kerenel_src is not a directory"
if echo $kernel_src | egrep -q 'tar.bz2$'
then
echo "Uncompressing and untarring src..."
bzcat $kernel_src | tar xvf -
elif echo $kernel_src | egrep -q 'tar.gz2$'
then
echo "Uncompressing and untarring src..."
tar -zxvf $kernel_src
elif echo $kernel_src | egrep -q 'tar$'
then
echo "Untaring src..."
tar -xvf $kernel_src
else
echo "$prog: $kerenel_src is not a directory or known extension"
_usage
fi
# need to go down 1 level
kernel_src=$tmp_linux_dir/`ls $tmp_linux_dir`
echo "using kernel source from $kernel_src"
elif [ ! -e $kernel_src/MAINTAINERS ]
then
echo "Are you sure the kernel src argument is correct: $kernel_src"
echo "$kernel_src/MAINTAINERS not found"
_usage
fi
echo "Using mainline source tree of $kernel_src"
}
# --------- main ------------
_process_args $*
echo "Update workarea..."
export WORKAREA=$ism
cd $ism
p_tupdate
echo "Files which are not in the census for workarea:"
p_list -W
echo "Update new kdb..."
_fixup_new_kdb_patches
echo "Apply patches to mainline src..."
_apply_custom_patches
echo "Diff 2.6.x-xfs with patched mainline src..."
diff -Naur -X $tmp.skip $ism $kernel_src |\
sed \
-e "s#^--- ${ism}#--- #" \
-e "s#^+++ ${kernel_src}#+++ #" \
>$tmp.patch
_new_files $tmp.patch >$tmp.new
_deleted_files $tmp.patch >$tmp.deleted
_modified_files $tmp.patch >$tmp.modified
echo "Fix up modified/deleted state for patched files..."
cd $ism
[ -s $tmp.deleted ] && p_delete -I $tmp.deleted
[ -s $tmp.modified ] && p_modify -I $tmp.modified
echo "Copy over the new and modified files..."
cat $tmp.new $tmp.modified | \
while read file
do
src_file=$kernel_src/$file
dst_file=$ism/$file
echo "cp $src_file $dst_file"
cp $src_file $dst_file
done
echo "Fix up fetal state for patched files..."
[ -s $tmp.new ] && p_fetal -I $tmp.new
status=0