Commit 546b737b authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info: replace tab with 4 spaces

parent b9dbd9ab
......@@ -13,17 +13,17 @@ PROGVERSION="20230406"
# Check for DISTRO specific file in /etc
distro()
{
#[ -n "$ROOTDIR" ] || return
# fill global DISTROFILE
DISTROFILE="$ROOTDIR/etc/$1"
[ -f "$DISTROFILE" ]
#[ -n "$ROOTDIR" ] || return
# fill global DISTROFILE
DISTROFILE="$ROOTDIR/etc/$1"
[ -f "$DISTROFILE" ]
}
# Has a distro file the specified word?
has()
{
[ -n "$DISTROFILE" ] || exit 1
grep "$*" "$DISTROFILE" >/dev/null 2>&1
[ -n "$DISTROFILE" ] || exit 1
grep "$*" "$DISTROFILE" >/dev/null 2>&1
}
# copied from epm-sh-functions
......@@ -57,59 +57,59 @@ is_command()
firstupper()
{
# FIXME: works with GNU sed only
echo "$*" | sed 's/.*/\u&/'
# FIXME: works with GNU sed only
echo "$*" | sed 's/.*/\u&/'
}
tolower()
{
# tr is broken in busybox (checked with OpenWrt)
#echo "$*" | tr "[:upper:]" "[:lower:]"
echo "$*" | awk '{print tolower($0)}'
# tr is broken in busybox (checked with OpenWrt)
#echo "$*" | tr "[:upper:]" "[:lower:]"
echo "$*" | awk '{print tolower($0)}'
}
print_bug_report_url()
{
echo "$BUG_REPORT_URL"
echo "$BUG_REPORT_URL"
}
override_distrib()
{
[ -n "$1" ] || return
VENDOR_ID=''
PRETTY_NAME=''
local name="$(echo "$1" | sed -e 's|x86_64/||')"
[ "$name" = "$1" ] && DIST_ARCH="x86" || DIST_ARCH="x86_64"
DISTRIB_ID="$(echo "$name" | sed -e 's|/.*||')"
DISTRO_NAME="$DISTRIB_ID"
DISTRIB_RELEASE="$(echo "$name" | sed -e 's|.*/||')"
[ "$DISTRIB_ID" = "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=''
DISTRIB_CODENAME="$DISTRIB_RELEASE"
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
[ -n "$1" ] || return
VENDOR_ID=''
PRETTY_NAME=''
local name="$(echo "$1" | sed -e 's|x86_64/||')"
[ "$name" = "$1" ] && DIST_ARCH="x86" || DIST_ARCH="x86_64"
DISTRIB_ID="$(echo "$name" | sed -e 's|/.*||')"
DISTRO_NAME="$DISTRIB_ID"
DISTRIB_RELEASE="$(echo "$name" | sed -e 's|.*/||')"
[ "$DISTRIB_ID" = "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=''
DISTRIB_CODENAME="$DISTRIB_RELEASE"
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
}
# Translate DISTRIB_ID to vendor name (like %_vendor does or package release name uses), uses VENDOR_ID by default
pkgvendor()
{
[ "$DISTRIB_ID" = "ALTLinux" ] && echo "alt" && return
[ "$DISTRIB_ID" = "ALTServer" ] && echo "alt" && return
[ "$DISTRIB_ID" = "MOC" ] && echo "alt" && return
[ "$DISTRIB_ID" = "MESh" ] && echo "alt" && return
[ "$DISTRIB_ID" = "AstraLinuxSE" ] && echo "astra" && return
[ "$DISTRIB_ID" = "AstraLinuxCE" ] && echo "astra" && return
[ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return
[ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return
[ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return
[ "$DISTRIB_ID" = "OpenSUSE" ] && echo "suse" && return
[ "$DISTRIB_ID" = "openSUSETumbleweed" ] && echo "suse" && return
[ "$DISTRIB_ID" = "openSUSELeap" ] && echo "suse" && return
if [ -n "$VENDOR_ID" ] ; then
[ "$VENDOR_ID" = "altlinux" ] && echo "alt" && return
echo "$VENDOR_ID"
return
fi
tolower "$DISTRIB_ID"
[ "$DISTRIB_ID" = "ALTLinux" ] && echo "alt" && return
[ "$DISTRIB_ID" = "ALTServer" ] && echo "alt" && return
[ "$DISTRIB_ID" = "MOC" ] && echo "alt" && return
[ "$DISTRIB_ID" = "MESh" ] && echo "alt" && return
[ "$DISTRIB_ID" = "AstraLinuxSE" ] && echo "astra" && return
[ "$DISTRIB_ID" = "AstraLinuxCE" ] && echo "astra" && return
[ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return
[ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return
[ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return
[ "$DISTRIB_ID" = "OpenSUSE" ] && echo "suse" && return
[ "$DISTRIB_ID" = "openSUSETumbleweed" ] && echo "suse" && return
[ "$DISTRIB_ID" = "openSUSELeap" ] && echo "suse" && return
if [ -n "$VENDOR_ID" ] ; then
[ "$VENDOR_ID" = "altlinux" ] && echo "alt" && return
echo "$VENDOR_ID"
return
fi
tolower "$DISTRIB_ID"
}
# TODO: in more appropriate way
......@@ -121,109 +121,109 @@ pkgmanager()
local CMD
# FIXME: some problems with multibased distros (Server Edition on CentOS and Desktop Edition on Ubuntu)
case $DISTRIB_ID in
ALTLinux|ALTServer)
#which ds-install 2>/dev/null >/dev/null && CMD=deepsolver-rpm
#which pkcon 2>/dev/null >/dev/null && CMD=packagekit-rpm
CMD="apt-rpm"
;;
ALTServer)
CMD="apt-rpm"
;;
PCLinux)
CMD="apt-rpm"
;;
Ubuntu|Debian|Mint|OSNovaLinux|AstraLinux*|Elbrus)
CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
#is_command snappy && CMD=snappy
;;
Solus)
CMD="eopkg"
;;
Mandriva)
CMD="urpm-rpm"
;;
ROSA)
CMD="urpm-rpm"
is_command yum && CMD="yum-rpm"
is_command dnf && CMD="dnf-rpm"
# use dnf since 2020
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;;
FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc"
is_command pkg && CMD=pkgng
;;
Gentoo)
CMD="emerge"
;;
ArchLinux)
CMD="pacman"
;;
Fedora|CentOS|OracleLinux|RockyLinux|AlmaLinux|RHEL|RELS|Scientific|GosLinux|Amzn|RedOS)
CMD="dnf-rpm"
is_command dnf || CMD="yum-rpm"
[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "CentOS/7" ] && CMD="yum-rpm"
;;
Slackware)
CMD="slackpkg"
;;
SUSE|SLED|SLES|openSUSETumbleweed|openSUSELeap)
CMD="zypper-rpm"
;;
ForesightLinux|rPathLinux)
CMD="conary"
;;
Windows)
CMD="appget"
is_command $CMD || CMD="chocolatey"
is_command $CMD || CMD="winget"
;;
MacOS)
CMD="homebrew"
;;
OpenWrt)
CMD="opkg"
;;
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
Cygwin)
CMD="aptcyg"
;;
alpine)
CMD="apk"
;;
TinyCoreLinux)
CMD="tce"
;;
VoidLinux)
CMD="xbps"
;;
*)
# try detect firstly
if grep -q "ID_LIKE=debian" /etc/os-release 2>/dev/null ; then
echo "apt-dpkg" && return
fi
if is_command "rpm" && [ -s /var/lib/rpm/Name ] || [ -s /var/lib/rpm/rpmdb.sqlite ] ; then
is_command "zypper" && echo "zypper-rpm" && return
is_command "dnf" && echo "dnf-rpm" && return
is_command "apt-get" && echo "apt-rpm" && return
is_command "yum" && echo "yum-rpm" && return
is_command "urpmi" && echo "urpm-rpm" && return
fi
if is_command "dpkg" && [ -s /var/lib/dpkg/status ] ; then
is_command "apt" && echo "apt-dpkg" && return
is_command "apt-get" && echo "apt-dpkg" && return
fi
echo "We don't support yet DISTRIB_ID $DISTRIB_ID" >&2
;;
ALTLinux|ALTServer)
#which ds-install 2>/dev/null >/dev/null && CMD=deepsolver-rpm
#which pkcon 2>/dev/null >/dev/null && CMD=packagekit-rpm
CMD="apt-rpm"
;;
ALTServer)
CMD="apt-rpm"
;;
PCLinux)
CMD="apt-rpm"
;;
Ubuntu|Debian|Mint|OSNovaLinux|AstraLinux*|Elbrus)
CMD="apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
#is_command snappy && CMD=snappy
;;
Solus)
CMD="eopkg"
;;
Mandriva)
CMD="urpm-rpm"
;;
ROSA)
CMD="urpm-rpm"
is_command yum && CMD="yum-rpm"
is_command dnf && CMD="dnf-rpm"
# use dnf since 2020
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;;
FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc"
is_command pkg && CMD=pkgng
;;
Gentoo)
CMD="emerge"
;;
ArchLinux)
CMD="pacman"
;;
Fedora|CentOS|OracleLinux|RockyLinux|AlmaLinux|RHEL|RELS|Scientific|GosLinux|Amzn|RedOS)
CMD="dnf-rpm"
is_command dnf || CMD="yum-rpm"
[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "CentOS/7" ] && CMD="yum-rpm"
;;
Slackware)
CMD="slackpkg"
;;
SUSE|SLED|SLES|openSUSETumbleweed|openSUSELeap)
CMD="zypper-rpm"
;;
ForesightLinux|rPathLinux)
CMD="conary"
;;
Windows)
CMD="appget"
is_command $CMD || CMD="chocolatey"
is_command $CMD || CMD="winget"
;;
MacOS)
CMD="homebrew"
;;
OpenWrt)
CMD="opkg"
;;
GNU/Linux/Guix)
CMD="guix"
;;
Android)
CMD="android"
;;
Cygwin)
CMD="aptcyg"
;;
alpine)
CMD="apk"
;;
TinyCoreLinux)
CMD="tce"
;;
VoidLinux)
CMD="xbps"
;;
*)
# try detect firstly
if grep -q "ID_LIKE=debian" /etc/os-release 2>/dev/null ; then
echo "apt-dpkg" && return
fi
if is_command "rpm" && [ -s /var/lib/rpm/Name ] || [ -s /var/lib/rpm/rpmdb.sqlite ] ; then
is_command "zypper" && echo "zypper-rpm" && return
is_command "dnf" && echo "dnf-rpm" && return
is_command "apt-get" && echo "apt-rpm" && return
is_command "yum" && echo "yum-rpm" && return
is_command "urpmi" && echo "urpm-rpm" && return
fi
if is_command "dpkg" && [ -s /var/lib/dpkg/status ] ; then
is_command "apt" && echo "apt-dpkg" && return
is_command "apt-get" && echo "apt-dpkg" && return
fi
echo "We don't support yet DISTRIB_ID $DISTRIB_ID" >&2
;;
esac
echo "$CMD"
}
......@@ -233,89 +233,89 @@ pkgtype()
{
# TODO: try use generic names
case $(pkgvendor) in
freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;;
archlinux|manjaro) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
alpine) echo "apk" ;;
tinycorelinux) echo "tcz" ;;
voidlinux) echo "xbps" ;;
openwrt) echo "ipk" ;;
cygwin) echo "tar.xz" ;;
solus) echo "eopkg" ;;
*)
case $(pkgmanager) in
*-dpkg)
echo "deb" ;;
*-rpm)
echo "rpm" ;;
*)
echo "rpm" ;;
esac
esac
freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;;
archlinux|manjaro) echo "pkg.tar.xz" ;;
gentoo) echo "tbz2" ;;
windows) echo "exe" ;;
android) echo "apk" ;;
alpine) echo "apk" ;;
tinycorelinux) echo "tcz" ;;
voidlinux) echo "xbps" ;;
openwrt) echo "ipk" ;;
cygwin) echo "tar.xz" ;;
solus) echo "eopkg" ;;
*)
case $(pkgmanager) in
*-dpkg)
echo "deb" ;;
*-rpm)
echo "rpm" ;;
*)
echo "rpm" ;;
esac
esac
}
print_codename()
{
echo "$DISTRIB_CODENAME"
echo "$DISTRIB_CODENAME"
}
print_repo_name()
{
echo "$DISTRIB_CODENAME"
echo "$DISTRIB_CODENAME"
}
get_var()
{
# get first variable and print it out, drop quotes if exists
grep -i "^$1 *=" | head -n 1 | sed -e "s/^[^=]*[ \t]*=[ \t]*//" | sed -e "s/^[\'\"]\(.*\)[\'\"]/\1/"
# get first variable and print it out, drop quotes if exists
grep -i "^$1 *=" | head -n 1 | sed -e "s/^[^=]*[ \t]*=[ \t]*//" | sed -e "s/^[\'\"]\(.*\)[\'\"]/\1/"
}
# 2010.1 -> 2010
get_major_version()
{
echo "$1" | sed -e "s/\..*//g"
echo "$1" | sed -e "s/\..*//g"
}
normalize_name()
{
case "$1" in
"RED OS")
echo "RedOS"
;;
"Debian GNU/Linux")
echo "Debian"
;;
"CentOS Linux")
echo "CentOS"
;;
"Fedora Linux")
echo "Fedora"
;;
"Red Hat Enterprise Linux Server")
echo "RHEL"
;;
"ROSA Fresh"*|"ROSA Desktop Fresh"*)
echo "ROSA"
;;
"ROSA Chrome Desktop")
echo "ROSA"
;;
"ROSA Enterprise Linux Desktop")
echo "RELS"
;;
"ROSA Enterprise Linux Server")
echo "RELS"
;;
*)
#echo "${1// /}"
#firstupper "$1" | sed -e "s/ //g" -e 's|(.*||'
echo "$1" | sed -e "s/ //g" -e 's|(.*||'
;;
esac
case "$1" in
"RED OS")
echo "RedOS"
;;
"Debian GNU/Linux")
echo "Debian"
;;
"CentOS Linux")
echo "CentOS"
;;
"Fedora Linux")
echo "Fedora"
;;
"Red Hat Enterprise Linux Server")
echo "RHEL"
;;
"ROSA Fresh"*|"ROSA Desktop Fresh"*)
echo "ROSA"
;;
"ROSA Chrome Desktop")
echo "ROSA"
;;
"ROSA Enterprise Linux Desktop")
echo "RELS"
;;
"ROSA Enterprise Linux Server")
echo "RELS"
;;
*)
#echo "${1// /}"
#firstupper "$1" | sed -e "s/ //g" -e 's|(.*||'
echo "$1" | sed -e "s/ //g" -e 's|(.*||'
;;
esac
}
# 1.2.3.4.5 -> 1
......@@ -352,101 +352,101 @@ BUILD_ID=""
# Default detection by /etc/os-release
# https://www.freedesktop.org/software/systemd/man/os-release.html
if distro os-release ; then
# shellcheck disable=SC1090
. $DISTROFILE
DISTRO_NAME="$NAME"
DISTRIB_ID="$(normalize_name "$NAME")"
DISTRIB_RELEASE_ORIG="$VERSION_ID"
DISTRIB_RELEASE="$VERSION_ID"
[ -n "$DISTRIB_RELEASE" ] || DISTRIB_RELEASE="CUR"
# set by os-release:
#PRETTY_NAME
VENDOR_ID="$ID"
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
DISTRIB_CODENAME="$VERSION_CODENAME"
# shellcheck disable=SC1090
. $DISTROFILE
DISTRO_NAME="$NAME"
DISTRIB_ID="$(normalize_name "$NAME")"
DISTRIB_RELEASE_ORIG="$VERSION_ID"
DISTRIB_RELEASE="$VERSION_ID"
[ -n "$DISTRIB_RELEASE" ] || DISTRIB_RELEASE="CUR"
# set by os-release:
#PRETTY_NAME
VENDOR_ID="$ID"
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
DISTRIB_CODENAME="$VERSION_CODENAME"
elif distro lsb-release ; then
DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRO_NAME=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE="$(cat $DISTROFILE | get_var DISTRIB_RELEASE)"
DISTRIB_RELEASE_ORIG="$DISTRIB_RELEASE"
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
PRETTY_NAME=$(cat $DISTROFILE | get_var DISTRIB_DESCRIPTION)
DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRO_NAME=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE="$(cat $DISTROFILE | get_var DISTRIB_RELEASE)"
DISTRIB_RELEASE_ORIG="$DISTRIB_RELEASE"
DISTRIB_FULL_RELEASE="$DISTRIB_RELEASE"
DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
PRETTY_NAME=$(cat $DISTROFILE | get_var DISTRIB_DESCRIPTION)
fi
DISTRIB_RELEASE=$(normalize_version2 "$DISTRIB_RELEASE")
[ -n "$DISTRIB_CODENAME" ] || DISTRIB_CODENAME=$DISTRIB_RELEASE
case "$VENDOR_ID" in
"alt"|"altlinux")
# 2.4.5.99 -> 2
DISTRIB_RELEASE=$(normalize_version1 "$DISTRIB_RELEASE_ORIG")
case "$DISTRIB_ID" in
"ALTServer"|"ALTSPWorkstation"|"Sisyphus")
;;
*)
DISTRIB_ID="ALTLinux"
;;
esac
;;
"astra")
DISTRIB_RELEASE=$(normalize_version2 "$DISTRIB_RELEASE_ORIG" | sed -e 's|_.*||')
DISTRIB_FULL_RELEASE=$(normalize_version3 "$DISTRIB_RELEASE_ORIG" | sed -e 's|_.*||')
if [ "$VARIANT" = "orel" ] || [ "$VARIANT" = "Orel" ] ; then
DISTRIB_ID="AstraLinuxCE"
else
DISTRIB_ID="AstraLinuxSE"
fi
if [ "$DISTRIB_ID" = "AstraLinuxSE" ] ; then
local fr="$(cat /etc/astra_version 2>/dev/null)"
[ -n "$fr" ] && echo "$fr" | grep -q "$DISTRIB_RELEASE" && DISTRIB_FULL_RELEASE="$fr"
fi
;;
"alt"|"altlinux")
# 2.4.5.99 -> 2
DISTRIB_RELEASE=$(normalize_version1 "$DISTRIB_RELEASE_ORIG")
case "$DISTRIB_ID" in
"ALTServer"|"ALTSPWorkstation"|"Sisyphus")
;;
*)
DISTRIB_ID="ALTLinux"
;;
esac
;;
"astra")
DISTRIB_RELEASE=$(normalize_version2 "$DISTRIB_RELEASE_ORIG" | sed -e 's|_.*||')
DISTRIB_FULL_RELEASE=$(normalize_version3 "$DISTRIB_RELEASE_ORIG" | sed -e 's|_.*||')
if [ "$VARIANT" = "orel" ] || [ "$VARIANT" = "Orel" ] ; then
DISTRIB_ID="AstraLinuxCE"
else
DISTRIB_ID="AstraLinuxSE"
fi
if [ "$DISTRIB_ID" = "AstraLinuxSE" ] ; then
local fr="$(cat /etc/astra_version 2>/dev/null)"
[ -n "$fr" ] && echo "$fr" | grep -q "$DISTRIB_RELEASE" && DISTRIB_FULL_RELEASE="$fr"
fi
;;
esac
case "$DISTRIB_ID" in
"ALTLinux")
echo "$VERSION" | grep -q "c9.* branch" && DISTRIB_RELEASE="c9"
echo "$VERSION" | grep -q "c9f1 branch" && DISTRIB_RELEASE="c9f1"
echo "$VERSION" | grep -q "c9f2 branch" && DISTRIB_RELEASE="c9f2"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
# FIXME: fast hack for fallback: 10.1 -> p10 for /etc/os-release
if echo "$DISTRIB_RELEASE" | grep -q "^[0-9]" && echo "$DISTRIB_RELEASE" | grep -q -v "[0-9][0-9][0-9]" ; then
DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
fi
;;
"ALTServer")
DISTRIB_CODENAME="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')"
;;
"ALTSPWorkstation")
DISTRIB_ID="ALTLinux"
case "$DISTRIB_RELEASE_ORIG" in
8.0|8.1)
;;
8.2|8.3)
DISTRIB_RELEASE="c9f1"
;;
8.4)
DISTRIB_RELEASE="c9f2"
;;
8.*)
DISTRIB_RELEASE="c9f3"
;;
esac
DISTRIB_CODENAME="$DISTRIB_RELEASE"
# DISTRIB_RELEASE=$(echo $DISTRIB_RELEASE | sed -e "s/\..*//g")
;;
"Sisyphus")
DISTRIB_ID="ALTLinux"
DISTRIB_RELEASE="Sisyphus"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
;;
"ROSA")
DISTRIB_FULL_RELEASE="$DISTRIB_CODENAME"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
;;
"ALTLinux")
echo "$VERSION" | grep -q "c9.* branch" && DISTRIB_RELEASE="c9"
echo "$VERSION" | grep -q "c9f1 branch" && DISTRIB_RELEASE="c9f1"
echo "$VERSION" | grep -q "c9f2 branch" && DISTRIB_RELEASE="c9f2"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
# FIXME: fast hack for fallback: 10.1 -> p10 for /etc/os-release
if echo "$DISTRIB_RELEASE" | grep -q "^[0-9]" && echo "$DISTRIB_RELEASE" | grep -q -v "[0-9][0-9][0-9]" ; then
DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
fi
;;
"ALTServer")
DISTRIB_CODENAME="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')"
;;
"ALTSPWorkstation")
DISTRIB_ID="ALTLinux"
case "$DISTRIB_RELEASE_ORIG" in
8.0|8.1)
;;
8.2|8.3)
DISTRIB_RELEASE="c9f1"
;;
8.4)
DISTRIB_RELEASE="c9f2"
;;
8.*)
DISTRIB_RELEASE="c9f3"
;;
esac
DISTRIB_CODENAME="$DISTRIB_RELEASE"
# DISTRIB_RELEASE=$(echo $DISTRIB_RELEASE | sed -e "s/\..*//g")
;;
"Sisyphus")
DISTRIB_ID="ALTLinux"
DISTRIB_RELEASE="Sisyphus"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
;;
"ROSA")
DISTRIB_FULL_RELEASE="$DISTRIB_CODENAME"
DISTRIB_CODENAME="$DISTRIB_RELEASE"
;;
esac
......@@ -457,123 +457,123 @@ esac
# ALT Linux based
if distro altlinux-release ; then
DISTRIB_ID="ALTLinux"
# FIXME: fast hack for fallback: 10 -> p10 for /etc/os-release
DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||' -e 's|^pp|p|')"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT p10.* p10 " ; then DISTRIB_RELEASE="p10"
elif has "ALTServer 10." ; then DISTRIB_RELEASE="p10"
elif has "ALTServer 9." ; then DISTRIB_RELEASE="p9"
elif has "ALT c10.* c10 " ; then DISTRIB_RELEASE="c10"
elif has "ALT p9.* p9 " ; then DISTRIB_RELEASE="p9"
elif has "ALT 9 SP " ; then DISTRIB_RELEASE="c9"
elif has "ALT c9f1" ; then DISTRIB_RELEASE="c9f1"
elif has "ALT MED72 " ; then DISTRIB_RELEASE="p8"
elif has "ALT 8 SP " ; then DISTRIB_RELEASE="c8"
elif has "ALT c8.2 " ; then DISTRIB_RELEASE="c8.2"
elif has "ALT c8.1 " ; then DISTRIB_RELEASE="c8.1"
elif has "ALT c8 " ; then DISTRIB_RELEASE="c8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 10." ; then DISTRIB_RELEASE="p10"
elif has "Simply Linux 9." ; then DISTRIB_RELEASE="p9"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p8" ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux p7" ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux t7." ; then DISTRIB_RELEASE="t7"
elif has "ALT Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p6" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p5" ; then DISTRIB_RELEASE="p5"
elif has "ALT Linux 5.1" ; then DISTRIB_RELEASE="5.1"
elif has "ALT Linux 5.0" ; then DISTRIB_RELEASE="5.0"
elif has "ALT Linux 4.1" ; then DISTRIB_RELEASE="4.1"
elif has "ALT Linux 4.0" ; then DISTRIB_RELEASE="4.0"
elif has "starter kit" ; then DISTRIB_RELEASE="Sisyphus"
elif has Citron ; then DISTRIB_RELEASE="2.4"
fi
PRETTY_NAME="$(cat /etc/altlinux-release)"
DISTRIB_ID="ALTLinux"
# FIXME: fast hack for fallback: 10 -> p10 for /etc/os-release
DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||' -e 's|^pp|p|')"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT p10.* p10 " ; then DISTRIB_RELEASE="p10"
elif has "ALTServer 10." ; then DISTRIB_RELEASE="p10"
elif has "ALTServer 9." ; then DISTRIB_RELEASE="p9"
elif has "ALT c10.* c10 " ; then DISTRIB_RELEASE="c10"
elif has "ALT p9.* p9 " ; then DISTRIB_RELEASE="p9"
elif has "ALT 9 SP " ; then DISTRIB_RELEASE="c9"
elif has "ALT c9f1" ; then DISTRIB_RELEASE="c9f1"
elif has "ALT MED72 " ; then DISTRIB_RELEASE="p8"
elif has "ALT 8 SP " ; then DISTRIB_RELEASE="c8"
elif has "ALT c8.2 " ; then DISTRIB_RELEASE="c8.2"
elif has "ALT c8.1 " ; then DISTRIB_RELEASE="c8.1"
elif has "ALT c8 " ; then DISTRIB_RELEASE="c8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 10." ; then DISTRIB_RELEASE="p10"
elif has "Simply Linux 9." ; then DISTRIB_RELEASE="p9"
elif has "Simply Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p8" ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT Linux p7" ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux t7." ; then DISTRIB_RELEASE="t7"
elif has "ALT Linux 6." ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p6" ; then DISTRIB_RELEASE="p6"
elif has "ALT Linux p5" ; then DISTRIB_RELEASE="p5"
elif has "ALT Linux 5.1" ; then DISTRIB_RELEASE="5.1"
elif has "ALT Linux 5.0" ; then DISTRIB_RELEASE="5.0"
elif has "ALT Linux 4.1" ; then DISTRIB_RELEASE="4.1"
elif has "ALT Linux 4.0" ; then DISTRIB_RELEASE="4.0"
elif has "starter kit" ; then DISTRIB_RELEASE="Sisyphus"
elif has Citron ; then DISTRIB_RELEASE="2.4"
fi
PRETTY_NAME="$(cat /etc/altlinux-release)"
elif distro gentoo-release ; then
DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
DISTRIB_RELEASE=$(basename $MAKEPROFILE)
echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=$(basename "$(dirname $MAKEPROFILE)") #"
DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
DISTRIB_RELEASE=$(basename $MAKEPROFILE)
echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=$(basename "$(dirname $MAKEPROFILE)") #"
elif distro slackware-version ; then
DISTRIB_ID="Slackware"
DISTRIB_RELEASE="$(grep -Eo '[0-9]+\.[0-9]+' $DISTROFILE)"
DISTRIB_ID="Slackware"
DISTRIB_RELEASE="$(grep -Eo '[0-9]+\.[0-9]+' $DISTROFILE)"
elif distro os-release && is_command tce-ab ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="TinyCoreLinux"
DISTRIB_RELEASE="$VERSION_ID"
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="TinyCoreLinux"
DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && is_command xbps-query ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux"
DISTRIB_RELEASE="Live"
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux"
DISTRIB_RELEASE="Live"
# TODO: use standart /etc/os-release or lsb
elif distro arch-release ; then
DISTRIB_ID="ArchLinux"
DISTRIB_RELEASE="rolling"
DISTRIB_ID="ArchLinux"
DISTRIB_RELEASE="rolling"
# Elbrus
elif distro mcst_version ; then
DISTRIB_ID="MCST"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g") #"
DISTRIB_ID="MCST"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g") #"
# OpenWrt
elif distro openwrt_release ; then
. $DISTROFILE
DISTRIB_RELEASE=$(cat $ROOTDIR/etc/openwrt_version)
. $DISTROFILE
DISTRIB_RELEASE=$(cat $ROOTDIR/etc/openwrt_version)
# Debian based
elif distro debian_version ; then
DISTRIB_ID="Debian"
DISTRIB_RELEASE=$(cat $DISTROFILE | sed -e "s/\..*//g")
DISTRIB_ID="Debian"
DISTRIB_RELEASE=$(cat $DISTROFILE | sed -e "s/\..*//g")
# SUSE based
elif distro SuSe-release || distro SuSE-release ; then
DISTRIB_ID="SUSE"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "VERSION" | sed -e "s|^VERSION = ||g")
if has "SUSE Linux Enterprise Desktop" ; then
DISTRIB_ID="SLED"
elif has "SUSE Linux Enterprise Server" ; then
DISTRIB_ID="SLES"
fi
DISTRIB_ID="SUSE"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "VERSION" | sed -e "s|^VERSION = ||g")
if has "SUSE Linux Enterprise Desktop" ; then
DISTRIB_ID="SLED"
elif has "SUSE Linux Enterprise Server" ; then
DISTRIB_ID="SLES"
fi
# fixme: can we detect by some file?
elif [ "$(uname)" = "FreeBSD" ] ; then
DISTRIB_ID="FreeBSD"
UNAME=$(uname -r)
DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g") #"
DISTRIB_ID="FreeBSD"
UNAME=$(uname -r)
DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g") #"
# fixme: can we detect by some file?
elif [ "$(uname)" = "SunOS" ] ; then
DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r)
DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file?
elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
DISTRIB_ID="MacOS"
DISTRIB_RELEASE=$(uname -r)
DISTRIB_ID="MacOS"
DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
elif [ "$(uname)" = "Linux" ] && is_command guix ; then
DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r)
DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r)
# fixme: move to up
elif [ "$(uname)" = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
elif [ "$(uname -o 2>/dev/null)" = "Cygwin" ] ; then
DISTRIB_ID="Cygwin"
......@@ -888,153 +888,153 @@ EOF
}
case "$2" in
-*)
echo "Unsupported option $2" >&2
exit 1
;;
-*)
echo "Unsupported option $2" >&2
exit 1
;;
esac
case "$1" in
-h|--help)
echo "distro_info v$PROGVERSION - distro information retriever"
echo "Usage: distro_info [options] [SystemName/Version]"
echo "Options:"
echo " -h | --help - this help"
echo " -a - print hardware architecture (--distro-arch for distro depended name)"
echo " -b - print size of arch bit (32/64)"
echo " -c - print number of CPU cores"
echo " -i - print virtualization type"
echo " -m - print system memory size (in MB)"
echo " -y|--service-manager - print running service manager"
echo " -z - print current CPU MHz"
echo " --glibc-version - print system glibc version"
echo
echo " -d|--base-distro-name - print distro id (short distro name)"
echo " -e - print full name of distro with version"
echo " -o | --os-name - print base OS name"
echo " -p | package-type - print type of the packaging system"
echo " -g - print name of the packaging system"
echo " -s|-n|--vendor-name - print name of the distro family (vendor name) (ubuntu for all Ubuntu family, alt for all ALT family) (see _vendor macros in rpm)"
echo " --pretty|--pretty-name - print pretty distro name"
echo " -v | --base-version - print version of the distro"
echo " --distro-name - print distro name"
echo " --distro-version - print full version of the distro"
echo " --full-version - print full version of the distro"
echo " --codename (obsoleted) - print distro codename (focal for Ubuntu 20.04)"
echo " -r|--repo-name - print repository name (focal for Ubuntu 20.04)"
echo " --build-id - print a string uniquely identifying the system image originally used as the installation base"
echo " -V - print the utility version"
echo "Run without args to print all information."
exit 0
;;
-p|--package-type)
override_distrib "$2"
pkgtype
exit 0
;;
-g)
override_distrib "$2"
pkgmanager
exit 0
;;
--pretty|--pretty-name)
override_distrib "$2"
print_pretty_name
;;
--distro-arch)
override_distrib "$2"
get_distro_arch
exit 0
;;
--debian-arch)
override_distrib "$2"
get_debian_arch
exit 0
;;
--glibc-version)
override_distrib "$2"
get_glibc_version
exit 0
;;
-d|--base-distro-name)
override_distrib "$2"
echo $DISTRIB_ID
;;
--distro-name)
override_distrib "$2"
echo $DISTRO_NAME
;;
--codename)
override_distrib "$2"
print_codename
;;
-a)
override_distrib "$2"
[ -n "$DIST_ARCH" ] && echo "$DIST_ARCH" && exit 0
get_arch
;;
-b)
get_bit_size
;;
-c)
get_core_count
;;
-z)
get_core_mhz
;;
-i)
get_virt
;;
-m)
get_memory_size
;;
-o|--os-name)
override_distrib "$2"
get_base_os_name
;;
-r|--repo-name)
override_distrib "$2"
print_repo_name
;;
--build-id)
echo "$BUILD_ID"
;;
-v|--base-version)
override_distrib "$2"
echo "$DISTRIB_RELEASE"
;;
--full-version|--distro-version)
override_distrib "$2"
echo "$DISTRIB_FULL_RELEASE"
;;
--bug-report-url)
print_bug_report_url
exit
;;
-s|-n|--vendor-name)
override_distrib "$2"
pkgvendor
exit 0
;;
-y|--service-manager)
override_distrib "$2"
get_service_manager
;;
-V)
echo "$PROGVERSION"
exit 0
;;
-e)
override_distrib "$2"
print_name_version
;;
-*)
echo "Unsupported option $1" >&2
exit 1
;;
*)
override_distrib "$1"
print_total_info
;;
-h|--help)
echo "distro_info v$PROGVERSION - distro information retriever"
echo "Usage: distro_info [options] [SystemName/Version]"
echo "Options:"
echo " -h | --help - this help"
echo " -a - print hardware architecture (--distro-arch for distro depended name)"
echo " -b - print size of arch bit (32/64)"
echo " -c - print number of CPU cores"
echo " -i - print virtualization type"
echo " -m - print system memory size (in MB)"
echo " -y|--service-manager - print running service manager"
echo " -z - print current CPU MHz"
echo " --glibc-version - print system glibc version"
echo
echo " -d|--base-distro-name - print distro id (short distro name)"
echo " -e - print full name of distro with version"
echo " -o | --os-name - print base OS name"
echo " -p | package-type - print type of the packaging system"
echo " -g - print name of the packaging system"
echo " -s|-n|--vendor-name - print name of the distro family (vendor name) (ubuntu for all Ubuntu family, alt for all ALT family) (see _vendor macros in rpm)"
echo " --pretty|--pretty-name - print pretty distro name"
echo " -v | --base-version - print version of the distro"
echo " --distro-name - print distro name"
echo " --distro-version - print full version of the distro"
echo " --full-version - print full version of the distro"
echo " --codename (obsoleted) - print distro codename (focal for Ubuntu 20.04)"
echo " -r|--repo-name - print repository name (focal for Ubuntu 20.04)"
echo " --build-id - print a string uniquely identifying the system image originally used as the installation base"
echo " -V - print the utility version"
echo "Run without args to print all information."
exit 0
;;
-p|--package-type)
override_distrib "$2"
pkgtype
exit 0
;;
-g)
override_distrib "$2"
pkgmanager
exit 0
;;
--pretty|--pretty-name)
override_distrib "$2"
print_pretty_name
;;
--distro-arch)
override_distrib "$2"
get_distro_arch
exit 0
;;
--debian-arch)
override_distrib "$2"
get_debian_arch
exit 0
;;
--glibc-version)
override_distrib "$2"
get_glibc_version
exit 0
;;
-d|--base-distro-name)
override_distrib "$2"
echo $DISTRIB_ID
;;
--distro-name)
override_distrib "$2"
echo $DISTRO_NAME
;;
--codename)
override_distrib "$2"
print_codename
;;
-a)
override_distrib "$2"
[ -n "$DIST_ARCH" ] && echo "$DIST_ARCH" && exit 0
get_arch
;;
-b)
get_bit_size
;;
-c)
get_core_count
;;
-z)
get_core_mhz
;;
-i)
get_virt
;;
-m)
get_memory_size
;;
-o|--os-name)
override_distrib "$2"
get_base_os_name
;;
-r|--repo-name)
override_distrib "$2"
print_repo_name
;;
--build-id)
echo "$BUILD_ID"
;;
-v|--base-version)
override_distrib "$2"
echo "$DISTRIB_RELEASE"
;;
--full-version|--distro-version)
override_distrib "$2"
echo "$DISTRIB_FULL_RELEASE"
;;
--bug-report-url)
print_bug_report_url
exit
;;
-s|-n|--vendor-name)
override_distrib "$2"
pkgvendor
exit 0
;;
-y|--service-manager)
override_distrib "$2"
get_service_manager
;;
-V)
echo "$PROGVERSION"
exit 0
;;
-e)
override_distrib "$2"
print_name_version
;;
-*)
echo "Unsupported option $1" >&2
exit 1
;;
*)
override_distrib "$1"
print_total_info
;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment