From: Herton R. Krzesinski <herton@xxxxxxxxxx> redhat: generate distgit changelog in genspec.sh as well This is forwarded ported from current rhel-9/centos9 tree. Due lots of recent changes in the ARK tree regarding Makefile and variables, some changes had to be done to this: dropped variable changes/additions to redhat/Makefile, redhat/genspec.sh and redhat/scripts/rh-dist-git.sh, since those now are exported from the Makefile; for the same reason, the usage of some variables is changed from what was used as arguments before, to use the exported values from the Makefile. Another difference is also that the selftest data conditional made the changelog not use the stripped and updated changelog, this is adjusted/fixed here in this version. From: Jan Stancek <jstancek@xxxxxxxxxx> Bugzilla: INTERNAL Upstream Status: RHEL only Forward port of rhel-8 commit: commit 924856ea3952cc52781d252be70f45c1231ee8ba Author: Jan Stancek <jstancek@xxxxxxxxxx> Date: Wed Mar 9 11:15:16 2022 +0100 redhat: generate distgit changelog in genspec.sh as well Bugzilla: INTERNAL Upstream Status: RHEL only To break our dependence on ZSTREAM flag, make genlog.py generate also dist-git Resolves lines. Whether Resolves line uses ZBZs or YBZs, depends on whether genlog.py finds any ZBZs. After this change kernel.changelog* will start to contain also Resolves lines, which we need for dist-git changelog. For RPM changelog, we strip Resolves lines and use as before. Signed-off-by: Jan Stancek <jstancek@xxxxxxxxxx> Signed-off-by: Jan Stancek <jstancek@xxxxxxxxxx> Signed-off-by: Herton R. Krzesinski <herton@xxxxxxxxxx> diff --git a/redhat/genlog.py b/redhat/genlog.py index blahblah..blahblah 100755 --- a/redhat/genlog.py +++ b/redhat/genlog.py @@ -74,6 +74,8 @@ def parse_commit(commit): if __name__ == "__main__": + all_bzs = [] + all_zbzs = [] commits = sys.stdin.read().split('\0') for c in commits: if not c: @@ -84,11 +86,25 @@ if __name__ == "__main__": entry += " [" if zbugs: entry += " ".join(zbugs) + all_zbzs.extend(zbugs) if bugs and zbugs: entry += " " if bugs: entry += " ".join(bugs) + all_bzs.extend(bugs) entry += "]" if cves: entry += " {" + " ".join(cves) + "}" print(entry) + + resolved_bzs = [] + for bzid in (all_zbzs if all_zbzs else all_bzs): + if not bzid in resolved_bzs: + resolved_bzs.append(bzid) + print("Resolves: ", end="") + for i, bzid in enumerate(resolved_bzs): + if i: + print(", ", end="") + print(f"rhbz#{bzid}", end="") + print("\n") + diff --git a/redhat/genspec.sh b/redhat/genspec.sh index blahblah..blahblah 100755 --- a/redhat/genspec.sh +++ b/redhat/genspec.sh @@ -57,8 +57,6 @@ fi test -f "$SOURCES/$SPECFILE" && sed -i -e " - /%%CHANGELOG%%/r $SOURCES/$CHANGELOG - /%%CHANGELOG%%/d s/%%BUILDID%%/$BUILDID_DEFINE/ s/%%RPMKVERSION%%/$RPMKVERSION/ s/%%RPMKPATCHLEVEL%%/$RPMKPATCHLEVEL/ @@ -85,13 +83,17 @@ 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. See redhat/Makefile setup-source target for related # test changes. -[ -n "$RHSELFTESTDATA" ] && exit 0 +if [ -n "$RHSELFTESTDATA" ]; then + test -f "$SOURCES/$SPECFILE" && + sed -i -e " + /%%CHANGELOG%%/r $SOURCES/$CHANGELOG + /%%CHANGELOG%%/d" "$SOURCES/$SPECFILE" + exit 0 +fi GIT_FORMAT="--format=- %s (%an)%n%N%n^^^NOTES-END^^^%n%b" GIT_NOTES="--notes=refs/notes/${RHEL_MAJOR}.${RHEL_MINOR}*" -echo > "$clogf" - lasttag=$(git rev-list --first-parent --grep="^\[redhat\] kernel-${RPMKVERSION}.${RPMKPATCHLEVEL}" --max-count=1 HEAD) # if we didn't find the proper tag, assume this is the first release if [[ -z $lasttag ]]; then @@ -106,11 +108,13 @@ fi echo "Gathering new log entries since $lasttag" # master is expected to track mainline. -git log --topo-order --reverse --no-merges -z $GIT_NOTES "$GIT_FORMAT" \ - ^"${UPSTREAM}" "$lasttag".. -- ':!/redhat/rhdocs' | "${0%/*}"/genlog.py >> "$clogf" +cname="$(git var GIT_COMMITTER_IDENT |sed 's/>.*/>/')" +cdate="$(LC_ALL=C date +"%a %b %d %Y")" +cversion="[$RPMVERSION]"; +echo "* $cdate $cname $cversion" > "$clogf" -grep -v "tagging $RPMVERSION" "$clogf" > "$clogf.stripped" -cp "$clogf.stripped" "$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" | @@ -144,25 +148,25 @@ if [ -n "$(git log --oneline --first-parent --grep="Merge ark patches" "$lasttag echo "- Merge ark-patches" >> "$clogf" fi -LENGTH=$(wc -l "$clogf" | awk '{print $1}') - -#the changelog was created in reverse order -#also remove the blank on top, if it exists -#left by the 'print version\n' logic above -cname="$(git var GIT_COMMITTER_IDENT |sed 's/>.*/>/')" -cdate="$(LC_ALL=C date +"%a %b %d %Y")" -cversion="[$RPMVERSION]"; -tac "$clogf" | sed "1{/^$/d; /^- /i\ -* $cdate $cname $cversion - }" > "$clogf.rev" - +# during rh-dist-git genspec runs again and generates empty changelog +# create empty file to avoid adding extra header to changelog +LENGTH=$(grep "^-" $clogf | wc -l | awk '{print $1}') if [ "$LENGTH" = 0 ]; then - rm -f "$clogf.rev"; touch "$clogf.rev" + rm -f $clogf + touch $clogf fi -cat "$clogf.rev" "$SOURCES/$CHANGELOG" > "$clogf.full" +cat "$clogf" "$SOURCES/$CHANGELOG" > "$clogf.full" mv -f "$clogf.full" "$SOURCES/$CHANGELOG" +# genlog.py generates Resolves lines as well, strip these from RPM changelog +cat "$SOURCES/$CHANGELOG" | grep -v -e "^Resolves: " > $clogf.stripped + +test -f "$SOURCES/$SPECFILE" && + sed -i -e " + /%%CHANGELOG%%/r $clogf.stripped + /%%CHANGELOG%%/d" "$SOURCES/$SPECFILE" + echo "MARKER is $MARKER" if [ "$SINGLE_TARBALL" = 0 ]; then @@ -179,4 +183,4 @@ else touch "${SOURCES}/patch-${RPMKVERSION}.${RPMKPATCHLEVEL}"-redhat.patch fi -rm -f "$clogf"{,.rev,.stripped}; +rm -f "$clogf"{,.stripped}; diff --git a/redhat/scripts/create_distgit_changelog.sh b/redhat/scripts/create_distgit_changelog.sh deleted file mode 100755 index blahblah..blahblah 0 --- a/redhat/scripts/create_distgit_changelog.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Outputs a ready to use commit message for dist-git -# $1: spec file -# $2: zstream flag - -spec=$1; -zstream_flag=$2; -package_name=$3; -tmp=$(mktemp); - -function die -{ - echo "Error: $1" >&2; - rm -f "$tmp"; - exit 1; -} - -if [ ! -f "$spec" ]; then - die "$0 <spec file>"; -fi - -# this expression looks for the beginning of the changelog and extracts the -# first entry -sed -n -e '0,/%changelog/d; :abc; s/^$//; t end; p; d; N; b abc; :end; q;' "$spec" > "$tmp"; -if [ ! -s "$tmp" ]; then - die "Unable to extract the changelog"; -fi - -# getting the version from the first line -version=$(head -n 1 "$tmp" | sed -e 's/.*\[\(.*\)\]/\1/'); -if [ -z "$version" ]; then - die "Unable to get version/release"; -fi - -# extracting the BZs to create the "Resolves" line -if [ "$zstream_flag" == "no" ]; then - bzs=$(grep ^- "$tmp" | - sed -n -e "s/.*\[\([0-9 ]\+\)\].*/\1/p") -else - bzs=$(awk '/^-/ { - if(match($0, /\[([0-9]+ [0-9]+ )*[0-9]+ [0-9]+\]/)) { - n = split(substr($0, RSTART + 1, RLENGTH - 2), bzs) - for(i = 1; i <= n/2; i++) - print bzs[i] - } - }' "$tmp") -fi - -echo "$bzs" | - tr ' ' '\n' | - sort -u | - tr '\n' ',' | - sed -e "s/^/Resolves: rhbz#/; s/,\$//; s/,/, rhbz#/g;" >> "$tmp"; - -echo -e "${package_name}-${version}\n" -cat "$tmp"; -echo; -rm -f "$tmp"; diff --git a/redhat/scripts/rh-dist-git.sh b/redhat/scripts/rh-dist-git.sh index blahblah..blahblah 100755 --- a/redhat/scripts/rh-dist-git.sh +++ b/redhat/scripts/rh-dist-git.sh @@ -60,8 +60,10 @@ echo "Creating diff for review ($tmpdir/diff) and changelog" # differences were found diff -X "$REDHAT"/git/dontdiff -upr "$tmpdir/$PACKAGE_NAME" "$REDHAT"/rpm/SOURCES/ > "$tmpdir"/diff; # creating the changelog file -"$REDHAT"/scripts/create_distgit_changelog.sh "$REDHAT/rpm/SOURCES/$PACKAGE_NAME".spec \ - "$__ZSTREAM" "$PACKAGE_NAME" >"$tmpdir"/changelog + +# changelog has been created by genspec.sh, including Resolves line, just copy it here +echo -e "${PACKAGE_NAME}-${RPMVERSION}\n" > $tmpdir/changelog +awk '1;/^Resolves: /{exit};' $REDHAT/$CHANGELOG >> $tmpdir/changelog # all done echo "$tmpdir" -- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1764 _______________________________________________ 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