updateminiupnpcstrings.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #! /bin/sh
  2. # $Id: updateminiupnpcstrings.sh,v 1.7 2011/01/04 11:41:53 nanard Exp $
  3. # project miniupnp : http://miniupnp.free.fr/
  4. # (c) 2009 Thomas Bernard
  5. FILE=miniupnpcstrings.h
  6. TMPFILE=miniupnpcstrings.h.tmp
  7. TEMPLATE_FILE=${FILE}.in
  8. # detecting the OS name and version
  9. OS_NAME=`uname -s`
  10. OS_VERSION=`uname -r`
  11. if [ -f /etc/debian_version ]; then
  12. OS_NAME=Debian
  13. OS_VERSION=`cat /etc/debian_version`
  14. fi
  15. # use lsb_release (Linux Standard Base) when available
  16. LSB_RELEASE=`which lsb_release`
  17. if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then
  18. OS_NAME=`${LSB_RELEASE} -i -s`
  19. OS_VERSION=`${LSB_RELEASE} -r -s`
  20. case $OS_NAME in
  21. Debian)
  22. #OS_VERSION=`${LSB_RELEASE} -c -s`
  23. ;;
  24. Ubuntu)
  25. #OS_VERSION=`${LSB_RELEASE} -c -s`
  26. ;;
  27. esac
  28. fi
  29. # on AmigaOS 3, uname -r returns "unknown", so we use uname -v
  30. if [ "$OS_NAME" = "AmigaOS" ]; then
  31. if [ "$OS_VERSION" = "unknown" ]; then
  32. OS_VERSION=`uname -v`
  33. fi
  34. fi
  35. echo "Detected OS [$OS_NAME] version [$OS_VERSION]"
  36. MINIUPNPC_VERSION=`cat VERSION`
  37. echo "MiniUPnPc version [${MINIUPNPC_VERSION}]"
  38. EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|"
  39. #echo $EXPR
  40. test -f ${FILE}.in
  41. echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE."
  42. sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE
  43. EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|"
  44. echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE."
  45. sed -e "$EXPR" < $TMPFILE > $FILE
  46. rm $TMPFILE