Annotation of embedaddon/miniupnpd/miniupnpc/updateminiupnpcstrings.sh, revision 1.1.1.1

1.1       misho       1: #! /bin/sh
                      2: # $Id: updateminiupnpcstrings.sh,v 1.9 2021/09/28 21:37:53 nanard Exp $
                      3: # project miniupnp : http://miniupnp.free.fr/
                      4: # (c) 2009-2021 Thomas Bernard
                      5: 
                      6: FILE=miniupnpcstrings.h
                      7: TEMPLATE_FILE=${FILE}.in
                      8: 
                      9: if [ -n "$1" ] ; then
                     10:   FILE="$1"
                     11: fi
                     12: if [ -n "$2" ] ; then
                     13:   TEMPLATE_FILE="$2"
                     14: fi
                     15: TMPFILE=`mktemp -t miniupnpcstringsXXXXXX`
                     16: if [ ! -f "$TMPFILE" ] ; then
                     17:        echo "mktemp failure"
                     18:        exit 1
                     19: fi
                     20: 
                     21: # detecting the OS name and version
                     22: OS_NAME=`uname -s`
                     23: OS_VERSION=`uname -r`
                     24: if [ -f /etc/debian_version ]; then
                     25:        OS_NAME=Debian
                     26:        OS_VERSION=`cat /etc/debian_version`
                     27: fi
                     28: 
                     29: # use lsb_release (Linux Standard Base) when available
                     30: LSB_RELEASE=`which lsb_release`
                     31: if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then
                     32:        # On NixOS, lsb_release returns strings such as "NixOS" (with quotes),
                     33:        # so we need to stript them with the following xargs trick:
                     34:        OS_NAME=`${LSB_RELEASE} -i -s | xargs echo`
                     35:        OS_VERSION=`${LSB_RELEASE} -r -s | xargs echo`
                     36:        case $OS_NAME in
                     37:                Debian)
                     38:                        #OS_VERSION=`${LSB_RELEASE} -c -s`
                     39:                        ;;
                     40:                Ubuntu)
                     41:                        #OS_VERSION=`${LSB_RELEASE} -c -s`
                     42:                        ;;
                     43:        esac
                     44: fi
                     45: 
                     46: # on AmigaOS 3, uname -r returns "unknown", so we use uname -v
                     47: if [ "$OS_NAME" = "AmigaOS" ]; then
                     48:        if [ "$OS_VERSION" = "unknown" ]; then
                     49:                OS_VERSION=`uname -v`
                     50:        fi
                     51: fi
                     52: 
                     53: echo "Detected OS [$OS_NAME] version [$OS_VERSION]"
                     54: MINIUPNPC_VERSION=`cat VERSION`
                     55: echo "MiniUPnPc version [${MINIUPNPC_VERSION}]"
                     56: 
                     57: EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|"
                     58: #echo $EXPR
                     59: test -f ${FILE}.in
                     60: echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE."
                     61: sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE
                     62: 
                     63: EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|"
                     64: echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE."
                     65: sed -e "$EXPR" < $TMPFILE > $FILE
                     66: rm $TMPFILE && echo "$TMPFILE deleted"
                     67: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>