From 1c8316e1ce23744fcfbde75e88d2927c4df07e69 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Sun, 28 Oct 2012 14:32:53 +0100 Subject: [PATCH] Start with a new concept --- .gitignore | 7 ++ debian/changelog | 12 +++ increase-version.sh | 240 +++++++++++++++++++++++++++++++++++++++++ setup.py | 56 ++++++++-- src/fbrehm/__init__.py | 12 ++- 5 files changed, 314 insertions(+), 13 deletions(-) create mode 100755 increase-version.sh diff --git a/.gitignore b/.gitignore index 551698e..74a3434 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,8 @@ +*.swp +*.old +*.pyc +*.egg +*-stamp +build +trace MANIFEST diff --git a/debian/changelog b/debian/changelog index 948f107..94e8b20 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +python-fbrehm-libs (0.4.1-0) unstable; urgency=low + + * Version bump + + -- Developer Sun, 28 Oct 2012 14:28:23 +0100 + +python-fbrehm-libs (0.3.0-1) unstable; urgency=low + + * Current state. + + -- Frank Brehm Sun, 28 Oct 2012 14:25:39 +0100 + python-fbrehm-libs (0.2-1) unstable; urgency=low * Initial release. (Closes: #0815) diff --git a/increase-version.sh b/increase-version.sh new file mode 100755 index 0000000..4c856f9 --- /dev/null +++ b/increase-version.sh @@ -0,0 +1,240 @@ +#!/bin/bash + +CUR_GIT_BRANCH=$(git branch | grep '^*' | sed -e 's/^[ ]*\*[ ]*//' -e 's/[ ]$//') + +RED="\033[38;5;196m" +YELLOW="\033[38;5;226m" +GREEN="\033[38;5;46m" +BLUE="\033[38;5;27m" +NORMAL="\033[39m" + +export LANG=C +export LANGUAGE= +export LC_CTYPE=C +export LC_NUMERIC=C +export LC_TIME=C +export LC_COLLATE=C +export LC_MONETARY=C +export LC_MESSAGES=C +export LC_PAPER=C +export LC_NAME=C +export LC_ADDRESS=C +export LC_TELEPHONE=C +export LC_MEASUREMENT=C +export LC_IDENTIFICATION=C +export LC_ALL= + +USE_MY_DEBCHANGE=y +if type -t debchange >/dev/null ; then + USE_MY_DEBCHANGE=n +fi + +usage() { + echo "Usage: $0 [-D unstable|testing|stable] [-a major|minor|micro|release]" + echo " $0 -h" + echo +} + +DO_HELP="n" +ACTION="release" +WANT_STAGE="unstable" +case "${CUR_GIT_BRANCH}" in + release/*) WANT_STAGE="stable";; + master) WANT_STAGE="stable";; +esac + +while getopts "ha:D:" options; do + case $options in + h) DO_HELP="y";; + a) ACTION="${OPTARG}";; + D) WANT_STAGE="${OPTARG}";; + *) usage >&2 + exit 1 + ;; + esac +done + +echo "WANT_STAGE: ${WANT_STAGE}" >/dev/null +echo "ACTION: ${ACTION}" >/dev/null + +if [ "${DO_HELP}" = "y" ] ; then + usage + exit 0 +fi + +case "${WANT_STAGE}" in + stable|testing|unstable) ;; + *) usage >&2 + exit 1 + ;; +esac + +cd $(dirname $0) + +if [ ! -f "debian/changelog" ] ; then + echo -e "File '${RED}debian/changelog${NORMAL}' does not exists." >&2 + exit 4 +fi + +FIRST_LINE_CHANGELOG=$(cat debian/changelog | head -n 1) +CUR_VERSION=$(echo "${FIRST_LINE_CHANGELOG}" | sed -e 's/^.*(//' -e 's/).*//') +CUR_STAGE=$(echo "${FIRST_LINE_CHANGELOG}" | sed -e 's/.*)[ ][ ]*//' -e 's/;.*//') + +#-------------------------------------------------- +my_debchange() { + + local stage version + + stage="${CUR_STAGE}" + version="${CUR_VERSION}" + + if [ "${1}" = '-D' ] ; then + stage="${2}" + shift + shift + fi + + if [ "${1}" = '-v' ] ; then + version="${2}" + shift + shift + fi + + TMP_FILE="debian/changelog.new" + + echo "python-fbrehm-libs (${version}) ${stage}; urgency=low" >"${TMP_FILE}" + echo >>"${TMP_FILE}" + for entry in "$@"; do + if [ "${entry}" != "" ] ; then + echo " * ${entry}" >>"${TMP_FILE}" + fi + done + echo >>"${TMP_FILE}" + + echo " -- ${DEBFULLNAME:-Developer} <${DEBEMAIL:-frank@brehm-online.com}> $(date -R)" >>"${TMP_FILE}" + echo >>"${TMP_FILE}" + + cat "debian/changelog" >>"${TMP_FILE}" + mv "${TMP_FILE}" "debian/changelog" + +} + +#-------------------------------------------------- +PB_VERSION=$(echo "${CUR_VERSION}" | awk -F'-' '{print $1}') +RELEASE_VERSION=$(echo "${CUR_VERSION}" | awk -F'-' '{print $2}') +if [ -z "${PB_VERSION}" ] ; then + PB_VERSION='0.0.0' +fi +if [ -z "${RELEASE_VERSION}" ] ; then + RELEASE_VERSION='1' +fi + +MAIN_VERSION=$( echo "${PB_VERSION}" | awk -F. '{print $1}') +if [ -z "${MAIN_VERSION}" ]; then + MAIN_VERSION=0 + MINOR_VERSION=0 + MICRO_VERSION=0 +else + MINOR_VERSION=$( echo "${PB_VERSION}" | awk -F. '{print $2}') + if [ -z "${MINOR_VERSION}" ]; then + MINOR_VERSION=0 + MICRO_VERSION=0 + else + MICRO_VERSION=$( echo "${PB_VERSION}" | awk -F. '{print $3}') + if [ -z "${MICRO_VERSION}" ]; then + MICRO_VERSION=0 + fi + fi +fi + +case "${ACTION}" in + major|minor|micro|release) + ;; + *) + usage >&2 + exit 1 + ;; +esac + +case "${ACTION}" in + major) + MAIN_VERSION=$(( ${MAIN_VERSION} + 1 )) + MINOR_VERSION=0 + MICRO_VERSION=0 + RELEASE_VERSION=1 + ;; + minor) + MINOR_VERSION=$(( ${MINOR_VERSION} + 1 )) + MICRO_VERSION=0 + RELEASE_VERSION=1 + ;; + micro) + MICRO_VERSION=$(( ${MICRO_VERSION} + 1 )) + RELEASE_VERSION=1 + ;; + release) + RELEASE_VERSION=$(( ${RELEASE_VERSION} + 1 )) + ;; +esac + +NEW_PB_VERSION=${MAIN_VERSION}.${MINOR_VERSION}.${MICRO_VERSION} +NEW_DEBIAN_VERSION="${NEW_PB_VERSION}-${RELEASE_VERSION}" +echo -e "Current version: ${GREEN}${CUR_VERSION}${NORMAL}" +echo -e "New version: ${GREEN}${NEW_PB_VERSION}${NORMAL}" +echo -e "New Debian version: ${GREEN}${NEW_DEBIAN_VERSION}${NORMAL}" +echo -e "Set distribution: ${GREEN}${WANT_STAGE}${NORMAL}" + +ACCEPT="" +while [ true ] ; do + echo + echo -e -n "Commit new version [${RED}y${NORMAL}/${GREEN}N${NORMAL}]?" + read -t 10 -p " " ACCEPT + if [ -z "${ACCEPT}" ]; then + echo + exit 0 + fi + ACCEPT=$( echo "${ACCEPT}" | tr '[:upper:]' '[:lower:]' ) + if [ "${ACCEPT}" = 'n' -o "${ACCEPT}" = 'no' ] ; then + exit 0 + fi + if [ "${ACCEPT}" = 'y' -o "${ACCEPT}" = 'yes' ] ; then + break + fi +done + +echo +echo -e "Increasing version to ${GREEN}${NEW_DEBIAN_VERSION}${NORMAL} ..." + +SECOND_LINE= +if [ "${CUR_STAGE}" != "${WANT_STAGE}" ] ; then + SECOND_LINE="Declared for ${WANT_STAGE}" +fi + +echo -n "debchange -D \"${WANT_STAGE}\" -v \"${NEW_DEBIAN_VERSION}\" \"Version bump\" " +if [ "${USE_MY_DEBCHANGE}" = "y" ] ; then + my_debchange -D "${WANT_STAGE}" -v "${NEW_DEBIAN_VERSION}" "Version bump" "${SECOND_LINE}" +else + echo -e "\n" | debchange -D "${WANT_STAGE}" -v "${NEW_DEBIAN_VERSION}" "Version bump" +fi +echo -e "[${GREEN}OK${NORMAL}]" + +if [ "${CUR_STAGE}" != "${WANT_STAGE}" ] ; then + echo -n "debchange \"Declared for ${WANT_STAGE}\" " + if [ "${USE_MY_DEBCHANGE}" != "y" ] ; then + debchange "Declared for ${WANT_STAGE}" + fi + echo -e "[${GREEN}OK${NORMAL}]" +fi + +scripts="src/fbrehm/__init__.py" +for script in $scripts; do + if [ -f $script ] ; then + echo -n "Performing $script ... " + sed -i -e "s/__version__\\([ ]*=[ ]*\\)[^ ]*/__version__\\1'${NEW_DEBIAN_VERSION}'/" $script + echo -e "[${GREEN}OK${NORMAL}]" + fi +done + +git status debian/changelog $scripts + +# vim: ts=4 expandtab diff --git a/setup.py b/setup.py index a93529e..0dbe749 100755 --- a/setup.py +++ b/setup.py @@ -1,21 +1,57 @@ #!/usr/bin/env python +import os +import sys from distutils.core import setup +# own modules: +cur_dir = os.getcwd() +if sys.argv[0] != '' and sys.argv[0] != '-c': + cur_dir = os.path.dirname(sys.argv[0]) +if os.path.exists(os.path.join(cur_dir, 'src', 'fbrehm')): + sys.path.insert(0, os.path.abspath(os.path.join(cur_dir, 'src'))) +del cur_dir + +import fbrehm + +packet_version = fbrehm.__version__ + long_description = ''' This is a collection of common usable python modules made by Frank Brehm. ''' -setup( name = 'fbrehm-libs', - version = '0.3', - description = 'collection of common python modules by Frank Brehm', - long_description = long_description, - author = 'Frank Brehm', - author_email = 'frank@brehm-online.com', - url = 'http://www.brehm-online.com/projects/fbrehm-libs', - packages = [ 'fbrehm', 'fbrehm.common', ], - package_dir = {'': 'src'}, - license = 'GPL-3', +setup( name = 'fbrehm', + version = packet_version, + description = 'collection of common python modules by Frank Brehm', + long_description = long_description, + author = 'Frank Brehm', + author_email = 'frank@brehm-online.com', + url = 'http://www.brehm-online.com/projects/fbrehm-libs', + license = 'LGPLv3+', + platforms = ['posix'], + packages = [ 'fbrehm', 'fbrehm.common', ], + package_dir = {'': 'src'}, + classifiers = [ + 'Development Status :: 2 - Pre-Alpha', + 'Environment :: Console', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)', + 'Natural Language :: English', + 'Operating System :: POSIX', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + provides = [ + 'fbrehm', + ], + requires = [ + 'argparse', + 'configobj', + ] ) +#======================================================================== + +# vim: fileencoding=utf-8 filetype=python ts=4 expandtab diff --git a/src/fbrehm/__init__.py b/src/fbrehm/__init__.py index 3d21abb..b5c0e46 100755 --- a/src/fbrehm/__init__.py +++ b/src/fbrehm/__init__.py @@ -1,9 +1,15 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -''' +""" @author: Frank Brehm @contact: frank@brehm-online.com -@copyright: (c) 2010 - 2011 by Frank Brehm, Berlin +@copyright: (c) 2010 - 2012 by Frank Brehm, Berlin @summary: All my own stuff -''' +""" +__author__ = 'Frank Brehm ' +__copyright__ = '(C) 2010-2012 by Frank Brehm, Berlin' +__contact__ = 'frank@brehm-online.com' +__version__ = '0.4.1-1' +__license__ = 'LGPLv3+' + # vim: fileencoding=utf-8 filetype=python ts=4 -- 2.39.5