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').user/chris/test/getversion
@ -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 |