--- lsb_release +++ lsb_release 2004/07/20 11:49:19 @@ -4,6 +4,7 @@ # # Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc. # Originally by Dominique MASSONIE +# 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" # - -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/SuSE-release" # - # 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 LINUX" # 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,10 +154,10 @@ # Get/Init LSB infos (maybe Distrib infos too) GetLSBInfo() { - if [ -f "$INFO_ROOT/$INFO_LSB_FILE" ] + if [ -f "$INFO_LSB_FILE" ] then # should init at least LSB_VERSION - . "$INFO_ROOT/$INFO_LSB_FILE" + . "$INFO_LSB_FILE" fi if [ -z "$LSB_VERSION" ] then @@ -210,35 +176,18 @@ # 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 NO="" # is Description string syntax correct ? @@ -265,8 +214,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=$(grep ^VERSION $FILENAME | cut "-d " -f 3) + [ -z "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=$MSG_NA + fi [ -z "$DISTRIB_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA fi fi @@ -282,16 +235,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 +343,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"