-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmkpatch
executable file
·60 lines (49 loc) · 1.11 KB
/
mkpatch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl
#
# $Id$
#
# Generate a kernel patch to add socketcan to a kernel src tree.
# The list of files to be added is read from stdin.
use POSIX qw(strftime);
$version = shift;
if (-r "patches/$version.diff") {
copy_file("patches/$version.diff");
} else {
die "Patch patches/$version.diff not found";
}
while (<>) {
next if (/^#/);
my ($file, $n) = split;
my ($name);
if ($n eq "") {
$name = $file;
} else {
$name = $file;
$name =~ s/[^\/]*$/$n/;
}
$name =~ s/[^\/]*\/[^\/]*\///;
add_file($file, $name);
}
sub copy_file {
my ($file) = @_;
open file, "$file" || die "open $file\n";
while (<file>) {
print;
}
close file;
}
sub add_file {
my ($file, $name) = @_;
my (@lines, $count, $ts);
open file, "./strip-src -i -m -v $version $file |" || die "open $file\n";
@lines = <file>;
close file;
$count = $#lines + 1;
$ts = strftime "%F %T", gmtime((stat($file))[9]);
print "--- a/$name 1970-01-01 00:00:00\n";
print "+++ b/$name $ts\n";
print "@@ -0,0 +1,$count @@\n";
for (@lines) {
print "+$_";
}
}