From 268a89a2f6ce2af8d8f108bc9fd29f6bf618811b Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Thu, 8 Apr 2010 18:43:40 +0200 Subject: [PATCH] added 'getversion.sh' script which simply returns a version string composed out of the versions of the OpenSDE framework and package database delimited by an '-' Note: The script is also capable in returning the single version strings of the framework (using cmdline option '-f') and the version of the package db (using cmdline option '-p'). --- lib/misc/getversion.sh | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 lib/misc/getversion.sh diff --git a/lib/misc/getversion.sh b/lib/misc/getversion.sh new file mode 100755 index 0000000..b312e3c --- /dev/null +++ b/lib/misc/getversion.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: lib/misc/getversion.sh +# Copyright (C) 2010 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- SDE-COPYRIGHT-NOTE-END --- + + +# If the script is able to determine a dedicated version for the OpenSDE +# framework and the package database, the sde version will be composed +# out of both version strings delimited by a '-'. +# In the case both strings are equal only the framework version string +# will be used. +# If there is no VERSION file available at all or the version file is +# empty the version will be set to "trunk". + +[ -n "$SDEROOT" ] || SDEROOT='.' + +# default version string +defaultver="trunk" + +# framework version +frmwkver_file="$SDEROOT/etc/VERSION" + +if [ -f $frmwkver_file ]; then + frmwkver=$(head -n 1 $frmwkver_file) + if [ -z $frmwkver ]; then + frmwkver="$defaultver" + fi +else + frmwkver="$defaultver" +fi + +# package db version +pkgdbver_file="$SDEROOT/package/VERSION" + +if [ -f $pkgdbver_file ]; then + pkgdbver=$(head -n 1 $pkgdbver_file) + if [ -z $pkgdbver ]; then + pkgdbver="$defaultver" + fi +else + pkgdbver="$defaultver" +fi + +if [ $# -gt 0 ]; then + case "$1" in + -f) echo "$frmwkver" ;; + -p) echo "$pkgdbver" ;; + esac +else + # check if both version strings are not the same + if [ "$frmwkver" != "$pkgdbver" ]; then + echo "$frmwkver-$pkgdbver" + else + echo "$frmwkver" + fi +fi