Commit de087e1a authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit pack in one file

parent 1b24e1df
...@@ -37,7 +37,8 @@ load_helper() ...@@ -37,7 +37,8 @@ load_helper()
inputisatty() inputisatty()
{ {
# check stdin # check stdin
tty -s 2>/dev/null #tty -s 2>/dev/null
test -t 0
} }
isatty() isatty()
...@@ -483,14 +484,14 @@ case $DISTRNAME in ...@@ -483,14 +484,14 @@ case $DISTRNAME in
ArchLinux) ArchLinux)
CMD="pacman" CMD="pacman"
;; ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux|Amzn)
CMD="yum-rpm" CMD="yum-rpm"
which dnf 2>/dev/null >/dev/null && test -d /var/lib/dnf/yumdb && CMD=dnf-rpm which dnf 2>/dev/null >/dev/null && test -d /var/lib/dnf/yumdb && CMD=dnf-rpm
;; ;;
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
;; ;;
SUSE|SLED|SLES|Tumbleweed) SUSE|SLED|SLES)
CMD="zypper-rpm" CMD="zypper-rpm"
;; ;;
ForesightLinux|rPathLinux) ForesightLinux|rPathLinux)
...@@ -502,8 +503,8 @@ case $DISTRNAME in ...@@ -502,8 +503,8 @@ case $DISTRNAME in
MacOS) MacOS)
CMD="homebrew" CMD="homebrew"
;; ;;
OpenWRT) OpenWrt)
CMD="ipkg" CMD="opkg"
;; ;;
GNU/Linux/Guix) GNU/Linux/Guix)
CMD="guix" CMD="guix"
...@@ -1051,8 +1052,8 @@ _print_additional_usage ...@@ -1051,8 +1052,8 @@ _print_additional_usage
internal_distr_info() internal_distr_info()
{ {
# Author: Vitaly Lipatov <lav@etersoft.ru> # Author: Vitaly Lipatov <lav@etersoft.ru>
# 2007, 2009, 2010, 2012, 2016 (c) Etersoft # 2007, 2009, 2010, 2012, 2016, 2017, 2018 (c) Etersoft
# 2007-2016 Public domain # 2007-2018 Public domain
# Detect the distro and version # Detect the distro and version
# Welcome to send updates! # Welcome to send updates!
...@@ -1060,6 +1061,8 @@ internal_distr_info() ...@@ -1060,6 +1061,8 @@ internal_distr_info()
# You can set ROOTDIR to root system dir # You can set ROOTDIR to root system dir
#ROOTDIR= #ROOTDIR=
# TODO: check /etc/system-release
# Check for DISTRO specific file in /etc # Check for DISTRO specific file in /etc
distro() distro()
{ {
...@@ -1076,11 +1079,24 @@ has() ...@@ -1076,11 +1079,24 @@ has()
grep "$*" "$DISTROFILE" >/dev/null 2>&1 grep "$*" "$DISTROFILE" >/dev/null 2>&1
} }
# Has a system the specified command?
hascommand()
{
which $1 2>/dev/null >/dev/null
}
firstupper() firstupper()
{ {
echo "$*" | sed 's/.*/\u&/' echo "$*" | sed 's/.*/\u&/'
} }
tolower()
{
# tr is broken in busybox (checked with OpenWrt)
#echo "$*" | tr "[:upper:]" "[:lower:]"
echo "$*" | awk '{print tolower($0)}'
}
# Translate DISTRIB_ID to vendor name (like %_vendor does) # Translate DISTRIB_ID to vendor name (like %_vendor does)
rpmvendor() rpmvendor()
{ {
...@@ -1089,7 +1105,8 @@ rpmvendor() ...@@ -1089,7 +1105,8 @@ rpmvendor()
[ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return [ "$DISTRIB_ID" = "LinuxXP" ] && echo "lxp" && return
[ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return [ "$DISTRIB_ID" = "TinyCoreLinux" ] && echo "tcl" && return
[ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return [ "$DISTRIB_ID" = "VoidLinux" ] && echo "void" && return
echo "$DISTRIB_ID" | tr "[:upper:]" "[:lower:]" [ "$DISTRIB_ID" = "OpenSUSE" ] && echo "suse" && return
tolower "$DISTRIB_ID"
} }
# Translate DISTRIB_ID name to package manner (like in the package release name) # Translate DISTRIB_ID name to package manner (like in the package release name)
...@@ -1114,11 +1131,12 @@ pkgtype() ...@@ -1114,11 +1131,12 @@ pkgtype()
alpine) echo "apk" ;; alpine) echo "apk" ;;
tinycorelinux) echo "tcz" ;; tinycorelinux) echo "tcz" ;;
voidlinux) echo "xbps" ;; voidlinux) echo "xbps" ;;
openwrt) echo "ipk" ;;
cygwin) echo "tar.xz" ;; cygwin) echo "tar.xz" ;;
debian|ubuntu|mint|runtu|mcst|astra) echo "deb" ;; debian|ubuntu|mint|runtu|mcst|astra) echo "deb" ;;
alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles) alt|asplinux|suse|mandriva|rosa|mandrake|pclinux|sled|sles)
echo "rpm" ;; echo "rpm" ;;
fedora|redhat|scientific|centos|rhel|goslinux) fedora|redhat|scientific|centos|rhel|goslinux|amzn)
echo "rpm" ;; echo "rpm" ;;
*) echo "rpm" ;; *) echo "rpm" ;;
esac esac
...@@ -1181,34 +1199,25 @@ elif distro gentoo-release ; then ...@@ -1181,34 +1199,25 @@ elif distro gentoo-release ; then
DISTRIB_ID="Gentoo" DISTRIB_ID="Gentoo"
MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile) MAKEPROFILE=$(readlink $ROOTDIR/etc/portage/make.profile 2>/dev/null) || MAKEPROFILE=$(readlink $ROOTDIR/etc/make.profile)
DISTRIB_RELEASE=$(basename $MAKEPROFILE) DISTRIB_RELEASE=$(basename $MAKEPROFILE)
echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=$(basename "$(dirname $MAKEPROFILE)") echo $DISTRIB_RELEASE | grep -q "[0-9]" || DISTRIB_RELEASE=$(basename "$(dirname $MAKEPROFILE)") #"
# Slackware based
elif distro mopslinux-version ; then
DISTRIB_ID="MOPSLinux"
if has 4.0 ; then DISTRIB_RELEASE="4.0"
elif has 5.0 ; then DISTRIB_RELEASE="5.0"
elif has 5.1 ; then DISTRIB_RELEASE="5.1"
elif has 6.0 ; then DISTRIB_RELEASE="6.0"
elif has 6.1 ; then DISTRIB_RELEASE="6.1"
fi
elif distro slackware-version ; then 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 && which apk 2>/dev/null >/dev/null ; then elif distro os-release && hascommand apk ; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="$(firstupper "$ID")" DISTRIB_ID="$(firstupper "$ID")"
DISTRIB_RELEASE="$VERSION_ID" DISTRIB_RELEASE="$VERSION_ID"
elif distro os-release && which tce-ab 2>/dev/null >/dev/null ; then elif distro os-release && hascommand 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 && which xbps-query 2>/dev/null >/dev/null ; then elif distro os-release && hascommand xbps-query ; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux" DISTRIB_ID="VoidLinux"
...@@ -1226,6 +1235,11 @@ elif distro mcst_version ; then ...@@ -1226,6 +1235,11 @@ elif distro mcst_version ; then
DISTRIB_ID="MCST" 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
. $DISTROFILE
DISTRIB_RELEASE=$(cat $ROOTDIR/etc/openwrt_version)
elif distro astra_version ; then elif distro astra_version ; then
#DISTRIB_ID=`cat $DISTROFILE | get_var DISTRIB_ID` #DISTRIB_ID=`cat $DISTROFILE | get_var DISTRIB_ID`
DISTRIB_ID="AstraLinux" DISTRIB_ID="AstraLinux"
...@@ -1267,26 +1281,6 @@ elif distro mandriva-release || distro mandrake-release ; then ...@@ -1267,26 +1281,6 @@ elif distro mandriva-release || distro mandrake-release ; then
fi fi
# Fedora based # Fedora based
elif distro linux-xp-release || distro lxp-release; then
DISTRIB_ID="LinuxXP"
if has "Attack of the Clones" ; then DISTRIB_RELEASE="2006"
elif has "2007" ; then DISTRIB_RELEASE="2007"
elif has "2008" ; then DISTRIB_RELEASE="2008"
elif has "2009" ; then DISTRIB_RELEASE="2009"
fi
elif distro asplinux-release ; then
DISTRIB_ID="ASPLinux"
if has Karelia ; then DISTRIB_RELEASE="10"
elif has Seliger ; then DISTRIB_RELEASE="11"
elif has "11.1" ; then DISTRIB_RELEASE="11.1"
elif has Ladoga ; then DISTRIB_RELEASE="11.2"
elif has "11.2" ; then DISTRIB_RELEASE="11.2"
elif has "12" ; then DISTRIB_RELEASE="12"
elif has "13" ; then DISTRIB_RELEASE="13"
elif has "14" ; then DISTRIB_RELEASE="14"
elif has "15" ; then DISTRIB_RELEASE="15"
fi
elif distro MCBC-release ; then elif distro MCBC-release ; then
DISTRIB_ID="MCBC" DISTRIB_ID="MCBC"
...@@ -1296,7 +1290,7 @@ elif distro MCBC-release ; then ...@@ -1296,7 +1290,7 @@ elif distro MCBC-release ; then
elif distro fedora-release ; then elif distro fedora-release ; then
DISTRIB_ID="Fedora" DISTRIB_ID="Fedora"
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") #"
elif distro redhat-release ; then elif distro redhat-release ; then
# FIXME if need # FIXME if need
...@@ -1312,14 +1306,11 @@ elif distro redhat-release ; then ...@@ -1312,14 +1306,11 @@ elif distro redhat-release ; then
if has Beryllium ; then if has Beryllium ; then
DISTRIB_ID="Scientific" DISTRIB_ID="Scientific"
DISTRIB_RELEASE="4.1" DISTRIB_RELEASE="4.1"
elif has Shrike ; then
DISTRIB_ID="RedHat"
DISTRIB_RELEASE="9"
elif has Taroon ; then DISTRIB_RELEASE="3"
elif has "release 4" ; then DISTRIB_RELEASE="4" elif has "release 4" ; then DISTRIB_RELEASE="4"
elif has "release 5" ; then DISTRIB_RELEASE="5" elif has "release 5" ; then DISTRIB_RELEASE="5"
elif has "release 6" ; then DISTRIB_RELEASE="6" elif has "release 6" ; then DISTRIB_RELEASE="6"
elif has "release 7" ; then DISTRIB_RELEASE="7" elif has "release 7" ; then DISTRIB_RELEASE="7"
elif has "release 8" ; then DISTRIB_RELEASE="8"
fi fi
# SUSE based # SUSE based
...@@ -1339,6 +1330,9 @@ elif distro os-release ; then ...@@ -1339,6 +1330,9 @@ elif distro os-release ; then
DISTRIB_ID="$(firstupper "$ID")" DISTRIB_ID="$(firstupper "$ID")"
DISTRIB_RELEASE="$VERSION_ID" DISTRIB_RELEASE="$VERSION_ID"
[ -n "$DISTRIB_RELEASE" ] || DISTRIB_RELEASE="CUR" [ -n "$DISTRIB_RELEASE" ] || DISTRIB_RELEASE="CUR"
if [ "$ID" = "opensuse-leap" ] ; then
DISTRIB_ID="SUSE"
fi
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ "$(uname)" = "FreeBSD" ] ; then elif [ "$(uname)" = "FreeBSD" ] ; then
...@@ -1357,7 +1351,7 @@ elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then ...@@ -1357,7 +1351,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" ] && which guix 2>/dev/null >/dev/null ; then elif [ "$(uname)" = "Linux" ] && hascommand guix ; then
DISTRIB_ID="GNU/Linux/Guix" DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
...@@ -1377,16 +1371,22 @@ elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then ...@@ -1377,16 +1371,22 @@ elif distro lsb-release && [ -n "$DISTRIB_RELEASE" ]; then
# fix distro name # fix distro name
case "$DISTRIB_ID" in case "$DISTRIB_ID" in
"openSUSE Tumbleweed") "openSUSE Tumbleweed")
DISTRIB_ID="Tumbleweed" DISTRIB_ID="SUSE"
DISTRIB_RELEASE="Tumbleweed"
;; ;;
esac esac
fi fi
get_uname()
{
tolower $(uname $1) | tr -d " \t\r\n"
}
get_base_os_name() get_base_os_name()
{ {
local DIST_OS local DIST_OS
# Resolve the os # Resolve the os
DIST_OS=`uname -s | tr [:upper:] [:lower:] | tr -d " \t\r\n"` DIST_OS="$(get_uname -s)"
case "$DIST_OS" in case "$DIST_OS" in
'sunos') 'sunos')
DIST_OS="solaris" DIST_OS="solaris"
...@@ -1407,16 +1407,12 @@ esac ...@@ -1407,16 +1407,12 @@ esac
echo "$DIST_OS" echo "$DIST_OS"
} }
get_uname_m()
{
uname -m | tr [:upper:] [:lower:] | tr -d " \t\r\n"
}
get_arch() get_arch()
{ {
local DIST_ARCH local DIST_ARCH
# Resolve the architecture # Resolve the architecture
DIST_ARCH="$(get_uname_m)" DIST_ARCH="$(get_uname -m)"
case "$DIST_ARCH" in case "$DIST_ARCH" in
'ia32' | 'i386' | 'i486' | 'i586' | 'i686') 'ia32' | 'i386' | 'i486' | 'i586' | 'i686')
DIST_ARCH="x86" DIST_ARCH="x86"
...@@ -1457,11 +1453,14 @@ get_bit_size() ...@@ -1457,11 +1453,14 @@ get_bit_size()
{ {
local DIST_BIT local DIST_BIT
# Check if we are running on 64bit platform, seems like a workaround for now... # Check if we are running on 64bit platform, seems like a workaround for now...
DIST_BIT="$(get_uname_m)" DIST_BIT="$(get_uname -m)"
case "$DIST_BIT" in case "$DIST_BIT" in
'amd64' | 'ia64' | 'x86_64' | 'ppc64') 'amd64' | 'ia64' | 'x86_64' | 'ppc64')
DIST_BIT="64" DIST_BIT="64"
;; ;;
'aarch64')
DIST_BIT="64"
;;
# 'pa_risc' | 'pa-risc') # Are some of these 64bit? Least not all... # 'pa_risc' | 'pa-risc') # Are some of these 64bit? Least not all...
# BIT="64" # BIT="64"
# ;; # ;;
...@@ -2185,7 +2184,7 @@ case $DISTRNAME in ...@@ -2185,7 +2184,7 @@ case $DISTRNAME in
# ArchLinux) # ArchLinux)
# CMD="pacman" # CMD="pacman"
# ;; # ;;
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux|Amzn)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
VoidLinux) VoidLinux)
...@@ -2194,7 +2193,7 @@ case $DISTRNAME in ...@@ -2194,7 +2193,7 @@ case $DISTRNAME in
Slackware) Slackware)
CMD="service-initd" CMD="service-initd"
;; ;;
SUSE|SLED|SLES|Tumbleweed) SUSE|SLED|SLES)
CMD="service-chkconfig" CMD="service-chkconfig"
;; ;;
# Windows) # Windows)
...@@ -2241,7 +2240,7 @@ $(get_help HELPOPT) ...@@ -2241,7 +2240,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 2.5.0" echo "Service manager version 2.5.4"
echo "Running on $($DISTRVENDOR) with $SERVICETYPE" echo "Running on $($DISTRVENDOR) with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012-2018" echo "Copyright (c) Etersoft 2012-2018"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
......
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