This commit is contained in:
Alexander Zhirov 2023-05-09 16:07:48 +03:00
parent 04cbcd5792
commit a8991c938f
3 changed files with 579 additions and 265 deletions

View File

@ -2,8 +2,44 @@
Стек библиотеки IUP
## Download
```sh
wget https://sourceforge.net/projects/imtoolkit/files/3.15/Docs%20and%20Sources/im-3.15_Sources.tar.gz
wget https://sourceforge.net/projects/canvasdraw/files/5.14/Docs%20and%20Sources/ftgl-2.1.5_Sources.tar.gz
wget https://sourceforge.net/projects/canvasdraw/files/5.14/Docs%20and%20Sources/freetype-2.10.2_Sources.tar.gz
wget https://sourceforge.net/projects/canvasdraw/files/5.14/Docs%20and%20Sources/pdflib_lite-7.0.5_Sources.tar.gz
wget https://sourceforge.net/projects/canvasdraw/files/5.14/Docs%20and%20Sources/cd-5.14_Sources.tar.gz
wget https://sourceforge.net/projects/iup/files/3.30/Docs%20and%20Sources/iup-3.30_Sources.tar.gz
wget https://www.lua.org/ftp/lua-5.4.4.tar.gz
```
## Сборка
Экспорт переменных, где `/root/iup/` путь к репозиторию, а `Linux62_64` релиз ядра (возможен другой путь после компиляции):
```sh
export USE_PKGCONFIG=Yes
export USE_LUA_VERSION=54
export USE_LUA54=Yes
export LUA_LIB=/root/iup/lua-5.4.4/src
export LUA_INC=/root/iup/lua-5.4.4/src
export IM_LIB=/root/iup/im/lib/Linux62_64
export IM_INC=/root/iup/im/include
export FTGL_LIB=/root/iup/ftgl/lib/Linux62_64
export FTGL_INC=/root/iup/ftgl/include
export PDFLIB_LIB=/root/iup/pdflib7/lib/Linux62_64
export PDFLIB_INC=/root/iup/pdflib7/include
export CD_LIB=/root/iup/cd/lib/Linux62_64
export CD_INC=/root/iup/cd/include
```
Установить при необходимости (возможны ошибки для старых `webkit`):
```sh
export USE_GTK3=Yes
```
### lua
```sh
@ -11,4 +47,55 @@ cd lua-5.4.4
make linux
```
### pdflib7
```sh
cd pdflib7
make
```
### ftgl
```sh
cd ftgl
make
```
### fftw
Библиотеку необходимо собрать [2 раза](https://www.linuxfromscratch.org/blfs/view/stable-systemd/general/fftw.html) - для одинарной точности и двойной точности (`--enable-sse`, `--enable-float`)
```sh
cd fftw
./configure --enable-shared --enable-sse --prefix=/usr
make -j16
make install
make clean
./configure --enable-shared --enable-float --prefix=/usr
make -j16
make install
```
### im
```sh
cd im
make
```
### cd
```sh
cd cd
make
```
### iup
Применить патч для ядра Linux v6:
```sh
cd iup
git apply without-lua-prefix-with-linux6.patch
make
```

View File

@ -1,224 +1,3 @@
diff --git a/srclua5/config.mak b/srclua5/config.mak
index 77a8920..2118290 100755
--- a/srclua5/config.mak
+++ b/srclua5/config.mak
@@ -38,7 +38,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iup_mglplot.mak b/srclua5/iup_mglplot.mak
index 3c3407c..422eb8d 100755
--- a/srclua5/iup_mglplot.mak
+++ b/srclua5/iup_mglplot.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iup_plot.mak b/srclua5/iup_plot.mak
index b2af19d..0ba78fb 100755
--- a/srclua5/iup_plot.mak
+++ b/srclua5/iup_plot.mak
@@ -43,7 +43,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iup_scintilla.mak b/srclua5/iup_scintilla.mak
index 502bf59..08de8a1 100755
--- a/srclua5/iup_scintilla.mak
+++ b/srclua5/iup_scintilla.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupcd.mak b/srclua5/iupcd.mak
index 429cd3e..1ee8c72 100755
--- a/srclua5/iupcd.mak
+++ b/srclua5/iupcd.mak
@@ -44,7 +44,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupcontrols.mak b/srclua5/iupcontrols.mak
index cb00b95..492906f 100755
--- a/srclua5/iupcontrols.mak
+++ b/srclua5/iupcontrols.mak
@@ -43,7 +43,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupfiledlg.mak b/srclua5/iupfiledlg.mak
index 6c6cf98..64ca8b3 100755
--- a/srclua5/iupfiledlg.mak
+++ b/srclua5/iupfiledlg.mak
@@ -40,7 +40,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupgl.mak b/srclua5/iupgl.mak
index f633c1c..e1ae256 100755
--- a/srclua5/iupgl.mak
+++ b/srclua5/iupgl.mak
@@ -41,7 +41,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupglcontrols.mak b/srclua5/iupglcontrols.mak
index e6469f9..570d924 100755
--- a/srclua5/iupglcontrols.mak
+++ b/srclua5/iupglcontrols.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupim.mak b/srclua5/iupim.mak
index d2eb2d4..c3fc431 100755
--- a/srclua5/iupim.mak
+++ b/srclua5/iupim.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupimglib.mak b/srclua5/iupimglib.mak
index fb56ad6..08afb97 100755
--- a/srclua5/iupimglib.mak
+++ b/srclua5/iupimglib.mak
@@ -40,7 +40,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupluascripterdlg.mak b/srclua5/iupluascripterdlg.mak
index 56ae104..9132831 100755
--- a/srclua5/iupluascripterdlg.mak
+++ b/srclua5/iupluascripterdlg.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupole.mak b/srclua5/iupole.mak
index 0b625b6..75dd416 100755
--- a/srclua5/iupole.mak
+++ b/srclua5/iupole.mak
@@ -41,7 +41,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iuptuio.mak b/srclua5/iuptuio.mak
index 853430c..09ecae1 100755
--- a/srclua5/iuptuio.mak
+++ b/srclua5/iuptuio.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srclua5/iupweb.mak b/srclua5/iupweb.mak
index 9d7dff2..afe171a 100755
--- a/srclua5/iupweb.mak
+++ b/srclua5/iupweb.mak
@@ -42,7 +42,7 @@ ifdef USE_LUA54
LUASFX = 54
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
else
ifdef USE_LUA52
LUASFX = 52
diff --git a/srcluaconsole/config.mak b/srcluaconsole/config.mak
index 12baea3..8b02917 100755
--- a/srcluaconsole/config.mak
+++ b/srcluaconsole/config.mak
@@ -41,7 +41,7 @@ ifdef USE_LUA54
endif
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
ifneq ($(findstring SunOS, $(TEC_UNAME)), )
ifneq ($(findstring x86, $(TEC_UNAME)), )
FLAGS = -std=gnu99
diff --git a/srcluascripter/config.mak b/srcluascripter/config.mak
index 76300c6..a201098 100755
--- a/srcluascripter/config.mak
+++ b/srcluascripter/config.mak
@@ -38,7 +38,7 @@ ifdef USE_LUA54
endif
else
ifdef USE_LUA53
- LUASFX = 53
+# LUASFX = 53
ifneq ($(findstring SunOS, $(TEC_UNAME)), )
ifneq ($(findstring x86, $(TEC_UNAME)), )
FLAGS = -std=gnu99
diff --git a/srcvled/config.mak b/srcvled/config.mak
index d072320..9daf3e8 100755
--- a/srcvled/config.mak
@ -231,75 +10,98 @@ index d072320..9daf3e8 100755
+
INCLUDES = ../src
diff --git a/srcweb/config.mak b/srcweb/config.mak
index c528f2c..0d321a4 100755
index c528f2c..4ff9689 100755
--- a/srcweb/config.mak
+++ b/srcweb/config.mak
@@ -35,7 +35,7 @@ else
@@ -35,15 +35,20 @@ else
LINK_WEBKIT = Yes
ifdef USE_GTK3
- ifneq ($(findstring Linux5, $(TEC_UNAME)), )
+ ifneq ($(findstring Linux5, $(subst Linux6,Linux5,$(TEC_UNAME))), )
+ ifneq ($(findstring Linux6, $(TEC_UNAME)), )
DEFINES += USE_WEBKIT2
STDINCS += $(GTK)/include/webkitgtk-4.0
else
- ifneq ($(findstring Linux4, $(TEC_UNAME)), )
+ ifneq ($(findstring Linux5, $(TEC_UNAME)), )
DEFINES += USE_WEBKIT2
STDINCS += $(GTK)/include/webkitgtk-4.0
else
- STDINCS += $(GTK)/include/webkitgtk-3.0
+ ifneq ($(findstring Linux4, $(TEC_UNAME)), )
+ DEFINES += USE_WEBKIT2
+ STDINCS += $(GTK)/include/webkitgtk-4.0
+ else
+ STDINCS += $(GTK)/include/webkitgtk-3.0
+ endif
endif
endif
else
diff --git a/tecmake.mak b/tecmake.mak
index 48991a4..42d7131 100755
index 48991a4..bafe31b 100755
--- a/tecmake.mak
+++ b/tecmake.mak
@@ -297,7 +297,7 @@ endif
@@ -297,6 +297,9 @@ endif
ifdef GTK_DEFAULT
ifndef USE_GTK2
- ifneq ($(findstring Linux5, $(TEC_UNAME)), )
+ ifneq ($(findstring Linux5, $(subst Linux6,Linux5,$(TEC_UNAME))), )
+ ifneq ($(findstring Linux6, $(TEC_UNAME)), )
+ USE_GTK3 = Yes
+ endif
ifneq ($(findstring Linux5, $(TEC_UNAME)), )
USE_GTK3 = Yes
endif
ifneq ($(findstring Linux4, $(TEC_UNAME)), )
@@ -469,7 +469,7 @@ ifdef USE_LUA52
LIBLUA_SFX := 52
endif
ifdef USE_LUA53
- LIBLUA_SFX := 53
+# LIBLUA_SFX := 53
endif
ifdef USE_LUA54
LIBLUA_SFX := 54
@@ -877,8 +877,8 @@ ifdef USE_LUA52
endif
ifdef USE_LUA53
- LUA_SFX := 53
- LIBLUA_SFX := 53
+# LUA_SFX := 53
+# LIBLUA_SFX := 53
override USE_LUA = Yes
LUA := $(LUA53)
NO_LUALIB := Yes
@@ -1207,7 +1207,7 @@ ifdef USE_CD
ifneq ($(findstring Linux4, $(TEC_UNAME)), )
LIBS += fontconfig
endif
- ifneq ($(findstring Linux5, $(TEC_UNAME)), )
+ ifneq ($(findstring Linux5, $(subst Linux6,Linux5,$(TEC_UNAME))), )
@@ -1210,6 +1213,9 @@ ifdef USE_CD
ifneq ($(findstring Linux5, $(TEC_UNAME)), )
LIBS += fontconfig
endif
+ ifneq ($(findstring Linux6, $(TEC_UNAME)), )
+ LIBS += fontconfig
+ endif
ifneq ($(findstring cygw, $(TEC_UNAME)), )
@@ -1245,7 +1245,7 @@ ifdef USE_IM
LIBS += fontconfig
endif
@@ -1245,20 +1251,24 @@ ifdef USE_IM
endif
ifdef LINK_WEBKIT
- ifneq ($(findstring Linux5, $(TEC_UNAME)), )
+ ifneq ($(findstring Linux5, $(subst Linux6,Linux5,$(TEC_UNAME))), )
+ ifneq ($(findstring Linux6, $(TEC_UNAME)), )
LIBS += webkit2gtk-4.0 gio-2.0
else
ifneq ($(findstring Linux4, $(TEC_UNAME)), )
@@ -1476,7 +1476,7 @@ ifdef USE_GTK
ifneq ($(findstring FreeBSD, $(TEC_UNAME)), )
STDINCS += /lib/X11R6/include/gtk-2.0
endif
- ifneq ($(findstring Linux5, $(TEC_UNAME)), )
+ ifneq ($(findstring Linux5, $(subst Linux6,Linux5,$(TEC_UNAME))), )
- else
- ifneq ($(findstring Linux4, $(TEC_UNAME)), )
+ else
+ ifneq ($(findstring Linux5, $(TEC_UNAME)), )
LIBS += webkit2gtk-4.0 gio-2.0
else
- ifneq ($(findstring Linux3, $(TEC_UNAME)), )
- ifdef USE_GTK3
- LIBS += webkitgtk-3.0
+ ifneq ($(findstring Linux4, $(TEC_UNAME)), )
+ LIBS += webkit2gtk-4.0 gio-2.0
+ else
+ ifneq ($(findstring Linux3, $(TEC_UNAME)), )
+ ifdef USE_GTK3
+ LIBS += webkitgtk-3.0
+ else
+ LIBS += webkitgtk-1.0
+ endif
else
- LIBS += webkitgtk-1.0
+ LIBS += webkit-1.0
endif
- else
- LIBS += webkit-1.0
endif
endif
endif
@@ -1479,6 +1489,9 @@ ifdef USE_GTK
ifneq ($(findstring Linux5, $(TEC_UNAME)), )
STDINCS += /usr/include/harfbuzz
endif
+ ifneq ($(findstring Linux6, $(TEC_UNAME)), )
+ STDINCS += /usr/include/harfbuzz
+ endif
endif
endif

425
lsb_release Executable file
View File

@ -0,0 +1,425 @@
#!/bin/sh
#
# lsb_release - collect LSB conformance status about a system
#
# Copyright (C) 2000, 2002, 2004 Free Standards Group, Inc.
# Originally by Dominique MASSONIE <mdomi@users.sourceforge.net>
#
# 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" # <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
# 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 [ -f "$INFO_ROOT/$INFO_LSB_FILE" ]
then
# should init at least LSB_VERSION
. "$INFO_ROOT/$INFO_LSB_FILE"
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 ""
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