Commit ed89eebb authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed 3.41.0

parent 08eafa41
...@@ -33,7 +33,7 @@ SHAREDIR=$PROGDIR ...@@ -33,7 +33,7 @@ SHAREDIR=$PROGDIR
# will replaced with /etc/eepm during install # will replaced with /etc/eepm during install
CONFIGDIR=$PROGDIR/../etc CONFIGDIR=$PROGDIR/../etc
EPMVERSION="3.40.1" EPMVERSION="3.41.0"
if [ "$EPMVERSION" = "@""VERSION""@" ] ; then if [ "$EPMVERSION" = "@""VERSION""@" ] ; then
EPMVERSION=$(head $PROGDIR/../eepm.spec | grep "^Version: " | sed -e 's|Version: ||' ) EPMVERSION=$(head $PROGDIR/../eepm.spec | grep "^Version: " | sed -e 's|Version: ||' )
...@@ -53,16 +53,6 @@ load_helper() ...@@ -53,16 +53,6 @@ load_helper()
# File bin/epm-sh-functions: # File bin/epm-sh-functions:
check_core_commands()
{
#which --help >/dev/null || fatal "Can't find which command (which package is missed?)"
# broken which on Debian systems
# TODO: use is_command and print_command_path instead of
which which >/dev/null || fatal "Can't find which command (which or debianutils package is missed?)"
which grep >/dev/null || fatal "Can't find grep command (coreutils package is missed?)"
which sed >/dev/null || fatal "Can't find sed command (sed package is missed?)"
}
inputisatty() inputisatty()
{ {
...@@ -99,7 +89,7 @@ check_tty() ...@@ -99,7 +89,7 @@ check_tty()
export EGREPCOLOR="--color" export EGREPCOLOR="--color"
fi fi
which tput >/dev/null 2>/dev/null || return is_command tput || return
# FreeBSD does not support tput -S # FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return echo | tput -S >/dev/null 2>/dev/null || return
[ -z "$USETTY" ] || return [ -z "$USETTY" ] || return
...@@ -223,13 +213,6 @@ sudocmd_foreach() ...@@ -223,13 +213,6 @@ sudocmd_foreach()
done done
} }
if ! which realpath 2>/dev/null >/dev/null ; then
realpath()
{
readlink -f "$@"
}
fi
make_filepath() make_filepath()
{ {
local i local i
...@@ -393,7 +376,7 @@ set_sudo() ...@@ -393,7 +376,7 @@ set_sudo()
# start error section # start error section
SUDO_TESTED="1" SUDO_TESTED="1"
if ! which $SUDO_CMD >/dev/null 2>/dev/null ; then if ! is_command $SUDO_CMD ; then
[ "$nofail" = "nofail" ] || SUDO="fatal 'Can't find sudo. Please install and tune sudo ('# epm install sudo') or run epm under root.'" [ "$nofail" = "nofail" ] || SUDO="fatal 'Can't find sudo. Please install and tune sudo ('# epm install sudo') or run epm under root.'"
return "$SUDO_TESTED" return "$SUDO_TESTED"
fi fi
...@@ -428,7 +411,7 @@ sudo_allowed() ...@@ -428,7 +411,7 @@ sudo_allowed()
withtimeout() withtimeout()
{ {
local TO=$(which timeout 2>/dev/null || which gtimeout 2>/dev/null) local TO=$(print_command_path timeout || print_command_path gtimeout)
if [ -x "$TO" ] ; then if [ -x "$TO" ] ; then
$TO "$@" $TO "$@"
return return
...@@ -446,7 +429,7 @@ set_eatmydata() ...@@ -446,7 +429,7 @@ set_eatmydata()
# skip if disabled # skip if disabled
[ -n "$EPMNOEATMYDATA" ] && return [ -n "$EPMNOEATMYDATA" ] && return
# use if possible # use if possible
which eatmydata >/dev/null 2>/dev/null || return is_command eatmydata || return
set_sudo set_sudo
# FIXME: check if SUDO already has eatmydata # FIXME: check if SUDO already has eatmydata
[ -n "$SUDO" ] && SUDO="$SUDO eatmydata" || SUDO="eatmydata" [ -n "$SUDO" ] && SUDO="$SUDO eatmydata" || SUDO="eatmydata"
...@@ -537,7 +520,7 @@ disabled_eget() ...@@ -537,7 +520,7 @@ disabled_eget()
# FIXME: we need disable output here, eget can be used for get output # FIXME: we need disable output here, eget can be used for get output
assure_exists eget eget 3.3 >/dev/null assure_exists eget eget 3.3 >/dev/null
# run external command, not the function # run external command, not the function
EGET=$(which eget) || fatal "Missed command eget from installed package eget" EGET=$(print_command_path eget) || fatal "Missed command eget from installed package eget"
$EGET "$@" $EGET "$@"
} }
...@@ -554,7 +537,7 @@ disabled_erc() ...@@ -554,7 +537,7 @@ disabled_erc()
# FIXME: we need disable output here, ercat can be used for get output # FIXME: we need disable output here, ercat can be used for get output
assure_exists_erc >/dev/null assure_exists_erc >/dev/null
# run external command, not the function # run external command, not the function
ERC=$(which erc) || fatal "Missed command erc from installed package erc" ERC=$(print_command_path erc) || fatal "Missed command erc from installed package erc"
$ERC "$@" $ERC "$@"
} }
...@@ -571,7 +554,7 @@ disabled_ercat() ...@@ -571,7 +554,7 @@ disabled_ercat()
# FIXME: we need disable output here, ercat can be used for get output # FIXME: we need disable output here, ercat can be used for get output
assure_exists_erc >/dev/null assure_exists_erc >/dev/null
# run external command, not the function # run external command, not the function
ERCAT=$(which ercat) || fatal "Missed command ercat from installed package erc" ERCAT=$(print_command_path ercat) || fatal "Missed command ercat from installed package erc"
$ERCAT "$@" $ERCAT "$@"
} }
...@@ -592,8 +575,9 @@ estrlist() ...@@ -592,8 +575,9 @@ estrlist()
eget() eget()
{ {
# check for both # check for both
which curl 2>/dev/null >/dev/null || assure_exists wget # we really need that cross here,
which wget 2>/dev/null >/dev/null || assure_exists curl is_command curl || assure_exists wget
is_command wget || assure_exists curl
internal_tools_eget "$@" internal_tools_eget "$@"
} }
...@@ -778,7 +762,7 @@ is_command() ...@@ -778,7 +762,7 @@ is_command()
} }
if ! which realpath 2>/dev/null >/dev/null ; then if ! is_command realpath ; then
realpath() realpath()
{ {
[ -n "$*" ] || return [ -n "$*" ] || return
...@@ -787,13 +771,26 @@ realpath() ...@@ -787,13 +771,26 @@ realpath()
fi fi
if ! which subst 2>/dev/null >/dev/null ; then
if ! is_command subst ; then
subst() subst()
{ {
sed -i -e "$@" sed -i -e "$@"
} }
fi fi
check_core_commands()
{
#which --help >/dev/null || fatal "Can't find which command (which package is missed?)"
# broken which on Debian systems
# TODO: use is_command and print_command_path instead of
which which >/dev/null || fatal "Can't find which command (which or debianutils package is missed?)"
is_command grep || fatal "Can't find grep command (coreutils package is missed?)"
is_command sed || fatal "Can't find sed command (sed package is missed?)"
}
# File bin/epm-addrepo: # File bin/epm-addrepo:
...@@ -851,6 +848,32 @@ __epm_addrepo_etersoft_addon() ...@@ -851,6 +848,32 @@ __epm_addrepo_etersoft_addon()
fi fi
} }
__epm_addrepo_altsp()
{
local comp
local repo="$1"
case "$repo" in
c9f2)
comp="CF2"
;;
c9f1)
comp="CF1"
;;
c9)
comp="cf"
;;
*)
fatal "Uknown CF comp $repo"
;;
esac
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/$DISTRARCH classic" || return
if [ "$DISTRARCH" = "x86_64" ] ; then
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/x86_64-i586 classic" || return
fi
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/noarch classic" || return
}
get_archlist() get_archlist()
{ {
echo "noarch" echo "noarch"
...@@ -913,23 +936,38 @@ __epm_addrepo_altlinux_url() ...@@ -913,23 +936,38 @@ __epm_addrepo_altlinux_url()
} }
__epm_addrepo_altlinux_help()
{
#sudocmd apt-repo $dryrun add branch
cat <<EOF
epm repo add - add branch repo. Use follow params:
etersoft - for LINUX@Etersoft repo"
basealt - for BaseALT repo"
yandex - for BaseALT repo mirror hosted by Yandex (recommended)"
altsp - add ALT SP repo"
autoimports - for BaseALT autoimports repo"
altlinuxclub - for altlinuxclub repo (http://altlinuxclub.ru/)"
<task number> - add task repo"
archive 2018/02/09 - add archive of the repo from that date"
/dir/to/repo [component] - add repo dir generated with epm repo index --init"
URL [arch] [component] - add repo by URL"
Examples:
# epm repo add yandex
# epm repo add "rpm http://somesite/pub/product x86_64 addon"
# epm repo add /var/ftp/pub/altlinux/p10
EOF
return
}
__epm_addrepo_altlinux() __epm_addrepo_altlinux()
{ {
local repo="$*" local repo="$*"
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
[ -n "$branch" ] || fatal "Empty DISTRVERSION"
if [ -z "$repo" ] || [ "$repo" == "--help" ] ; then if [ -z "$repo" ] || [ "$repo" == "-h" ] || [ "$repo" == "--list" ] || [ "$repo" == "--help" ] ; then
info "Add branch repo. Use follow params:" __epm_addrepo_altlinux_help
sudocmd apt-repo $dryrun add branch
echo "etersoft - for LINUX@Etersoft repo"
echo "basealt - for BaseALT repo"
echo "yandex - for BaseALT repo mirror on yandex (recommended)"
echo "<task number> - add task repo"
echo "archive 2018/02/09 - for archive from that date"
echo "autoimports - for BaseALT autoimports repo"
echo "/dir/to/repo [component] - add repo dir generated with epm repo index --init"
echo "URL [arch] [component] - add repo by URL"
return return
fi fi
...@@ -951,43 +989,48 @@ __epm_addrepo_altlinux() ...@@ -951,43 +989,48 @@ __epm_addrepo_altlinux()
return return
fi fi
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
[ -n "$branch" ] || fatal "Empty DISTRVERSION"
case "$1" in case "$1" in
etersoft) etersoft)
info "add Etersoft's addon repo" # TODO: return when Etersoft improved its repos
assure_exists apt-repo #info "add Etersoft's addon repo"
__epm_addrepo_etersoft_addon #__epm_addrepo_etersoft_addon
sudocmd apt-repo add $branch epm repo add $branch
epm repofix etersoft epm repofix etersoft
return 0 return 0
;; ;;
basealt|ALTLinux|ALTServer) basealt|alt|altsp)
# TODO: setrepo? repo="$branch"
assure_exists apt-repo
sudocmd apt-repo add $branch
return 0
;; ;;
yandex) yandex)
assure_exists apt-repo epm repo add $branch
sudocmd apt-repo add $branch
epm repofix yandex epm repofix yandex
return 0 return 0
;; ;;
autoimports) autoimports)
repo="autoimports.$branch" repo="autoimports.$branch"
;; ;;
altlinuxclub)
repo="altlinuxclub.$branch"
;;
autoimports.*|altlinuxclub.*)
repo="$1"
;;
archive) archive)
datestr="$2" datestr="$2"
echo "$datestr" | grep -Eq "^20[0-2][0-9]/[01][0-9]/[0-3][0-9]$" || fatal "use follow date format: 2017/12/31" echo "$datestr" | grep -Eq "^20[0-2][0-9]/[01][0-9]/[0-3][0-9]$" || fatal "use follow date format: 2017/12/31"
echo "" | sudocmd tee -a /etc/apt/sources.list
local distrversion="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
local rpmsign='[alt]' local rpmsign='[alt]'
[ "$distrversion" != "sisyphus" ] && rpmsign="[$distrversion]" [ "$branch" != "sisyphus" ] && rpmsign="[$branch]"
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/$DISTRARCH classic" | sudocmd tee -a /etc/apt/sources.list
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/$DISTRARCH classic"
if [ "$DISTRARCH" = "x86_64" ] ; then if [ "$DISTRARCH" = "x86_64" ] ; then
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/x86_64-i586 classic" | sudocmd tee -a /etc/apt/sources.list epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/x86_64-i586 classic"
fi fi
echo "rpm $rpmsign $ALTLINUXPUBURL archive/$distrversion/date/$datestr/noarch classic" | sudocmd tee -a /etc/apt/sources.list epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/noarch classic"
return 0 return 0
;; ;;
esac esac
...@@ -999,6 +1042,14 @@ __epm_addrepo_altlinux() ...@@ -999,6 +1042,14 @@ __epm_addrepo_altlinux()
return return
fi fi
case "$repo" in
c9f2|c9f1|c9)
__epm_addrepo_altsp "$repo"
return
;;
esac
# don't add again # don't add again
epm repo list --quiet | grep -q -F "$repo" && return 0 epm repo list --quiet | grep -q -F "$repo" && return 0
...@@ -1194,7 +1245,7 @@ case $PMTYPE in ...@@ -1194,7 +1245,7 @@ case $PMTYPE in
sudocmd dnf config-manager --add-repo "$repo" sudocmd dnf config-manager --add-repo "$repo"
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi.addmedia "$repo" sudocmd urpmi.addmedia "$@"
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper ar "$repo" sudocmd zypper ar "$repo"
...@@ -1227,7 +1278,7 @@ esac ...@@ -1227,7 +1278,7 @@ esac
__check_command_in_path() __check_command_in_path()
{ {
PATH=$PATH:/sbin:/usr/sbin which "$1" 2>/dev/null PATH=$PATH:/sbin:/usr/sbin print_command_path "$1"
} }
__epm_need_update() __epm_need_update()
...@@ -2291,87 +2342,6 @@ esac ...@@ -2291,87 +2342,6 @@ esac
} }
# File bin/epm-commentrepo:
__epm_commentrepo_alt_grepremove()
{
local rl
__replace_text_in_alt_repo "/^ *#/! s! *(.*$1)!# \1!g"
exit
# TODO
# ^rpm means full string
if rhas "$1" "^rpm" ; then
rl="$1"
else
rl="$( (epm --quiet repo list) 2>/dev/null | grep -E "$1")"
[ -z "$rl" ] && warning "Can't find '$1' in the repos (see '# epm repolist' output)" && return 1
fi
echo "$rl" | while read rp ; do
if [ -n "$dryrun" ] ; then
echo "$rp" | grep -E --color -- "$1"
continue
fi
#if [ -n "$verbose" ] ; then
# sudocmd apt-repo $dryrun rm "$rp"
#else
__replace_text_in_alt_repo "s! *$rp!# $rp!g"
#fi
done
}
__epm_commentrepo_alt()
{
local repo="$*"
[ -n "$repo" ] || fatal "No such repo or task. Use epm repo comment <regexp|archive|tasks|TASKNUMBER>"
assure_exists apt-repo
if tasknumber "$repo" >/dev/null ; then
local tn
for tn in $(tasknumber "$repo") ; do
__epm_commentrepo_alt_grepremove " repo/$tn/"
done
return
fi
case "$1" in
archive)
info "remove archive repos"
__epm_commentrepo_alt_grepremove "archive/"
;;
tasks)
info "remove task repos"
__epm_commentrepo_alt_grepremove " repo/[0-9]+/"
;;
task)
shift
__epm_commentrepo_alt_grepremove " repo/$1/"
;;
-*)
fatal "epm commentrepo: no options are supported"
;;
*)
__epm_commentrepo_alt_grepremove "$*"
;;
esac
}
epm_commentrepo()
{
case $BASEDISTRNAME in
"alt")
__epm_commentrepo_alt "$@"
return
;;
esac;
fatal "Have no suitable command for $PMTYPE"
}
# File bin/epm-conflicts: # File bin/epm-conflicts:
...@@ -2785,7 +2755,9 @@ __epm_download_alt() ...@@ -2785,7 +2755,9 @@ __epm_download_alt()
try_change_alt_repo try_change_alt_repo
epm_addrepo "$@" epm_addrepo "$@"
docmd epm download $print_url "$installlist" epm update
[ -n "$verbose" ] && epm repo list
docmd epm download $print_url $installlist
epm_removerepo "$@" epm_removerepo "$@"
end_change_alt_repo end_change_alt_repo
...@@ -2797,7 +2769,7 @@ __epm_download_alt() ...@@ -2797,7 +2769,7 @@ __epm_download_alt()
for i in $(sudocmd apt-get install -y --print-uris --reinstall "$pkg" | cut -f1 -d " " | grep ".rpm'$" | sed -e "s|^'||" -e "s|'$||") ; do for i in $(sudocmd apt-get install -y --print-uris --reinstall "$pkg" | cut -f1 -d " " | grep ".rpm'$" | sed -e "s|^'||" -e "s|'$||") ; do
echo "$(basename "$i")" | grep -q "^$pkg" || continue echo "$(basename "$i")" | grep -q "^$pkg" || continue
[ -n "$print_url" ] && echo "$i" && continue [ -n "$print_url" ] && echo "$i" && continue
eget $i eget "$i"
done done
done done
return return
...@@ -3190,14 +3162,14 @@ epm_full_upgrade() ...@@ -3190,14 +3162,14 @@ epm_full_upgrade()
fi fi
if [ -z "$full_upgrade_no_flatpack" ] ; then if [ -z "$full_upgrade_no_flatpack" ] ; then
if which flatpak 2>/dev/null >/dev/null ; then if is_command flatpak ; then
[ -n "$quiet" ] || echo [ -n "$quiet" ] || echo
docmd flatpak update docmd flatpak update
fi fi
fi fi
if [ -z "$full_upgrade_no_snap" ] ; then if [ -z "$full_upgrade_no_snap" ] ; then
if which snap 2>/dev/null >/dev/null && serv snapd exists && serv snapd status ; then if is_command snap && serv snapd exists && serv snapd status >/dev/null ; then
[ -n "$quiet" ] || echo [ -n "$quiet" ] || echo
sudocmd snap refresh sudocmd snap refresh
fi fi
...@@ -3209,34 +3181,57 @@ epm_full_upgrade() ...@@ -3209,34 +3181,57 @@ epm_full_upgrade()
# File bin/epm-history: # File bin/epm-history:
EHOG='\(apt-get\|rpm\)'
__alt_epm_history_journal()
{
a= journalctl -t apt-get -t rpm
}
__alt_epm_history_uniq() __alt_epm_history_uniq()
{ {
a= journalctl -t apt-get | grep "apt-get\[[0-9][0-9]*\]:" | sed -e "s|.*apt-get\[\([0-9][0-9]*\)\]: .*|\1|" | uniq | tac __alt_epm_history_journal | grep "$EHOG\[[0-9][0-9]*\]:" | sed -e "s@.*$EHOG\[\([0-9][0-9]*\)\]: .*@\2@" | uniq | tac
} }
__alt_epm_history_select() __alt_epm_history_select()
{ {
local pid="$1" local pid="$1"
local verb="$2" local verb="$2"
a= journalctl -t apt-get | grep "apt-get\[$pid\]: .*$verb" | sed -e "s|.*apt-get\[[0-9][0-9]*\]: ||" | cut -d" " -f 1 __alt_epm_history_journal | grep "$EHOG\[$pid\]: .*$verb" | sed -e "s@.*$EHOG\[[0-9][0-9]*\]: @@" | cut -d" " -f 1
} }
_alt_epm_history_date() _alt_epm_history_date()
{ {
local pid="$1" local pid="$1"
a= journalctl -t apt-get | grep "apt-get\[$pid\]: " | head -n1 | cut -d" " -f 1-3 __alt_epm_history_journal | grep "$EHOG\[$pid\]: " | head -n1 | cut -d" " -f 1-3,5 | sed -e 's|:$||'
}
_alt_epm_history_print_group()
{
local i
if [ -n "$2" ] ; then
echo
echo "$1 session:"
shift
else
return
fi
for i in $* ; do
echo " $i"
done
} }
__alt_epm_history_removed() __alt_epm_history_removed()
{ {
echo "Removed packages history:" echo "Removed packages history:"
__alt_epm_history_uniq | while read pid ; do __alt_epm_history_uniq | while read pid ; do
date="$(_alt_epm_history_date $pid)" date="$(_alt_epm_history_date $pid)"
echo
echo "$date apt-get session $pid:"
removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )" removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )"
installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )" installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )"
epm tool --quiet estrlist exclude "$installed" "$removed" | xargs -n1 echo | sed -e "s|^| |" _alt_epm_history_print_group "$date" $(estrlist exclude "$installed" "$removed")
done done
} }
...@@ -3244,13 +3239,11 @@ __alt_epm_history_installed() ...@@ -3244,13 +3239,11 @@ __alt_epm_history_installed()
{ {
echo "Installed packages history:" echo "Installed packages history:"
__alt_epm_history_uniq | while read pid ; do __alt_epm_history_uniq | while read pid ; do
echo
date="$(_alt_epm_history_date $pid)" date="$(_alt_epm_history_date $pid)"
echo "$date apt-get session $pid:"
#epm print shortname for $(__alt_epm_history_select $pid "installed") | sed -e "s|^| |" #epm print shortname for $(__alt_epm_history_select $pid "installed") | sed -e "s|^| |"
removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )" removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )"
installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )" installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )"
epm tool --quiet estrlist exclude "$removed" "$installed" | xargs -n1 echo | sed -e "s|^| |" _alt_epm_history_print_group "$date" $(estrlist exclude "$removed" "$installed")
done done
} }
...@@ -3258,13 +3251,11 @@ __alt_epm_history_updated() ...@@ -3258,13 +3251,11 @@ __alt_epm_history_updated()
{ {
echo "Updated packages history:" echo "Updated packages history:"
__alt_epm_history_uniq | while read pid ; do __alt_epm_history_uniq | while read pid ; do
echo
date="$(_alt_epm_history_date $pid)" date="$(_alt_epm_history_date $pid)"
echo "$date apt-get session $pid:"
#epm print shortname for $(__alt_epm_history_select $pid "installed") | sed -e "s|^| |" #epm print shortname for $(__alt_epm_history_select $pid "installed") | sed -e "s|^| |"
removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )" removed="$(epm print shortname for $(__alt_epm_history_select $pid "removed") )"
installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )" installed="$(epm print shortname for $(__alt_epm_history_select $pid "installed") )"
epm tool --quiet estrlist intersection "$removed" "$installed" | xargs -n1 echo | sed -e "s|^| |" _alt_epm_history_print_group "$date" $(estrlist intersection "$removed" "$installed")
done done
} }
...@@ -3316,7 +3307,7 @@ fi ...@@ -3316,7 +3307,7 @@ fi
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
docmd journalctl -t apt-get docmd journalctl -t apt-get -t rpm -r
;; ;;
apt-dpkg) apt-dpkg)
docmd less /var/log/dpkg.log docmd less /var/log/dpkg.log
...@@ -4762,6 +4753,7 @@ __epm_pack() ...@@ -4762,6 +4753,7 @@ __epm_pack()
local repackcode="$EPM_PACK_SCRIPTS_DIR/$packname.sh" local repackcode="$EPM_PACK_SCRIPTS_DIR/$packname.sh"
[ -x "$repackcode" ] || fatal "Can't find script $repackcode for packname $packname" [ -x "$repackcode" ] || fatal "Can't find script $repackcode for packname $packname"
[ -f "$repackcode.rpmnew" ] && warning "There is .rpmnew file(s) in $EPM_PACK_SCRIPTS_DIR dir. The pack script can be outdated."
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
filefortarname="$tmpdir/filefortarname" filefortarname="$tmpdir/filefortarname"
...@@ -5090,6 +5082,8 @@ __run_script() ...@@ -5090,6 +5082,8 @@ __run_script()
{ {
local script="$psdir/$1.sh" local script="$psdir/$1.sh"
[ -x "$script" ] || return [ -x "$script" ] || return
[ -f "$script.rpmnew" ] && warning "There is .rpmnew file(s) in $psdir dir. The play script can be outdated."
shift shift
( unset EPMCURDIR ; $script "$@" ) ( unset EPMCURDIR ; $script "$@" )
return return
...@@ -5735,7 +5729,7 @@ compare_version() ...@@ -5735,7 +5729,7 @@ compare_version()
{ {
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
which rpmevrcmp 2>/dev/null >/dev/null || fatal "rpmevrcmp exists in ALT Linux only" is_command rpmevrcmp || fatal "rpmevrcmp exists in ALT Linux only"
a= rpmevrcmp "$@" a= rpmevrcmp "$@"
;; ;;
*-dpkg) *-dpkg)
...@@ -6389,7 +6383,7 @@ __do_query_real_file() ...@@ -6389,7 +6383,7 @@ __do_query_real_file()
if [ -e "$1" ] ; then if [ -e "$1" ] ; then
TOFILE="$(__abs_filename "$1")" TOFILE="$(__abs_filename "$1")"
else else
TOFILE=$(which -- "$1" 2>/dev/null || echo "$1") TOFILE=$(print_command_path "$1" || echo "$1")
if [ "$TOFILE" != "$1" ] ; then if [ "$TOFILE" != "$1" ] ; then
info " > $1 is placed as $TOFILE" info " > $1 is placed as $TOFILE"
fi fi
...@@ -7248,6 +7242,26 @@ epm_release_upgrade() ...@@ -7248,6 +7242,26 @@ epm_release_upgrade()
;; ;;
esac esac
case $DISTRNAME in
"Mageia")
epm repo remove all
sudocmd urpmi.addmedia --distrib --mirrorlist 'http://mirrors.mageia.org/api/mageia.8.$DISTRARCH.list'
sudocmd urpmi --auto-update $non_interactive $force
return
;;
"ROSA")
urpm-rpm)
# TODO: move to distro related upgrade
#epm repo remove all
# FIXME: don't work:
#epm repo add "http://mirror.rosalinux.ru/rosa/rosa2021.1/repository/$DISTRARCH"
#showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
#sudocmd urpmi --auto-update --replacefiles
return
*)
;;
esac
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
#docmd epm update #docmd epm update
...@@ -7345,15 +7359,9 @@ epm_release_upgrade() ...@@ -7345,15 +7359,9 @@ epm_release_upgrade()
sudocmd dnf distro-sync --releasever=$RELEASEVER sudocmd dnf distro-sync --releasever=$RELEASEVER
info "You can run '# epm autoorphans' to remove orphaned packages" info "You can run '# epm autoorphans' to remove orphaned packages"
;; ;;
urpm-rpm)
sudocmd urpmi.removemedia -av
info "Try do manually"
showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
sudocmd urpmi --auto-update --replacefiles
;;
zypper-rpm) zypper-rpm)
docmd epm repolist docmd epm repolist
# TODO # TODO: move to distro related upgrade
# sudocmd zypper rr <номер_репозитория> # sudocmd zypper rr <номер_репозитория>
showcmd rr N showcmd rr N
showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss showcmd epm ar http://mirror.yandex.ru/opensuse/distribution/11.1/repo/oss 11.1oss
...@@ -7363,13 +7371,13 @@ epm_release_upgrade() ...@@ -7363,13 +7371,13 @@ epm_release_upgrade()
docmd epm upgrade docmd epm upgrade
;; ;;
pacman) pacman)
epm Upgrade docmd epm Upgrade
;; ;;
conary) conary)
epm Upgrade docmd epm Upgrade
;; ;;
emerge) emerge)
epm Upgrade docmd epm Upgrade
;; ;;
guix) guix)
sudocmd guix pull --verbose sudocmd guix pull --verbose
...@@ -7734,7 +7742,7 @@ epm_remove_old_kernels() ...@@ -7734,7 +7742,7 @@ epm_remove_old_kernels()
[ -n "$dryrun" ] && return [ -n "$dryrun" ] && return
# remove unused nvidia drivers # remove unused nvidia drivers
if which nvidia-clean-driver 2>/dev/null ; then if is_command nvidia-clean-driver ; then
if [ -n "$non_interactive" ] ; then if [ -n "$non_interactive" ] ; then
yes | sudocmd nvidia-clean-driver yes | sudocmd nvidia-clean-driver
else else
...@@ -7790,7 +7798,7 @@ __epm_removerepo_alt_grepremove() ...@@ -7790,7 +7798,7 @@ __epm_removerepo_alt_grepremove()
if [ "$1" = "all" ] || rhas "$1" "^rpm" ; then if [ "$1" = "all" ] || rhas "$1" "^rpm" ; then
rl="$1" rl="$1"
else else
rl="$( epm --quiet repolist 2>/dev/null | grep -F "$1" | head -n1 )" rl="$( epm --quiet repolist 2>/dev/null | grep -F "$1")"
[ -z "$rl" ] && warning "Can't find '$1' in the repos (see '# epm repolist' output)" && return 1 [ -z "$rl" ] && warning "Can't find '$1' in the repos (see '# epm repolist' output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
...@@ -7799,7 +7807,7 @@ __epm_removerepo_alt_grepremove() ...@@ -7799,7 +7807,7 @@ __epm_removerepo_alt_grepremove()
docmd apt-repo $dryrun rm "$rp" docmd apt-repo $dryrun rm "$rp"
continue continue
fi fi
if [ -n "$verbose" ] ; then if [ -z "$quiet" ] ; then
sudocmd apt-repo $dryrun rm "$rp" sudocmd apt-repo $dryrun rm "$rp"
else else
sudorun apt-repo $dryrun rm "$rp" sudorun apt-repo $dryrun rm "$rp"
...@@ -7822,11 +7830,13 @@ __epm_removerepo_alt() ...@@ -7822,11 +7830,13 @@ __epm_removerepo_alt()
return return
fi fi
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
case "$1" in case "$1" in
autoimports) autoimports)
info "remove autoimports repo" info "remove autoimports repo"
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION" [ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="autoimports.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")" repo="autoimports.$branch"
sudocmd apt-repo $dryrun rm "$repo" sudocmd apt-repo $dryrun rm "$repo"
;; ;;
archive) archive)
...@@ -7859,24 +7869,21 @@ case $BASEDISTRNAME in ...@@ -7859,24 +7869,21 @@ case $BASEDISTRNAME in
__epm_removerepo_alt "$@" __epm_removerepo_alt "$@"
return return
;; ;;
"astra")
echo "Use workaround for AstraLinux"
[ -n "$*" ] || fatal "empty repo name"
# aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel
sudocmd sed -i -e "s|.*$*.*||" /etc/apt/sources.list
if [ -d /etc/apt/sources.list.d ] && ls /etc/apt/sources.list.d/*.list >/dev/null 2>/dev/null ; then
sudocmd sed -i -e "s|.*$*.*||" /etc/apt/sources.list.d/*.list
fi
return
;;
esac; esac;
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
assure_exists apt-add-repository software-properties-common assure_exists apt-add-repository software-properties-common
set_sudo
if [ "$DISTRNAME" = "AstraLinuxCE" ] || [ "$DISTRNAME" = "AstraLinuxSE" ] ; then
echo "Use workaround for AstraLinux"
[ -n "$*" ] || fatal "empty repo name"
# aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel
sudocmd sed -i -e "s|.*$*.*||" /etc/apt/sources.list
if [ -d /etc/apt/sources.list.d ] && ls /etc/apt/sources.list.d/*.list >/dev/null 2>/dev/null ; then
sudocmd sed -i -e "s|.*$*.*||" /etc/apt/sources.list.d/*.list
fi
exit
fi
# FIXME: it is possible there is troubles to pass the args # FIXME: it is possible there is troubles to pass the args
sudocmd apt-add-repository --remove "$*" sudocmd apt-add-repository --remove "$*"
info "Check file /etc/apt/sources.list if needed" info "Check file /etc/apt/sources.list if needed"
...@@ -7889,6 +7896,10 @@ case $PMTYPE in ...@@ -7889,6 +7896,10 @@ case $PMTYPE in
sudocmd yum-config-manager --disable "$@" sudocmd yum-config-manager --disable "$@"
;; ;;
urpm-rpm) urpm-rpm)
if [ "$1" = "all" ] ; then
sudocmd urpmi.removemedia -av
return
fi
sudocmd urpmi.removemedia "$@" sudocmd urpmi.removemedia "$@"
;; ;;
zypper-rpm) zypper-rpm)
...@@ -8224,6 +8235,8 @@ __apply_fix_code() ...@@ -8224,6 +8235,8 @@ __apply_fix_code()
{ {
local repackcode="$EPM_REPACK_SCRIPTS_DIR/$1.sh" local repackcode="$EPM_REPACK_SCRIPTS_DIR/$1.sh"
[ -s "$repackcode" ] || return [ -s "$repackcode" ] || return
[ -f "$repackcode.rpmnew" ] && warning "There is .rpmnew file(s) in $EPM_REPACK_SCRIPTS_DIR dir. The pack script can be outdated."
shift shift
export PATH=$PROGDIR:$PATH export PATH=$PROGDIR:$PATH
local bashopt='' local bashopt=''
...@@ -8401,24 +8414,15 @@ epm_repo() ...@@ -8401,24 +8414,15 @@ epm_repo()
switch) # HELPCMD: switch repo to <repo>: rewrite URLs to the repo switch) # HELPCMD: switch repo to <repo>: rewrite URLs to the repo
epm_reposwitch "$@" epm_reposwitch "$@"
;; ;;
index) # HELPCMD: index repo: [--init] [path] [name]
epm_repoindex "$@"
;;
pkgadd) # HELPCMD: add to <dir> applied <package-filename1> [<package-filename2>...]
epm_repo_pkgadd "$@"
;;
pkgupdate) # HELPCMD: replace in <dir> with new <package-filename1> [<package-filename2>...]
epm_repo_pkgupdate "$@"
;;
pkgdel) # HELPCMD: del from <dir> <package1> [<package2>...]
epm_repo_pkgdel "$@"
;;
enable) # HELPCMD: enable <repo> enable) # HELPCMD: enable <repo>
epm_repoenable "$@" epm_repoenable "$@"
;; ;;
disable) # HELPCMD: disable <repo> disable) # HELPCMD: disable <repo>
epm_repodisable "$@" epm_repodisable "$@"
;; ;;
addkey) # HELPCMD: add repository gpg key
epm_addkey "$@"
;;
clean) # HELPCMD: remove temp. repos (tasks and CD-ROMs) clean) # HELPCMD: remove temp. repos (tasks and CD-ROMs)
# TODO: check for ALT # TODO: check for ALT
sudocmd apt-repo $dryrun clean sudocmd apt-repo $dryrun clean
...@@ -8439,14 +8443,24 @@ epm_repo() ...@@ -8439,14 +8443,24 @@ epm_repo()
epm_addrepo "$@" epm_addrepo "$@"
epm update epm update
;; ;;
addkey) # HELPCMD: add repository gpg key
epm_addkey "$@"
;;
rm|remove) # HELPCMD: remove repository from the sources lists (epm repo remove all for all) rm|remove) # HELPCMD: remove repository from the sources lists (epm repo remove all for all)
epm_removerepo "$@" epm_removerepo "$@"
;; ;;
comment) # HELPCMD: comment out repository line from the sources lists
epm_commentrepo "$@" create) # HELPCMD: create (initialize) repo: [path] [name]
epm_repocreate "$@"
;;
index) # HELPCMD: index repo: [--init] [path] [name]
epm_repoindex "$@"
;;
pkgadd) # HELPCMD: add to <dir> applied <package-filename1> [<package-filename2>...]
epm_repo_pkgadd "$@"
;;
pkgupdate) # HELPCMD: replace in <dir> with new <package-filename1> [<package-filename2>...]
epm_repo_pkgupdate "$@"
;;
pkgdel) # HELPCMD: del from <dir> <package1> [<package2>...]
epm_repo_pkgdel "$@"
;; ;;
*) *)
fatal "Unknown command $ epm repo '$CMD'" fatal "Unknown command $ epm repo '$CMD'"
...@@ -8873,6 +8887,7 @@ __epm_repoindex_deb() ...@@ -8873,6 +8887,7 @@ __epm_repoindex_deb()
local dir="$1" local dir="$1"
sudocmd mkdir -pv "$dir" || fatal sudocmd mkdir -pv "$dir" || fatal
assure_exists gzip
sudocmd dpkg-scanpackages -t deb "$dir" | gzip | cat > "$dir/Packages.gz" sudocmd dpkg-scanpackages -t deb "$dir" | gzip | cat > "$dir/Packages.gz"
} }
...@@ -8910,6 +8925,11 @@ esac ...@@ -8910,6 +8925,11 @@ esac
} }
epm_repocreate()
{
epm_repoindex --init "$@"
}
# File bin/epm-repolist: # File bin/epm-repolist:
...@@ -9018,7 +9038,7 @@ case $PMTYPE in ...@@ -9018,7 +9038,7 @@ case $PMTYPE in
[ -n "$verbose" ] || info "Use --verbose if you need detail information." [ -n "$verbose" ] || info "Use --verbose if you need detail information."
;; ;;
urpm-rpm) urpm-rpm)
docmd urpmq --list-url docmd urpmq --list-media active --list-url
;; ;;
zypper-rpm) zypper-rpm)
docmd zypper sl -d docmd zypper sl -d
...@@ -10776,7 +10796,7 @@ run_command_if_exists() ...@@ -10776,7 +10796,7 @@ run_command_if_exists()
{ {
local CMD="$1" local CMD="$1"
shift shift
if which "$CMD" 2>/dev/null >/dev/null ; then if is_command "$CMD" ; then
docmd $CMD "$@" docmd $CMD "$@"
return 0 return 0
fi fi
...@@ -10888,6 +10908,7 @@ epm_tool_help() ...@@ -10888,6 +10908,7 @@ epm_tool_help()
Examples: Examples:
epm tool eget -U http://ya.ru epm tool eget -U http://ya.ru
epm tool estrlist union a b a c epm tool estrlist union a b a c
epm tool erc archive.zip
EOF EOF
} }
...@@ -10898,7 +10919,7 @@ epm_tool() ...@@ -10898,7 +10919,7 @@ epm_tool()
case "$WHAT" in case "$WHAT" in
"") "")
fatal "Use epm tool help to get help." fatal "Use epm tool --help to get help."
;; ;;
"-h"|"--help"|"help") "-h"|"--help"|"help")
epm_tool_help epm_tool_help
...@@ -11449,9 +11470,17 @@ case $DISTRIB_ID in ...@@ -11449,9 +11470,17 @@ case $DISTRIB_ID in
CMD="urpm-rpm" CMD="urpm-rpm"
;; ;;
ROSA) ROSA)
CMD="dnf-rpm" CMD="urpm-rpm"
hascommand dnf || CMD="yum-rpm" hascommand yum && CMD="yum-rpm"
[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm" hascommand dnf && CMD="dnf-rpm"
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;;
ROSAFresh)
CMD="urpm-rpm"
hascommand yum && CMD="yum-rpm"
hascommand dnf && CMD="dnf-rpm"
# use dnf since 2020
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;; ;;
FreeBSD|NetBSD|OpenBSD|Solaris) FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc" CMD="pkgsrc"
...@@ -11512,12 +11541,12 @@ case $DISTRIB_ID in ...@@ -11512,12 +11541,12 @@ case $DISTRIB_ID in
echo "apt-dpkg" && return echo "apt-dpkg" && return
fi fi
if hascommand "rpm" && [ -s /var/lib/rpm/Name ] ; then if hascommand "rpm" && [ -s /var/lib/rpm/Name ] || [ -s /var/lib/rpm/rpmdb.sqlite ] ; then
hascommand "zypper" && echo "zypper-rpm" && return hascommand "zypper" && echo "zypper-rpm" && return
hascommand "dnf" && echo "dnf-rpm" && return hascommand "dnf" && echo "dnf-rpm" && return
hascommand "apt-get" && echo "apt-rpm" && return hascommand "apt-get" && echo "apt-rpm" && return
hascommand "yum" && echo "yum-rpm" && return hascommand "yum" && echo "yum-rpm" && return
hascommand "urpmi" && echo "urpmi-rpm" && return hascommand "urpmi" && echo "urpm-rpm" && return
fi fi
if hascommand "dpkg" && [ -s /var/lib/dpkg/status ] ; then if hascommand "dpkg" && [ -s /var/lib/dpkg/status ] ; then
...@@ -11601,6 +11630,9 @@ normalize_name() ...@@ -11601,6 +11630,9 @@ normalize_name()
"Red Hat Enterprise Linux Server") "Red Hat Enterprise Linux Server")
echo "RHEL" echo "RHEL"
;; ;;
"ROSA Fresh"*|"ROSA Desktop Fresh"*)
echo "ROSAFresh"
;;
"ROSA Chrome Desktop") "ROSA Chrome Desktop")
echo "ROSA" echo "ROSA"
;; ;;
...@@ -11707,9 +11739,9 @@ esac ...@@ -11707,9 +11739,9 @@ esac
case "$DISTRIB_ID" in case "$DISTRIB_ID" in
"ALTLinux") "ALTLinux")
echo "$VERSION" | grep -q "c9.* branch" && DISTRIB_RELEASE="c9" echo "$VERSION" | grep -q "c9.* branch" && DISTRIB_RELEASE="c9"
echo "$VERSION" | grep -q "c9f1 branch" && DISTRIB_RELEASE="c9f1"
echo "$VERSION" | grep -q "c9f2 branch" && DISTRIB_RELEASE="c9f2"
DISTRIB_CODENAME="$DISTRIB_RELEASE" DISTRIB_CODENAME="$DISTRIB_RELEASE"
echo "$VERSION" | grep -q "c9f1 branch" && DISTRIB_CODENAME="c9f1"
echo "$VERSION" | grep -q "c9f2 branch" && DISTRIB_CODENAME="c9f2"
# FIXME: fast hack for fallback: 10.1 -> p10 for /etc/os-release # FIXME: fast hack for fallback: 10.1 -> p10 for /etc/os-release
if echo "$DISTRIB_RELEASE" | grep -q "^[0-9]" && echo "$DISTRIB_RELEASE" | grep -q -v "[0-9][0-9][0-9]" ; then if echo "$DISTRIB_RELEASE" | grep -q "^[0-9]" && echo "$DISTRIB_RELEASE" | grep -q -v "[0-9][0-9][0-9]" ; then
DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')" DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')"
...@@ -11742,6 +11774,9 @@ case "$DISTRIB_ID" in ...@@ -11742,6 +11774,9 @@ case "$DISTRIB_ID" in
DISTRIB_RELEASE="Sisyphus" DISTRIB_RELEASE="Sisyphus"
DISTRIB_CODENAME="$DISTRIB_RELEASE" DISTRIB_CODENAME="$DISTRIB_RELEASE"
;; ;;
"ROSAFresh")
DISTRIB_CODENAME="$DISTRIB_RELEASE"
;;
esac esac
...@@ -12162,14 +12197,14 @@ local orig='' ...@@ -12162,14 +12197,14 @@ local orig=''
cat <<EOF cat <<EOF
distro_info v$PROGVERSION : Copyright © 2007-2023 Etersoft distro_info v$PROGVERSION : Copyright © 2007-2023 Etersoft
Pretty distro name (--pretty): $(print_pretty_name) Pretty distro name (--pretty): $(print_pretty_name)
Distro name / version: $DISTRO_NAME / $DISTRIB_FULL_RELEASE$orig Distro name / version (--distro-name/version): $DISTRO_NAME / $DISTRIB_FULL_RELEASE$orig
Base distro name (-d) / version (-v): $(print_name_version) Base distro name (-d) / version (-v): $(print_name_version)
Base distro name (-s) / Repo name (-r): $(pkgvendor) / $(print_repo_name) Vendor distro name (-s) / Repo name (-r): $(pkgvendor) / $(print_repo_name)
Package manager/type (-g/-p): $(pkgmanager) / $(pkgtype) Package manager/type (-g/-p): $(pkgmanager) / $(pkgtype)
Base OS name (-o) / CPU arch (-a): $(get_base_os_name) $(get_arch) Base OS name (-o) / CPU arch (-a): $(get_base_os_name) $(get_arch)
Bug report URL (--bug-report-url): $(print_bug_report_url) Bug report URL (--bug-report-url): $(print_bug_report_url)
CPU norm register size (-b): $(get_bit_size) CPU norm register size (-b): $(get_bit_size)
Virtualization (-i): $(get_virt) Virtualization (-i): $(get_virt)
CPU Cores/MHz (-c/-z): $(get_core_count) / $(get_core_mhz) MHz CPU Cores/MHz (-c/-z): $(get_core_count) / $(get_core_mhz) MHz
System memory size (MB) (-m): $(get_memory_size) System memory size (MB) (-m): $(get_memory_size)
...@@ -12206,14 +12241,14 @@ case "$1" in ...@@ -12206,14 +12241,14 @@ case "$1" in
echo " -o | --os-name - print base OS name" echo " -o | --os-name - print base OS name"
echo " -p | package-type - print type of the packaging system" echo " -p | package-type - print type of the packaging system"
echo " -g - print name of the packaging system" echo " -g - print name of the packaging system"
echo " -s|-n|--vendor-name - print base name of the distro (vendor name) (ubuntu for all Ubuntu family, alt for all ALT family) (see _vendor macros in rpm)" echo " -s|-n|--vendor-name - print name of the distro family (vendor name) (ubuntu for all Ubuntu family, alt for all ALT family) (see _vendor macros in rpm)"
echo " --pretty|--pretty-name - print pretty distro name" echo " --pretty|--pretty-name - print pretty distro name"
echo " -v | --base-version - print version of the distro" echo " -v | --base-version - print version of the distro"
echo " --distro-name - print distro name" echo " --distro-name - print distro name"
echo " --distro-version - print full version of the distro" echo " --distro-version - print full version of the distro"
echo " --full-version - print full version of the distro" echo " --full-version - print full version of the distro"
echo " --codename (obsoleted) - print distro codename (focal for Ubuntu 20.04)" echo " --codename (obsoleted) - print distro codename (focal for Ubuntu 20.04)"
echo " --repo-name - print repository name (focal for Ubuntu 20.04)" echo " -r|--repo-name - print repository name (focal for Ubuntu 20.04)"
echo " --build-id - print a string uniquely identifying the system image originally used as the installation base" echo " --build-id - print a string uniquely identifying the system image originally used as the installation base"
echo " -V - print the utility version" echo " -V - print the utility version"
echo "Run without args to print all information." echo "Run without args to print all information."
...@@ -12779,6 +12814,14 @@ get_host_only() ...@@ -12779,6 +12814,14 @@ get_host_only()
echo "$1/" | grep -Eo '(.*://[^/]+)' echo "$1/" | grep -Eo '(.*://[^/]+)'
} }
concatenate_url_and_filename()
{
local url="$1"
local fn="$2"
# workaround for a slash in the end of URL
echo "$(echo "$url" | sed -e 's|/*$||' )/$fn"
}
# Args: URL filename # Args: URL filename
make_fileurl() make_fileurl()
{ {
...@@ -12788,24 +12831,17 @@ make_fileurl() ...@@ -12788,24 +12831,17 @@ make_fileurl()
fn="$(echo "$fn" | sed -e 's|^./||' -e 's|^/+||')" fn="$(echo "$fn" | sed -e 's|^./||' -e 's|^/+||')"
if is_fileurl "$url" ; then if is_fileurl "$url" ; then
echo "$url/$fn" # if it is url
return :
elif echo "$fn" | grep -q "^/" ; then
# if there is file path from the root of the site
url="$(get_host_only "$url")"
elif echo "$url" | grep -q -v "/$" ; then
# if there is no slash in the end of URL
url="$(dirname "$url")"
fi fi
# if there is file path from the root of the site concatenate_url_and_filename "$url" "$fn"
if echo "$fn" | grep -q "^/" ; then
echo "$(get_host_only "$url")$fn"
return
fi
# if there is no slash in the end of URL
if echo "$url" | grep -q -v "/$" ; then
echo "$(dirname "$url" | sed -e 's|/*$||')/$fn"
return
fi
# workaround for a slash in the end of URL
echo "$(echo "$url" | sed -e 's|/*$||')/$fn"
} }
get_urls() get_urls()
......
...@@ -34,16 +34,6 @@ load_helper() ...@@ -34,16 +34,6 @@ load_helper()
# File bin/epm-sh-functions: # File bin/epm-sh-functions:
check_core_commands()
{
#which --help >/dev/null || fatal "Can't find which command (which package is missed?)"
# broken which on Debian systems
# TODO: use is_command and print_command_path instead of
which which >/dev/null || fatal "Can't find which command (which or debianutils package is missed?)"
which grep >/dev/null || fatal "Can't find grep command (coreutils package is missed?)"
which sed >/dev/null || fatal "Can't find sed command (sed package is missed?)"
}
inputisatty() inputisatty()
{ {
...@@ -80,7 +70,7 @@ check_tty() ...@@ -80,7 +70,7 @@ check_tty()
export EGREPCOLOR="--color" export EGREPCOLOR="--color"
fi fi
which tput >/dev/null 2>/dev/null || return is_command tput || return
# FreeBSD does not support tput -S # FreeBSD does not support tput -S
echo | tput -S >/dev/null 2>/dev/null || return echo | tput -S >/dev/null 2>/dev/null || return
[ -z "$USETTY" ] || return [ -z "$USETTY" ] || return
...@@ -204,13 +194,6 @@ sudocmd_foreach() ...@@ -204,13 +194,6 @@ sudocmd_foreach()
done done
} }
if ! which realpath 2>/dev/null >/dev/null ; then
realpath()
{
readlink -f "$@"
}
fi
make_filepath() make_filepath()
{ {
local i local i
...@@ -374,7 +357,7 @@ set_sudo() ...@@ -374,7 +357,7 @@ set_sudo()
# start error section # start error section
SUDO_TESTED="1" SUDO_TESTED="1"
if ! which $SUDO_CMD >/dev/null 2>/dev/null ; then if ! is_command $SUDO_CMD ; then
[ "$nofail" = "nofail" ] || SUDO="fatal 'Can't find sudo. Please install and tune sudo ('# epm install sudo') or run epm under root.'" [ "$nofail" = "nofail" ] || SUDO="fatal 'Can't find sudo. Please install and tune sudo ('# epm install sudo') or run epm under root.'"
return "$SUDO_TESTED" return "$SUDO_TESTED"
fi fi
...@@ -409,7 +392,7 @@ sudo_allowed() ...@@ -409,7 +392,7 @@ sudo_allowed()
withtimeout() withtimeout()
{ {
local TO=$(which timeout 2>/dev/null || which gtimeout 2>/dev/null) local TO=$(print_command_path timeout || print_command_path gtimeout)
if [ -x "$TO" ] ; then if [ -x "$TO" ] ; then
$TO "$@" $TO "$@"
return return
...@@ -427,7 +410,7 @@ set_eatmydata() ...@@ -427,7 +410,7 @@ set_eatmydata()
# skip if disabled # skip if disabled
[ -n "$EPMNOEATMYDATA" ] && return [ -n "$EPMNOEATMYDATA" ] && return
# use if possible # use if possible
which eatmydata >/dev/null 2>/dev/null || return is_command eatmydata || return
set_sudo set_sudo
# FIXME: check if SUDO already has eatmydata # FIXME: check if SUDO already has eatmydata
[ -n "$SUDO" ] && SUDO="$SUDO eatmydata" || SUDO="eatmydata" [ -n "$SUDO" ] && SUDO="$SUDO eatmydata" || SUDO="eatmydata"
...@@ -518,7 +501,7 @@ disabled_eget() ...@@ -518,7 +501,7 @@ disabled_eget()
# FIXME: we need disable output here, eget can be used for get output # FIXME: we need disable output here, eget can be used for get output
assure_exists eget eget 3.3 >/dev/null assure_exists eget eget 3.3 >/dev/null
# run external command, not the function # run external command, not the function
EGET=$(which eget) || fatal "Missed command eget from installed package eget" EGET=$(print_command_path eget) || fatal "Missed command eget from installed package eget"
$EGET "$@" $EGET "$@"
} }
...@@ -535,7 +518,7 @@ disabled_erc() ...@@ -535,7 +518,7 @@ disabled_erc()
# FIXME: we need disable output here, ercat can be used for get output # FIXME: we need disable output here, ercat can be used for get output
assure_exists_erc >/dev/null assure_exists_erc >/dev/null
# run external command, not the function # run external command, not the function
ERC=$(which erc) || fatal "Missed command erc from installed package erc" ERC=$(print_command_path erc) || fatal "Missed command erc from installed package erc"
$ERC "$@" $ERC "$@"
} }
...@@ -552,7 +535,7 @@ disabled_ercat() ...@@ -552,7 +535,7 @@ disabled_ercat()
# FIXME: we need disable output here, ercat can be used for get output # FIXME: we need disable output here, ercat can be used for get output
assure_exists_erc >/dev/null assure_exists_erc >/dev/null
# run external command, not the function # run external command, not the function
ERCAT=$(which ercat) || fatal "Missed command ercat from installed package erc" ERCAT=$(print_command_path ercat) || fatal "Missed command ercat from installed package erc"
$ERCAT "$@" $ERCAT "$@"
} }
...@@ -573,8 +556,9 @@ estrlist() ...@@ -573,8 +556,9 @@ estrlist()
eget() eget()
{ {
# check for both # check for both
which curl 2>/dev/null >/dev/null || assure_exists wget # we really need that cross here,
which wget 2>/dev/null >/dev/null || assure_exists curl is_command curl || assure_exists wget
is_command wget || assure_exists curl
internal_tools_eget "$@" internal_tools_eget "$@"
} }
...@@ -759,7 +743,7 @@ is_command() ...@@ -759,7 +743,7 @@ is_command()
} }
if ! which realpath 2>/dev/null >/dev/null ; then if ! is_command realpath ; then
realpath() realpath()
{ {
[ -n "$*" ] || return [ -n "$*" ] || return
...@@ -768,13 +752,26 @@ realpath() ...@@ -768,13 +752,26 @@ realpath()
fi fi
if ! which subst 2>/dev/null >/dev/null ; then
if ! is_command subst ; then
subst() subst()
{ {
sed -i -e "$@" sed -i -e "$@"
} }
fi fi
check_core_commands()
{
#which --help >/dev/null || fatal "Can't find which command (which package is missed?)"
# broken which on Debian systems
# TODO: use is_command and print_command_path instead of
which which >/dev/null || fatal "Can't find which command (which or debianutils package is missed?)"
is_command grep || fatal "Can't find grep command (coreutils package is missed?)"
is_command sed || fatal "Can't find sed command (sed package is missed?)"
}
# File bin/serv-cat: # File bin/serv-cat:
serv_cat() serv_cat()
...@@ -1582,9 +1579,17 @@ case $DISTRIB_ID in ...@@ -1582,9 +1579,17 @@ case $DISTRIB_ID in
CMD="urpm-rpm" CMD="urpm-rpm"
;; ;;
ROSA) ROSA)
CMD="dnf-rpm" CMD="urpm-rpm"
hascommand dnf || CMD="yum-rpm" hascommand yum && CMD="yum-rpm"
[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm" hascommand dnf && CMD="dnf-rpm"
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;;
ROSAFresh)
CMD="urpm-rpm"
hascommand yum && CMD="yum-rpm"
hascommand dnf && CMD="dnf-rpm"
# use dnf since 2020
#[ "$DISTRIB_ID/$DISTRIB_RELEASE" = "ROSA/2020" ] && CMD="urpm-rpm"
;; ;;
FreeBSD|NetBSD|OpenBSD|Solaris) FreeBSD|NetBSD|OpenBSD|Solaris)
CMD="pkgsrc" CMD="pkgsrc"
...@@ -1645,12 +1650,12 @@ case $DISTRIB_ID in ...@@ -1645,12 +1650,12 @@ case $DISTRIB_ID in
echo "apt-dpkg" && return echo "apt-dpkg" && return
fi fi
if hascommand "rpm" && [ -s /var/lib/rpm/Name ] ; then if hascommand "rpm" && [ -s /var/lib/rpm/Name ] || [ -s /var/lib/rpm/rpmdb.sqlite ] ; then
hascommand "zypper" && echo "zypper-rpm" && return hascommand "zypper" && echo "zypper-rpm" && return
hascommand "dnf" && echo "dnf-rpm" && return hascommand "dnf" && echo "dnf-rpm" && return
hascommand "apt-get" && echo "apt-rpm" && return hascommand "apt-get" && echo "apt-rpm" && return
hascommand "yum" && echo "yum-rpm" && return hascommand "yum" && echo "yum-rpm" && return
hascommand "urpmi" && echo "urpmi-rpm" && return hascommand "urpmi" && echo "urpm-rpm" && return
fi fi
if hascommand "dpkg" && [ -s /var/lib/dpkg/status ] ; then if hascommand "dpkg" && [ -s /var/lib/dpkg/status ] ; then
...@@ -1734,6 +1739,9 @@ normalize_name() ...@@ -1734,6 +1739,9 @@ normalize_name()
"Red Hat Enterprise Linux Server") "Red Hat Enterprise Linux Server")
echo "RHEL" echo "RHEL"
;; ;;
"ROSA Fresh"*|"ROSA Desktop Fresh"*)
echo "ROSAFresh"
;;
"ROSA Chrome Desktop") "ROSA Chrome Desktop")
echo "ROSA" echo "ROSA"
;; ;;
...@@ -1840,9 +1848,9 @@ esac ...@@ -1840,9 +1848,9 @@ esac
case "$DISTRIB_ID" in case "$DISTRIB_ID" in
"ALTLinux") "ALTLinux")
echo "$VERSION" | grep -q "c9.* branch" && DISTRIB_RELEASE="c9" echo "$VERSION" | grep -q "c9.* branch" && DISTRIB_RELEASE="c9"
echo "$VERSION" | grep -q "c9f1 branch" && DISTRIB_RELEASE="c9f1"
echo "$VERSION" | grep -q "c9f2 branch" && DISTRIB_RELEASE="c9f2"
DISTRIB_CODENAME="$DISTRIB_RELEASE" DISTRIB_CODENAME="$DISTRIB_RELEASE"
echo "$VERSION" | grep -q "c9f1 branch" && DISTRIB_CODENAME="c9f1"
echo "$VERSION" | grep -q "c9f2 branch" && DISTRIB_CODENAME="c9f2"
# FIXME: fast hack for fallback: 10.1 -> p10 for /etc/os-release # FIXME: fast hack for fallback: 10.1 -> p10 for /etc/os-release
if echo "$DISTRIB_RELEASE" | grep -q "^[0-9]" && echo "$DISTRIB_RELEASE" | grep -q -v "[0-9][0-9][0-9]" ; then if echo "$DISTRIB_RELEASE" | grep -q "^[0-9]" && echo "$DISTRIB_RELEASE" | grep -q -v "[0-9][0-9][0-9]" ; then
DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')" DISTRIB_RELEASE="$(echo p$DISTRIB_RELEASE | sed -e 's|\..*||')"
...@@ -1875,6 +1883,9 @@ case "$DISTRIB_ID" in ...@@ -1875,6 +1883,9 @@ case "$DISTRIB_ID" in
DISTRIB_RELEASE="Sisyphus" DISTRIB_RELEASE="Sisyphus"
DISTRIB_CODENAME="$DISTRIB_RELEASE" DISTRIB_CODENAME="$DISTRIB_RELEASE"
;; ;;
"ROSAFresh")
DISTRIB_CODENAME="$DISTRIB_RELEASE"
;;
esac esac
...@@ -2295,14 +2306,14 @@ local orig='' ...@@ -2295,14 +2306,14 @@ local orig=''
cat <<EOF cat <<EOF
distro_info v$PROGVERSION : Copyright © 2007-2023 Etersoft distro_info v$PROGVERSION : Copyright © 2007-2023 Etersoft
Pretty distro name (--pretty): $(print_pretty_name) Pretty distro name (--pretty): $(print_pretty_name)
Distro name / version: $DISTRO_NAME / $DISTRIB_FULL_RELEASE$orig Distro name / version (--distro-name/version): $DISTRO_NAME / $DISTRIB_FULL_RELEASE$orig
Base distro name (-d) / version (-v): $(print_name_version) Base distro name (-d) / version (-v): $(print_name_version)
Base distro name (-s) / Repo name (-r): $(pkgvendor) / $(print_repo_name) Vendor distro name (-s) / Repo name (-r): $(pkgvendor) / $(print_repo_name)
Package manager/type (-g/-p): $(pkgmanager) / $(pkgtype) Package manager/type (-g/-p): $(pkgmanager) / $(pkgtype)
Base OS name (-o) / CPU arch (-a): $(get_base_os_name) $(get_arch) Base OS name (-o) / CPU arch (-a): $(get_base_os_name) $(get_arch)
Bug report URL (--bug-report-url): $(print_bug_report_url) Bug report URL (--bug-report-url): $(print_bug_report_url)
CPU norm register size (-b): $(get_bit_size) CPU norm register size (-b): $(get_bit_size)
Virtualization (-i): $(get_virt) Virtualization (-i): $(get_virt)
CPU Cores/MHz (-c/-z): $(get_core_count) / $(get_core_mhz) MHz CPU Cores/MHz (-c/-z): $(get_core_count) / $(get_core_mhz) MHz
System memory size (MB) (-m): $(get_memory_size) System memory size (MB) (-m): $(get_memory_size)
...@@ -2339,14 +2350,14 @@ case "$1" in ...@@ -2339,14 +2350,14 @@ case "$1" in
echo " -o | --os-name - print base OS name" echo " -o | --os-name - print base OS name"
echo " -p | package-type - print type of the packaging system" echo " -p | package-type - print type of the packaging system"
echo " -g - print name of the packaging system" echo " -g - print name of the packaging system"
echo " -s|-n|--vendor-name - print base name of the distro (vendor name) (ubuntu for all Ubuntu family, alt for all ALT family) (see _vendor macros in rpm)" echo " -s|-n|--vendor-name - print name of the distro family (vendor name) (ubuntu for all Ubuntu family, alt for all ALT family) (see _vendor macros in rpm)"
echo " --pretty|--pretty-name - print pretty distro name" echo " --pretty|--pretty-name - print pretty distro name"
echo " -v | --base-version - print version of the distro" echo " -v | --base-version - print version of the distro"
echo " --distro-name - print distro name" echo " --distro-name - print distro name"
echo " --distro-version - print full version of the distro" echo " --distro-version - print full version of the distro"
echo " --full-version - print full version of the distro" echo " --full-version - print full version of the distro"
echo " --codename (obsoleted) - print distro codename (focal for Ubuntu 20.04)" echo " --codename (obsoleted) - print distro codename (focal for Ubuntu 20.04)"
echo " --repo-name - print repository name (focal for Ubuntu 20.04)" echo " -r|--repo-name - print repository name (focal for Ubuntu 20.04)"
echo " --build-id - print a string uniquely identifying the system image originally used as the installation base" echo " --build-id - print a string uniquely identifying the system image originally used as the installation base"
echo " -V - print the utility version" echo " -V - print the utility version"
echo "Run without args to print all information." echo "Run without args to print all information."
...@@ -2565,7 +2576,7 @@ print_version() ...@@ -2565,7 +2576,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.40.1 https://wiki.etersoft.ru/Epm" echo "Service manager version 3.41.0 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