#65 bumpspec, newspec: Add ability to use legacy datestamp when desirable
Merged 3 years ago by ngompa. Opened 3 years ago by ngompa.

file modified
+6 -1
@@ -154,7 +154,10 @@ 

                      evrstring = ' - %s' % evr

                  else:

                      evrstring = ''

-                 date = time.strftime("%a %b %d %T %Z %Y", time.gmtime())

+                 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 @@ 

      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',

file modified
+5 -1
@@ -293,7 +293,11 @@ 

  $ {

      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

+     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"

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.

Fixes #63

Pull-Request has been merged by ngompa

3 years ago
Metadata