root/i2c/trunk/mkpatch/mkpatch.pl @ 3328

Revision 3328, 2.5 KB (checked in by frodo, 15 years ago)

Start of automatic patch generation script

The generated patch already puts all files in the right places and modifies
#include paths. The Makefiles are not yet updated. Not yet usable.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/perl
2
3#    mkpatch - Create patches against the Linux kernel
4#    Copyright (c) 1999  Frodo Looijaard <frodol@dds.nl>
5#
6#    This program is free software; you can redistribute it and/or modify
7#    it under the terms of the GNU General Public License as published by
8#    the Free Software Foundation; either version 2 of the License, or
9#    (at your option) any later version.
10#
11#    This program is distributed in the hope that it will be useful,
12#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#    GNU General Public License for more details.
15#
16#    You should have received a copy of the GNU General Public License
17#    along with this program; if not, write to the Free Software
18#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20use strict;
21
22# $_[0]: i2c package root (like /tmp/i2c)
23# $_[1]: Linux kernel tree (like /usr/src/linux)
24sub main
25{
26  my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file);
27  my ($diff_command,$dummy,$data0,$data1,$sedscript);
28
29  # --> Read the command-lineo
30  $package_root = $ARGV[0];
31  die "Package root `$package_root' is not found\n" 
32        unless -d "$package_root/mkpatch";
33  $kernel_root = $ARGV[1];
34  die "Kernel root `$kernel_root' is not found\n" 
35        unless -f "$kernel_root/Rules.make";
36
37  # --> Read FILES
38  open INPUT, "$package_root/mkpatch/FILES" 
39        or die "Can't open `$package_root/mkpatch/FILES'";
40  while (<INPUT>) {
41    ($data0,$data1) = /(\S+)\s+(\S+)/;
42    $files{$data0} = $data1;
43  } 
44  close INPUT;
45
46  # --> Read INCLUDES
47  open INPUT, "$package_root/mkpatch/INCLUDES" 
48        or die "Can't open `$package_root/mkpatch/INCLUDES'";
49  while (<INPUT>) {
50    ($data0,$data1) = /(\S+)\s+(\S+)/;
51    $includes{$data0} = $data1;
52    $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; ';
53  } 
54  close INPUT;
55
56  # --> Start generating
57  foreach $package_file (keys %files) {
58    $kernel_file = $files{$package_file};
59    $diff_command = "diff -u2 ";
60    if ( -f "$kernel_root/$kernel_file") {
61      $diff_command .= "$kernel_root/$kernel_file";
62    } else {
63      $diff_command .= "/dev/null";
64    }
65    $diff_command .= " $package_root/$package_file";
66    open INPUT, "$diff_command|";
67    $dummy = <INPUT>;
68    $dummy = <INPUT>;
69    print "--- linux-old/$kernel_file\t".`date`;
70    print "+++ linux/$kernel_file\t".`date`;
71   
72    while (<INPUT>) {
73      eval $sedscript;
74      print;
75    }
76    close INPUT;
77  }
78}
79
80main;
81
Note: See TracBrowser for help on using the browser.