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
580c8cfd
Commit
580c8cfd
authored
Apr 10, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distr_info: drop out direct which using
parent
0eb1eb61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
28 deletions
+49
-28
distr_info
bin/distr_info
+49
-28
No files found.
bin/distr_info
View file @
580c8cfd
...
@@ -26,11 +26,34 @@ has()
...
@@ -26,11 +26,34 @@ has()
grep
"
$*
"
"
$DISTROFILE
"
>
/dev/null 2>&1
grep
"
$*
"
"
$DISTROFILE
"
>
/dev/null 2>&1
}
}
# Has a system the specified command?
# copied from epm-sh-functions
hascommand
()
# print a path to the command if exists in $PATH
if
a
=
which which 2>/dev/null
>
/dev/null
;
then
# the best case if we have which command (other ways needs checking)
# TODO: don't use which at all, it is binary, not builtin shell command
print_command_path
()
{
{
which
"
$1
"
2>/dev/null
>
/dev/null
a
=
which
--
"
$1
"
2
>/dev/null
}
}
elif
a
=
type
-a
type
2>/dev/null
>
/dev/null
;
then
print_command_path
()
{
a
=
type
-fpP
--
"
$1
"
2>/dev/null
}
else
print_command_path
()
{
a
=
type
"
$1
"
2>/dev/null |
sed
-e
's|.* /|/|'
}
fi
# check if <arg> is a real command
is_command
()
{
print_command_path
"
$1
"
>
/dev/null
}
##########################3
firstupper
()
firstupper
()
{
{
...
@@ -111,7 +134,7 @@ case $DISTRIB_ID in
...
@@ -111,7 +134,7 @@ case $DISTRIB_ID in
Ubuntu|Debian|Mint|OSNovaLinux|AstraLinux
*
|
Elbrus
)
Ubuntu|Debian|Mint|OSNovaLinux|AstraLinux
*
|
Elbrus
)
CMD
=
"apt-dpkg"
CMD
=
"apt-dpkg"
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
#which aptitude 2>/dev/null >/dev/null && CMD=aptitude-dpkg
#
has
command snappy && CMD=snappy
#
is_
command snappy && CMD=snappy
;;
;;
Solus
)
Solus
)
CMD
=
"eopkg"
CMD
=
"eopkg"
...
@@ -121,14 +144,14 @@ case $DISTRIB_ID in
...
@@ -121,14 +144,14 @@ case $DISTRIB_ID in
;;
;;
ROSA
)
ROSA
)
CMD
=
"urpm-rpm"
CMD
=
"urpm-rpm"
has
command yum
&&
CMD
=
"yum-rpm"
is_
command yum
&&
CMD
=
"yum-rpm"
has
command dnf
&&
CMD
=
"dnf-rpm"
is_
command dnf
&&
CMD
=
"dnf-rpm"
# use dnf since 2020
# use dnf since 2020
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;;
;;
FreeBSD|NetBSD|OpenBSD|Solaris
)
FreeBSD|NetBSD|OpenBSD|Solaris
)
CMD
=
"pkgsrc"
CMD
=
"pkgsrc"
has
command pkg
&&
CMD
=
pkgng
is_
command pkg
&&
CMD
=
pkgng
;;
;;
Gentoo
)
Gentoo
)
CMD
=
"emerge"
CMD
=
"emerge"
...
@@ -138,7 +161,7 @@ case $DISTRIB_ID in
...
@@ -138,7 +161,7 @@ case $DISTRIB_ID in
;;
;;
Fedora|CentOS|OracleLinux|RockyLinux|AlmaLinux|RHEL|RELS|Scientific|GosLinux|Amzn|RedOS
)
Fedora|CentOS|OracleLinux|RockyLinux|AlmaLinux|RHEL|RELS|Scientific|GosLinux|Amzn|RedOS
)
CMD
=
"dnf-rpm"
CMD
=
"dnf-rpm"
has
command dnf
||
CMD
=
"yum-rpm"
is_
command dnf
||
CMD
=
"yum-rpm"
[
"
$DISTRIB_ID
/
$DISTRIB_RELEASE
"
=
"CentOS/7"
]
&&
CMD
=
"yum-rpm"
[
"
$DISTRIB_ID
/
$DISTRIB_RELEASE
"
=
"CentOS/7"
]
&&
CMD
=
"yum-rpm"
;;
;;
Slackware
)
Slackware
)
...
@@ -152,8 +175,8 @@ case $DISTRIB_ID in
...
@@ -152,8 +175,8 @@ case $DISTRIB_ID in
;;
;;
Windows
)
Windows
)
CMD
=
"appget"
CMD
=
"appget"
has
command
$CMD
||
CMD
=
"chocolatey"
is_
command
$CMD
||
CMD
=
"chocolatey"
has
command
$CMD
||
CMD
=
"winget"
is_
command
$CMD
||
CMD
=
"winget"
;;
;;
MacOS
)
MacOS
)
CMD
=
"homebrew"
CMD
=
"homebrew"
...
@@ -185,17 +208,17 @@ case $DISTRIB_ID in
...
@@ -185,17 +208,17 @@ case $DISTRIB_ID in
echo
"apt-dpkg"
&&
return
echo
"apt-dpkg"
&&
return
fi
fi
if
has
command
"rpm"
&&
[
-s
/var/lib/rpm/Name
]
||
[
-s
/var/lib/rpm/rpmdb.sqlite
]
;
then
if
is_
command
"rpm"
&&
[
-s
/var/lib/rpm/Name
]
||
[
-s
/var/lib/rpm/rpmdb.sqlite
]
;
then
has
command
"zypper"
&&
echo
"zypper-rpm"
&&
return
is_
command
"zypper"
&&
echo
"zypper-rpm"
&&
return
has
command
"dnf"
&&
echo
"dnf-rpm"
&&
return
is_
command
"dnf"
&&
echo
"dnf-rpm"
&&
return
has
command
"apt-get"
&&
echo
"apt-rpm"
&&
return
is_
command
"apt-get"
&&
echo
"apt-rpm"
&&
return
has
command
"yum"
&&
echo
"yum-rpm"
&&
return
is_
command
"yum"
&&
echo
"yum-rpm"
&&
return
has
command
"urpmi"
&&
echo
"urpm-rpm"
&&
return
is_
command
"urpmi"
&&
echo
"urpm-rpm"
&&
return
fi
fi
if
has
command
"dpkg"
&&
[
-s
/var/lib/dpkg/status
]
;
then
if
is_
command
"dpkg"
&&
[
-s
/var/lib/dpkg/status
]
;
then
has
command
"apt"
&&
echo
"apt-dpkg"
&&
return
is_
command
"apt"
&&
echo
"apt-dpkg"
&&
return
has
command
"apt-get"
&&
echo
"apt-dpkg"
&&
return
is_
command
"apt-get"
&&
echo
"apt-dpkg"
&&
return
fi
fi
echo
"We don't support yet DISTRIB_ID
$DISTRIB_ID
"
>
&2
echo
"We don't support yet DISTRIB_ID
$DISTRIB_ID
"
>
&2
...
@@ -481,13 +504,13 @@ elif distro slackware-version ; then
...
@@ -481,13 +504,13 @@ elif distro slackware-version ; then
DISTRIB_ID
=
"Slackware"
DISTRIB_ID
=
"Slackware"
DISTRIB_RELEASE
=
"
$(
grep
-Eo
'[0-9]+\.[0-9]+'
$DISTROFILE
)
"
DISTRIB_RELEASE
=
"
$(
grep
-Eo
'[0-9]+\.[0-9]+'
$DISTROFILE
)
"
elif
distro os-release
&&
has
command tce-ab
;
then
elif
distro os-release
&&
is_
command tce-ab
;
then
# shellcheck disable=SC1090
# shellcheck disable=SC1090
.
$ROOTDIR
/etc/os-release
.
$ROOTDIR
/etc/os-release
DISTRIB_ID
=
"TinyCoreLinux"
DISTRIB_ID
=
"TinyCoreLinux"
DISTRIB_RELEASE
=
"
$VERSION_ID
"
DISTRIB_RELEASE
=
"
$VERSION_ID
"
elif
distro os-release
&&
has
command xbps-query
;
then
elif
distro os-release
&&
is_
command xbps-query
;
then
# shellcheck disable=SC1090
# shellcheck disable=SC1090
.
$ROOTDIR
/etc/os-release
.
$ROOTDIR
/etc/os-release
DISTRIB_ID
=
"VoidLinux"
DISTRIB_ID
=
"VoidLinux"
...
@@ -541,7 +564,7 @@ elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
...
@@ -541,7 +564,7 @@ elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
DISTRIB_RELEASE
=
$(
uname
-r
)
DISTRIB_RELEASE
=
$(
uname
-r
)
# fixme: move to up
# fixme: move to up
elif
[
"
$(
uname
)
"
=
"Linux"
]
&&
has
command guix
;
then
elif
[
"
$(
uname
)
"
=
"Linux"
]
&&
is_
command guix
;
then
DISTRIB_ID
=
"GNU/Linux/Guix"
DISTRIB_ID
=
"GNU/Linux/Guix"
DISTRIB_RELEASE
=
$(
uname
-r
)
DISTRIB_RELEASE
=
$(
uname
-r
)
...
@@ -634,7 +657,7 @@ case "$DIST_ARCH" in
...
@@ -634,7 +657,7 @@ case "$DIST_ARCH" in
armv7
*
)
armv7
*
)
# TODO: use uname only
# TODO: use uname only
# uses binutils package
# uses binutils package
if
has
command readelf
&&
[
-z
"
$(
readelf
-A
/proc/self/exe |
grep
Tag_ABI_VFP_args
)
"
]
;
then
if
is_
command readelf
&&
[
-z
"
$(
readelf
-A
/proc/self/exe |
grep
Tag_ABI_VFP_args
)
"
]
;
then
DIST_ARCH
=
"armel"
DIST_ARCH
=
"armel"
else
else
DIST_ARCH
=
"armhf"
DIST_ARCH
=
"armhf"
...
@@ -778,10 +801,8 @@ get_core_mhz()
...
@@ -778,10 +801,8 @@ get_core_mhz()
get_virt
()
get_virt
()
{
{
local
VIRT
local
VIRT
local
SDCMD
if
is_command systemd-detect-virt
;
then
SDCMD
=
$(
which systemd-detect-virt 2>/dev/null
)
VIRT
=
"
$(
systemd-detect-virt
)
"
if
[
-n
"
$SDCMD
"
]
;
then
VIRT
=
"
$(
$SDCMD
)
"
[
"
$VIRT
"
=
"none"
]
&&
echo
"(host system)"
&&
return
[
"
$VIRT
"
=
"none"
]
&&
echo
"(host system)"
&&
return
[
-z
"
$VIRT
"
]
&&
echo
"(unknown)"
&&
return
[
-z
"
$VIRT
"
]
&&
echo
"(unknown)"
&&
return
echo
"
$VIRT
"
&&
return
echo
"
$VIRT
"
&&
return
...
@@ -813,7 +834,7 @@ get_service_manager()
...
@@ -813,7 +834,7 @@ get_service_manager()
[
-d
/run/systemd/system
]
&&
echo
"systemd"
&&
return
[
-d
/run/systemd/system
]
&&
echo
"systemd"
&&
return
# TODO
# TODO
#[ -d /usr/share/upstart ] && echo "upstart" && return
#[ -d /usr/share/upstart ] && echo "upstart" && return
has
command systemctl
&&
echo
"systemd"
&&
return
is_
command systemctl
&&
echo
"systemd"
&&
return
[
-d
/etc/init.d
]
&&
echo
"sysvinit"
&&
return
[
-d
/etc/init.d
]
&&
echo
"sysvinit"
&&
return
echo
"(unknown)"
echo
"(unknown)"
}
}
...
...
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