]> code.ossystems Code Review - openembedded-core.git/commitdiff
combo-layer-hook-default.sh: handle patches without Signed-off-by
authorPatrick Ohly <patrick.ohly@intel.com>
Fri, 13 Mar 2015 12:04:08 +0000 (13:04 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 20 Mar 2015 11:03:10 +0000 (11:03 +0000)
Inserting the "From rev" comment depended on having at least one
Signed-off-by line in the patch header. Some old repository commits in
openembedded-core and bitbake do not have those.

When inporting those, just insert at the end of the patch
header. While doing so, ensure that there's exactly one blank line
since the last non-blank line.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/combo-layer-hook-default.sh

index 46f2b70fc46b3606199b759aa40d4470448fca1d..1e3a3b9bc8a5240ad62e7f69b390e5ebae36ce5d 100755 (executable)
@@ -10,4 +10,11 @@ rev=$2
 reponame=$3
 
 sed -i -e "0,/^Subject:/s#^Subject: \[PATCH\] \($reponame: \)*\(.*\)#Subject: \[PATCH\] $reponame: \2#" $patchfile
-sed -i -e "0,/^Signed-off-by:/s#\(^Signed-off-by:.*\)#\($reponame rev: $rev\)\n\n\1#" $patchfile
+if grep -q '^Signed-off-by:' $patchfile; then
+    # Insert before Signed-off-by.
+    sed -i -e "0,/^Signed-off-by:/s#\(^Signed-off-by:.*\)#\(From $reponame rev: $rev\)\n\n\1#" $patchfile
+else
+    # Insert before final --- separator, with extra blank lines removed.
+    perl -e "\$_ = join('', <>); s/^(.*\S[ \t]*)(\n|\n\s*\n)---\n/\$1\n\nFrom $reponame rev: $rev\n---\n/s; print;" $patchfile >$patchfile.tmp
+    mv $patchfile.tmp $patchfile
+fi