]>
git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - scripts/c2p
ca3d8008909130de1fb7ce66d797496bcd78df1b
2 # SPDX-License-Identifier: GPL-2.0
4 # convert git commit id to a pretty patch we can apply to the stable tree
6 # Written in perl because the bash version is broken, it doesn't pass
7 # through the patch correctly :(
12 my $firstline = "true";
14 my $header_complete = "false";
15 my $signed_off_by_seen = "false";
16 my $signed_off_by_complete = "false";
17 my $eat_subject_trailer = "false";
24 # what usually happens is we don't have the git version, so clean up
25 # the temp file we created.
31 $numArgs = $#ARGV + 1;
33 print "must provide git id\n";
40 print "must provide git id\n";
44 #$kernel_version = shift;
45 #if (!defined($kernel_version)) {
46 # $kernel_version = "";
49 #print "handing commit id $base_id\n";
51 $tmpfile = `mktemp patch.XXXXX` || die "Failed to run mktemp";
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";
59 open FILE
, ">$tmpfile" || die "Failed to create $tmpfile";
60 #open GIT, "git show --pretty=email $base_id |" || die "Failed to run git";
61 open GIT
, "git format-patch -n1 --no-numbered -k --stdout $base_id |" || die "Failed to run git";
63 while ($line = <GIT
>) {
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
68 if ($eat_subject_trailer eq "true") {
69 $eat_subject_trailer = "false";
76 # If this is the subject line, use our own.
77 if ($line =~m/^Subject: /) {
79 $eat_subject_trailer = "true";
82 if ($line =~m/^Signed-off-by:/) {
83 $signed_off_by_seen = "true";
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";
98 if ($firstline eq "true") {
99 my @from = split(/ /, $line);
101 #print "git_id = $git_id\n";
102 $firstline = "false";
104 if ($header_complete eq "false") {
106 print FILE
"From: $from\n";
107 print FILE
"commit $git_id upstream.\n\n";
108 $header_complete = "true";
117 system "vim -c \":set syntax=mail\" $tmpfile";
119 $new_file = `rename-patch $tmpfile`;
121 system "mv $new_file ~/linux/stable/";
122 #print "moved $new_file to ~/linux/stable/\n";
124 print "cd ~/linux/stable && ./apply_it $new_file @ARGV\n";
125 system "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";
129 #TMPFILE1=`mktemp patch.XXXXXX` || exit 1
130 #TMPFILE2=`mktemp patch.XXXXXX` || exit 1
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: "`
135 #git show --pretty=email $COMMIT_ID > $TMPFILE1
137 #HEADER_COMPLETE=false
140 # # Strip out the [PATCH] portion of the subject line, it's annoying.
141 # new=`echo "$line" | sed -e 's/^Subject: \[PATCH\]/Subject:/g'`
143 # # copy the line out to the new file
144 # echo "$new" >> $TMPFILE2
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
160 #PATCH=`rename-patch $TMPFILE2`
161 #mv $PATCH ~/linux/stable/
163 #echo "moved $PATCH to ~/linux/stable/"