[OS-BUILD PATCHv5 1/9] redhat: split changelog generation from genspec.sh

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

 



From: Herton R. Krzesinski <herton@xxxxxxxxxx>

redhat: split changelog generation from genspec.sh

This creates a new genlog.sh script to split out the changelog
generation code from genspec.sh. The splitted code is kept
as is.

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

diff --git a/redhat/genlog.sh b/redhat/genlog.sh
new file mode 100755
index blahblah..blahblah 100755
--- /dev/null
+++ b/redhat/genlog.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+LAST_MARKER=$(cat "${REDHAT}"/marker)
+clogf="$SOURCES/changelog"
+# hide [redhat] entries from changelog
+HIDE_REDHAT=1;
+# hide entries for unsupported arches
+HIDE_UNSUPPORTED_ARCH=1;
+# override LC_TIME to avoid date conflicts when building the srpm
+LC_TIME=
+
+GIT_FORMAT="--format=- %s (%an)%n%N%n^^^NOTES-END^^^%n%b"
+GIT_NOTES="--notes=refs/notes/${RHEL_MAJOR}.${RHEL_MINOR}*"
+
+lasttag=$(git rev-list --first-parent --grep="^\[redhat\] kernel-${SPECKVERSION}.${SPECKPATCHLEVEL}" --max-count=1 HEAD)
+# if we didn't find the proper tag, assume this is the first release
+if [[ -z $lasttag ]]; then
+    if [[ -z ${MARKER//[0-9a-f]/} ]]; then
+        # if we're doing an untagged release, just use the marker
+        echo "Using $MARKER"
+        lasttag=$MARKER
+    else
+	lasttag=$(git describe --match="$MARKER" --abbrev=0)
+    fi
+fi
+echo "Gathering new log entries since $lasttag"
+# master is expected to track mainline.
+
+cname="$(git var GIT_COMMITTER_IDENT |sed 's/>.*/>/')"
+cdate="$(LC_ALL=C date +"%a %b %d %Y")"
+cversion="[$BASEVERSION]";
+echo "* $cdate $cname $cversion" > "$clogf"
+
+git log --topo-order --no-merges -z "$GIT_NOTES" "$GIT_FORMAT" \
+	^"${UPSTREAM}" "$lasttag".. -- ':!/redhat/rhdocs' | "${0%/*}"/genlog.py >> "$clogf"
+
+if [ "$HIDE_REDHAT" = "1" ]; then
+	grep -v -e "^- \[redhat\]" "$clogf" |
+		sed -e 's!\[Fedora\]!!g' > "$clogf.stripped"
+	cp "$clogf.stripped" "$clogf"
+fi
+
+if [ "$HIDE_UNSUPPORTED_ARCH" = "1" ]; then
+	grep -E -v "^- \[(alpha|arc|arm|avr32|blackfin|c6x|cris|frv|h8300|hexagon|ia64|m32r|m68k|metag|microblaze|mips|mn10300|openrisc|parisc|score|sh|sparc|tile|um|unicore32|xtensa)\]" "$clogf" > "$clogf.stripped"
+	cp "$clogf.stripped" "$clogf"
+fi
+
+# If the markers aren't the same then this a rebase.
+# This means we need to zap entries that are already present in the changelog.
+if [ "$MARKER" != "$LAST_MARKER" ]; then
+	# awk trick to get all unique lines
+	awk '!seen[$0]++' "$SOURCES/$SPECCHANGELOG" "$clogf" > "$clogf.unique"
+	# sed trick to get the end of the changelog minus the line
+	sed -e '1,/# END OF CHANGELOG/ d' "$clogf.unique" > "$clogf.tmp"
+	# Add an explicit entry to indicate a rebase.
+	echo "" > "$clogf"
+	echo -e "- $MARKER rebase" | cat "$clogf.tmp" - >> "$clogf"
+	rm "$clogf.tmp" "$clogf.unique"
+fi
+
+# HACK temporary hack until single tree workflow
+# Don't reprint all the ark-patches again.
+if [ -n "$(git log --oneline --first-parent --grep="Merge ark patches" "$lasttag"..)" ]; then
+	# Throw away the clogf and just print the summary merge
+	echo "" > "$clogf"
+	echo "- Merge ark-patches" >> "$clogf"
+fi
+
+# during rh-dist-git genspec runs again and generates empty changelog
+# create empty file to avoid adding extra header to changelog
+LENGTH=$(grep -c "^-" "$clogf" | awk '{print $1}')
+if [ "$LENGTH" = 0 ]; then
+	rm -f "$clogf"
+	touch "$clogf"
+fi
+
+cat "$clogf" "$SOURCES/$SPECCHANGELOG" > "$clogf.full"
+mv -f "$clogf.full" "$SOURCES/$SPECCHANGELOG"
+
+# genlog.py generates Resolves lines as well, strip these from RPM changelog
+grep -v -e "^Resolves: " "$SOURCES/$SPECCHANGELOG" > "$clogf".stripped
+
+test -f "$SOURCES/$SPECFILE" &&
+	sed -i -e "
+	/%%SPECCHANGELOG%%/r $clogf.stripped
+	/%%SPECCHANGELOG%%/d" "$SOURCES/$SPECFILE"
+
+echo "MARKER is $MARKER"
+
+rm -f "$clogf"{,.stripped};
diff --git a/redhat/genspec.sh b/redhat/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -1,16 +1,6 @@
 #!/bin/bash
 # shellcheck disable=SC2153
 
-LAST_MARKER=$(cat "${REDHAT}"/marker)
-clogf="$SOURCES/changelog"
-# hide [redhat] entries from changelog
-HIDE_REDHAT=1;
-# hide entries for unsupported arches
-HIDE_UNSUPPORTED_ARCH=1;
-# override LC_TIME to avoid date conflicts when building the srpm
-LC_TIME=
-# STAMP=$(echo $MARKER | cut -f 1 -d '-' | sed -e "s/v//"); # unused
-
 UPSTREAM=$(git rev-parse -q --verify origin/"${UPSTREAM_BRANCH}" || \
 	   git rev-parse -q --verify "${UPSTREAM_BRANCH}")
 
@@ -97,83 +87,7 @@ if [ -n "$RHSELFTESTDATA" ]; then
 	exit 0
 fi
 
-GIT_FORMAT="--format=- %s (%an)%n%N%n^^^NOTES-END^^^%n%b"
-GIT_NOTES="--notes=refs/notes/${RHEL_MAJOR}.${RHEL_MINOR}*"
-
-lasttag=$(git rev-list --first-parent --grep="^\[redhat\] kernel-${SPECKVERSION}.${SPECKPATCHLEVEL}" --max-count=1 HEAD)
-# if we didn't find the proper tag, assume this is the first release
-if [[ -z $lasttag ]]; then
-    if [[ -z ${MARKER//[0-9a-f]/} ]]; then
-        # if we're doing an untagged release, just use the marker
-        echo "Using $MARKER"
-        lasttag=$MARKER
-    else
-	lasttag=$(git describe --match="$MARKER" --abbrev=0)
-    fi
-fi
-echo "Gathering new log entries since $lasttag"
-# master is expected to track mainline.
-
-cname="$(git var GIT_COMMITTER_IDENT |sed 's/>.*/>/')"
-cdate="$(LC_ALL=C date +"%a %b %d %Y")"
-cversion="[$BASEVERSION]";
-echo "* $cdate $cname $cversion" > "$clogf"
-
-git log --topo-order --no-merges -z "$GIT_NOTES" "$GIT_FORMAT" \
-	^"${UPSTREAM}" "$lasttag".. -- ':!/redhat/rhdocs' | "${0%/*}"/genlog.py >> "$clogf"
-
-if [ "$HIDE_REDHAT" = "1" ]; then
-	grep -v -e "^- \[redhat\]" "$clogf" |
-		sed -e 's!\[Fedora\]!!g' > "$clogf.stripped"
-	cp "$clogf.stripped" "$clogf"
-fi
-
-if [ "$HIDE_UNSUPPORTED_ARCH" = "1" ]; then
-	grep -E -v "^- \[(alpha|arc|arm|avr32|blackfin|c6x|cris|frv|h8300|hexagon|ia64|m32r|m68k|metag|microblaze|mips|mn10300|openrisc|parisc|score|sh|sparc|tile|um|unicore32|xtensa)\]" "$clogf" > "$clogf.stripped"
-	cp "$clogf.stripped" "$clogf"
-fi
-
-# If the markers aren't the same then this a rebase.
-# This means we need to zap entries that are already present in the changelog.
-if [ "$MARKER" != "$LAST_MARKER" ]; then
-	# awk trick to get all unique lines
-	awk '!seen[$0]++' "$SOURCES/$SPECCHANGELOG" "$clogf" > "$clogf.unique"
-	# sed trick to get the end of the changelog minus the line
-	sed -e '1,/# END OF CHANGELOG/ d' "$clogf.unique" > "$clogf.tmp"
-	# Add an explicit entry to indicate a rebase.
-	echo "" > "$clogf"
-	echo -e "- $MARKER rebase" | cat "$clogf.tmp" - >> "$clogf"
-	rm "$clogf.tmp" "$clogf.unique"
-fi
-
-# HACK temporary hack until single tree workflow
-# Don't reprint all the ark-patches again.
-if [ -n "$(git log --oneline --first-parent --grep="Merge ark patches" "$lasttag"..)" ]; then
-	# Throw away the clogf and just print the summary merge
-	echo "" > "$clogf"
-	echo "- Merge ark-patches" >> "$clogf"
-fi
-
-# during rh-dist-git genspec runs again and generates empty changelog
-# create empty file to avoid adding extra header to changelog
-LENGTH=$(grep -c "^-" "$clogf" | awk '{print $1}')
-if [ "$LENGTH" = 0 ]; then
-	rm -f "$clogf"
-	touch "$clogf"
-fi
-
-cat "$clogf" "$SOURCES/$SPECCHANGELOG" > "$clogf.full"
-mv -f "$clogf.full" "$SOURCES/$SPECCHANGELOG"
-
-# genlog.py generates Resolves lines as well, strip these from RPM changelog
-grep -v -e "^Resolves: " "$SOURCES/$SPECCHANGELOG" > "$clogf".stripped
-
-test -f "$SOURCES/$SPECFILE" &&
-	sed -i -e "
-	/%%SPECCHANGELOG%%/r $clogf.stripped
-	/%%SPECCHANGELOG%%/d" "$SOURCES/$SPECFILE"
-
-echo "MARKER is $MARKER"
+"${0%/*}"/genlog.sh
 
 if [ "$DISTRO" == "fedora" ]; then
 	# The tarball in the SRPM contains only the upstream sources.
@@ -188,5 +102,3 @@ else
 	# compatibility is necessary.
 	touch "${SOURCES}/patch-${SPECKVERSION}.${SPECKPATCHLEVEL}"-redhat.patch
 fi
-
-rm -f "$clogf"{,.stripped};

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1980
_______________________________________________
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
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[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