2014-03-15 16:59:03 +00:00
|
|
|
|
#! /bin/sh
|
2023-12-30 16:35:35 +00:00
|
|
|
|
# $Id: updateminiupnpcstrings.sh,v 1.10 2022/10/16 05:28:15 nanard Exp $
|
2014-03-15 16:59:03 +00:00
|
|
|
|
# project miniupnp : http://miniupnp.free.fr/
|
2023-12-30 16:35:35 +00:00
|
|
|
|
# (c) 2009-2021 Thomas Bernard
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
|
|
FILE=miniupnpcstrings.h
|
|
|
|
|
TEMPLATE_FILE=${FILE}.in
|
|
|
|
|
|
2023-12-30 16:35:35 +00:00
|
|
|
|
if [ -n "$1" ] ; then
|
|
|
|
|
FILE="$1"
|
|
|
|
|
fi
|
|
|
|
|
if [ -n "$2" ] ; then
|
|
|
|
|
TEMPLATE_FILE="$2"
|
|
|
|
|
fi
|
|
|
|
|
TMPFILE=`mktemp -t miniupnpcstringsXXXXXX`
|
|
|
|
|
if [ ! -f "$TMPFILE" ] ; then
|
|
|
|
|
echo "mktemp failure"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
|
# detecting the OS name and version
|
|
|
|
|
OS_NAME=`uname -s`
|
|
|
|
|
OS_VERSION=`uname -r`
|
|
|
|
|
if [ -f /etc/debian_version ]; then
|
|
|
|
|
OS_NAME=Debian
|
|
|
|
|
OS_VERSION=`cat /etc/debian_version`
|
|
|
|
|
fi
|
2023-12-30 16:35:35 +00:00
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
|
# use lsb_release (Linux Standard Base) when available
|
|
|
|
|
LSB_RELEASE=`which lsb_release`
|
|
|
|
|
if [ 0 -eq $? -a -x "${LSB_RELEASE}" ]; then
|
2023-12-30 16:35:35 +00:00
|
|
|
|
# On NixOS, lsb_release returns strings such as "NixOS" (with quotes),
|
|
|
|
|
# so we need to stript them with the following xargs trick:
|
|
|
|
|
OS_NAME=`${LSB_RELEASE} -i -s | xargs echo`
|
|
|
|
|
OS_VERSION=`${LSB_RELEASE} -r -s | xargs echo`
|
2014-03-15 16:59:03 +00:00
|
|
|
|
case $OS_NAME in
|
|
|
|
|
Debian)
|
|
|
|
|
#OS_VERSION=`${LSB_RELEASE} -c -s`
|
|
|
|
|
;;
|
|
|
|
|
Ubuntu)
|
|
|
|
|
#OS_VERSION=`${LSB_RELEASE} -c -s`
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# on AmigaOS 3, uname -r returns "unknown", so we use uname -v
|
|
|
|
|
if [ "$OS_NAME" = "AmigaOS" ]; then
|
|
|
|
|
if [ "$OS_VERSION" = "unknown" ]; then
|
|
|
|
|
OS_VERSION=`uname -v`
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "Detected OS [$OS_NAME] version [$OS_VERSION]"
|
|
|
|
|
MINIUPNPC_VERSION=`cat VERSION`
|
|
|
|
|
echo "MiniUPnPc version [${MINIUPNPC_VERSION}]"
|
|
|
|
|
|
|
|
|
|
EXPR="s|OS_STRING \".*\"|OS_STRING \"${OS_NAME}/${OS_VERSION}\"|"
|
|
|
|
|
#echo $EXPR
|
|
|
|
|
test -f ${FILE}.in
|
|
|
|
|
echo "setting OS_STRING macro value to ${OS_NAME}/${OS_VERSION} in $FILE."
|
|
|
|
|
sed -e "$EXPR" < $TEMPLATE_FILE > $TMPFILE
|
|
|
|
|
|
|
|
|
|
EXPR="s|MINIUPNPC_VERSION_STRING \".*\"|MINIUPNPC_VERSION_STRING \"${MINIUPNPC_VERSION}\"|"
|
|
|
|
|
echo "setting MINIUPNPC_VERSION_STRING macro value to ${MINIUPNPC_VERSION} in $FILE."
|
|
|
|
|
sed -e "$EXPR" < $TMPFILE > $FILE
|
2023-12-30 16:35:35 +00:00
|
|
|
|
rm $TMPFILE && echo "$TMPFILE deleted"
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|