diff -Nur [old source] [new source]

 

diff -Nur linux-2.6.30/Makefile linux-2.6.31.5/Makefile
--- linux-2.6.30/Makefile       2009-06-10 11:05:27.000000000 +0800
+++ linux-2.6.31.5/Makefile     2009-10-23 06:57:56.000000000 +0800

@@ -1,7 +1,7 @@                                       ‘-’号为旧,'+'号为新这句的意思是:比较范围:从旧的源码的第1行开始的7行

 VERSION = 2                                                                                                                 新的源码的第1行开始的7行
 PATCHLEVEL = 6
-SUBLEVEL = 30
-EXTRAVERSION =
+SUBLEVEL = 31
+EXTRAVERSION = .5

 NAME = Man-Eating Seals of Antiquity

 # *DOCUMENTATION*
@@ -35,10 +35,8 @@     这句的意思是: 比较范围:从旧的源码的第35行开始的10行新的源码的 第35行开始的8行
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands

-ifdef V
-  ifeq ("$(origin V)", "command line")
-    KBUILD_VERBOSE = $(V)
-  endif

+ifeq ("$(origin V)", "command line")
+  KBUILD_VERBOSE = $(V)

 endif
 ifndef KBUILD_VERBOSE
   KBUILD_VERBOSE = 0

 

diff -Nur linux-2.6.30/arch/alpha/include/asm/bitsperlong.h linux-2.6.31.5/arch/alpha/include/asm/bitsperlong.h
--- linux-2.6.30/arch/alpha/include/asm/bitsperlong.h    1970-01-01 08:00:00.000000000 +0800
+++ linux-2.6.31.5/arch/alpha/include/asm/bitsperlong.h    2009-10-23 06:57:56.000000000 +0800

@@ -0,0 +1,8 @@          如果是0,则说明文件不存在
+#ifndef __ASM_ALPHA_BITSPERLONG_H
+#define __ASM_ALPHA_BITSPERLONG_H
+
+#define __BITS_PER_LONG 64
+
+#include <asm-generic/bitsperlong.h>
+
+#endif /* __ASM_ALPHA_BITSPERLONG_H */

 

 

2、 diff Linux源码,并将有不一样的源码整理在一起,要求:文件名以new和old区分(以diff -Nur linux-2.6.30 linux-2.6.31.5为例)。

 

rm -rf ~/Desktop/20091107

#cat linux-patch.txt | grep 'diff -Nur ' | sed 's/^.*linux-2.6.30g'| sed 's/ linux-2.6.31.5.*$//g' > ~/Desktop/diff.txt

old_source_noprefix=`cat linux-patch.txt | grep 'diff -Nur ' | sed 's/^.*linux-2.6.30g'| sed 's/ linux-2.6.31.5.*$//g'`
new_source_noprefix=`cat linux-patch.txt | grep 'diff -Nur ' | sed 's/^.*linux-2.6.31.5g'`

old_source_haveprefix=`cat linux-patch.txt | grep 'diff -Nur ' | sed 's/^.*linux-2.6.30/linux-2.6.30/g'| sed 's/ linux-2.6.31.5.*$//g'`
new_source_haveprefix=`cat linux-patch.txt | grep 'diff -Nur ' | sed 's/^.*linux-2.6.31.5/linux-2.6.31.5/g'`

cp_source()
{
#for i in `find . -type d -print`
for i in $1
do
  #echo $i

  #basename $i
  #dirname $i
 
  #Used "diff -Nur", some file didn't exist! Diff时有些文件不存在的,所以会提示文件不存在,这里不想看到这些提示,所以把stderr>/dev/null!

  mkdir -p ~/Desktop/20091107/`dirname $i` && cp ./$2/$i ~/Desktop/20091107/`dirname $i`/`basename $i`_"$3" 2>/dev/null
done
}

cp_source "$old_source_noprefix" "linux-2.6.30" "old"
cp_source "$new_source_noprefix" "linux-2.6.31.5" "new"


Logo

更多推荐