Commit 7cebd564 authored by Vitaly Lipatov's avatar Vitaly Lipatov

distr_info: improve override support

parent 0309402c
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# You can set ROOTDIR to root system dir # You can set ROOTDIR to root system dir
#ROOTDIR= #ROOTDIR=
PROGVERSION="20220718" PROGVERSION="20220719"
# TODO: check /etc/system-release # TODO: check /etc/system-release
...@@ -48,8 +48,13 @@ override_distrib() ...@@ -48,8 +48,13 @@ override_distrib()
{ {
[ -n "$1" ] || return [ -n "$1" ] || return
VENDOR_ID='' VENDOR_ID=''
DISTRIB_ID="$(echo "$1" | sed -e 's|/.*||')" PRETTY_NAME=''
DISTRIB_RELEASE="$(echo "$1" | sed -e 's|.*/||')" 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|/.*||')"
DISTRIB_RELEASE="$(echo "$name" | sed -e 's|.*/||')"
[ "$DISTRIB_ID" = "$DISTRIB_RELEASE" ] && DISTRIB_RELEASE=''
} }
# Translate DISTRIB_ID to vendor name (like %_vendor does or package release name uses), uses VENDOR_ID by default # Translate DISTRIB_ID to vendor name (like %_vendor does or package release name uses), uses VENDOR_ID by default
...@@ -455,10 +460,6 @@ fi ...@@ -455,10 +460,6 @@ fi
fill_distr_info fill_distr_info
[ -n "$DISTRIB_ID" ] || DISTRIB_ID="Generic" [ -n "$DISTRIB_ID" ] || DISTRIB_ID="Generic"
if [ -z "$PRETTY_NAME" ] ; then
PRETTY_NAME="$DISTRIB_ID $DISTRIB_RELEASE"
fi
get_uname() get_uname()
{ {
tolower $(uname $1) | tr -d " \t\r\n" tolower $(uname $1) | tr -d " \t\r\n"
...@@ -710,6 +711,10 @@ get_service_manager() ...@@ -710,6 +711,10 @@ get_service_manager()
print_pretty_name() print_pretty_name()
{ {
if [ -z "$PRETTY_NAME" ] ; then
PRETTY_NAME="$DISTRIB_ID $DISTRIB_RELEASE"
fi
echo "$PRETTY_NAME" echo "$PRETTY_NAME"
} }
...@@ -771,6 +776,7 @@ case $1 in ...@@ -771,6 +776,7 @@ case $1 in
exit 0 exit 0
;; ;;
--pretty) --pretty)
override_distrib "$2"
print_pretty_name print_pretty_name
;; ;;
--distro-arch) --distro-arch)
...@@ -784,9 +790,12 @@ case $1 in ...@@ -784,9 +790,12 @@ case $1 in
exit 0 exit 0
;; ;;
-d) -d)
override_distrib "$2"
echo $DISTRIB_ID echo $DISTRIB_ID
;; ;;
-a) -a)
override_distrib "$2"
[ -n "$DIST_ARCH" ] && echo "$DIST_ARCH" && exit 0
get_arch get_arch
;; ;;
-b) -b)
...@@ -808,6 +817,7 @@ case $1 in ...@@ -808,6 +817,7 @@ case $1 in
get_base_os_name get_base_os_name
;; ;;
-v) -v)
override_distrib "$2"
echo $DISTRIB_RELEASE echo $DISTRIB_RELEASE
;; ;;
-s|-n) -s|-n)
...@@ -823,9 +833,11 @@ case $1 in ...@@ -823,9 +833,11 @@ case $1 in
exit 0 exit 0
;; ;;
-e) -e)
override_distrib "$2"
print_name_version print_name_version
;; ;;
*) *)
override_distrib "$1"
print_total_info print_total_info
;; ;;
esac 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