File lsb-release-2.0.dif of Package lsb-release
--- lsb_release
+++ lsb_release 2015/01/30 10:06:09
@@ -4,6 +4,7 @@
#
# Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc.
# Originally by Dominique MASSONIE <mdomi@users.sourceforge.net>
+# Modified for SUSE Linux products by Thorsten Kukuk
#
# 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
@@ -19,43 +20,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# * Changes in 2.0
-# - Support LSB 2.0 module layout (Mats Wichmann)
-# The LSB_VERSION is now a colon-separated field of supported module versions
-# An /etc/lsb-release.d is searched for modules beyond the core.
-# Only the filenames in this directory is looked at, those names are added
-# to LSB_VERSION. This allows module support to be handled easily by
-# package install/removal without a need to edit lsb-release on the fly.
-# - Correct license: FSG == Free Standards Group, Inc.
-#
-# * Changes in 1.4
-# - "awk" not needed anymore (Loic Lefort)
-# - fixed bug #121879 reported by Chris D. Faulhaber,
-# some shells doesn't support local variables
-# - fixed a bug when single parameter sets many args including -s
-# - function DisplayProgramVersion (undocumented) now exits script like Usage
-# - cosmetic changes in comments/outputs
-#
-# * Changes in 1.3
-# - No changes in script, only in build infrastructure
-#
-# * Changes in 1.2
-# - Fixed more bash'isms
-# - LSB_VERSION is no longer required in /etc/lsb-release file
-#
-# * Changes in 1.1
-# - removed some bash-ism and typos
-# Notice: script remains broken with ash because of awk issues
-# - changed licence to FSG - "Free Software Group, Inc"
-# - fixed problem with --short single arg call
-# - changed Debian specifics, codename anticipates release num
-#
# Description:
# Collect information from sourceable /etc/lsb-release file (present on
# LSB-compliant systems) : LSB_VERSION, DISTRIB_ID, DISTRIB_RELEASE,
# DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional)
# Then (if needed) find and add names from /etc/lsb-release.d
-# Then (if needed) find and parse the /etc/[distro]-release file
###############################################################################
@@ -63,16 +32,12 @@
###############################################################################
# This script version
-SCRIPTVERSION="2.0"
+SCRIPTVERSION="2.0-SUSE"
# Defines the data files
-INFO_ROOT="/etc" # directory of config files
-INFO_LSB_FILE="lsb-release" # where to get LSB version
-INFO_LSB_DIR="lsb-release.d" # where to get LSB addon modules
-INFO_DISTRIB_SUFFIX="release" # <distrib>-<suffix>
-ALTERNATE_DISTRIB_FILE="/etc/debian_version" # for Debian [based distrib]
-ALTERNATE_DISTRIB_NAME="Debian" # "
-CHECKFIRST="/etc/redhat-release" # check it before file search
+INFO_LSB_FILE="/etc/lsb-release" # where to get LSB version
+INFO_LSB_DIR="/etc/lsb-release.d" # where to get LSB addon modules
+INFO_DISTRIB_FILE="/etc/os-release" # <distrib>-<suffix>
# Defines our exit codes
EXIT_STATUS="0" # default = Ok :)
@@ -91,6 +56,7 @@
MSG_NA="n/a"
MSG_NONE="(none)"
MSG_RESULT="" # contains the result in case short output selected
+MSG_DISTRIBUTOR="SUSE"
# Description string delimiter
DESCSTR_DELI="release"
@@ -101,7 +67,7 @@
###############################################################################
# Display Program Version for internal use (needed by help2man)
-DisplayProgramVersion() {
+DisplayProgramVersion() {
echo "FSG `basename $0` v$SCRIPTVERSION"
echo
echo "Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc."
@@ -188,65 +154,54 @@
# Get/Init LSB infos (maybe Distrib infos too)
GetLSBInfo() {
- if [ -f "$INFO_ROOT/$INFO_LSB_FILE" ]
+ LSB_VERSION=""
+ if [ -f "$INFO_LSB_FILE" ]
then
# should init at least LSB_VERSION
- . "$INFO_ROOT/$INFO_LSB_FILE"
+ . "$INFO_LSB_FILE"
+ fi
+ # Always look in the directories
+ if [ -d "$INFO_ROOT/$INFO_LSB_DIR" ]
+ then
+ for tag in "$INFO_ROOT/$INFO_LSB_DIR/"*
+ do
+ if [ -z "$LSB_VERSION" ]
+ then
+ LSB_VERSION=`basename $tag`
+ else
+ LSB_VERSION=$LSB_VERSION:`basename $tag`
+ fi
+ done
fi
if [ -z "$LSB_VERSION" ]
then
LSB_VERSION=$MSG_NA
- else
- # if we found LSB_VERSION, continue to look in directory
- if [ -d "$INFO_ROOT/$INFO_LSB_DIR" ]
- then
- for tag in "$INFO_ROOT/$INFO_LSB_DIR/"*
- do
- LSB_VERSION=$LSB_VERSION:`basename $tag`
- done
- fi
fi
}
# Get the whole distrib information string (from ARG $1 file)
InitDistribInfo() {
-## Notice: Debian has a debian_version file
-## (at least) Mandrake has two files, a mandrake and a redhat one
- FILENAME=$1 # CHECKFIRST or finds' result in GetDistribInfo() or ""
+ FILENAME=$1
if [ -z "$FILENAME" ]
then
if [ -f "$ALTERNATE_DISTRIB_FILE" ]
- then # For Debian only
- [ -z "$DISTRIB_ID" ] && DISTRIB_ID="$ALTERNATE_DISTRIB_NAME"
- [ -z "$DISTRIB_RELEASE" ] \
- && DISTRIB_RELEASE=$(cat $ALTERNATE_DISTRIB_FILE)
- [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.1" ] \
- && DISTRIB_CODENAME="Slink"
- [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.2" ] \
- && DISTRIB_CODENAME="Potato"
-# [ -z "$DISTRIB_CODENAME" ] && [ "$DISTRIB_RELEASE" = "2.3" ] \
-# && DISTRIB_CODENAME="Woody"
- [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$DISTRIB_RELEASE
- # build the DISTRIB_DESCRIPTION string (never need to be parsed)
- [ -z "$DISTRIB_DESCRIPTION" ] \
- && DISTRIB_DESCRIPTION="$DISTRIB_ID $DESCSTR_DELI $DISTRIB_REL\
-EASE ($DISTRIB_CODENAME)"
- else # Only for nothing known compliant distrib :(
- [ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA
- [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA
- [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA
- [ -z "$DISTRIB_DESCRIPTION" ] && DISTRIB_DESCRIPTION=$MSG_NONE
+ then
+ [ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA
+ [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA
+ [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA
+ [ -z "$DISTRIB_DESCRIPTION" ] && DISTRIB_DESCRIPTION=$MSG_NONE
- EXIT_STATUS=$ERROR_NOANSWER
+ EXIT_STATUS=$ERROR_NOANSWER
fi
else
+ source $INFO_DISTRIB_FILE
NO="" # is Description string syntax correct ?
if [ -z "$DISTRIB_DESCRIPTION" ] \
|| [ -n "$(echo $DISTRIB_DESCRIPTION | \
sed -e "s/.*$DESCSTR_DELI.*//")" ]
then
- TMP_DISTRIB_DESC=$(head -n 1 $FILENAME 2>/dev/null)
+ TMP_DISTRIB_DESC=$PRETTY_NAME
[ -z "$DISTRIB_DESCRIPTION" ] \
&& DISTRIB_DESCRIPTION=$TMP_DISTRIB_DESC
else
@@ -265,8 +220,12 @@
if [ -n "$NO" ]
then # does not contain "release" delimiter
- [ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_NA
- [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA
+ [ -z "$DISTRIB_ID" ] && DISTRIB_ID=$MSG_DISTRIBUTOR
+ if [ -z "$DISTRIB_RELEASE" ]
+ then
+ DISTRIB_RELEASE=$VERSION_ID
+ [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA
+ fi
[ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA
fi
fi
@@ -282,16 +241,7 @@
if [ -n "$NO" ]
then
- if [ ! -f "$CHECKFIRST" ]
- then
- CHECKFIRST=$(find $INFO_ROOT/ -maxdepth 1 \
- -name \*$INFO_DISTRIB_SUFFIX \
- -and ! -name $INFO_LSB_FILE \
- -and -type f \
- 2>/dev/null \
- | head -n 1 ) # keep one of the files found (if many)
- fi
- InitDistribInfo $CHECKFIRST
+ InitDistribInfo $INFO_DISTRIB_FILE
fi
}
@@ -399,7 +349,7 @@
fi
fi
-# Update args to All if requested
+# Update args to All if requested
if [ -n "$ARG_A" ]
then
[ -z "$ARG_C" ] && ARG_C="y"