From e1007c7cd92d8d27c93c615054b5e65d34f23e5b Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Aug 19 2020 11:52:23 +0000 Subject: [PATCH 1/2] bumpspec,newspec: Use full timestamps consistently newspec was using local timezone while bumpspec was not, which is inconsistent and not useful. Switch to using local time zone consistently. --- diff --git a/rpmdev-bumpspec b/rpmdev-bumpspec index 2e84797..5a40f4d 100755 --- a/rpmdev-bumpspec +++ b/rpmdev-bumpspec @@ -154,7 +154,7 @@ class SpecFile(object): evrstring = ' - %s' % evr else: evrstring = '' - date = time.strftime("%a %b %d %T %Z %Y", time.gmtime()) + date = time.strftime("%a %b %e %T %Z %Y", time.localtime()) newchangelogentry = "* %s %s%s\n%s\n\n" % \ (date, email, evrstring, entry) self.lines[i] += newchangelogentry diff --git a/rpmdev-newspec.in b/rpmdev-newspec.in index 2818f27..d58d541 100644 --- a/rpmdev-newspec.in +++ b/rpmdev-newspec.in @@ -293,7 +293,7 @@ cat "$tempspec" | sed -rne " $ { g s/^(Name:[ \\t]*)[^\\n]*/\\1$appname/IMg - s|^%changelog\\s*|%changelog\\n* $(LC_ALL=C date +'%a %b %d %T %Z %Y') $(rpmdev-packager)\\n- |Mg + s|^%changelog\\s*|%changelog\\n* $(LC_ALL=C date +'%a %b %e %T %Z %Y') $(rpmdev-packager)\\n- |Mg $specfilter p }" > "$specfile" From 1a8a0aaa3f75f022920cb82b0c6419ae2db1b9c9 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Aug 19 2020 11:54:37 +0000 Subject: [PATCH 2/2] bumpspec, newspec: Add ability to use legacy datestamp when desirable If a spec file is being created on a system with an old RPM version that does not support the richer datestamp format, we should not use full datestamps when creating the spec. Additionally, if someone wants to bump the spec file with the legacy datestamp format that is still supported (for a spec that supports targeting older systems using versions of RPM that do not support it), then the new --legacy-datestamp switch for bumpspec will generate compatible changelog entries for it. --- diff --git a/rpmdev-bumpspec b/rpmdev-bumpspec index 5a40f4d..de3ee84 100755 --- a/rpmdev-bumpspec +++ b/rpmdev-bumpspec @@ -154,7 +154,10 @@ class SpecFile(object): evrstring = ' - %s' % evr else: evrstring = '' - date = time.strftime("%a %b %e %T %Z %Y", time.localtime()) + if opts.legacy_datestamp: + date = time.strftime("%a %b %e %Y", time.gmtime()) + else: + date = time.strftime("%a %b %e %T %Z %Y", time.localtime()) newchangelogentry = "* %s %s%s\n%s\n\n" % \ (date, email, evrstring, entry) self.lines[i] += newchangelogentry @@ -285,6 +288,8 @@ the Free Software Foundation; either version 2 of the License, or parser.add_option("-n", "--new", help="set new version and reset/set release " "(simple spec files only)") + parser.add_option("-D", "--legacy-datestamp", default=False, action='store_true', + help="use legacy datestamp for changelog entries") parser.add_option("-V", "--verbose", default=False, action='store_true', help="more output") parser.add_option("-v", "--version", default=False, action='store_true', diff --git a/rpmdev-newspec.in b/rpmdev-newspec.in index d58d541..cf54aea 100644 --- a/rpmdev-newspec.in +++ b/rpmdev-newspec.in @@ -293,7 +293,11 @@ cat "$tempspec" | sed -rne " $ { g s/^(Name:[ \\t]*)[^\\n]*/\\1$appname/IMg - s|^%changelog\\s*|%changelog\\n* $(LC_ALL=C date +'%a %b %e %T %Z %Y') $(rpmdev-packager)\\n- |Mg + if [[ $rpmver -ge 41400 ]] ; then # >= 4.14 (RHEL >= 8, Fedora >= 27) + s|^%changelog\\s*|%changelog\\n* $(LC_ALL=C date +'%a %b %e %T %Z %Y') $(rpmdev-packager)\\n- |Mg + else + s|^%changelog\\s*|%changelog\\n* $(LC_ALL=C date --utc +'%a %b %e %Y') $(rpmdev-packager)\\n- |Mg + fi $specfilter p }" > "$specfile"