Whamcloud - gitweb
b=17671
[fs/lustre-release.git] / lustre / kernel_patches / scripts / split-patch
1 #!/usr/bin/perl -w
2 $out = "";
3 while (<>) {
4         next if (/^Only/);
5         next if (/^Binary/);
6         if (/^diff/ || /^Index/) {
7                 if ($out) {
8                         close OUT;
9                 }
10                 (@out) = split(' ', $_);
11                 shift(@out) if (/^diff/);
12                 $out = pop(@out);
13                 $out =~ s:/*usr/:/:;
14                 $out =~ s:/*src/:/:;
15                 $out =~ s:^/*linux[^/]*::;
16                 $out =~ s:\(w\)::;
17                 next if ($out eq "");
18                 $out = "/var/tmp/patches/$out";
19                 $dir = $out;
20                 $dir =~ s:/[^/]*$::;
21                 print STDERR "$out\n";
22                 system("mkdir -p $dir");
23                 open(OUT, ">$out") || die("cannot open $out");
24         }
25         if ($out) {
26                 print OUT $_;
27         }
28 }
29