Commit 9e5b000f authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed 3.13.3

parent c4cbd4bd
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012-2013, 2016, 2020 Etersoft # Copyright (C) 2012-2013, 2016, 2020, 2021 Etersoft
# Copyright (C) 2012-2013, 2016, 2020 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012-2013, 2016, 2020, 2021 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -110,9 +110,11 @@ echon() ...@@ -110,9 +110,11 @@ echon()
set_target_pkg_env() set_target_pkg_env()
{ {
[ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env." [ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env."
PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME") local ver="$DISTRVERSION"
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME") [ -n "$ver" ] && ver="/$ver"
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME") PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME$ver")
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME$ver")
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME$ver")
} }
showcmd() showcmd()
...@@ -120,7 +122,7 @@ showcmd() ...@@ -120,7 +122,7 @@ showcmd()
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#" is_root && PROMTSIG="#"
echo " $PROMTSIG $*" echo " $PROMTSIG $*"
restore_color restore_color
fi >&2 fi >&2
...@@ -253,7 +255,13 @@ clean_store_output() ...@@ -253,7 +255,13 @@ clean_store_output()
epm() epm()
{ {
[ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script" [ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script"
$PROGDIR/$PROGNAME --inscript $@ $PROGDIR/$PROGNAME --inscript "$@"
}
sudoepm()
{
[ -n "$PROGNAME" ] || fatal "Can't use epm call from the piped script"
sudorun $PROGDIR/$PROGNAME --inscript "$@"
} }
fatal() fatal()
...@@ -302,10 +310,8 @@ set_sudo() ...@@ -302,10 +310,8 @@ set_sudo()
return return
fi fi
EFFUID=$(id -u)
# if we are root, do not need sudo # if we are root, do not need sudo
[ $EFFUID = "0" ] && return is_root && return
# start error section # start error section
SUDO_TESTED="1" SUDO_TESTED="1"
...@@ -397,10 +403,15 @@ confirm_info() ...@@ -397,10 +403,15 @@ confirm_info()
} }
is_root()
{
local EFFUID="$(id -u)"
[ "$EFFUID" = "0" ]
}
assure_root() assure_root()
{ {
set_sudo is_root || fatal "run me only under root"
[ "$EFFUID" = 0 ] || fatal "run me only under root"
} }
regexp_subst() regexp_subst()
...@@ -558,7 +569,7 @@ if [ -n "$FORCEPM" ] ; then ...@@ -558,7 +569,7 @@ if [ -n "$FORCEPM" ] ; then
return return
fi fi
PMTYPE="$($DISTRVENDOR -g $DISTRNAME)" PMTYPE="$($DISTRVENDOR -g $DISTRNAME/$DISTRVERSION)"
} }
is_active_systemd() is_active_systemd()
...@@ -1318,7 +1329,15 @@ tolower() ...@@ -1318,7 +1329,15 @@ tolower()
echo "$*" | awk '{print tolower($0)}' echo "$*" | awk '{print tolower($0)}'
} }
# Translate DISTRIB_ID to vendor name (like %_vendor does) override_distrib()
{
[ -n "$1" ] || return
VENDOR_ID=''
DISTRIB_ID="$(echo "$1" | sed -e 's|/.*||')"
DISTRIB_RELEASE="$(echo "$1" | sed -e 's|.*/||')"
}
# Translate DISTRIB_ID to vendor name (like %_vendor does), uses VENDOR_ID by default
rpmvendor() rpmvendor()
{ {
[ "$DISTRIB_ID" = "ALTLinux" ] && echo "alt" && return [ "$DISTRIB_ID" = "ALTLinux" ] && echo "alt" && return
...@@ -1402,6 +1421,7 @@ case $DISTRIB_ID in ...@@ -1402,6 +1421,7 @@ case $DISTRIB_ID in
Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux|Amzn|RedOS) Fedora|LinuxXP|ASPLinux|CentOS|RHEL|Scientific|GosLinux|Amzn|RedOS)
CMD="dnf-rpm" CMD="dnf-rpm"
which dnf 2>/dev/null >/dev/null || CMD=yum-rpm which dnf 2>/dev/null >/dev/null || CMD=yum-rpm
[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "CentOS/7" ] && CMD=yum-rpm
;; ;;
Slackware) Slackware)
CMD="slackpkg" CMD="slackpkg"
...@@ -1442,7 +1462,7 @@ case $DISTRIB_ID in ...@@ -1442,7 +1462,7 @@ case $DISTRIB_ID in
CMD="xbps" CMD="xbps"
;; ;;
*) *)
fatal "Have no suitable DISTRIB_ID $DISTRIB_ID" echo "We don't support yet DISTRIB_ID $DISTRIB_ID" >&2
;; ;;
esac esac
echo "$CMD" echo "$CMD"
...@@ -1993,14 +2013,12 @@ case $1 in ...@@ -1993,14 +2013,12 @@ case $1 in
exit 0 exit 0
;; ;;
-p) -p)
# override DISTRIB_ID override_distrib "$2"
test -n "$2" && DISTRIB_ID="$2"
pkgtype pkgtype
exit 0 exit 0
;; ;;
-g) -g)
# override DISTRIB_ID override_distrib "$2"
test -n "$2" && DISTRIB_ID="$2"
pkgmanager pkgmanager
exit 0 exit 0
;; ;;
...@@ -2008,14 +2026,12 @@ case $1 in ...@@ -2008,14 +2026,12 @@ case $1 in
print_pretty_name print_pretty_name
;; ;;
--distro-arch) --distro-arch)
# override DISTRIB_ID override_distrib "$2"
test -n "$2" && DISTRIB_ID="$2"
get_distro_arch get_distro_arch
exit 0 exit 0
;; ;;
--debian-arch) --debian-arch)
# override DISTRIB_ID override_distrib "$2"
test -n "$2" && DISTRIB_ID="$2"
get_debian_arch get_debian_arch
exit 0 exit 0
;; ;;
...@@ -2047,14 +2063,12 @@ case $1 in ...@@ -2047,14 +2063,12 @@ case $1 in
echo $DISTRIB_RELEASE echo $DISTRIB_RELEASE
;; ;;
-s) -s)
# override DISTRIB_ID override_distrib "$2"
test -n "$2" && DISTRIB_ID="$2"
pkgvendor pkgvendor
exit 0 exit 0
;; ;;
-n) -n)
# override DISTRIB_ID override_distrib "$2"
test -n "$2" && DISTRIB_ID="$2"
rpmvendor rpmvendor
exit 0 exit 0
;; ;;
...@@ -2941,7 +2955,7 @@ print_version() ...@@ -2941,7 +2955,7 @@ print_version()
local on_text="(host system)" local on_text="(host system)"
local virt="$($DISTRVENDOR -i)" local virt="$($DISTRVENDOR -i)"
[ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)" [ "$virt" = "(unknown)" ] || [ "$virt" = "(host system)" ] || on_text="(under $virt)"
echo "Service manager version 3.13.0 https://wiki.etersoft.ru/Epm" echo "Service manager version 3.13.3 https://wiki.etersoft.ru/Epm"
echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE" echo "Running on $($DISTRVENDOR -e) $on_text with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012-2021" echo "Copyright (c) Etersoft 2012-2021"
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