From 33bf5750b05834ca6a2f4beb3eb12e0795411f76 Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 3 Mar 2021 19:13:20 +0100 Subject: [PATCH] fix(linux): Improve version number This change modifies the reported version number for km-config: if km-config is installed from a debian package, the package version will be output as well, e.g.: `km-config version 14.0.252-beta (package version 14.0.252-1+bionic1)` Otherwise the output will be identical to before: `km-config version 14.0.252-beta-local`. This change also modifies the script that sets the version number so that builds on Jenkins are now detected in addition to TC. This fixes #4579. --- linux/.gitignore | 7 +++++++ linux/keyman-config/debian/rules | 1 + linux/keyman-config/keyman_config/__init__.py | 1 + linux/keyman-config/keyman_config/version.py.in | 1 + linux/keyman-config/km-config | 8 ++++++-- linux/scripts/launchpad.sh | 1 - resources/build/build-utils.sh | 4 ++-- 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/linux/.gitignore b/linux/.gitignore index f559eeae9d..3bfb0eb6f6 100644 --- a/linux/.gitignore +++ b/linux/.gitignore @@ -90,3 +90,10 @@ keyman-config/keyman_config/version.py keyman-config/locale/*/LC_MESSAGES/ test.sh debianpackage/ +*.deb +*.build +*.buildinfo +*.changes +*.tar.xz +*.tar.gz +*.dsc \ No newline at end of file diff --git a/linux/keyman-config/debian/rules b/linux/keyman-config/debian/rules index bde563844e..8b4c7082af 100755 --- a/linux/keyman-config/debian/rules +++ b/linux/keyman-config/debian/rules @@ -9,6 +9,7 @@ export PYBUILD_INSTALL_ARGS=--install-scripts=/usr/share/keyman-config/ override_dh_auto_build: make man + sed -i -e "s/^__pkgversion__ = \"\"/__pkgversion__ = \"$(shell dpkg-parsechangelog --show-field Version)\"/g" keyman_config/version.py make compile-po dh_auto_build $@ diff --git a/linux/keyman-config/keyman_config/__init__.py b/linux/keyman-config/keyman_config/__init__.py index 4a1b314b87..f75cac273c 100644 --- a/linux/keyman-config/keyman_config/__init__.py +++ b/linux/keyman-config/keyman_config/__init__.py @@ -9,6 +9,7 @@ from .version import __versionwithtag__ from .version import __majorversion__ from .version import __releaseversion__ from .version import __tier__ +from .version import __pkgversion__ def _(txt): diff --git a/linux/keyman-config/keyman_config/version.py.in b/linux/keyman-config/keyman_config/version.py.in index c2970be4be..366071faa5 100644 --- a/linux/keyman-config/keyman_config/version.py.in +++ b/linux/keyman-config/keyman_config/version.py.in @@ -9,3 +9,4 @@ __versionwithtag__ = "_VERSIONWITHTAG_" __majorversion__ = "_MAJORVERSION_" __releaseversion__ = "_RELEASEVERSION_" __tier__ = "_TIER_" +__pkgversion__ = "" diff --git a/linux/keyman-config/km-config b/linux/keyman-config/km-config index 0f0bfeae46..172e484055 100755 --- a/linux/keyman-config/km-config +++ b/linux/keyman-config/km-config @@ -3,13 +3,17 @@ import argparse import logging -from keyman_config import __versionwithtag__ +from keyman_config import __versionwithtag__, __pkgversion__ from keyman_config.handle_install import download_and_install_package if __name__ == '__main__': + if __pkgversion__: + versionstring = "%s (package version %s)" % (__versionwithtag__, __pkgversion__) + else: + versionstring = "%s" % __versionwithtag__ parser = argparse.ArgumentParser(description='Keyman keyboards installation and information') - parser.add_argument('--version', action='version', version='%(prog)s version ' + __versionwithtag__) + parser.add_argument('--version', action='version', version='%(prog)s version ' + versionstring) parser.add_argument('-v', '--verbose', action='store_true', help='verbose logging') parser.add_argument('-vv', '--veryverbose', action='store_true', help='very verbose logging') parser.add_argument('-i', '--install', action='store', nargs='?', help='install .kmp package') diff --git a/linux/scripts/launchpad.sh b/linux/scripts/launchpad.sh index f7a9b75448..351cb73fa8 100755 --- a/linux/scripts/launchpad.sh +++ b/linux/scripts/launchpad.sh @@ -61,7 +61,6 @@ for proj in ${projects}; do cd ${proj}-${version} echo $(pwd) cp debian/changelog ../${proj}-changelog - #TODO separate source builds and dputs for each of $dists? for dist in ${distributions}; do cp ../${proj}-changelog debian/changelog dch -v ${version}-${packageversion}~${dist} "source package for PPA" diff --git a/resources/build/build-utils.sh b/resources/build/build-utils.sh index 0211dd14af..a6696402aa 100755 --- a/resources/build/build-utils.sh +++ b/resources/build/build-utils.sh @@ -73,12 +73,12 @@ function findVersion() { VERSION_TAG= fi - if [ -z "${TEAMCITY_VERSION-}" ]; then + if [ -z "${TEAMCITY_VERSION-}" -a -z "${JENKINS_HOME-}" ]; then # Local dev machine, not TeamCity VERSION_TAG="$VERSION_TAG-local" VERSION_ENVIRONMENT=local else - # On TeamCity; are we running a pull request build or a master/beta/stable build? + # On TeamCity: are we running a pull request build or a master/beta/stable build? if [ ! -z "${TEAMCITY_PR_NUMBER-}" ]; then VERSION_ENVIRONMENT=test # Note TEAMCITY_PR_NUMBER can also be 'master', 'beta', or 'stable-x.y'