[OS-BUILD PATCHv2 2/2] redhat: replace inline awk script with genlog.py call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Herton R. Krzesinski <herton@xxxxxxxxxx>

redhat: replace inline awk script with genlog.py call

Upstream Status: RHEL only
Tested: verified changelog created after make rh-release

This wires in the genlog.py script call in genspec.sh, replacing the
previous inline awk script.

Signed-off-by: Herton R. Krzesinski <herton@xxxxxxxxxx>

diff a/redhat/genspec.sh b/redhat/genspec.sh
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -47,124 +47,8 @@ if [[ -z $lasttag ]]; then
     fi
 fi
 echo "Gathering new log entries since $lasttag"
-git format-patch --no-renames -k --stdout ^master "$lasttag".. -- ":!/redhat/rhdocs" | awk '
-BEGIN{TYPE="PATCHJUNK"; }
-	# add an entry to changelog
-	function changelog(subjectline, nameline, zstream)
-	{
-		subj = substr(subjectline, 10);
-		gsub(/%/, "", subj)
-		name = substr(nameline, 7);
-		pos=match(name, /</);
-		name=substr(name,1,pos-2);
-		bz=substr(BZ,11);
-		zbz=substr(ZBZ,13);
-		meta = "";
-		if (zstream == "no") {
-			if (bz != "") {
-				meta = " [" bz "]";
-			}
-		} else {
-			if (zbz != "") {
-				if (bz != "") {
-					meta = " [" zbz " " bz "]";
-				} else {
-					meta = " [" zbz "]";
-				}
-			}
-		}
-		cve = substr(CVE, 6);
-		if (cve != "") {
-			if (meta != "") {
-				meta = meta " {" cve "}";
-			} else {
-				meta = " {" cve "}";
-			}
-		}
-
-		print "- " subj " (" name ")" meta >> CLOGF;
-	}
-
-	#special separator, close previous patch
-	/^From / { if (TYPE=="PATCHJUNK") {
-			COMMIT=substr($0, 6, 40);
-			TYPE="HEADER";
-			LASTHDR="NEW";
-			next;
-		} }
-
-	#interesting header stuff
-	/^From: / { if (TYPE=="HEADER") {
-			namestr=$0;
-			#check for mime encoding on the email headers
-			#git uses utf-8 q encoding
-			if ( $0 ~ /=\?utf-8\?q/ ) {
-				#get rid of the meta utf-8 junk
-				gsub(/=\?utf-8\?q\?/, "");
-				gsub(/\?=/, "");
-
-				#translate each char
-				n=split($0, a, "=");
-				namestr = sprintf("%s", a[1]);
-				for (i = 2; i <= n; ++i) {
-					utf = substr(a[i], 0, 2);
-					c = strtonum("0x" utf);
-					namestr = sprintf("%s%c%s", namestr, c, substr(a[i],3));
-				}
-			}
-			NAMELINE=namestr; next;
-		    }
-	    }
-	/^Date: / {if (TYPE=="HEADER") {DATELINE=$0; next; } }
-	/^Subject: / { if (TYPE=="HEADER") {SUBJECTLINE=$0; LASTHDR="SUBJ"; next; } }
-	# partially attempt to deal with RFC2822 continuation lines in headers
-	/^\s/ { if (TYPE=="HEADER") { if (LASTHDR=="SUBJ") { SUBJECTLINE=(SUBJECTLINE $0); } next; } }
-	/^Bugzilla: / { if (TYPE=="META") {BZ=$0; } }
-	/^Z-Bugzilla: / { if (TYPE=="META") {ZBZ=$0; } }
-	/^CVE: / { if (TYPE=="META") {CVE=$0; } }
-
-	#blank line triggers end of header and to begin processing
-	/^$/ { 
-	    if (TYPE=="META") {
-		#create the dynamic changelog entry
-		changelog(SUBJECTLINE, NAMELINE, ZSTREAM);
-		#reset cve values because they do not always exist
-		CVE="";
-		BZ="";
-		ZBZ="";
-		TYPE="BODY";
-	    }
-	    if (TYPE=="HEADER") {
-		TYPE="META"; next;
-	    }
-	}
-
-	#in order to handle overlapping keywords, we keep track of each
-	#section of the patchfile and only process keywords in the correct section
-	/^---$/ {
-		if (TYPE=="META") {
-			# no meta data found, just use the subject line to fill
-			# the changelog
-			changelog(SUBJECTLINE, NAMELINE, ZSTREAM);
-			#reset cve values because they do not always exist
-			CVE="";
-			BZ="";
-			ZBZ="";
-			TYPE="BODY";
-		}
-		if (TYPE=="BODY") {
-			TYPE="PATCHSEP";
-		}
-	}
-	/^diff --git/ { if (TYPE=="PATCHSEP") { TYPE="PATCH"; } }
-	/^-- $/ { if (TYPE=="PATCH") { TYPE="PATCHJUNK"; } }
-
-	#filter out stuff we do not care about
-	{ if (TYPE == "PATCHSEP") { next; } }
-	{ if (TYPE == "PATCHJUNK") { next; } }
-	{ if (TYPE == "HEADER") { next; } }
-
-' SOURCES="$SOURCES" SPECFILE="$SPECFILE" CLOGF="$clogf" ZSTREAM="$ZSTREAM_FLAG"
+git log --topo-order --reverse --no-merges -z --format="- %s (%an)%n%b" \
+	^master "$lasttag".. -- ':!/redhat/rhdocs' | ${0%/*}/genlog.py >> "$clogf"
 
 grep -v "tagging $RPM_VERSION" "$clogf" > "$clogf.stripped"
 cp "$clogf.stripped" "$clogf"

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/865
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux