OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.0 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: lib/version.sh
  6. # Copyright (C) 2010 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. # NAME
  16. # version.sh - determine OpenSDE version information
  17. #
  18. # SYNOPSIS
  19. # version.sh [-fp]
  20. #
  21. # DESCRIPTION
  22. # The version.sh script determines OpenSDE version informations
  23. # by first checking if dedicated VERSION files for the OpenSDE
  24. # framework and the package tree do exist, for extracting the
  25. # version strings out of the files. In the case a VERSION file
  26. # does not exist or if it extracts an empty version string from
  27. # the an existing VERSION file it will assign a default version.
  28. #
  29. # If the version strings of the framework and the package tree
  30. # are not the same the returned version string will be composed
  31. # out of framework and the package tree version strings delimited
  32. # by an '-'. Otherwise it will only return the framework version
  33. # string.
  34. #
  35. # OPTIONS
  36. # -f
  37. # only return the version of the OpenSDE framework
  38. # -p
  39. # only return the version of the OpenSDE package tree
  40. #
  41. version_sh_usage() {
  42. echo "Usage: $0 [-fp]" >&2
  43. }
  44. while [ $# -gt 0 ] ; do
  45. case "$1" in
  46. -f)
  47. mode=fm ;;
  48. -p)
  49. mode=pkg ;;
  50. -*) version_sh_usage
  51. exit 1 ;;
  52. *)
  53. break ;;
  54. esac
  55. shift
  56. done
  57. [ -n "$SDEROOT" ] || SDEROOT='.'
  58. for x in fmver:etc/VERSION pkgver:package/VERSION; do
  59. k="${x%%:*}" f="${x#*:}"
  60. v=$(head -n1 "$SDEROOT/$f" 2> /dev/null)
  61. [ -n "$v" ] || v=master
  62. eval "$k='$v'"
  63. done
  64. case "$mode" in
  65. fm) echo "$fmver" ;;
  66. pkg) echo "$pkgver" ;;
  67. *) if [ "$fmver" = "$pkgver" ]; then
  68. echo "$fmver"
  69. else
  70. echo "$fmver-$pkgver"
  71. fi
  72. ;;
  73. esac