Commit 58ff7dc2 authored by Vitaly Lipatov's avatar Vitaly Lipatov

add --pretty option to print pretty name of the distro

parent c2bff0b3
......@@ -100,6 +100,7 @@ get_major_version()
}
# Default values
PRETTY_NAME=""
DISTRIB_ID="Generic"
DISTRIB_RELEASE=""
DISTRIB_CODENAME=""
......@@ -109,6 +110,7 @@ if distro lsb-release ; then
DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE=$(cat $DISTROFILE | get_var DISTRIB_RELEASE)
DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
PRETTY_NAME=$(cat $DISTROFILE | get_var DISTRIB_DESCRIPTION)
fi
# ALT Linux based
......@@ -138,6 +140,7 @@ if distro altlinux-release ; then
elif has "starter kit" ; then DISTRIB_RELEASE="p8"
elif has Citron ; then DISTRIB_RELEASE="2.4"
fi
PRETTY_NAME="$(cat /etc/altlinux-release)"
elif distro gentoo-release ; then
DISTRIB_ID="Gentoo"
......@@ -177,7 +180,7 @@ elif distro arch-release ; then
# Elbrus
elif distro mcst_version ; then
DISTRIB_ID="MCST"
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g")
DISTRIB_RELEASE=$(cat "$DISTROFILE" | grep "release" | sed -e "s|.*release \([0-9]*\).*|\1|g") #"
# OpenWrt
elif distro openwrt_release ; then
......@@ -486,11 +489,16 @@ get_service_manager()
echo "(unknown)"
}
print_pretty_name()
{
echo "$PRETTY_NAME"
}
print_total_info()
{
cat <<EOF
distro_info total information (run with -h to get help):
Pretty distro name (--pretty): $(print_pretty_name)
Distro name and version (-e): $(print_name_version)
Packaging system (-p): $(pkgtype)
Running service manager (-y): $(get_service_manager)
......@@ -521,7 +529,8 @@ case $1 in
echo " -o - print base OS name"
echo " -p [SystemName] - print type of the packaging system"
echo " -s [SystemName] - print name of distro for build system (like in the package release name)"
ecgi " -y - print running service manager"
echo " -y - print running service manager"
echo " --pretty - print pretty distro name"
echo " -v - print version of distro"
echo " -V - print the utility version"
echo "Run without args to print all information."
......@@ -533,6 +542,9 @@ case $1 in
pkgtype
exit 0
;;
--pretty)
print_pretty_name
;;
-d)
echo $DISTRIB_ID
;;
......
......@@ -5,22 +5,7 @@
.\" This file has been put into the public domain.
.\" You can do whatever you want with this file.
.\"
.TH EEPM 1 "November 2019" "Version 0.1"
<------><------>echo " -a - print hardware architecture"
<------><------>echo " -b - print size of arch bit (32/64)"
<------><------>echo " -d - print distro name"
<------><------>echo " -e - print full name of distro with version"
<------><------>echo " -h - this help"
<------><------>echo " -m - print system memory size (in MB)"
<------><------>echo " -n [SystemName] - print vendor name (as _vendor macros in rpm)"
<------><------>echo " -o - print base os name"
<------><------>echo " -p [SystemName] - print type of the packaging system"
<------><------>echo " -s [SystemName] - print name of distro for build system (like in the package release name)"
<------><------>echo " -v - print version of distro"
<------><------>echo " -V - print the utility version"
<------><------>echo "Run without args to print all information."
<------><------>exit 0
.TH EEPM 1 "November 2019" "Version 1.1"
.SH NAME
distro_info \- get various info about a system and used distro
......@@ -73,6 +58,9 @@ print type of the packaging system (deb, rpm)
.I -y
print running service manager (systemd, sysvinit)
.TP
.I --pretty
print name name of the distro
.TP
.I -v
print version of the distro (f.i. 20.04 or p9)
.TP
......
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