diff options
author | Jerome Martin <jxm@risingtidesystems.com> | 2011-09-21 22:07:31 +0200 |
---|---|---|
committer | Jerome Martin <jxm@risingtidesystems.com> | 2011-09-22 00:34:29 +0200 |
commit | ee601478938fcaf05c46274c41802dc6422d116f (patch) | |
tree | 457ac7911ad57cc7f18cd22ca4392b84ad574ea7 | |
parent | 93154da0b71d6e217a78320cbf8379391b1101d2 (diff) | |
download | configshell-fb-ee601478938fcaf05c46274c41802dc6422d116f.tar.gz |
Now using a tarball-release based Makefile.
* Removed useless obsolete targets (setup.py based)
* Merged version templating in Makefile (removed bin/gen_changelog*).
* Added 'release' make target that generates a dist/*.tar.gz official
versionned release tarball from which one can just use setup.py,
dpkg-buildpackage or rpmbuild (no Makefile in it).
* Removed obsolete bin/lint as well.
* Now the 'rpm' and 'deb' Makefile targets use the generated release build.
* Makefile commands now use no echo mode.
* Added timestamps for virtual targets.
* Added *.pyc to .gitignore.
* Merged doc generation in debian/rules and rpm specfile (removed bin/gendoc).
* Cleaned up setup.py alignements.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 175 | ||||
-rwxr-xr-x | bin/gen_changelog | 38 | ||||
-rwxr-xr-x | bin/gen_changelog_cleanup | 22 | ||||
-rwxr-xr-x | bin/gendoc | 31 | ||||
-rwxr-xr-x | debian/rules | 10 | ||||
-rw-r--r-- | redhat/python-configshell.spec.tmpl | 7 | ||||
-rwxr-xr-x | setup.py | 23 |
8 files changed, 125 insertions, 182 deletions
@@ -20,4 +20,5 @@ debian/python-configshell.substvars debian/configshell-doc.debhelper.log debian/tmp/ *.spec +*.pyc rtslib-* @@ -14,94 +14,113 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. NAME = configshell -LIB = /usr/share -DOC = ${LIB}/doc/ -SETUP = ./setup.py -GENDOC = ./bin/gendoc -RPMVERSION = $$(grep Version: redhat/python-configshell.spec | awk '{print $$2}') GIT_BRANCH = $$(git branch | grep \* | tr -d \*) +VERSION = $$(basename $$(git describe --tags | tr - .)) -all: usage -usage: +all: @echo "Usage:" + @echo @echo " make deb - Builds debian packages." @echo " make rpm - Builds redhat packages." - @echo " make clean - Cleanup the local repository" - @echo " make cleanall - Cleanup the local repository and packages" - @echo "Developer targets:" - @echo " make doc - Generate the documentation" - @echo " make sdist - Build the source tarball" - @echo " make bdist - Build the installable tarball" - @echo " make install - Install configshell" - @echo " make installdocs - Install the documentation" - -install: - ${SETUP} install - -doc: - ${GENDOC} - -installdocs: doc - @test -e ${DOC} || \ - echo "Could not find ${DOC}; check the makefile variables." - @test -e ${DOC} - cp -r doc/* ${DOC}/${NAME}/ + @echo " make release - Generates the release tarball." + @echo + @echo " make clean - Cleanup the local repository build files." + @echo " make cleanall - Also remove dist/*" clean: - rm -fv configshell/*.pyc configshell/*.html - rm -frv doc doc/*.pdf doc/html doc/pdf doc/*.html - rm -frv configshell.egg-info MANIFEST build - rm -frv pdf html - rm -frv debian/tmp - rm -fv build-stamp - rm -fv dpkg-buildpackage.log dpkg-buildpackage.version - rm -frv *.rpm - rm -fv debian/files debian/*.log debian/*.substvars - rm -frv debian/configshell-doc/ debian/python2.5-configshell/ - rm -frv debian/python2.6-configshell/ debian/python-configshell/ - rm -frv results - rm -fv redhat/*.spec *.spec redhat/sed* sed* - rm -frv configshell-* - ./bin/gen_changelog_cleanup + @rm -fv ${NAME}/*.pyc ${NAME}/*.html + @rm -frv doc + @rm -frv ${NAME}.egg-info MANIFEST build + @rm -frv debian/tmp + @rm -fv build-stamp + @rm -fv dpkg-buildpackage.log dpkg-buildpackage.version + @rm -frv *.rpm + @rm -fv debian/files debian/*.log debian/*.substvars + @rm -frv debian/${NAME}-doc/ debian/python2.5-${NAME}/ + @rm -frv debian/python2.6-${NAME}/ debian/python-${NAME}/ + @rm -frv results + @rm -fv redhat/*.spec *.spec redhat/sed* sed* + @rm -frv ${NAME}-* @echo "Finished cleanup." cleanall: clean - rm -frv dist - -deb: doc - ./bin/gen_changelog - dpkg-buildpackage -rfakeroot | tee dpkg-buildpackage.log - ./bin/gen_changelog_cleanup - grep "source version" dpkg-buildpackage.log | awk '{print $$4}' > dpkg-buildpackage.version - @test -e dist || mkdir dist - mv ../${NAME}_$$(cat dpkg-buildpackage.version).dsc dist - mv ../${NAME}_$$(cat dpkg-buildpackage.version)_*.changes dist - mv ../${NAME}_$$(cat dpkg-buildpackage.version).tar.gz dist - mv ../*${NAME}*$$(cat dpkg-buildpackage.version)*.deb dist - ./bin/gen_changelog_cleanup - -rpm: doc - ./bin/gen_changelog - @echo Building RPM version ${RPMVERSION} - mkdir -p ~/rpmbuild/SOURCES/ - mkdir -p build - git archive $(GIT_BRANCH) --prefix configshell/ > build/configshell.tar - cd build; tar mxf configshell.tar; rm configshell.tar - cp configshell/__init__.py build/configshell/configshell - cp -r doc build/configshell/ - mv build/configshell configshell-${RPMVERSION} - tar zcf ~/rpmbuild/SOURCES/configshell-${RPMVERSION}.tar.gz configshell-${RPMVERSION} - rm -fr configshell-${RPMVERSION} - rpmbuild -ba redhat/*.spec - @test -e dist || mkdir dist - mv ~/rpmbuild/SRPMS/python-configshell-${RPMVERSION}*.src.rpm dist/ - mv ~/rpmbuild/RPMS/noarch/python-configshell-${RPMVERSION}*.rpm dist/ - mv ~/rpmbuild/RPMS/noarch/python-configshell-doc-${RPMVERSION}*.rpm dist/ - ./bin/gen_changelog_cleanup + @rm -frv dist -sdist: clean doc - ${SETUP} sdist +release: build/release-stamp +build/release-stamp: + @mkdir -p build + @echo "Exporting the repository files..." + @git archive ${GIT_BRANCH} --prefix ${NAME}-${VERSION}/ \ + | (cd build; tar xf -) + @echo "Cleaning up the target tree..." + @rm -f build/${NAME}-${VERSION}/Makefile + @rm -f build/${NAME}-${VERSION}/.gitignore + @echo "Fixing version string..." + @sed -i "s/__version__ = .*/__version__ = '${VERSION}'/g" \ + build/${NAME}-${VERSION}/${NAME}/__init__.py + @echo "Generating rpm specfile from template..." + @cd build/${NAME}-${VERSION}; \ + for spectmpl in redhat/*.spec.tmpl; do \ + sed -i "s/Version:\( *\).*/Version:\1${VERSION}/g" $${spectmpl}; \ + mv $${spectmpl} $$(basename $${spectmpl} .tmpl); \ + done; \ + rm -r redhat + @echo "Generating rpm changelog..." + @for commit in $$(git log --date=iso | grep -e ^commit -e ^Date: \ + | tr -d '\n' | sed 's/commit /\n/g' | sed 's/Date: //g' \ + | awk '{print $$2, $$3, $$1}' | sort -r | awk '{print $$3}'); do \ + version=$$(basename $$(git describe $${commit} --tags | tr - .)); \ + author=$$(git show $${commit} --format="format:%an <%ae>" -s); \ + date=$$(git show $${commit} --format="format:%ad" -s \ + | awk '{print $$1,$$2,$$3,$$5}'); \ + echo '* '"$${date} $${author} $${version}-1"; \ + git show $${commit} --format="format:%s%n" -s; \ + git show $${commit} --format="format:%b" -s \ + | sed 's/^* /- /g' | sed 's/^/ /g'; \ + done >> $$(ls build/${NAME}-${VERSION}/*.spec) + @echo "Generating debian changelog..." + @for commit in $$(git log | grep ^commit | awk '{print $$2}'); do \ + version=$$(basename $$(git describe $${commit} --tags | tr - .)); \ + author=$$(git show $${commit} --format="format:%an <%ae>" -s); \ + date=$$(git show $${commit} --format="format:%aD" -s); \ + day=$$(git show $${commit} --format='format:%ai' -s \ + | awk -F '-' '{print $$2}'); \ + date=$$(echo $${date} \ + | awk '{print $$1, "'"$${day}"'", $$3, $$4, $$5, $$6}'); \ + echo "${NAME} ($${version}) unstable; urgency=low"; \ + echo ; \ + git show $${commit} --format="format: * %s%n" -s; \ + git show $${commit} --format="format:%b%n" -s \ + | sed 's/^* /- /g' | sed 's/^/ /g'; \ + echo " -- $${author} $${date}"; \ + echo ; \ + done > build/${NAME}-${VERSION}/debian/changelog + @mkdir -p dist + @cd build; tar zcf ../dist/${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION} + @echo "Generated release tarball:" + @echo " $$(ls dist/${NAME}-${VERSION}.tar.gz)" + @touch build/release-stamp -bdist: clean doc - ${SETUP} bdist +deb: release build/deb-stamp +build/deb-stamp: + @echo "Building debian packages..." + @cd build/${NAME}-${VERSION}; \ + dpkg-buildpackage -rfakeroot -us -uc + @mv build/*_${VERSION}_*.deb dist/ + @echo "Generated debian packages:" + @for pkg in $$(ls dist/*_${VERSION}_*.deb); do echo " $${pkg}"; done + @touch build/deb-stamp +rpm: release build/rpm-stamp +build/rpm-stamp: + @echo "Building rpm packages..." + @mkdir -p build/rpm + @build=$$(pwd)/build/rpm; dist=$$(pwd)/dist/; rpmbuild \ + --define "_topdir $${build}" --define "_sourcedir $${dist}" \ + --define "_rpmdir $${build}" --define "_buildir $${build}" \ + --define "_srcrpmdir $${build}" -ba build/${NAME}-${VERSION}/*.spec + @mv build/rpm/*-${VERSION}*.src.rpm dist/ + @mv build/rpm/*/*-${VERSION}*.rpm dist/ + @echo "Generated rpm packages:" + @for pkg in $$(ls dist/*-${VERSION}*.rpm); do echo " $${pkg}"; done + @touch build/rpm-stamp diff --git a/bin/gen_changelog b/bin/gen_changelog deleted file mode 100755 index 35e5ac7..0000000 --- a/bin/gen_changelog +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -# This file is part of ConfigShell Community Edition. -# Copyright (c) 2011 by RisingTide Systems LLC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, version 3 (AGPLv3). -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - - -NAME=$(git config --get user.name) -EMAIL=$(git config --get user.email) -DATE=$(date +'%a, %d %b %Y %H:%M:%S %z') - -SRCPKG=$(cat debian/control | grep ^Source | awk '{print $2}') -VERSION=$(basename $(git describe --tags | tr - .)) - -sed -i "s/__version__ = .*/__version__ = '${VERSION}'/g" ${SRCPKG}/__init__.py - -echo "${SRCPKG} (${VERSION}) unstable; urgency=low" > debian/changelog -echo >> debian/changelog -echo " * Generated package." >> debian/changelog -echo >> debian/changelog -echo " -- ${NAME} <${EMAIL}> ${DATE}" >> debian/changelog - -RH_SPEC="redhat/python-configshell.spec" -cp redhat/python-configshell.spec.tmpl $RH_SPEC -sed -i "s/Version:\( *\).*/Version:\1${VERSION}/g" $RH_SPEC -echo "* $(date +'%a %b %d %Y') ${NAME} <${EMAIL}> - ${VERSION}" >> $RH_SPEC -echo "- Generated package." >> $RH_SPEC diff --git a/bin/gen_changelog_cleanup b/bin/gen_changelog_cleanup deleted file mode 100755 index 71faccc..0000000 --- a/bin/gen_changelog_cleanup +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# This file is part of ConfigShell Community Edition. -# Copyright (c) 2011 by RisingTide Systems LLC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, version 3 (AGPLv3). -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -SRCPKG=$(cat debian/control | grep ^Source | awk '{print $2}') -RH_SPEC="redhat/python-configshell.spec" -rm -f debian/changelog -sed -i "s/__version__ = .*/__version__ = 'GIT_VERSION'/g" ${SRCPKG}/__init__.py -rm -f $RH_SPEC diff --git a/bin/gendoc b/bin/gendoc deleted file mode 100755 index 317e1e7..0000000 --- a/bin/gendoc +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# This file is part of ConfigShell Community Edition. -# Copyright (c) 2011 by RisingTide Systems LLC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, version 3 (AGPLv3). -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -path=$PWD -options='-n configshell configshell/*.py' - -rm -rf doc &>/dev/null -mkdir doc -epydoc --no-sourcecode --pdf -v $options -mkdir doc/pdf 2>/dev/null -mv pdf/api.pdf doc/pdf/configshell-API-reference.pdf -rm pdf -rf -epydoc --no-sourcecode --html $options -mv html doc/ -perl -pi -e "s/<\?/<!/g" doc/html/*.html -perl -pi -e "s/\?>/>/g" doc/html/*.html -cp README COPYING doc/ diff --git a/debian/rules b/debian/rules index d8cd635..20834f4 100755 --- a/debian/rules +++ b/debian/rules @@ -3,6 +3,7 @@ build_dir = build install_dir = debian/tmp setup = /usr/bin/python ./setup.py --quiet +name = configshell binary: binary-indep @@ -32,6 +33,15 @@ build-stamp: dh_testdir $(setup) build --build-base $(build_dir) install --no-compile --install-purelib $(install_dir)/lib/configshell --install-scripts $(install_dir)/bin echo "2.6" > $(install_dir)/lib/configshell/.version + mkdir -p $(build_dir) doc/pdf + cd $(build_dir); epydoc --no-sourcecode --pdf -n $(name) \ + --exclude configobj ../$(name)/*.py + cp $(build_dir)/pdf/api.pdf doc/pdf/$(name)_API_Documentation.pdf + cd $(build_dir); epydoc --no-sourcecode --html -n $(name) \ + --exclude configobj ../$(name)/*.py + sed -i "s/<\?/<!/g" $(build_dir)/html/*.html + sed -i "s/\?>/>/g" $(build_dir)/html/*.html + cp -r $(build_dir)/html doc/ touch build-stamp clean: diff --git a/redhat/python-configshell.spec.tmpl b/redhat/python-configshell.spec.tmpl index f3d8073..b00ac09 100644 --- a/redhat/python-configshell.spec.tmpl +++ b/redhat/python-configshell.spec.tmpl @@ -30,6 +30,13 @@ PDF and HTML API reference for python-configshell. %build %{__python} setup.py build +mkdir -p doc/pdf +epydoc --no-sourcecode --pdf -n %{oname} --exclude configobj %{oname}/*.py +mv pdf/api.pdf doc/pdf/%{oname}_API_Documentation.pdf +epydoc --no-sourcecode --html -n %{oname} --exclude configobj %{oname}/*.py +sed -i "s/<\?/<!/g" html/*.html +sed -i "s/\?>/>/g" html/*.html +mv html doc/ %install rm -rf %{buildroot} @@ -1,5 +1,4 @@ #! /usr/bin/env python - ''' This file is part of ConfigShell Community Edition. Copyright (c) 2011 by RisingTide Systems LLC @@ -29,15 +28,13 @@ LICENSE = PKG.__license__ SCRIPTS = [] DESCRIPTION = PKG.__description__ -setup( - name=PKG.__name__, - description=DESCRIPTION, - version=VERSION, - author=AUTHOR, - author_email=EMAIL, - license=LICENSE, - url=URL, - scripts=SCRIPTS, - packages=[PKG.__name__], - package_data = {'':[]} - ) +setup(name=PKG.__name__, + description=DESCRIPTION, + version=VERSION, + author=AUTHOR, + author_email=EMAIL, + license=LICENSE, + url=URL, + scripts=SCRIPTS, + packages=[PKG.__name__], + package_data = {'':[]}) |