]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame_incremental - scripts/c2p
fix up queue-6.1/coresight-only-check-bottom-two-claim-bits.patch
[thirdparty/kernel/stable-queue.git] / scripts / c2p
... / ...
CommitLineData
1#!/usr/bin/perl -W
2# SPDX-License-Identifier: GPL-2.0
3#
4# convert git commit id to a pretty patch we can apply to the stable tree
5#
6# Written in perl because the bash version is broken, it doesn't pass
7# through the patch correctly :(
8#
9
10my $base_id = "";
11my $line;
12my $firstline = "true";
13my $git_id;
14my $header_complete = "false";
15my $signed_off_by_seen = "false";
16my $signed_off_by_complete = "false";
17my $eat_subject_trailer = "false";
18my $tmpfile;
19#my $kernel_version;
20
21
22$SIG{__DIE__} = sub
23{
24 # what usually happens is we don't have the git version, so clean up
25 # the temp file we created.
26 if ($tmpfile ne "") {
27 unlink $tmpfile;
28 }
29};
30
31$numArgs = $#ARGV + 1;
32if ($numArgs < 1) {
33 print "must provide git id\n";
34 exit;
35}
36
37$base_id = shift;
38
39if ($base_id eq "") {
40 print "must provide git id\n";
41 exit;
42}
43
44#$kernel_version = shift;
45#if (!defined($kernel_version)) {
46# $kernel_version = "";
47#}
48
49#print "handing commit id $base_id\n";
50
51$tmpfile = `mktemp patch.XXXXX` || die "Failed to run mktemp";
52chomp($tmpfile);
53
54# if we were smart, we could just reconstruct the header the way we want to
55# with a format: string, but we are not, so let's parse the thing out...
56$from = `git show --pretty=format:"%aN <%ae>" $base_id | head -n 1` || die "Failed to run git to get from";
57$subj = `git show --pretty=format:"Subject: %s" $base_id | head -n 1` || die "Failed to run git to get subject";
58
59open FILE, ">$tmpfile" || die "Failed to create $tmpfile";
60#open GIT, "git show --pretty=email $base_id |" || die "Failed to run git";
61open GIT, "git format-patch -n1 --no-numbered -k --stdout $base_id |" || die "Failed to run git";
62
63while ($line = <GIT>) {
64
65 # subjects have the fun ability to line-wrap, but we handled that above
66 # when we grabbed the "raw" subject, so just ignore trailing subject
67 # lines.
68 if ($eat_subject_trailer eq "true") {
69 $eat_subject_trailer = "false";
70 if ($line =~m/^ /) {
71 # eat this line
72 next;
73 }
74 }
75
76 # If this is the subject line, use our own.
77 if ($line =~m/^Subject: /) {
78 $line = $subj;
79 $eat_subject_trailer = "true";
80 }
81
82 if ($line =~m/^Signed-off-by:/) {
83 $signed_off_by_seen = "true";
84 }
85
86 if ($signed_off_by_seen eq "true") {
87 if ($signed_off_by_complete eq "false") {
88 if ($line eq "\n" || $line eq "---\n") {
89 print FILE "Signed-off-by: Greg Kroah-Hartman <gregkh\@linuxfoundation.org>\n";
90 $signed_off_by_complete = "true";
91 $signed_off_by_seen = "false";
92 }
93 }
94 }
95
96 print FILE $line;
97
98 if ($firstline eq "true") {
99 my @from = split(/ /, $line);
100 $git_id = $from[1];
101 #print "git_id = $git_id\n";
102 $firstline = "false";
103 }
104 if ($header_complete eq "false") {
105 if ($line eq "\n") {
106 print FILE "From: $from\n";
107 print FILE "commit $git_id upstream.\n\n";
108 $header_complete = "true";
109 }
110 }
111}
112close GIT;
113close FILE;
114
115#print "$tmpfile\n";
116
117system "vim -c \":set syntax=mail\" $tmpfile";
118system "reset";
119$new_file = `rename-patch $tmpfile`;
120chomp($new_file);
121system "mv $new_file ~/linux/stable/";
122#print "moved $new_file to ~/linux/stable/\n";
123
124print "cd ~/linux/stable && ./apply_it $new_file @ARGV\n";
125system "cd ~/linux/stable && ./apply_it $new_file @ARGV";
126#system "cp ~/linux/stable/$new_file ~/linux/longterm";
127#system "cd ~/linux/longterm && ./apply_it $new_file";
128
129#TMPFILE1=`mktemp patch.XXXXXX` || exit 1
130#TMPFILE2=`mktemp patch.XXXXXX` || exit 1
131#
132#GIT_ID=`git show $COMMIT_ID | head -n 1 | cut -f 2 -d ' '`
133#FROM=`git show --pretty=email $COMMIT_ID | head -n 2 | grep "From: "`
134#
135#git show --pretty=email $COMMIT_ID > $TMPFILE1
136#
137#HEADER_COMPLETE=false
138#while read line
139#do
140# # Strip out the [PATCH] portion of the subject line, it's annoying.
141# new=`echo "$line" | sed -e 's/^Subject: \[PATCH\]/Subject:/g'`
142#
143# # copy the line out to the new file
144# echo "$new" >> $TMPFILE2
145#
146# # add our special text (author and git id) right before
147# # the changelog text happens.
148# if [ "$line" == "" ] ; then
149# if [ $HEADER_COMPLETE == false ] ; then
150# echo "$FROM" >> $TMPFILE2
151# echo "" >> $TMPFILE2
152# echo "commit $GIT_ID upstream." >> $TMPFILE2
153# echo "" >> $TMPFILE2
154# HEADER_COMPLETE=true
155# fi
156# fi
157#done < $TMPFILE1
158#rm $TMPFILE1
159#vim $TMPFILE2
160#PATCH=`rename-patch $TMPFILE2`
161#mv $PATCH ~/linux/stable/
162#
163#echo "moved $PATCH to ~/linux/stable/"
164#