[OS-BUILD PATCHv2 4/5] redhat/genspec.sh: Rearrange genspec.sh

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

 



From: Prarit Bhargava <prarit@xxxxxxxxxx>

redhat/genspec.sh: Rearrange genspec.sh

genspec.sh takes a long time to run when executed to create test
examples.  The script does three things: creates a changelog, creates a
patch file, and creates the specfile.  Reorganize the code so that the
specfile is created first, and exit if the file is created for a test
examples.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/redhat/genspec.sh b/redhat/genspec.sh
index blahblah..blahblah 100755
--- a/redhat/genspec.sh
+++ b/redhat/genspec.sh
@@ -10,6 +10,82 @@ HIDE_UNSUPPORTED_ARCH=1;
 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}")
+
+if [ "$SNAPSHOT" = 0 ]; then
+	# This is based off a tag on Linus's tree (e.g. v5.5 or v5.5-rc5).
+	# Two kernels are built, one with debug configuration and one without.
+	DEBUG_BUILDS_ENABLED=1
+else
+	# All kernels are built with debug configurations.
+	DEBUG_BUILDS_ENABLED=0
+fi
+
+if [ -n "$BUILDID" ]; then
+	BUILDID_DEFINE=$(printf "%%define buildid %s" "$BUILDID")
+else
+	BUILDID_DEFINE="# define buildid .local"
+fi
+
+EXCLUDE_FILES=":(exclude,top).get_maintainer.conf \
+		:(exclude,top).gitattributes \
+		:(exclude,top).gitignore \
+		:(exclude,top).gitlab-ci.yml \
+		:(exclude,top)makefile \
+		:(exclude,top)Makefile.rhelver \
+		:(exclude,top)redhat \
+		:(exclude,top)configs"
+
+# If PATCHLIST_URL is not set to "none", generate Patchlist.changelog file that
+# holds the shas and commits not included upstream and git commit url.
+PATCHLIST_CHANGELOG=0
+if [ "$PATCHLIST_URL" != "none" ]; then
+	# sed convert
+	# <sha> <description>
+	# to
+	# <ark_commit_url>/<sha>
+	#  <sha> <description>
+	#
+	# May need to preserve word splitting in EXCLUDE_FILES
+	# shellcheck disable=SC2086
+	git log --no-merges --pretty=oneline --no-decorate ${UPSTREAM}.. $EXCLUDE_FILES | \
+		sed "s!^\([^ ]*\)!$PATCHLIST_URL/\1\n &!; s!\$!\n!" \
+		> "$SOURCES"/Patchlist.changelog
+	PATCHLIST_CHANGELOG=1
+fi
+
+test -f "$SOURCES/$SPECFILE" &&
+	sed -i -e "
+	/%%CHANGELOG%%/r $SOURCES/$CHANGELOG
+	/%%CHANGELOG%%/d
+	s/%%BUILDID%%/$BUILDID_DEFINE/
+	s/%%RPMKVERSION%%/$RPMKVERSION/
+	s/%%RPMKPATCHLEVEL%%/$RPMKPATCHLEVEL/
+	s/%%RPMKSUBLEVEL%%/$RPMKSUBLEVEL/
+	s/%%PKGRELEASE%%/$PKGRELEASE/
+	s/%%SPECRELEASE%%/$SPECRELEASE/
+	s/%%DISTRO_BUILD%%/$DISTRO_BUILD/
+	s/%%RELEASED_KERNEL%%/$RELEASED_KERNEL/
+	s/%%DEBUG_BUILDS_ENABLED%%/$DEBUG_BUILDS_ENABLED/
+	s/%%INCLUDE_FEDORA_FILES%%/$INCLUDE_FEDORA_FILES/
+	s/%%INCLUDE_RHEL_FILES%%/$INCLUDE_RHEL_FILES/
+	s/%%PATCHLIST_CHANGELOG%%/$PATCHLIST_CHANGELOG/
+	s/%%TARFILE_RELEASE%%/$TARFILE_RELEASE/" "$SOURCES/$SPECFILE"
+
+# We depend on work splitting of BUILDOPTS
+# shellcheck disable=SC2086
+for opt in $BUILDOPTS; do
+	add_opt=
+	[ -z "${opt##+*}" ] && add_opt="_with_${opt#?}"
+	[ -z "${opt##-*}" ] && add_opt="_without_${opt#?}"
+	[ -n "$add_opt" ] && sed -i "s/^\\(# The following build options\\)/%define $add_opt 1\\n\\1/" "$SOURCES/$SPECFILE"
+done
+
+# The self-test data doesn't currently have tests for the changelog or patch file, so the
+# rest of the script can be ignored.
+[ -n "$RHSELFTESTDATA" ] && exit 0
+
 echo > "$clogf"
 
 lasttag=$(git rev-list --first-parent --grep="^\[redhat\] kernel-${RPMKVERSION}.${RPMKPATCHLEVEL}" --max-count=1 HEAD)
@@ -25,9 +101,7 @@ if [[ -z $lasttag ]]; then
 fi
 echo "Gathering new log entries since $lasttag"
 # master is expected to track mainline.
-UPSTREAM=$(git rev-parse -q --verify origin/"${UPSTREAM_BRANCH}" || \
-          git rev-parse -q --verify "${UPSTREAM_BRANCH}")
- 
+
 git log --topo-order --reverse --no-merges -z --format="- %s (%an)%n%b" \
 	^"${UPSTREAM}" "$lasttag".. -- ':!/redhat/rhdocs' | "${0%/*}"/genlog.py >> "$clogf"
 
@@ -85,66 +159,6 @@ fi
 cat "$clogf.rev" "$SOURCES/$CHANGELOG" > "$clogf.full"
 mv -f "$clogf.full" "$SOURCES/$CHANGELOG"
 
-if [ "$SNAPSHOT" = 0 ]; then
-	# This is based off a tag on Linus's tree (e.g. v5.5 or v5.5-rc5).
-	# Two kernels are built, one with debug configuration and one without.
-	DEBUG_BUILDS_ENABLED=1
-else
-	# All kernels are built with debug configurations.
-	DEBUG_BUILDS_ENABLED=0
-fi
-
-if [ -n "$BUILDID" ]; then
-	BUILDID_DEFINE=$(printf "%%define buildid %s" "$BUILDID")
-else
-	BUILDID_DEFINE="# define buildid .local"
-fi
-
-EXCLUDE_FILES=":(exclude,top).get_maintainer.conf \
-		:(exclude,top).gitattributes \
-		:(exclude,top).gitignore \
-		:(exclude,top).gitlab-ci.yml \
-		:(exclude,top)makefile \
-		:(exclude,top)Makefile.rhelver \
-		:(exclude,top)redhat \
-		:(exclude,top)configs"
-
-# If PATCHLIST_URL is not set to "none", generate Patchlist.changelog file that
-# holds the shas and commits not included upstream and git commit url.
-PATCHLIST_CHANGELOG=0
-if [ "$PATCHLIST_URL" != "none" ]; then
-	# sed convert
-	# <sha> <description>
-	# to
-	# <ark_commit_url>/<sha>
-	#  <sha> <description>
-	#
-	# May need to preserve word splitting in EXCLUDE_FILES
-	# shellcheck disable=SC2086
-	git log --no-merges --pretty=oneline --no-decorate ${UPSTREAM}.. $EXCLUDE_FILES | \
-		sed "s!^\([^ ]*\)!$PATCHLIST_URL/\1\n &!; s!\$!\n!" \
-		> "$SOURCES"/Patchlist.changelog
-	PATCHLIST_CHANGELOG=1
-fi
-
-test -f "$SOURCES/$SPECFILE" &&
-	sed -i -e "
-	/%%CHANGELOG%%/r $SOURCES/$CHANGELOG
-	/%%CHANGELOG%%/d
-	s/%%BUILDID%%/$BUILDID_DEFINE/
-	s/%%RPMKVERSION%%/$RPMKVERSION/
-	s/%%RPMKPATCHLEVEL%%/$RPMKPATCHLEVEL/
-	s/%%RPMKSUBLEVEL%%/$RPMKSUBLEVEL/
-	s/%%PKGRELEASE%%/$PKGRELEASE/
-	s/%%SPECRELEASE%%/$SPECRELEASE/
-	s/%%DISTRO_BUILD%%/$DISTRO_BUILD/
-	s/%%RELEASED_KERNEL%%/$RELEASED_KERNEL/
-	s/%%DEBUG_BUILDS_ENABLED%%/$DEBUG_BUILDS_ENABLED/
-	s/%%INCLUDE_FEDORA_FILES%%/$INCLUDE_FEDORA_FILES/
-	s/%%INCLUDE_RHEL_FILES%%/$INCLUDE_RHEL_FILES/
-	s/%%PATCHLIST_CHANGELOG%%/$PATCHLIST_CHANGELOG/
-	s/%%TARFILE_RELEASE%%/$TARFILE_RELEASE/" "$SOURCES/$SPECFILE"
-
 echo "MARKER is $MARKER"
 
 if [ "$SINGLE_TARBALL" = 0 ]; then
@@ -157,13 +171,4 @@ else
 	touch "${SOURCES}/patch-${RPMKVERSION}.${RPMKPATCHLEVEL}"-redhat.patch
 fi
 
-# We depend on work splitting of BUILDOPTS
-# shellcheck disable=SC2086
-for opt in $BUILDOPTS; do
-	add_opt=
-	[ -z "${opt##+*}" ] && add_opt="_with_${opt#?}"
-	[ -z "${opt##-*}" ] && add_opt="_without_${opt#?}"
-	[ -n "$add_opt" ] && sed -i "s/^\\(# The following build options\\)/%define $add_opt 1\\n\\1/" "$SOURCES/$SPECFILE"
-done
-
 rm -f "$clogf"{,.rev,.stripped};

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1706
_______________________________________________
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 on the list, report it: https://pagure.io/fedora-infrastructure




[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