Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
a13479c2
Commit
a13479c2
authored
Oct 21, 2017
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distr_info: add support for get info about arch, bus size, memory size, base os name
parent
b266ad97
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
0 deletions
+122
-0
distr_info
bin/distr_info
+122
-0
No files found.
bin/distr_info
View file @
a13479c2
...
...
@@ -329,6 +329,112 @@ elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
esac
fi
get_base_os_name
()
{
local
DIST_OS
# Resolve the os
DIST_OS
=
`
uname
-s
|
tr
[
:upper:]
[
:lower:] |
tr
-d
"
\t\r\n
"
`
case
"
$DIST_OS
"
in
'sunos'
)
DIST_OS
=
"solaris"
;;
'hp-ux'
|
'hp-ux64'
)
DIST_OS
=
"hpux"
;;
'darwin'
|
'oarwin'
)
DIST_OS
=
"macosx"
;;
'unix_sv'
)
DIST_OS
=
"unixware"
;;
'freebsd'
|
'openbsd'
|
'netbsd'
)
DIST_OS
=
"freebsd"
;;
esac
echo
"
$DIST_OS
"
}
get_arch
()
{
local
DIST_ARCH
# Resolve the architecture
DIST_ARCH
=
`
uname
-m
|
tr
[
:upper:]
[
:lower:] |
tr
-d
"
\t\r\n
"
`
case
"
$DIST_ARCH
"
in
'amd64'
|
'ia32'
|
'i386'
|
'i486'
|
'i586'
|
'i686'
|
'x86_64'
)
DIST_ARCH
=
"x86"
;;
'ia64'
|
'ia-64'
)
DIST_ARCH
=
"ia64"
;;
'ip27'
|
'mips'
)
DIST_ARCH
=
"mips"
;;
'powermacintosh'
|
'power'
|
'powerpc'
|
'power_pc'
|
'ppc64'
)
DIST_ARCH
=
"ppc"
;;
'pa_risc'
|
'pa-risc'
)
DIST_ARCH
=
"parisc"
;;
'sun4u'
|
'sparcv9'
)
DIST_ARCH
=
"sparc"
;;
'9000/800'
)
DIST_ARCH
=
"parisc"
;;
armv
*
)
if
[
-z
"
`
readelf
-A
/proc/self/exe |
grep
Tag_ABI_VFP_args
`
"
]
;
then
DIST_ARCH
=
"armel"
else
DIST_ARCH
=
"armhf"
fi
;;
esac
echo
"
$DIST_ARCH
"
}
get_bit_size
()
{
local
DIST_BIT
# Check if we are running on 64bit platform, seems like a workaround for now...
DIST_BIT
=
`
uname
-m
|
tr
[
:upper:]
[
:lower:] |
tr
-d
"
\t\r\n
"
`
case
"
$DIST_BIT
"
in
'amd64'
|
'ia64'
|
'x86_64'
|
'ppc64'
)
DIST_BIT
=
"64"
;;
# 'pa_risc' | 'pa-risc') # Are some of these 64bit? Least not all...
# BIT="64"
# ;;
'sun4u'
|
'sparcv9'
)
# Are all sparcs 64?
DIST_BIT
=
"64"
;;
# '9000/800')
# DIST_BIT="64"
# ;;
*
)
# In any other case default to 32
DIST_BIT
=
"32"
;;
esac
echo
"
$DIST_BIT
"
}
get_memory_size
()
{
local
detected
=
0
local
DIST_OS
=
$(
get_base_os_name
)
if
[
$DIST_OS
=
"macosx"
]
then
detected
=
$((
`
sysctl hw.memsize |
sed
s/
"hw.memsize: "
//
`
/
1024
/
1024
))
elif
[
$DIST_OS
=
"freebsd"
]
then
detected
=
$((
`
sysctl hw.physmem |
sed
s/
"hw.physmem: "
//
`
/
1024
/
1024
))
elif
[
$DIST_OS
=
"linux"
]
then
detected
=
$((
`
cat
/proc/meminfo |
grep
MemTotal |
awk
'{print $2}'
`
/
1024
))
fi
# Exit codes only support values between 0 and 255. So use stdout.
echo
$detected
}
case
$1
in
-p
)
# override DISTRIB_ID
...
...
@@ -341,6 +447,10 @@ case $1 in
echo
"Usage: distr_vendor [options] [args]"
echo
"-p [SystemName] - print type of packaging system"
echo
"-d - print distro name"
echo
"-a - print hardware architecture"
echo
"-b - print size of arch bit (32/64)"
echo
"-m - print system memory size (in MB)"
echo
"-o - print base os name"
echo
"-v - print version of distro"
echo
"-e - print full name of distro with version (by default)"
echo
"-s [SystemName] - print name of distro for build system (like in the package release name)"
...
...
@@ -352,6 +462,18 @@ case $1 in
-d
)
echo
$DISTRIB_ID
;;
-a
)
get_arch
;;
-b
)
get_bit_size
;;
-m
)
get_memory_size
;;
-o
)
get_base_os_name
;;
-v
)
echo
$DISTRIB_RELEASE
;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment