File: [Development] / xfs-cmds / xfsmisc / Attic / update_26_xfs (download)
Revision 1.2, Thu Oct 26 15:44:21 2006 UTC (10 years, 11 months ago) by tes.longdrop.melbourne.sgi.com
Branch: MAIN
Changes since 1.1: +69 -13
lines
Fix up some bugs. Not handling leading slash in diff pathnames for directory.
Not ensuring existence of new directory for copying.
Put the kdb patch into quilt for easy revert to base tree.
etc..
Merge of master-melb:xfs-cmds:27285a by kenmcd.
Fix up some bugs. Not handling leading slash in diff pathnames for directory.
Not ensuring existence of new directory for copying.
Put the kdb patch into quilt for easy revert to base tree.
etc..
|
#!/bin/sh
#
# Update the 2.6 ism workarea with a 2.6 kernel src tree
#
# NEED to update:
# - kernel_version
# - kdb_prefix
# - kdb_suffix
#
#
# Useful commands for the exercise:
# ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.gz 50Mb
# cd isms
# bzcat /build/kaos/kernel.org-sgidev/linux-2.6.18.tar.bz2 | tar xvf -
# cd linux-2.6.18
# mkdir patches
# quilt import ~/patches/patch-2.6.19-rc3
# quilt push
#
tmp=/tmp/$$
here=`pwd`
prog=`basename $0`
status=1
debug=false
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
kernel_version=2.6.19-rc3
kdb_prefix="kdb-v4.4-${kernel_version}-"
kdb_suffix="-1.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
# fix up kdb patches
if ls kdb* >/dev/null 2>&1
then
p_delete kdb*
fi
ftp -aiv "$kdb_ftp_host:$kdb_ftp_dir/$kdb_glob"
if ! ls kdb* >/dev/null 2>&1
then
echo "Failed to download kdb patches: $kdb_ftp_host:$kdb_ftp_dir/$kdb_glob"
exit
fi
p_fetal -kb kdb*
# fix up series file
p_modify series
>series # truncate it
for f in kdb*
do
echo $f | sed 's/\.bz2//' >>series
done
echo dmapi-enable >>series
p_state `p_list -c`
}
# 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 using quilt..."
[ -d patches ] || mkdir patches
for p in $ism/$patches/${kdb_prefix}{i386,ia64,common,x86_64}${kdb_suffix}
do
quilt import $p
quilt push
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)..."
[ -d patches ] || mkdir patches
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#^--- /#--- #" \
-e "s#^+++ ${kernel_src}#+++ #" \
-e "s#^+++ /#+++ #" \
>$tmp.patch
if $debug
then
cp $tmp.patch $here/THE_PATCH
fi
_new_files $tmp.patch >$tmp.new
_deleted_files $tmp.patch >$tmp.deleted
_modified_files $tmp.patch >$tmp.modified
if $debug
then
cp $tmp.modified $here/THE_MODIFIED
cp $tmp.new $here/THE_NEW
cp $tmp.deleted $here/THE_DELETED
fi
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
dst_dir=`dirname $dst_file`
[ -d $dst_dir ] || mkdir -p $dst_dir
echo "cp $src_file $dst_file"
if ! cp $src_file $dst_file
then
echo "Failed to copy from $src_file to $dst_file"
exit
fi
done
echo "Fix up fetal state for patched files..."
[ -s $tmp.new ] && p_fetal -I $tmp.new
status=0