Skip to content

Commit

Permalink
Automatically generate %changelog section for RPM spec file
Browse files Browse the repository at this point in the history
The spec file uses a different changelog style than the ChangeLog file, which would be too
verbose for this purpose. Usually package maintainers note changes to the spec file itself
here as well and often give a more high-level summary of changes of the software being
packaged. Our automatically generated changelog will not be of the same quality as we only
indicate the timestamps a version was tagged and an "Update to version x.y.z"-style message.
But until now we didn't use the ChangeLog section at all. And package maintainers can still
replace it with a more detailed, manually maintained version.
  • Loading branch information
pief committed Apr 27, 2013
1 parent d184c12 commit e4a21d8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
setup.py
ChangeLog
python-netsnmpagent.spec.changelog
MANIFEST
build
dist
Expand Down
25 changes: 24 additions & 1 deletion Makefile
Expand Up @@ -68,10 +68,33 @@ ChangeLog:
dist:
@mkdir dist

dist/python-netsnmpagent.spec: dist python-netsnmpagent.spec.in
.PHONY: python-netsnmpagent.spec.changelog
python-netsnmpagent.spec.changelog: dist
@[ -e python-netsnmpagent.spec.changelog ] && rm python-netsnmpagent.spec.changelog || true
@AUTHOR=`git config user.email`; \
CURRENT=`git describe`; \
set -- `git tag -l | egrep ^[[:digit:]]+.[[:digit:]]+\(.[[:digit:]]+\)?$ | sort -r`; \
if [ "$$CURRENT" == "$$1" ] ; then shift; fi; \
until [ -z "$$CURRENT" ] ; do \
if [ -n "$$1" ] ; then \
LINE="Update to v$$CURRENT"; \
else \
LINE="Initial version $$CURRENT"; \
fi; \
GITDATE=`git log --format="%ad" --date=iso -n1 $$CURRENT`; \
OURDATE=`date -d "$$GITDATE" +"%a %b %d %Y"`; \
echo >>python-netsnmpagent.spec.changelog "* $$OURDATE $$AUTHOR"; \
echo >>python-netsnmpagent.spec.changelog "- $$LINE"; \
echo >>python-netsnmpagent.spec.changelog; \
CURRENT=$$1; \
shift || true; \
done

dist/python-netsnmpagent.spec: dist python-netsnmpagent.spec.changelog python-netsnmpagent.spec.in
@sed "s/%{netsnmpagent_version}/$(VERSION)/" \
python-netsnmpagent.spec.in \
>dist/python-netsnmpagent.spec
@cat >>dist/python-netsnmpagent.spec python-netsnmpagent.spec.changelog

install: setup.py
python setup.py install
Expand Down

0 comments on commit e4a21d8

Please sign in to comment.