diff --git a/Makefile b/Makefile index bda71bbd..cc8e2775 100644 --- a/Makefile +++ b/Makefile @@ -5,33 +5,26 @@ RELEASE_MICRO := 11 RELEASE_NAME := dkms RELEASE_VERSION := $(RELEASE_MAJOR).$(RELEASE_MINOR).$(RELEASE_MICRO) RELEASE_STRING := $(RELEASE_NAME)-$(RELEASE_VERSION) -DIST := unstable SHELL=bash -SBIN = $(DESTDIR)/usr/sbin -ETC = $(DESTDIR)/etc/dkms -VAR = $(DESTDIR)/var/lib/dkms -MAN = $(DESTDIR)/usr/share/man/man8 -INITD = $(DESTDIR)/etc/rc.d/init.d -LIBDIR = $(DESTDIR)/usr/lib/dkms -BASHDIR = $(DESTDIR)/usr/share/bash-completion/completions -KCONF = $(DESTDIR)/etc/kernel -SHAREDIR = $(DESTDIR)/usr/share -DOCDIR = $(SHAREDIR)/doc/dkms -SYSTEMD = $(DESTDIR)/usr/lib/systemd/system +SBIN = /usr/sbin +LIBDIR = /usr/lib/dkms +KCONF = /etc/kernel +SYSTEMD = /usr/lib/systemd/system #Define the top-level build directory BUILDDIR := $(shell pwd) -TOPDIR := $(shell pwd) -.PHONY = tarball - -all: clean tarball +all: dkms dkms.8 dkms_autoinstaller dkms.service kernel_install.d_dkms kernel_postinst.d_dkms clean: -rm -rf dist/ -rm -rf dkms -rm -rf dkms.8 + -rm -rf dkms_autoinstaller + -rm -rf dkms.service + -rm -rf kernel_install.d_dkms + -rm -rf kernel_postinst.d_dkms dkms: dkms.in sed -e 's/#RELEASE_STRING#/$(RELEASE_STRING)/' $^ > $@ @@ -39,36 +32,60 @@ dkms: dkms.in dkms.8: dkms.8.in sed -e 's/#RELEASE_STRING#/$(RELEASE_STRING)/' -e 's/#RELEASE_DATE#/$(RELEASE_DATE)/' $^ > $@ -install: dkms dkms.8 - mkdir -p $(VAR) - install -D -m 0755 dkms_common.postinst $(LIBDIR)/common.postinst - install -D -m 0755 dkms $(SBIN)/dkms - install -D -m 0755 dkms_autoinstaller $(LIBDIR)/dkms_autoinstaller - install -D -m 0644 dkms_framework.conf $(ETC)/framework.conf - mkdir -p $(ETC)/framework.conf.d - install -D -m 0644 dkms.bash-completion $(BASHDIR)/dkms - install -D -m 0644 dkms.8 $(MAN)/dkms.8 - install -D -m 0755 kernel_install.d_dkms $(KCONF)/install.d/40-dkms.install - install -D -m 0755 kernel_postinst.d_dkms $(KCONF)/postinst.d/dkms - install -D -m 0755 kernel_prerm.d_dkms $(KCONF)/prerm.d/dkms - gzip -n -9 $(MAN)/dkms.8 +dkms_autoinstaller: dkms_autoinstaller.in + sed -e 's,@SBINDIR@,$(SBIN),g' $^ > $@ + +dkms.service: dkms.service.in + sed -e 's,@SBINDIR@,$(SBIN),g' $^ > $@ + +kernel_install.d_dkms: kernel_install.d_dkms.in + sed -e 's,@KCONFDIR@,$(KCONF),g' $^ > $@ + +kernel_postinst.d_dkms: kernel_postinst.d_dkms.in + sed -e 's,@LIBDIR@,$(LIBDIR),g' $^ > $@ + +install: all + $(if $(strip $(VAR)),$(error Setting VAR is not supported)) + install -d -m 0755 $(DESTDIR)/var/lib/dkms +ifneq (,$(DESTDIR)) + $(if $(filter $(DESTDIR)%,$(SBIN)),$(error Using a DESTDIR as prefix for SBIN is no longer supported)) + $(if $(filter $(DESTDIR)%,$(LIBDIR)),$(error Using a DESTDIR as prefix for LIBDIR is no longer supported)) + $(if $(filter $(DESTDIR)%,$(KCONF)),$(error Using a DESTDIR as prefix for KCONF is no longer supported)) +endif + install -D -m 0755 dkms $(DESTDIR)$(SBIN)/dkms + install -D -m 0755 dkms_common.postinst $(DESTDIR)$(LIBDIR)/common.postinst + install -D -m 0755 dkms_autoinstaller $(DESTDIR)$(LIBDIR)/dkms_autoinstaller + $(if $(strip $(ETC)),$(error Setting ETC is not supported)) + install -D -m 0644 dkms_framework.conf $(DESTDIR)/etc/dkms/framework.conf + install -d -m 0755 $(DESTDIR)/etc/dkms/framework.conf.d + $(if $(strip $(BASHDIR)),$(error Setting BASHDIR is not supported)) + install -D -m 0644 dkms.bash-completion $(DESTDIR)/usr/share/bash-completion/completions/dkms + install -D -m 0644 dkms.8 $(DESTDIR)/usr/share/man/man8/dkms.8 + install -D -m 0755 kernel_install.d_dkms $(DESTDIR)$(KCONF)/install.d/40-dkms.install + install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/postinst.d/dkms + install -D -m 0755 kernel_prerm.d_dkms $(DESTDIR)$(KCONF)/prerm.d/dkms install-redhat: install - install -D -m 0755 dkms_find-provides $(LIBDIR)/find-provides - install -D -m 0755 lsb_release $(LIBDIR)/lsb_release - install -D -m 0644 dkms.service $(SYSTEMD)/dkms.service +ifneq (,$(DESTDIR)) + $(if $(filter $(DESTDIR)%,$(SYSTEMD)),$(error Using a DESTDIR as prefix for SYSTEMD is no longer supported)) +endif + install -D -m 0644 dkms.service $(DESTDIR)$(SYSTEMD)/dkms.service install-debian: install - install -D -m 0755 dkms_apport.py $(SHAREDIR)/apport/package-hooks/dkms_packages.py - install -D -m 0755 kernel_postinst.d_dkms $(KCONF)/header_postinst.d/dkms + $(if $(strip $(SHAREDIR)),$(error Setting SHAREDIR is not supported)) + install -D -m 0755 dkms_apport.py $(DESTDIR)/usr/share/apport/package-hooks/dkms_packages.py + install -D -m 0755 kernel_postinst.d_dkms $(DESTDIR)$(KCONF)/header_postinst.d/dkms install-doc: - install -d -m 0644 COPYING $(DOCDIR) - install -d -m 0644 README.md $(DOCDIR) + $(if $(strip $(DOC)),$(error Setting DOCDIR is not supported)) + install -d -m 0755 $(DESTDIR)/usr/share/doc/dkms + install -m 0644 COPYING README.md $(DESTDIR)/usr/share/doc/dkms + +.PHONY = tarball TARBALL=$(BUILDDIR)/dist/$(RELEASE_STRING).tar.gz tarball: $(TARBALL) -$(TARBALL): dkms dkms.8 +$(TARBALL): all mkdir -p $(@D) git archive --prefix=$(RELEASE_STRING)/ --add-file=dkms --add-file=dkms.8 -o $@ HEAD diff --git a/dkms.8.in b/dkms.8.in index 6bfc5aa3..a228f8c3 100644 --- a/dkms.8.in +++ b/dkms.8.in @@ -595,17 +595,6 @@ This also introduces a implicit distribution/version dependency on the package, as the value of .B OBSOLETE_BY is meaningful only in the context of a single distribution/version. - -If you feel you must use it, please use as such in dkms.conf: - - ubuntu_804="Ubuntu - 8.04" - if [ \-x /usr/bin/lsb_release ]; then - if [ "$(/usr/bin/lsb_release \-sir)" == "${ubuntu_804}" ]; then - OBSOLETE_BY="2.6.25" - fi - fi - .TP .B PATCH[#]= Use the PATCH directive array to specify patches which should be applied to your source before a build occurs. diff --git a/dkms.in b/dkms.in index ef94ad19..2b55582c 100644 --- a/dkms.in +++ b/dkms.in @@ -327,10 +327,10 @@ do_depmod() } # Grab distro information from os-release. -# Falls back to LSB for compliant distros. distro_version() { - if [[ -r /etc/os-release ]]; then + [[ -r /etc/os-release ]] || die 4 $"System is missing /etc/os-release file." + ( . /etc/os-release if [[ "$ID" = "ubuntu" ]]; then # ID_LIKE=debian in ubuntu @@ -340,36 +340,7 @@ distro_version() else echo $ID fi - return - fi - - local DISTRIB_ID - - # Try the LSB-provided strings first - if [ -r /etc/lsb-release ]; then - . /etc/lsb-release - elif type lsb_release >/dev/null 2>&1; then - DISTRIB_ID=$(lsb_release -i -s) - fi - - case ${DISTRIB_ID} in - Fedora) - echo fedora - ;; - RedHatEnterprise*|CentOS|ScientificSL) - echo rhel - ;; - SUSE*) - echo sles - ;; - *) - if [[ ${DISTRIB_ID} ]]; then - echo "${DISTRIB_ID}" - else - echo unknown - fi - ;; - esac + ) } override_dest_module_location() @@ -2339,9 +2310,6 @@ autoinstall() { #### #### ############################# -# Set a standard path -PATH="$PATH:/usr/lib/dkms" - # Ensure files and directories we create are readable to anyone, # since we aim to build as a non-root user umask 022 diff --git a/dkms.service b/dkms.service.in similarity index 78% rename from dkms.service rename to dkms.service.in index f4c39fb3..7c55819e 100644 --- a/dkms.service +++ b/dkms.service.in @@ -6,7 +6,7 @@ Before=network-pre.target graphical.target [Service] Type=oneshot RemainAfterExit=true -ExecStart=/usr/sbin/dkms autoinstall --verbose --kernelver %v +ExecStart=@SBINDIR@/dkms autoinstall --verbose --kernelver %v [Install] WantedBy=multi-user.target diff --git a/dkms_autoinstaller b/dkms_autoinstaller.in similarity index 99% rename from dkms_autoinstaller rename to dkms_autoinstaller.in index 4dcfa39f..10c93484 100755 --- a/dkms_autoinstaller +++ b/dkms_autoinstaller.in @@ -31,7 +31,7 @@ if [ ! -f /etc/debian_version ]; then alias log_action_msg=/bin/echo fi -exec="/usr/sbin/dkms" +exec="@SBINDIR@/dkms" prog=${exec##*/} test -f $exec || exit 0 diff --git a/dkms_common.postinst b/dkms_common.postinst index eb650dad..52fb3a49 100644 --- a/dkms_common.postinst +++ b/dkms_common.postinst @@ -201,16 +201,6 @@ echo "Building for $KERNELS" | tr '\n' ',' \ | sed -e 's/,/, /g; s/, $/\n/; s/, \([^,]\+\)$/ and \1/' if [ -n "$ARCH" ]; then - if which lsb_release >/dev/null && [ $(lsb_release -s -i) = "Ubuntu" ]; then - case $ARCH in - amd64) - ARCH="x86_64" - ;; - lpia|i?86) - ARCH="i686" - ;; - esac - fi echo "Building for architecture $ARCH" ARCH="-a $ARCH" fi diff --git a/dkms_find-provides b/dkms_find-provides deleted file mode 100755 index 97532165..00000000 --- a/dkms_find-provides +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash - -# heavily based upon find-suggests.ksyms by Andreas Gruenbacher . -# with modifications by Michael Brown -# -# -- added module versioning info to modalias() symbols -# -- removed code which inspects spec files. - -IFS=$'\n' - -print_modaliases() { - declare class=$1 variants=$2 pos=$3 - if [ -n "$variants" ]; then - echo "${class:0:pos}[$variants]${class:pos+1}" - else - [ -z "$class" ] || echo "$class" - fi -} - -combine_modaliases() { - declare tag class variants pos n - read class - while read tag; do - for ((n=0; n<${#class}; n++)); do - if [ "*" != "${class:n:1}" -a \ - "${class:0:n}" = "${tag:0:n}" -a \ - "${class:n+1}" = "${tag:n+1}" ] && - ( [ -z "$pos" ] || [ $n = $pos ] ); then - variants="${variants:-${class:n:1}}${tag:n:1}" - pos=$n - break - fi - done - if [ $n -eq ${#class} ]; then - print_modaliases "$class" "$variants" "$pos" - variants= - pos= - class=$tag - fi - done - print_modaliases "$class" "$variants" "$pos" -} - -get_modinfo() { - module=$1 - - # | head -n1 because some modules have *two* version tags. *cough*b44*cough* - modver=$(/sbin/modinfo -F version "$module"| head -n1) - modver=${modver// /_} - - # only add version tag if it has a version - if [ -n "$modver" ]; then - /sbin/modinfo -F alias "$module" \ - | sed -nre "s,(.+),modalias(\\1) = $modver,p" - else - /sbin/modinfo -F alias "$module" \ - | sed -nre "s,(.+),modalias(\\1),p" - fi -} - - -tmp=${TMPDIR:-/tmp} -TMPDIR=$(mktemp -d ${tmp}/dkms-findprovides-$$-$RANDOM-XXXXXX) -trap "rm -rf $TMPDIR >/dev/null 2>&1" QUIT EXIT HUP INT TERM - -modlist= -for cand in $(grep -E '(/lib/modules/.+\.ko$|tgz$|tbz$|tar\.(gz|bz2|xz)$)') $*; do - if echo $cand | grep -q -E '/lib/modules/.+\.ko$' > /dev/null 2>&1; then - modlist="$modlist $cand" - fi - - [ -f $cand ] || continue - - opts=x - if gzip -t $cand >/dev/null 2>&1; then - opts=${opts}z - elif bzip2 -t $cand >/dev/null 2>&1; then - opts=${opts}j - elif xz -t $cand >/dev/null 2>&1; then - opts=${opts}J - fi - tar ${opts}f $cand -C $TMPDIR > /dev/null 2>&1 -done - -for module in $(find $TMPDIR -name \*.ko) $modlist; do - if echo $module | grep -q -E '.ko$' >/dev/null 2>&1; then - # it is a straight module - get_modinfo $module - continue - fi -done \ -| sort -u \ -| combine_modaliases diff --git a/kernel_install.d_dkms b/kernel_install.d_dkms.in similarity index 52% rename from kernel_install.d_dkms rename to kernel_install.d_dkms.in index ae231564..35c004b0 100755 --- a/kernel_install.d_dkms +++ b/kernel_install.d_dkms.in @@ -1,9 +1,9 @@ #!/bin/sh if [ "$1" = "add" ]; then - /etc/kernel/postinst.d/dkms "$2" + @KCONFDIR@/postinst.d/dkms "$2" fi if [ "$1" = "remove" ]; then - /etc/kernel/prerm.d/dkms "$2" + @KCONFDIR@/prerm.d/dkms "$2" fi diff --git a/kernel_postinst.d_dkms b/kernel_postinst.d_dkms.in similarity index 90% rename from kernel_postinst.d_dkms rename to kernel_postinst.d_dkms.in index c0b9cda0..82fcfff1 100755 --- a/kernel_postinst.d_dkms +++ b/kernel_postinst.d_dkms.in @@ -34,8 +34,8 @@ case "${uname_s}" in ;; esac -if [ -x /usr/lib/dkms/dkms_autoinstaller ]; then - exec /usr/lib/dkms/dkms_autoinstaller start "$inst_kern" +if [ -x @LIBDIR@/dkms_autoinstaller ]; then + exec @LIBDIR@/dkms_autoinstaller start "$inst_kern" fi if ! _check_kernel_dir "$inst_kern" ; then diff --git a/lsb_release b/lsb_release deleted file mode 100755 index 5333f73d..00000000 --- a/lsb_release +++ /dev/null @@ -1,415 +0,0 @@ -#!/bin/sh -# -# lsb_release - collect LSB conformance status about a system -# -# Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc. -# Originally by Dominique MASSONIE -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# 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 - - -############################################################################### -# DECLARATIONS -############################################################################### - -# This script version -SCRIPTVERSION="2.0" - -# 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 - -# Defines our exit codes -EXIT_STATUS="0" # default = Ok :) -ERROR_UNKNOWN="10" # unknown error -ERROR_USER="1" # program misuse -ERROR_PROGRAM="2" # internal error -ERROR_NOANSWER="3" # all required info not available - # typically non LSB compliant distro! - -# Defines our messages -MSG_LSBVER="LSB Version:\t" -MSG_DISTID="Distributor ID:\t" -MSG_DISTDESC="Description:\t" -MSG_DISTREL="Release:\t" -MSG_DISTCODE="Codename:\t" -MSG_NA="n/a" -MSG_NONE="(none)" -MSG_RESULT="" # contains the result in case short output selected - -# Description string delimiter -DESCSTR_DELI="release" - - -############################################################################### -# FUNCTIONS -############################################################################### - -# Display Program Version for internal use (needed by help2man) -DisplayProgramVersion() { - echo "FSG $(basename $0) v$SCRIPTVERSION" - echo - echo "Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc." - echo "This is free software; see the source for copying conditions. There\ - is NO" - echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR\ - PURPOSE." - echo - echo "Originally written by Dominique MASSONIE." - - exit $EXIT_STATUS -} - -# defines the Usage for lsb_release -Usage() { - echo "FSG $(basename $0) v$SCRIPTVERSION prints certain LSB (Linux\ - Standard Base) and" - echo "Distribution information." - echo - echo "Usage: $(basename $0) [OPTION]..." - echo "With no OPTION specified defaults to -v." - echo - echo "Options:" - echo " -v, --version" - echo " Display the version of the LSB specification against which the distribution is compliant." - echo " -i, --id" - echo " Display the string id of the distributor." - echo " -d, --description" - echo " Display the single line text description of the distribution." - echo " -r, --release" - echo " Display the release number of the distribution." - echo " -c, --codename" - echo " Display the codename according to the distribution release." - echo " -a, --all" - echo " Display all of the above information." - echo " -s, --short" - echo " Use short output format for information requested by other options (or version if none)." - echo " -h, --help" - echo " Display this message." - - exit $EXIT_STATUS -} - -# Handles the enhanced args (i.e. --something) -EnhancedGetopt() { - getopt -T >/dev/null 2>&1 # is getopt the enhanced one ? - if [ $? = 4 ] - then # Yes, advanced args ALLOWED - OPT=$(getopt -o acdhirsvp \ ---long all,codename,description,help,id,release,short,version,program_version \ - -n 'lsb_release' \ - -- "$@") - else # No, advanced args NOT allowed - # convert (if needed) the enhanced options into basic ones - MYARGS=$(echo "$@" | sed -e "/--/s/-\(-[[:alnum:]]\)[[:alnum:]]*/\1/g") - OPT=$(getopt -o acdhirsvp \ - -n 'lsb_release' \ - -- "$MYARGS") - fi - if [ $? != 0 ] - then - exit $ERROR_PROGRAM - fi - - NB_ARG="" # enabled if many args set in one parameter (i.e. -dris) - eval set -- "$OPT" - while true ; do - case "$1" in - -a|--all) ARG_A="y"; NB_ARG="y"; shift;; - -c|--codename) ARG_C="y"; NB_ARG="y"; shift;; - -d|--description) ARG_D="y"; NB_ARG="y"; shift;; - -i|--id) ARG_I="y"; NB_ARG="y"; shift;; - -r|--release) ARG_R="y"; NB_ARG="y"; shift;; - -s|--short) ARG_S="y"; shift;; - -v|--version) ARG_V="y"; NB_ARG="y"; shift;; - -p|--program_version) DisplayProgramVersion;; - -h|--help) Usage;; - --) shift; break;; - *) EXIT_STATUS=$ERROR_USER - Usage;; - esac - done -} - -# Get/Init LSB infos (maybe Distrib infos too) -GetLSBInfo() { - # 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 -} - -# 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 "" - - 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 - - EXIT_STATUS=$ERROR_NOANSWER - fi - else - 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) - [ -z "$DISTRIB_DESCRIPTION" ] \ - && DISTRIB_DESCRIPTION=$TMP_DISTRIB_DESC - else - TMP_DISTRIB_DESC=$DISTRIB_DESCRIPTION - fi - - if [ -z "$TMP_DISTRIB_DESC" ] # head or lsb-release init - then # file contains no data - DISTRIB_DESCRIPTION=$MSG_NONE - NO="y" - else # Do simple check - [ -n "$(echo $TMP_DISTRIB_DESC | \ - sed -e "s/.*$DESCSTR_DELI.*//")" ] \ - && NO="y" - fi - - 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_CODENAME" ] && DISTRIB_CODENAME=$MSG_NA - fi - fi -} - -# Check missing and requested infos, then find the file and get infos -GetDistribInfo() { - NO="" # /etc/lsb-release data are enough to reply what is requested? - [ -n "$ARG_D" ] && [ -z "$DISTRIB_DESCRIPTION" ] && NO="y" - [ -z "$NO" ] && [ -n "$ARG_I" ] && [ -z "$DISTRIB_ID" ] && NO="y" - [ -z "$NO" ] && [ -n "$ARG_R" ] && [ -z "$DISTRIB_RELEASE" ] && NO="y" - [ -z "$NO" ] && [ -n "$ARG_C" ] && [ -z "$DISTRIB_CODENAME" ] && NO="y" - - 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 - fi -} - -# Display version of LSB against which distribution is compliant -DisplayVersion() { - if [ -z "$ARG_S" ] - then - echo -e "$MSG_LSBVER$LSB_VERSION" # at least "n/a" - else - MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$LSB_VERSION" - fi -} - -# Display string id of distributor ( i.e. a single word! ) -DisplayID() { - if [ -z "$DISTRIB_ID" ] - then -## Linux could be part of the distro name (i.e. Turbolinux) or a separate word -## set before, after... -## also expect a delimiter ( i.e. "release" ) - if [ -n "$(echo $TMP_DISTRIB_DESC | sed "s/.*$DESCSTR_DELI.*//")" ] - then - DISTRIB_ID=$MSG_NA - else - DISTRIB_ID=$(echo " $TMP_DISTRIB_DESC" \ - | sed -e "s/[[:blank:]][Ll][Ii][Nn][Uu][Xx][[:blank:]]/ /g" \ - -e "s/\(.*\)[[:blank:]]$DESCSTR_DELI.*/\1/" -e "s/[[:blank:]]//g") - fi - fi - if [ -z "$ARG_S" ] - then - echo -e "$MSG_DISTID$DISTRIB_ID" - else - MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$DISTRIB_ID" - fi -} - -# Diplay single line text description of distribution -DisplayDescription() { - if [ -z "$DISTRIB_DESCRIPTION" ] - then - # should not be empty since GetDistribInfo called on Initialization ! - EXIT_STATUS=$ERROR_PROGRAM - fi - if [ -z "$ARG_S" ] - then - echo -e "$MSG_DISTDESC$DISTRIB_DESCRIPTION" - else - MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }\"$DISTRIB_DESCRIPTION\"" - fi -} - -# Display release number of distribution. -DisplayRelease() { - if [ -z "$DISTRIB_RELEASE" ] - then # parse the "$DISTRIB_DESCRIPTION" string - DISTRIB_RELEASE=$(echo "$TMP_DISTRIB_DESC" | \ - sed -e "s/.*$DESCSTR_DELI[[:blank:]]*\([[:digit:]][[:graph:]]*\).*/\1/" ) - [ "$DISTRIB_RELEASE" = "$TMP_DISTRIB_DESC" ] \ - || [ -z "$DISTRIB_RELEASE" ] \ - && DISTRIB_RELEASE=$MSG_NA - fi - if [ -z "$ARG_S" ] - then - echo -e "$MSG_DISTREL$DISTRIB_RELEASE" - else - MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$DISTRIB_RELEASE" - fi -} - -# Display codename according to distribution version. -DisplayCodename() { - if [ -z "$DISTRIB_CODENAME" ] - then # parse the "$DISTRIB_DESCRIPTION" string - DISTRIB_CODENAME=$(echo "$TMP_DISTRIB_DESC" | \ - sed -e "s/.*$DESCSTR_DELI.*(\(.*\)).*/\1/") - [ "$DISTRIB_CODENAME" = "$TMP_DISTRIB_DESC" ] \ - || [ -z "$DISTRIB_CODENAME" ] \ - && DISTRIB_CODENAME=$MSG_NA - fi - if [ -z "$ARG_S" ] - then - echo -e "$MSG_DISTCODE$(echo "$DISTRIB_CODENAME" | \ - tr -d "[:blank:]")" # Remove blanks - else - MSG_RESULT="$MSG_RESULT${MSG_RESULT:+ }$(echo "$DISTRIB_CODENAME" | \ - tr -d "[:blank:]")" - fi -} - - -############################################################################### -# MAIN -############################################################################### - -# Check if any prog argument -if [ -z "$1" ] -then - ARG_V="y" # default set to Display LSB Version (not Usage) -else - EnhancedGetopt "$@" # Parse program args - if [ -n "$ARG_S" ] && [ -z "$NB_ARG" ] - then - ARG_V="y" # set also default for --short when single arg - fi -fi - -# Update args to All if requested -if [ -n "$ARG_A" ] -then - [ -z "$ARG_C" ] && ARG_C="y" - [ -z "$ARG_D" ] && ARG_D="y" - [ -z "$ARG_I" ] && ARG_I="y" - [ -z "$ARG_R" ] && ARG_R="y" - [ -z "$ARG_V" ] && ARG_V="y" -fi - -# Initialization -GetLSBInfo -GetDistribInfo - -# Display requested infos (order as follow) -[ -n "$ARG_V" ] && DisplayVersion -[ -n "$ARG_I" ] && DisplayID -[ -n "$ARG_D" ] && DisplayDescription -[ -n "$ARG_R" ] && DisplayRelease -[ -n "$ARG_C" ] && DisplayCodename - -[ -n "$ARG_S" ] && echo "$MSG_RESULT" - -exit $EXIT_STATUS