Re: [Xenomai-core] prepare-kernel.sh patch to factorize generated patches

2006-03-08 Thread Gilles Chanteperdrix
Romain Lenglet wrote:
  Hi,
  
  I have added two new command-line options to prepare-kernel.sh to 
  filter the changes to record in the generated patch files.
  The patch to prepare-kernel.sh is attached.

Applied, thanks.

-- 


Gilles Chanteperdrix.

___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


[Xenomai-core] prepare-kernel.sh patch to factorize generated patches

2006-03-07 Thread Romain Lenglet
Hi,

I have added two new command-line options to prepare-kernel.sh to 
filter the changes to record in the generated patch files.
The patch to prepare-kernel.sh is attached.

I have observed that most of the changes (95% in size) are not 
specific to the kernel version or the architecture, so it is a 
waste of space to include those changes in every patch for every 
kernel version / architecture combination (every patch file 
would be about 2Mo!).

With the new options, we can generate four distinct patch files 
(figures are for 2.6.15 / i386):
- kernel-specific and arch-specific: 24 lines / 617 bytes
- kernel-specific and arch-NON-specific: 16 lines / 572 bytes
- kernel-NON-specific and arch-specific: 3116 lines / 95633 bytes
- kernel-NON-specific and arch-NON-specific: 77661 lines / 
2095346 bytes

total: 80817 lines / 2192168 bytes

Xenomai supports 6 architectures. Say that we want to generate 
patches for 10 Linux versions, all patch files now take only 
about:
2095346 + 6*95633 + 10*572 + 6*10*617 = 2711884 bytes

-- 
Romain LENGLET
--- xenomai/ChangeLog	2006-03-07 12:34:36.621119888 +0900
+++ xenomai-scriptmod/ChangeLog	2006-03-07 20:54:47.705741544 +0900
@@ -1,3 +1,11 @@
+2006-02-27  Romain Lenglet [EMAIL PROTECTED]
+
+	* scripts/prepare-kernel.sh: Added options to select changes to ignore
+	and to not include in the output patch file when the --outpatch option
+	is used: --filterkvers=y|n and --filterarch=y|n.
+	The ksrc/nucleus/udev/ directory is no more copied into the Linux
+	tree.
+
 2006-03-06  Jan Kiszka  [EMAIL PROTECTED]
 
 	* src/skins/{native,posix,rtdm}/Makefile.am: Suppress warnings
--- xenomai/scripts/prepare-kernel.sh	2006-02-28 12:11:09.817490880 +0900
+++ xenomai-scriptmod/scripts/prepare-kernel.sh	2006-03-07 20:54:14.832739000 +0900
@@ -1,6 +1,29 @@
 #! /bin/bash
 set -e
 
+# At all time, this variable must be set to either:
+# y if the changes to the Linux tree are specific to the kernel version;
+# n otherwise.
+patch_kernelversion_specific=n
+
+# At all time, this variable must be set to either:
+# y if the changes to the Linux tree are specific to the architecture;
+# n otherwise.
+patch_architecture_specific=n
+
+# At all time, this variable must be set to either:
+# y: ignore kernel-version-specific changes;
+# n: ignore non-kernel-version-specific changes;
+# b: don't filter according to the kernel version.
+patch_kernelversion_filter=b
+
+# At all time, this variable must be set to either:
+# y: ignore architecture-specific changes;
+# n: ignore non-architecture-specific changes;
+# b: don't filter according to the architecture.
+patch_architecture_filter=b
+
+
 patch_copytempfile() {
 file=$1
 if ! test -f $temp_tree/$file; then
@@ -10,26 +33,40 @@
 fi
 }
 
+check_filter() {
+if test $patch_kernelversion_specific != $patch_kernelversion_filter \
+-a $patch_architecture_specific != $patch_architecture_filter; then
+echo ok
+elif test -e $temp_tree/$1; then
+echo $me: inconsistent multiple changes to $1 in Linux kernel tree 2
+	echo error
+else
+echo ignore
+fi
+}
+
 patch_append() {
 file=$1
 if test x$output_patch = x; then
-realfile=$linux_tree/$file
+cat  $linux_tree/$file
 else
-patch_copytempfile $file
-realfile=$temp_tree/$file
+if test `check_filter $file` = ok; then
+patch_copytempfile $file
+cat  $temp_tree/$file
+fi
 fi
-cat  $realfile
 }
 
 patch_ed() {
 file=$1
 if test x$output_patch = x; then
-realfile=$linux_tree/$file
+ed -s $linux_tree/$file  /dev/null
 else
-patch_copytempfile $file
-realfile=$temp_tree/$file
+if test `check_filter $file` = ok; then
+patch_copytempfile $file
+ed -s $temp_tree/$file  /dev/null
+fi
 fi
-ed -s $realfile  /dev/null
 }
 
 patch_link() {
@@ -73,8 +110,10 @@
 ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
 fi
 else
-mkdir -p $temp_tree/$link_dir/$d
-cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
+if test `check_filter $link_dir/$f` = ok; then
+mkdir -p $temp_tree/$link_dir/$d
+cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
+fi
 fi
 done
 )
@@ -94,7 +133,7 @@
 }
 
 
-usage='usage: prepare-kernel --linux=linux-tree --adeos=adeos-patch [--arch=arch] [--outpatch=file tempdir] [--forcelink]'
+usage='usage: prepare-kernel --linux=linux-tree --adeos=adeos-patch [--arch=arch] [--outpatch=file tempdir [--filterkvers=y|n] [--filterarch=y|n]] [--forcelink]'
 me=`basename $0`
 
 while test $# -gt 0; do
@@ -115,6 +154,12 @@
 	shift
 	temp_tree=`echo $1|sed -e 's,^--tempdir=\\(.*\\)$,\\1,g'`
 	;;
+--filterkvers=*)
+patch_kernelversion_filter=`echo $1|sed -e