# HG changeset patch # User Gilles Moris # Date 1257498368 -3600 # Node ID 5070e4d572761e7d0a0decb8aa63817ce354fba7 # Parent 2059795bb5d03394d24112b35b9027fdcef04d3c buildrpm: enhance changelog of the RPM file Now the changelog is different depending if the parent is tagged: - for tags, keep the previous content, i.e. changelog of the tags. - for nightly build, changelog of the changesets since the latest tag As RPM is expecting strictly descending dates, I have used a python script to reorder the mercurial changelog. diff -r 2059795bb5d0 -r 5070e4d57276 contrib/buildrpm --- a/contrib/buildrpm Fri Nov 06 09:59:55 2009 +0100 +++ b/contrib/buildrpm Fri Nov 06 10:06:08 2009 +0100 @@ -57,18 +57,50 @@ -e "s,^Release:.*,Release: $release," \ $specfile > $rpmspec -cat <> $rpmspec -%changelog -* `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release -- Automatically built via $0 +echo >> $rpmspec +echo "%changelog" >> $rpmspec + +if echo $version | grep '+' > /dev/null 2>&1; then + latesttag="`echo $version | sed -e 's/+.*//'`" + $HG log -r .:"$latesttag" -fM \ + --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' +import sys, time + +def datestr(date, format): + return time.strftime(format, time.gmtime(float(date[0]) - date[1])) -EOF -$HG log \ - --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ - .hgtags \ - | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ - -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ - >> $rpmspec +changelog = [] +for l in sys.stdin.readlines(): + tok = l.split("\t") + hgdate = tuple(int(v) for v in tok[0].split()) + changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) +prevtitle = "" +for l in sorted(changelog, reverse=True): + title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) + if prevtitle != title: + prevtitle = title + print + print title + print "- %s" % l[3].strip() +' >> $rpmspec + +else + + $HG log \ + --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ + .hgtags | python -c ' +import sys, time + +def datestr(date, format): + return time.strftime(format, time.gmtime(float(date[0]) - date[1])) + +for l in sys.stdin.readlines(): + tok = l.split("\t") + hgdate = tuple(int(v) for v in tok[0].split()) + print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]) +' >> $rpmspec + +fi rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean if [ $? = 0 ]; then