Commit 881076c4 authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit packed files

parent 4472df44
...@@ -33,6 +33,7 @@ load_helper() ...@@ -33,6 +33,7 @@ load_helper()
local CMD="$SHAREDIR/$1" local CMD="$SHAREDIR/$1"
# do not use fatal() here, it can be initial state # do not use fatal() here, it can be initial state
[ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; } [ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; }
# shellcheck disable=SC1090
. $CMD . $CMD
} }
...@@ -69,7 +70,7 @@ check_tty() ...@@ -69,7 +70,7 @@ check_tty()
# egrep from busybox may not --color # egrep from busybox may not --color
# egrep from MacOS print help to stderr # egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then if grep -E --help 2>&1 | grep -q -- "--color" ; then
export EGREPCOLOR="--color" export EGREPCOLOR="--color"
fi fi
...@@ -109,7 +110,7 @@ echover() ...@@ -109,7 +110,7 @@ echover()
echon() echon()
{ {
# default /bin/sh on MacOS does not recognize -n # default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@" /bin/echo -n "$*"
} }
...@@ -127,14 +128,14 @@ showcmd() ...@@ -127,14 +128,14 @@ showcmd()
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#" [ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@" echo " $PROMTSIG $*"
restore_color restore_color
fi >&2 fi >&2
} }
docmd() docmd()
{ {
showcmd "$@$EXTRA_SHOWDOCMD" showcmd "$*$EXTRA_SHOWDOCMD"
$@ $@
} }
...@@ -151,7 +152,7 @@ docmd_foreach() ...@@ -151,7 +152,7 @@ docmd_foreach()
sudocmd() sudocmd()
{ {
showcmd "$SUDO $@" showcmd "$SUDO $*"
$SUDO $@ $SUDO $@
} }
...@@ -181,11 +182,10 @@ get_firstarg() ...@@ -181,11 +182,10 @@ get_firstarg()
get_lastarg() get_lastarg()
{ {
local lastarg local lastarg
eval lastarg=\${$#} eval "lastarg=\${$#}"
echon "$lastarg" echon "$lastarg"
} }
filter_strip_spaces() filter_strip_spaces()
{ {
# possible use just # possible use just
...@@ -212,7 +212,7 @@ store_output() ...@@ -212,7 +212,7 @@ store_output()
echo 1 >$CMDSTATUS echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp) #RC_STDERR=$(mktemp)
( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT ( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS) return "$(cat $CMDSTATUS)"
# bashism # bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
#return $PIPESTATUS #return $PIPESTATUS
...@@ -238,7 +238,7 @@ epm() ...@@ -238,7 +238,7 @@ epm()
fatal() fatal()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Error: $@" >&2 echo "Error: $*" >&2
fi fi
exit 1 exit 1
} }
...@@ -246,7 +246,7 @@ fatal() ...@@ -246,7 +246,7 @@ fatal()
warning() warning()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Warning: $@" >&2 echo "Warning: $*" >&2
fi fi
} }
...@@ -257,9 +257,9 @@ info() ...@@ -257,9 +257,9 @@ info()
# print message to stderr if stderr forwarded to (a file) # print message to stderr if stderr forwarded to (a file)
if isatty2 ; then if isatty2 ; then
isatty || return 0 isatty || return 0
echo "$@" echo "$*"
else else
echo "$@" >&2 echo "$*" >&2
fi fi
} }
...@@ -273,7 +273,7 @@ set_sudo() ...@@ -273,7 +273,7 @@ set_sudo()
return return
fi fi
EFFUID=`id -u` EFFUID=$(id -u)
# do not need sudo # do not need sudo
[ $EFFUID = "0" ] && return [ $EFFUID = "0" ] && return
...@@ -409,7 +409,7 @@ get_help() ...@@ -409,7 +409,7 @@ get_help()
return return
fi fi
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do grep -v -- "^#" $0 | grep -- "# $1" | while read -r n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g") opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g") desc=$(echo $n | sed -e "s|.*) # $1:||g")
printf " %-20s %s\n" $opt "$desc" printf " %-20s %s\n" $opt "$desc"
...@@ -513,9 +513,10 @@ is_active_systemd() ...@@ -513,9 +513,10 @@ is_active_systemd()
SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd
[ -x "$SYSTEMCTL" ] || return [ -x "$SYSTEMCTL" ] || return
[ -d "$SYSTEMD_CGROUP_DIR" ] || return [ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return a='' mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
readlink /sbin/init | grep -q 'systemd' || return readlink /sbin/init | grep -q 'systemd' || return
# some hack # some hack
# shellcheck disable=SC2009
ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev' ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev'
} }
...@@ -549,7 +550,7 @@ case $DISTRNAME in ...@@ -549,7 +550,7 @@ case $DISTRNAME in
;; ;;
autoimports) autoimports)
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION" [ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[A-Z]" "[a-z]")" repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
esac esac
assure_exists apt-repo assure_exists apt-repo
...@@ -609,7 +610,7 @@ __check_command_in_path() ...@@ -609,7 +610,7 @@ __check_command_in_path()
rhas() rhas()
{ {
echo "$1" | egrep -q -- "$2" echo "$1" | grep -E -q -- "$2"
} }
is_dirpath() is_dirpath()
...@@ -696,6 +697,7 @@ epm_assure() ...@@ -696,6 +697,7 @@ epm_assure()
[ -n "$pkg_filenames" ] || fatal "Assure: Missing params. Check $0 --help for info." [ -n "$pkg_filenames" ] || fatal "Assure: Missing params. Check $0 --help for info."
# use helper func for extract separate params # use helper func for extract separate params
# shellcheck disable=SC2046
__epm_assure $(eval echo $quoted_args) __epm_assure $(eval echo $quoted_args)
} }
...@@ -745,7 +747,7 @@ case $PMTYPE in ...@@ -745,7 +747,7 @@ case $PMTYPE in
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
assure_exists deborphan assure_exists deborphan
showcmd deborphan showcmd deborphan
a= deborphan | docmd epm remove a='' deborphan | docmd epm remove
;; ;;
#aura) #aura)
# sudocmd aura -Oj # sudocmd aura -Oj
...@@ -904,6 +906,7 @@ case $PMTYPE in ...@@ -904,6 +906,7 @@ case $PMTYPE in
yum-rpm) yum-rpm)
# cleanup orphanes? # cleanup orphanes?
while true ; do while true ; do
# shellcheck disable=SC2046
docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes) docmd package-cleanup --leaves $(subst_option non_interactive --assumeyes)
# FIXME: package-cleanup have to use stderr for errors # FIXME: package-cleanup have to use stderr for errors
local PKGLIST=$(package-cleanup -q --leaves | grep -v "^eepm-") local PKGLIST=$(package-cleanup -q --leaves | grep -v "^eepm-")
...@@ -1084,6 +1087,9 @@ case $PMTYPE in ...@@ -1084,6 +1087,9 @@ case $PMTYPE in
docmd rpm -Va --nofiles --nodigest docmd rpm -Va --nofiles --nodigest
;; ;;
dnf-rpm)
sudocmd dnf check
;;
emerge) emerge)
sudocmd revdep-rebuild sudocmd revdep-rebuild
;; ;;
...@@ -1206,7 +1212,7 @@ epm_checksystem_ALTLinux() ...@@ -1206,7 +1212,7 @@ epm_checksystem_ALTLinux()
touch $TDIR/added touch $TDIR/added
for ft in $(ls /usr/lib/rpm/*.filetrigger | sort) ; do for ft in $(ls /usr/lib/rpm/*.filetrigger | sort) ; do
echo "Try run $ft ..." echo "Try run $ft ..."
echo $TDIR/added $TDIR/removed | a= time $ft echo $TDIR/added $TDIR/removed | a='' time $ft
done done
rm -f $TDIR/added fatal rm -f $TDIR/added fatal
rmdir $TDIR || fatal rmdir $TDIR || fatal
...@@ -1281,11 +1287,11 @@ update_repo_if_needed() ...@@ -1281,11 +1287,11 @@ update_repo_if_needed()
sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; } sudo -n true 2>/dev/null || { info "sudo requires a password, skip repo status checking" ; return 0 ; }
fi fi
cd / cd / || fatal
if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then if ! __is_repo_info_downloaded || ! __is_repo_info_uptodate ; then
pkg_filenames= epm_update pkg_filenames='' epm_update
fi fi
cd - >/dev/null cd - >/dev/null || fatal
} }
...@@ -1415,7 +1421,7 @@ case $PMTYPE in ...@@ -1415,7 +1421,7 @@ case $PMTYPE in
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
showcmd dpkg -s $pkg_names showcmd dpkg -s $pkg_names
a= dpkg -s $pkg_names | grep "^Conflicts:" | sed "s|^Conflicts:||g" a='' dpkg -s $pkg_names | grep "^Conflicts:" | sed "s|^Conflicts:||g"
return return
else else
EXTRA_SHOWDOCMD=' | grep "Conflicts:"' EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
...@@ -1697,7 +1703,7 @@ epm_epm_install(){ ...@@ -1697,7 +1703,7 @@ epm_epm_install(){
# FIXME: some way to get latest package # FIXME: some way to get latest package
local download_link=$etersoft_updates_site/$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #" local download_link=$etersoft_updates_site/$(wget -qO- $etersoft_updates_site/ | grep -m1 -Eo "eepm[^\"]+\.$($DISTRVENDOR -p)" | tail -n1) #"
pkg_names= pkg_files= pkg_urls=$download_link epm_install pkg_names='' pkg_files='' pkg_urls="$download_link" epm_install
} }
# File bin/epm-filelist: # File bin/epm-filelist:
...@@ -1723,7 +1729,7 @@ __alt_local_content_filelist() ...@@ -1723,7 +1729,7 @@ __alt_local_content_filelist()
__deb_local_content_filelist() __deb_local_content_filelist()
{ {
showcmd "apt-file list $1 | grep '^$1: ' | sed -e 's|$1: ||g'" showcmd "apt-file list $1 | grep '^$1: ' | sed -e 's|$1: ||g'"
a= apt-file list "$1" | grep "^$1: " | sed -e "s|$1: ||g" a='' apt-file list "$1" | grep "^$1: " | sed -e "s|$1: ||g"
} }
...@@ -1734,13 +1740,24 @@ __epm_filelist_remote() ...@@ -1734,13 +1740,24 @@ __epm_filelist_remote()
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# TODO: use RESTful interface to prometeus? See ALT bug #29496 # TODO: use RESTful interface to prometeus? See ALT bug #29496
docmd_foreach __alt_local_content_filelist $@ docmd_foreach __alt_local_content_filelist "$@"
;; ;;
apt-dpkg) apt-dpkg)
assure_exists apt-file || return assure_exists apt-file || return
# if sudo requires a password, skip autoupdate if sudo -n true 2>/dev/null ; then
sudo -n true 2>/dev/null && sudocmd apt-file update || info "sudo requires a password, skip apt-file update" sudocmd apt-file update
docmd_foreach __deb_local_content_filelist $@ else
info "sudo requires a password, skip apt-file update"
fi
docmd_foreach __deb_local_content_filelist "$@"
;;
yum-rpm)
assure_exists yum-utils || return
docmd repoquery -q -l "$@"
;;
dnf-rpm)
assure_exists dnf-plugins-core || return
docmd dnf repoquery -l "$@"
;; ;;
*) *)
fatal "Query filelist for non installed packages is not implemented yet." fatal "Query filelist for non installed packages is not implemented yet."
...@@ -1835,6 +1852,7 @@ epm_filelist() ...@@ -1835,6 +1852,7 @@ epm_filelist()
__epm_filelist_file $pkg_files || return __epm_filelist_file $pkg_files || return
# shellcheck disable=SC2046
__epm_filelist_name $(print_name $pkg_names) || return __epm_filelist_name $(print_name $pkg_names) || return
} }
...@@ -1851,15 +1869,25 @@ __epm_info_rpm_low() ...@@ -1851,15 +1869,25 @@ __epm_info_rpm_low()
is_installed $pkg_names && docmd rpm -qi $pkg_names && return is_installed $pkg_names && docmd rpm -qi $pkg_names && return
} }
epm_info() __epm_info_by_pkgtype()
{ {
[ -n "$pkg_files" ] || return 1
if [ -n "$pkg_urls" ] ; then case $(get_package_type $pkg_files) in
__handle_pkg_urls_to_checking rpm)
fi __epm_info_rpm_low && return
;;
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name" deb)
docmd dpkg -I $pkg_files
;;
*)
return 1
;;
esac
}
__epm_info_by_pmtype()
{
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_info_rpm_low && return __epm_info_rpm_low && return
...@@ -1941,6 +1969,19 @@ case $PMTYPE in ...@@ -1941,6 +1969,19 @@ case $PMTYPE in
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
}
epm_info()
{
if [ -n "$pkg_urls" ] ; then
__handle_pkg_urls_to_checking
fi
[ -n "$pkg_filenames" ] || fatal "Info: missing package(s) name"
__epm_info_by_pkgtype || __epm_info_by_pmtype
local RETVAL=$? local RETVAL=$?
...@@ -1967,6 +2008,7 @@ filter_out_installed_packages() ...@@ -1967,6 +2008,7 @@ filter_out_installed_packages()
# sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g' # sed -e 's|\.\+$||g' -e 's|^.*[Nn]o packages found matching \(.*\)|\1|g'
# ;; # ;;
*) *)
# shellcheck disable=SC2013
for i in $(cat) ; do for i in $(cat) ; do
is_installed $i || echo $i is_installed $i || echo $i
done done
...@@ -1976,7 +2018,7 @@ filter_out_installed_packages() ...@@ -1976,7 +2018,7 @@ filter_out_installed_packages()
__use_zypper_no_gpg_checks() __use_zypper_no_gpg_checks()
{ {
a= zypper install --help 2>&1 | grep -q -- "--no-gpg-checks" && echo "--no-gpg-checks" a='' zypper install --help 2>&1 | grep -q -- "--no-gpg-checks" && echo "--no-gpg-checks"
} }
__separate_sudocmd_foreach() __separate_sudocmd_foreach()
...@@ -2072,14 +2114,14 @@ epm_install_names() ...@@ -2072,14 +2114,14 @@ epm_install_names()
return ;; return ;;
homebrew) homebrew)
# FIXME: sudo and quote # FIXME: sudo and quote
SUDO= __separate_sudocmd "brew install" "brew upgrade" $@ SUDO='' __separate_sudocmd "brew install" "brew upgrade" "$@"
return ;; return ;;
ipkg) ipkg)
[ -n "$force" ] && force=-force-depends [ -n "$force" ] && force=-force-depends
sudocmd ipkg $force install $@ sudocmd ipkg $force install $@
return ;; return ;;
nix) nix)
__separate_sudocmd "nix-env --install" "nix-env --upgrade" $@ __separate_sudocmd "nix-env --install" "nix-env --upgrade" "$@"
return ;; return ;;
apk) apk)
sudocmd apk add $@ sudocmd apk add $@
...@@ -2146,7 +2188,7 @@ epm_ni_install_names() ...@@ -2146,7 +2188,7 @@ epm_ni_install_names()
return ;; return ;;
npackd) npackd)
# npackdcl update --package=<package> (remove old and install new) # npackdcl update --package=<package> (remove old and install new)
sudocmd npackdcl add --package=$@ sudocmd npackdcl add --package="$*"
return ;; return ;;
chocolatey) chocolatey)
docmd chocolatey install $@ docmd chocolatey install $@
...@@ -2168,7 +2210,7 @@ epm_ni_install_names() ...@@ -2168,7 +2210,7 @@ epm_ni_install_names()
return ;; return ;;
homebrew) homebrew)
# FIXME: sudo and quote # FIXME: sudo and quote
SUDO= __separate_sudocmd "brew install" "brew upgrade" $@ SUDO='' __separate_sudocmd "brew install" "brew upgrade" $@
return ;; return ;;
#android) #android)
# sudocmd pm install $@ # sudocmd pm install $@
...@@ -2203,7 +2245,7 @@ __epm_check_if_try_install_deb() ...@@ -2203,7 +2245,7 @@ __epm_check_if_try_install_deb()
assure_exists alien assure_exists alien
local TDIR=$(mktemp -d) local TDIR=$(mktemp -d)
cd $TDIR cd $TDIR || fatal
for pkg in $debpkgs ; do for pkg in $debpkgs ; do
# TODO: fakeroot for non ALT? # TODO: fakeroot for non ALT?
showcmd_store_output alien -r -k --scripts "$pkg" || fatal showcmd_store_output alien -r -k --scripts "$pkg" || fatal
...@@ -2232,7 +2274,7 @@ __epm_check_if_try_install_rpm() ...@@ -2232,7 +2274,7 @@ __epm_check_if_try_install_rpm()
assure_exists fakeroot assure_exists fakeroot
local TDIR=$(mktemp -d) local TDIR=$(mktemp -d)
cd $TDIR cd $TDIR || fatal
for pkg in $rpmpkgs ; do for pkg in $rpmpkgs ; do
showcmd_store_output fakeroot alien -d -k --scripts "$pkg" showcmd_store_output fakeroot alien -d -k --scripts "$pkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g") local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
...@@ -2393,48 +2435,48 @@ epm_print_install_command() ...@@ -2393,48 +2435,48 @@ epm_print_install_command()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm) apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
echo "rpm -Uvh --force $nodeps $@" echo "rpm -Uvh --force $nodeps $*"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
echo "dpkg -i $@" echo "dpkg -i $*"
;; ;;
pkgsrc) pkgsrc)
echo "pkg_add $@" echo "pkg_add $*"
;; ;;
pkgng) pkgng)
echo "pkg add $@" echo "pkg add $*"
;; ;;
emerge) emerge)
# need be placed in /usr/portage/packages/somewhere # need be placed in /usr/portage/packages/somewhere
echo "emerge --usepkg $@" echo "emerge --usepkg $*"
;; ;;
pacman) pacman)
echo "pacman -U --noconfirm --force $nodeps $@" echo "pacman -U --noconfirm --force $nodeps $*"
;; ;;
slackpkg) slackpkg)
echo "/sbin/installpkg $@" echo "/sbin/installpkg $*"
;; ;;
npackd) npackd)
echo "npackdcl add --package=$@" echo "npackdcl add --package=$*"
;; ;;
ipkg) ipkg)
echo "ipkg install $@" echo "ipkg install $*"
;; ;;
android) android)
echo "pm install $@" echo "pm install $*"
;; ;;
aptcyg) aptcyg)
echo "apt-cyg install $@" echo "apt-cyg install $*"
;; ;;
tce) tce)
echo "tce-load -wi $@" echo "tce-load -wi $*"
;; ;;
xbps) xbps)
echo "xbps-install -y $@" echo "xbps-install -y $*"
;; ;;
homebrew) homebrew)
# FIXME: sudo and quote # FIXME: sudo and quote
echo "brew install $@" echo "brew install $*"
;; ;;
*) *)
...@@ -2498,7 +2540,7 @@ epm_Install() ...@@ -2498,7 +2540,7 @@ epm_Install()
yum-rpm) yum-rpm)
;; ;;
*) *)
pkg_filenames= epm_update || return pkg_filenames='' epm_update || return
;; ;;
esac esac
...@@ -2616,7 +2658,7 @@ __repack_rpm_base() ...@@ -2616,7 +2658,7 @@ __repack_rpm_base()
cd /var/lib/rpm || fatal cd /var/lib/rpm || fatal
mv Packages Packages.BACKUP || fatal mv Packages Packages.BACKUP || fatal
# mask dependencies with a= # mask dependencies with a=
a= db_dump Packages.BACKUP | a= db_load Packages || fatal a='' db_dump Packages.BACKUP | a='' db_load Packages || fatal
rm Packages.BACKUP rm Packages.BACKUP
} }
...@@ -2645,10 +2687,10 @@ __epm_packages_sort() ...@@ -2645,10 +2687,10 @@ __epm_packages_sort()
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm) apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
# FIXME: space with quotes problems, use point instead # FIXME: space with quotes problems, use point instead
docmd rpm -qa --queryformat "%{size}.%{name}-%{version}-%{release}\n" $pkg_filenames | sort -n docmd rpm -qa --queryformat "%{size}@%{name}-%{version}-%{release}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;; ;;
apt-dpkg) apt-dpkg)
docmd dpkg-query -W --showformat="\${Size}.\${Package}-\${Version}\n" $pkg_filenames | sort -n docmd dpkg-query -W --showformat="\${Installed-Size}@\${Package}-\${Version}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;; ;;
*) *)
fatal "Sorted package list function is not implemented for $PMTYPE" fatal "Sorted package list function is not implemented for $PMTYPE"
...@@ -2801,6 +2843,7 @@ docmd $CMD | __fo_pfn ...@@ -2801,6 +2843,7 @@ docmd $CMD | __fo_pfn
# File bin/epm-policy: # File bin/epm-policy:
epm_policy() epm_policy()
{ {
...@@ -2875,7 +2918,7 @@ print_pkgname() ...@@ -2875,7 +2918,7 @@ print_pkgname()
print_srcname() print_srcname()
{ {
print_name $(print_srcpkgname "$@") print_name "$(print_srcpkgname "$@")"
} }
print_specname() print_specname()
...@@ -2936,7 +2979,7 @@ EOF ...@@ -2936,7 +2979,7 @@ EOF
"name") "name")
[ -n "$1" ] || fatal "Arg is missed" [ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then if [ -n "$FNFLAG" ] ; then
print_name $(print_pkgname "$@") print_name "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then elif [ -n "$PKFLAG" ] ; then
query_package_field "name" "$@" query_package_field "name" "$@"
else else
...@@ -2946,7 +2989,7 @@ EOF ...@@ -2946,7 +2989,7 @@ EOF
"version") "version")
[ -n "$1" ] || fatal "Arg is missed" [ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then if [ -n "$FNFLAG" ] ; then
print_version $(print_pkgname "$@") print_version "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then elif [ -n "$PKFLAG" ] ; then
query_package_field "version" "$@" query_package_field "version" "$@"
else else
...@@ -2956,7 +2999,7 @@ EOF ...@@ -2956,7 +2999,7 @@ EOF
"release") "release")
[ -n "$1" ] || fatal "Arg is missed" [ -n "$1" ] || fatal "Arg is missed"
if [ -n "$FNFLAG" ] ; then if [ -n "$FNFLAG" ] ; then
print_release $(print_pkgname "$@") print_release "$(print_pkgname "$@")"
elif [ -n "$PKFLAG" ] ; then elif [ -n "$PKFLAG" ] ; then
query_package_field "release" "$@" query_package_field "release" "$@"
else else
...@@ -3021,6 +3064,8 @@ epm_print() ...@@ -3021,6 +3064,8 @@ epm_print()
{ {
[ -n "$pkg_filenames" ] || fatal "Missed args. Use epm print help for get help." [ -n "$pkg_filenames" ] || fatal "Missed args. Use epm print help for get help."
# Note! do not quote args below (see eterbug #11863)
# shellcheck disable=SC2046
__epm_print $(eval echo $quoted_args) __epm_print $(eval echo $quoted_args)
} }
...@@ -3041,9 +3086,9 @@ epm_programs() ...@@ -3041,9 +3086,9 @@ epm_programs()
[ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system." [ -d "$DESKTOPDIR" ] || fatal "There is no $DESKTOPDIR dir on the system."
#find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u #find /usr/share/applications -type f -name "*.desktop" | while read f; do pkg_files="$f" quiet=1 short=1 epm_query_file ; done | sort -u
showcmd "find $DESKTOPDIR -type f -name "*.desktop" | xargs $0 -qf --quiet --short | sort -u" showcmd "find $DESKTOPDIR -type f -print0 -name "*.desktop" | xargs -0 $0 -qf --quiet --short | sort -u"
find $DESKTOPDIR -type f -name "*.desktop" | \ find $DESKTOPDIR -type f -print0 -name "*.desktop" | \
xargs $0 -qf --quiet --short | sort -u xargs -0 $0 -qf --quiet --short | sort -u
} }
# File bin/epm-provides: # File bin/epm-provides:
...@@ -3051,7 +3096,7 @@ epm_programs() ...@@ -3051,7 +3096,7 @@ epm_programs()
epm_provides_files() epm_provides_files()
{ {
local pkg_files="$@" local pkg_files="$*"
[ -n "$pkg_files" ] || return [ -n "$pkg_files" ] || return
local PKGTYPE="$(get_package_type $pkg_files)" local PKGTYPE="$(get_package_type $pkg_files)"
...@@ -3075,7 +3120,7 @@ epm_provides_files() ...@@ -3075,7 +3120,7 @@ epm_provides_files()
epm_provides_names() epm_provides_names()
{ {
local pkg_names="$@" local pkg_names="$*"
local CMD local CMD
[ -n "$pkg_names" ] || return [ -n "$pkg_names" ] || return
...@@ -3131,6 +3176,7 @@ epm_provides() ...@@ -3131,6 +3176,7 @@ epm_provides()
[ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Provides: missing package(s) name"
epm_provides_files $pkg_files epm_provides_files $pkg_files
# shellcheck disable=SC2046
epm_provides_names $(print_name $pkg_names) epm_provides_names $(print_name $pkg_names)
} }
...@@ -3231,11 +3277,12 @@ __epm_get_hilevel_name() ...@@ -3231,11 +3277,12 @@ __epm_get_hilevel_name()
for i in $@ ; do for i in $@ ; do
local pkg local pkg
# get short form in pkg # get short form in pkg
quiet=1 pkg=$(__epm_query_shortname $i) || continue # drop not installed packages # FIXME: where we use it? continue or pkg=$i?
quiet=1 pkg=$(__epm_query_shortname "$i") || pkg="$i" #continue # drop not installed packages
# if already short form, skipped # if already short form, skipped
[ "$pkg" = "$i" ] && echo "$i" && continue [ "$pkg" = "$i" ] && echo "$i" && continue
# try get long form or use short form # try get long form or use short form
__epm_get_hilevel_nameform $i || echo $pkg __epm_get_hilevel_nameform "$i" || echo $pkg
done done
} }
...@@ -3266,7 +3313,7 @@ __epm_query_dpkg_check() ...@@ -3266,7 +3313,7 @@ __epm_query_dpkg_check()
{ {
local i local i
for i in $@ ; do for i in $@ ; do
a= dpkg -s $i >/dev/null 2>/dev/null || return a='' dpkg -s $i >/dev/null 2>/dev/null || return
done done
return 0 return 0
} }
...@@ -3289,7 +3336,7 @@ __epm_query_name() ...@@ -3289,7 +3336,7 @@ __epm_query_name()
return return
;; ;;
npackd) npackd)
docmd "npackdcl path --package=$@" docmd "npackdcl path --package=$1"
return return
;; ;;
conary) conary)
...@@ -3299,6 +3346,10 @@ __epm_query_name() ...@@ -3299,6 +3346,10 @@ __epm_query_name()
docmd brew info "$1" >/dev/null 2>/dev/null && echo "$1" && return docmd brew info "$1" >/dev/null 2>/dev/null && echo "$1" && return
return 1 return 1
;; ;;
pacman)
docmd pacman -Q $@
return
;;
# TODO: need to print name if exists # TODO: need to print name if exists
#pkgng) #pkgng)
# CMD="pkg info -e" # CMD="pkg info -e"
...@@ -3331,7 +3382,7 @@ __epm_query_shortname() ...@@ -3331,7 +3382,7 @@ __epm_query_shortname()
return return
;; ;;
npackd) npackd)
docmd "npackdcl path --package=$@" docmd "npackdcl path --package=$1"
return return
;; ;;
conary) conary)
...@@ -3341,6 +3392,12 @@ __epm_query_shortname() ...@@ -3341,6 +3392,12 @@ __epm_query_shortname()
docmd brew info "$1" >/dev/null 2>/dev/null && echo "$1" && return docmd brew info "$1" >/dev/null 2>/dev/null && echo "$1" && return
return 1 return 1
;; ;;
# TODO: check status
#pacman)
# docmd pacman -Q $@ | sed -e "s| .*||g"
# return
# ;;
# TODO: need to print name if exists # TODO: need to print name if exists
#pkgng) #pkgng)
# CMD="pkg info -e" # CMD="pkg info -e"
...@@ -3358,7 +3415,7 @@ __epm_query_shortname() ...@@ -3358,7 +3415,7 @@ __epm_query_shortname()
is_installed() is_installed()
{ {
__epm_query_shortname $pkg_names >/dev/null 2>/dev/null __epm_query_shortname "$@" >/dev/null 2>/dev/null
# broken way to recursive call here (overhead!) # broken way to recursive call here (overhead!)
#epm installed $@ >/dev/null 2>/dev/null #epm installed $@ >/dev/null 2>/dev/null
} }
...@@ -3367,7 +3424,7 @@ separate_installed() ...@@ -3367,7 +3424,7 @@ separate_installed()
{ {
pkg_installed= pkg_installed=
pkg_noninstalled= pkg_noninstalled=
for i in $* ; do for i in "$@" ; do
is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i" is_installed $i && pkg_installed="$pkg_installed $i" || pkg_noninstalled="$pkg_noninstalled $i"
done done
} }
...@@ -3379,8 +3436,10 @@ epm_query() ...@@ -3379,8 +3436,10 @@ epm_query()
__epm_query_file $pkg_files || return __epm_query_file $pkg_files || return
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
# shellcheck disable=SC2046
__epm_query_shortname $(print_name $pkg_names) || return __epm_query_shortname $(print_name $pkg_names) || return
else else
# shellcheck disable=SC2046
__epm_query_name $(print_name $pkg_names) || return __epm_query_name $(print_name $pkg_names) || return
fi fi
} }
...@@ -3431,7 +3490,7 @@ __do_query_real_file() ...@@ -3431,7 +3490,7 @@ __do_query_real_file()
dpkg_print_name_version() dpkg_print_name_version()
{ {
local ver i local ver i
for i in $* ; do for i in "$@" ; do
ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g") ver=$(dpkg -s $i 2>/dev/null | grep "Version:" | sed -e "s|Version: ||g")
if [ -z "$ver" ] ; then if [ -z "$ver" ] ; then
echo "$i" echo "$i"
...@@ -3450,8 +3509,8 @@ __do_query() ...@@ -3450,8 +3509,8 @@ __do_query()
CMD="rpm -qf" CMD="rpm -qf"
;; ;;
*-dpkg) *-dpkg)
showcmd dpkg -S $1 showcmd dpkg -S "$1"
dpkg_print_name_version $(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||") dpkg_print_name_version "$(dpkg -S $1 | grep -v "^diversion by" | sed -e "s|:.*||")"
return ;; return ;;
yum-rpm|dnf-rpm|urpm-rpm) yum-rpm|dnf-rpm|urpm-rpm)
CMD="rpm -qf" CMD="rpm -qf"
...@@ -3506,8 +3565,8 @@ __do_short_query() ...@@ -3506,8 +3565,8 @@ __do_short_query()
CMD="rpm -qf --queryformat %{NAME}\n" CMD="rpm -qf --queryformat %{NAME}\n"
;; ;;
NOapt-dpkg) NOapt-dpkg)
showcmd dpkg -S $1 showcmd dpkg -S "$1"
dpkg_print_name_version $(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by") dpkg_print_name_version "$(dpkg -S $1 | sed -e "s|:.*||" | grep -v "^diversion by")"
return ;; return ;;
NOemerge) NOemerge)
assure_exists equery assure_exists equery
...@@ -3559,7 +3618,7 @@ epm_query_file() ...@@ -3559,7 +3618,7 @@ epm_query_file()
__epm_query_package() __epm_query_package()
{ {
pkg_filenames="$@" quoted_args="$@" quiet=1 epm_query_package pkg_filenames="$*" quoted_args="$*" quiet=1 epm_query_package
} }
epm_query_package() epm_query_package()
...@@ -3570,7 +3629,7 @@ epm_query_package() ...@@ -3570,7 +3629,7 @@ epm_query_package()
MGS=$(eval __epm_search_make_grep $quoted_args) MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD=$MGS EXTRA_SHOWDOCMD=$MGS
# Note: get all packages list and do grep # Note: get all packages list and do grep
eval "pkg_filenames= epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS" eval "pkg_filenames='' epm_packages \"$(eval get_firstarg $quoted_args)\" $MGS"
} }
# File bin/epm-reinstall: # File bin/epm-reinstall:
...@@ -3660,10 +3719,10 @@ __detect_alt_release_by_repo() ...@@ -3660,10 +3719,10 @@ __detect_alt_release_by_repo()
{ {
local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \ local BRD=$(cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list \
| grep -v "^#" \ | grep -v "^#" \
| grep "p[5-9]/branch/" \ | grep "[tp][5-9]/branch/" \
| sed -e "s|.*\(p[5-9]\)/branch.*|\1|g" \ | sed -e "s|.*\([tp][5-9]\)/branch.*|\1|g" \
| sort -u ) | sort -u )
if [ $(__wcount $BRD) = "1" ] ; then if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD" echo "$BRD"
return return
fi fi
...@@ -3673,7 +3732,7 @@ __detect_alt_release_by_repo() ...@@ -3673,7 +3732,7 @@ __detect_alt_release_by_repo()
| grep "Sisyphus/" \ | grep "Sisyphus/" \
| sed -e "s|.*\(Sisyphus\).*|\1|g" \ | sed -e "s|.*\(Sisyphus\).*|\1|g" \
| sort -u ) | sort -u )
if [ $(__wcount $BRD) = "1" ] ; then if [ "$(__wcount $BRD)" = "1" ] ; then
echo "$BRD" echo "$BRD"
return return
fi fi
...@@ -3686,9 +3745,9 @@ __replace_alt_version_in_repo() ...@@ -3686,9 +3745,9 @@ __replace_alt_version_in_repo()
local i local i
assure_exists apt-repo assure_exists apt-repo
#echo "Upgrading $DISTRNAME from $1 to $2 ..." #echo "Upgrading $DISTRNAME from $1 to $2 ..."
docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | egrep --color -- "$1" docmd apt-repo list | sed -e "s|\($1\)|{\1}->{$2}|g" | grep -E --color -- "$1"
# ask and replace only we will have changes # ask and replace only we will have changes
if a= apt-repo list | egrep -q -- "$1" ; then if a='' apt-repo list | grep -E -q -- "$1" ; then
confirm "Are these correct changes? [y/N]" || fatal "Exiting" confirm "Are these correct changes? [y/N]" || fatal "Exiting"
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g" __replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi fi
...@@ -3698,8 +3757,8 @@ __replace_alt_version_in_repo() ...@@ -3698,8 +3757,8 @@ __replace_alt_version_in_repo()
__alt_repofix() __alt_repofix()
{ {
showcmd epm repofix showcmd epm repofix
quiet=1 pkg_filenames= epm_repofix >/dev/null quiet=1 pkg_filenames='' epm_repofix >/dev/null
__replace_text_in_alt_repo "/^ *#/! s!\[p[6-9]\]![updates]!g" __replace_text_in_alt_repo "/^ *#/! s!\[[tp][6-9]\]![updates]!g"
} }
get_fix_release_pkg() get_fix_release_pkg()
...@@ -3712,25 +3771,26 @@ get_fix_release_pkg() ...@@ -3712,25 +3771,26 @@ get_fix_release_pkg()
__update_to_the_distro() __update_to_the_distro()
{ {
local TO="$1"
__alt_repofix __alt_repofix
case "$1" in case "$TO" in
p7) p7)
docmd epm update || fatal docmd epm update || fatal
docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg p7) || fatal "Check an error and run epm release-upgrade again" docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
__alt_repofix __alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![p7]!g" __replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal docmd epm update || fatal
docmd epm upgrade || fatal "Check an error and run epm release-upgrade again" docmd epm upgrade || fatal "Check an error and run epm release-upgrade again"
;; ;;
p8) p8)
docmd epm update || fatal docmd epm update || fatal
if ! docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg p8) ; then if ! docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" ; then
# Hack for error: execution of %post scriptlet from glibc-core-2.23-alt1.eter1 # Hack for error: execution of %post scriptlet from glibc-core-2.23-alt1.eter1
docmd rpm -ev glibc-core-2.17 || fatal "Check an error and run epm release-upgrade again" docmd rpm -ev glibc-core-2.17 || fatal "Check an error and run epm release-upgrade again"
docmd epm install apt rpm apt-conf-branch $(get_fix_release_pkg p8) || fatal "Check an error and run epm release-upgrade again" docmd epm install apt rpm apt-conf-branch "$(get_fix_release_pkg "$TO")" || fatal "Check an error and run epm release-upgrade again"
fi fi
__alt_repofix __alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![p8]!g" __replace_text_in_alt_repo "/^ *#/! s!\[updates\]![$TO]!g"
docmd epm update || fatal docmd epm update || fatal
if is_installed systemd && is_active_systemd systemd ; then if is_installed systemd && is_active_systemd systemd ; then
docmd epm install systemd || fatal docmd epm install systemd || fatal
...@@ -3748,48 +3808,53 @@ __update_to_the_distro() ...@@ -3748,48 +3808,53 @@ __update_to_the_distro()
__update_alt_to_next_distro() __update_alt_to_next_distro()
{ {
local FROMTO=$(echo "$*" | sed -e "s| | to |") local TO=""
local FROM="$1"
info info
case "$*" in case "$*" in
"p6"|"p6 p7") "p6"|"p6 p7"|"t6 p7")
info "Upgrade $DISTRNAME from p6 to p7 ..." TO="p7"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal docmd epm install apt-conf-branch || fatal
__replace_alt_version_in_repo p6/branch/ p7/branch/ __replace_alt_version_in_repo "$FROM/branch/" "$TO/branch/"
__update_to_the_distro p7 __update_to_the_distro "$TO"
docmd epm update-kernel docmd epm update-kernel
info "Done." info "Done."
info "Run epm release-upgrade again for update to p8" info "Run epm release-upgrade again for update to p8"
;; ;;
"p7"|"p7 p8") "p7"|"p7 p8"|"t7 p8")
info "Upgrade $DISTRNAME from p7 to p8 ..." TO="p8"
docmd epm install apt-conf-branch $(get_fix_release_pkg p7) || fatal info "Upgrade $DISTRNAME from $FROM to $TO ..."
__replace_alt_version_in_repo p7/branch/ p8/branch/ docmd epm install apt-conf-branch "$(get_fix_release_pkg "$FROM")" || fatal
__update_to_the_distro p8 __replace_alt_version_in_repo $FROM/branch/ $TO/branch/
__update_to_the_distro $TO
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
info "Done." info "Done."
;; ;;
"Sisyphus p8") "Sisyphus p8")
info "Downgrade $DISTRNAME from Sisyphus to p8 ..." TO="p8"
info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal docmd epm install apt-conf-branch || fatal
__replace_alt_version_in_repo Sisyphus/ p8/branch/ __replace_alt_version_in_repo "$FROM/" "$FROM/branch/"
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]![p8]!g" __replace_text_in_alt_repo "/^ *#/! s!\[alt\]![$TO]!g"
__update_to_the_distro p8 __update_to_the_distro $TO
docmd epm downgrade || fatal docmd epm downgrade || fatal
info "Done." info "Done."
;; ;;
"p8 Sisyphus") "p8 Sisyphus")
info "Upgrade $DISTRNAME from p8 to Sisyphus ..." TO="Sisyphus"
info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install apt-conf-branch || fatal docmd epm install apt-conf-branch || fatal
docmd epm upgrade || fatal docmd epm upgrade || fatal
__replace_alt_version_in_repo p8/branch/ Sisyphus/ __replace_alt_version_in_repo "$FROM/branch/" "$TO/"
__alt_repofix __alt_repofix
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]![alt]!g" __replace_text_in_alt_repo "/^ *#/! s!\[updates\]![alt]!g"
__update_to_the_distro Sisyphus __update_to_the_distro $TO
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
info "Done." info "Done."
;; ;;
*) *)
warning "Have no idea how to update from $DISTRNAME $DISTRVERSION." warning "Have no idea how to update from $DISTRNAME $FROM to $DISTRNAME $TO."
info "Try run f.i. # epm release-upgrade p8 or # epm release-upgrade Sisyphus" info "Try run f.i. # epm release-upgrade p8 or # epm release-upgrade Sisyphus"
info "Also possible you need install altlinux-release-p? package for correct distro version detecting" info "Also possible you need install altlinux-release-p? package for correct distro version detecting"
return 1 return 1
...@@ -3908,6 +3973,7 @@ epm_remove_low() ...@@ -3908,6 +3973,7 @@ epm_remove_low()
sudocmd rpm -ev $nodeps $@ sudocmd rpm -ev $nodeps $@
return ;; return ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
# shellcheck disable=SC2046
sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@") sudocmd dpkg -P $(subst_option nodeps --force-all) $(print_name "$@")
return ;; return ;;
pkgsrc) pkgsrc)
...@@ -3981,7 +4047,7 @@ epm_remove_names() ...@@ -3981,7 +4047,7 @@ epm_remove_names()
sudocmd conary erase $@ sudocmd conary erase $@
return ;; return ;;
npackd) npackd)
sudocmd npackdcl remove --package=$@ sudocmd npackdcl remove --package=$1
return ;; return ;;
nix) nix)
sudocmd nix-env --uninstall $@ sudocmd nix-env --uninstall $@
...@@ -4011,6 +4077,7 @@ epm_remove_names() ...@@ -4011,6 +4077,7 @@ epm_remove_names()
sudocmd xbps remove -R $@ sudocmd xbps remove -R $@
return ;; return ;;
ipkg) ipkg)
# shellcheck disable=SC2046
sudocmd ipkg $(subst_option force -force-depends) remove $@ sudocmd ipkg $(subst_option force -force-depends) remove $@
return ;; return ;;
*) *)
...@@ -4063,34 +4130,34 @@ epm_print_remove_command() ...@@ -4063,34 +4130,34 @@ epm_print_remove_command()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm) apt-rpm|yum-rpm|zypper-rpm|urpm-rpm|dnf-rpm)
echo "rpm -ev $nodeps $@" echo "rpm -ev $nodeps $*"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
echo "dpkg -P $@" echo "dpkg -P $*"
;; ;;
pkgsrc) pkgsrc)
echo "pkg_delete -r $@" echo "pkg_delete -r $*"
;; ;;
pkgng) pkgng)
echo "pkg delete -R $@" echo "pkg delete -R $*"
;; ;;
pacman) pacman)
echo "pacman -R $@" echo "pacman -R $*"
;; ;;
emerge) emerge)
echo "emerge --unmerge $@" echo "emerge --unmerge $*"
;; ;;
slackpkg) slackpkg)
echo "/sbin/removepkg $@" echo "/sbin/removepkg $*"
;; ;;
ipkg) ipkg)
echo "ipkg remove $@" echo "ipkg remove $*"
;; ;;
aptcyg) aptcyg)
echo "apt-cyg remove $@" echo "apt-cyg remove $*"
;; ;;
xbps) xbps)
echo "xbps remove -y $@" echo "xbps remove -y $*"
;; ;;
*) *)
fatal "Have no suitable appropriate remove command for $PMTYPE" fatal "Have no suitable appropriate remove command for $PMTYPE"
...@@ -4185,7 +4252,7 @@ case $DISTRNAME in ...@@ -4185,7 +4252,7 @@ case $DISTRNAME in
autoimports) autoimports)
info "remove autoimports repo" info "remove autoimports repo"
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION" [ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
repo="$repo.$(echo "$DISTRVERSION" | tr "[A-Z]" "[a-z]")" repo="$repo.$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
;; ;;
esac esac
...@@ -4259,7 +4326,7 @@ __try_fix_apt_source_list() ...@@ -4259,7 +4326,7 @@ __try_fix_apt_source_list()
__fix_apt_sources_list() __fix_apt_sources_list()
{ {
# for beauty spaces # for beauty spaces
local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|p6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi' local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ](Sisyphus|p8[/ ]branch|p7[/ ]branch|t7[/ ]branch|c7[/ ]branch|p6[/ ]branch|t6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
local i local i
assure_root assure_root
for i in "$@" ; do for i in "$@" ; do
...@@ -4377,7 +4444,7 @@ esac ...@@ -4377,7 +4444,7 @@ esac
epm_requires_files() epm_requires_files()
{ {
local pkg_files="$@" local pkg_files="$*"
[ -n "$pkg_files" ] || return [ -n "$pkg_files" ] || return
local PKGTYPE="$(get_package_type $pkg_files)" local PKGTYPE="$(get_package_type $pkg_files)"
...@@ -4389,7 +4456,7 @@ epm_requires_files() ...@@ -4389,7 +4456,7 @@ epm_requires_files()
;; ;;
deb) deb)
assure_exists dpkg assure_exists dpkg
a= docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g" a='' docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
;; ;;
*) *)
fatal "Have no suitable command for $PKGTYPE" fatal "Have no suitable command for $PKGTYPE"
...@@ -4399,7 +4466,7 @@ epm_requires_files() ...@@ -4399,7 +4466,7 @@ epm_requires_files()
epm_requires_names() epm_requires_names()
{ {
local pkg_names="$@" local pkg_names="$*"
local CMD local CMD
[ -n "$pkg_names" ] || return [ -n "$pkg_names" ] || return
...@@ -4445,7 +4512,7 @@ case $PMTYPE in ...@@ -4445,7 +4512,7 @@ case $PMTYPE in
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
showcmd dpkg -s $pkg_names showcmd dpkg -s $pkg_names
a= dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g" a='' dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
return return
else else
CMD="apt-cache depends" CMD="apt-cache depends"
...@@ -4482,6 +4549,7 @@ epm_requires() ...@@ -4482,6 +4549,7 @@ epm_requires()
{ {
[ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Requires: missing package(s) name"
epm_requires_files $pkg_files epm_requires_files $pkg_files
# shellcheck disable=SC2046
epm_requires_names $(print_name $pkg_names) epm_requires_names $(print_name $pkg_names)
} }
...@@ -4599,7 +4667,7 @@ __epm_search_make_grep() ...@@ -4599,7 +4667,7 @@ __epm_search_make_grep()
#list=$(strip_spaces $list | sed -e "s/ /|/g") #list=$(strip_spaces $list | sed -e "s/ /|/g")
listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g") listN=$(strip_spaces $listN | sed -e "s/ /|/g" | sed -e "s/\^//g")
if [ "$short" ] ; then if [ -n "$short" ] ; then
echon " | sed -e \"s| .*||g\"" echon " | sed -e \"s| .*||g\""
fi fi
...@@ -4720,7 +4788,7 @@ case $PMTYPE in ...@@ -4720,7 +4788,7 @@ case $PMTYPE in
CMD="xbps-query -Ro" CMD="xbps-query -Ro"
;; ;;
aptcyg) aptcyg)
docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g") docmd apt-cyg searchall "$(echo " $pkg_filenames" | sed -e "s| /| |g")"
return return
;; ;;
*) *)
...@@ -4752,13 +4820,13 @@ get_local_alt_mirror_path() ...@@ -4752,13 +4820,13 @@ get_local_alt_mirror_path()
__local_ercat() __local_ercat()
{ {
local i local i
for i in $* ; do for i in "$@" ; do
case "$i" in case "$i" in
*.xz) *.xz)
a= xzcat $i a='' xzcat $i
;; ;;
*.lz4) *.lz4)
a= lz4cat $i a='' lz4cat $i
;; ;;
*.failed) *.failed)
# just ignore # just ignore
...@@ -4774,10 +4842,13 @@ compress_file_inplace() ...@@ -4774,10 +4842,13 @@ compress_file_inplace()
{ {
local OFILE="$1" local OFILE="$1"
if epm assure lz4 </dev/null ; then if epm assure lz4 </dev/null ; then
docmd lz4 --rm "$OFILE" "$OFILE.lz4" || return #docmd lz4 --rm "$OFILE" "$OFILE.lz4" || return
# due old lz4
docmd lz4 -f "$OFILE" "$OFILE.lz4" || return
rm -fv "$OFILE"
else else
epm assure xz </dev/null || return epm assure xz </dev/null || return
docmd xz "$OFILE" || return docmd xz -f "$OFILE" || return
fi fi
return 0 return 0
} }
...@@ -4799,11 +4870,12 @@ download_alt_contents_index() ...@@ -4799,11 +4870,12 @@ download_alt_contents_index()
if echo "$URL" | grep -q "^file:/" ; then if echo "$URL" | grep -q "^file:/" ; then
URL=$(echo "$URL" | sed -e "s|^file:||") URL=$(echo "$URL" | sed -e "s|^file:||")
[ -s "$URL" ] || { touch $OFILE.failed ; return 1; } [ -s "$URL" ] || { touch $OFILE.failed ; return 1; }
ln -s "$URL" "$OFILE" || { touch $OFILE.failed ; return 1; } ln -sf "$URL" "$OFILE" || { touch $OFILE.failed ; return 1; }
else else
docmd eget -O "$OFILE" "$URL" || { rm -fv $OFILE ; touch $OFILE.failed ; return 1; } docmd eget -O "$OFILE" "$URL" || { rm -fv $OFILE ; touch $OFILE.failed ; return 1; }
fi fi
rm -f $OFILE.failed
compress_file_inplace "$OFILE" compress_file_inplace "$OFILE"
} }
...@@ -4812,9 +4884,9 @@ get_local_alt_contents_index() ...@@ -4812,9 +4884,9 @@ get_local_alt_contents_index()
local LOCALPATH local LOCALPATH
epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read URL ARCH other ; do epm_repolist | grep -E "rpm.*(ftp://|http://|https://|file:/)" | sed -e "s@^rpm.*\(ftp://\|http://\|https://\|file:\)@\1@g" | while read -r URL ARCH other ; do
LOCALPATH=$(get_local_alt_mirror_path "$URL/$ARCH") LOCALPATH=$(get_local_alt_mirror_path "$URL/$ARCH")
download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH || continue download_alt_contents_index $URL/$ARCH/base/contents_index $LOCALPATH >&2 || continue
echo "$LOCALPATH/contents_index*" echo "$LOCALPATH/contents_index*"
done done
...@@ -4825,12 +4897,12 @@ get_local_alt_contents_index() ...@@ -4825,12 +4897,12 @@ get_local_alt_contents_index()
__use_zypper_dry_run() __use_zypper_dry_run()
{ {
a= zypper install --help 2>&1 | grep -q -- "--dry-run" && echo "--dry-run" a='' zypper install --help 2>&1 | grep -q -- "--dry-run" && echo "--dry-run"
} }
__use_yum_assumeno() __use_yum_assumeno()
{ {
a= yum --help 2>&1 | grep -q -- "--assumeno" a='' yum --help 2>&1 | grep -q -- "--assumeno"
} }
...@@ -4947,7 +5019,11 @@ epm_simulate() ...@@ -4947,7 +5019,11 @@ epm_simulate()
_epm_do_simulate $filenames _epm_do_simulate $filenames
local RES=$? local RES=$?
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
[ "$RES" = 0 ] && info "Simulate result: $filenames package(s) CAN BE installed" || info "Simulate result: There are PROBLEMS with install some package(s)" if [ "$RES" = 0 ] ; then
info "Simulate result: $filenames package(s) CAN BE installed"
else
info "Simulate result: There are PROBLEMS with install some package(s)"
fi
fi fi
return $RES return $RES
} }
...@@ -4963,14 +5039,14 @@ paoapi() ...@@ -4963,14 +5039,14 @@ paoapi()
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs # http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs
epm assure curl || return 1 epm assure curl || return 1
showcmd curl "$PAOURL/api/$1" showcmd curl "$PAOURL/api/$1"
a= curl -s --header "Accept: application/json" "$PAOURL/api/$1" a='' curl -s --header "Accept: application/json" "$PAOURL/api/$1"
} }
get_pao_var() get_pao_var()
{ {
local FIELD="$1" local FIELD="$1"
#grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g' #grep '"$FIELD"' | sed -e 's|.*"$FIELD":"||g' | sed -e 's|".*||g'
internal_tools_json -b | egrep "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g' internal_tools_json -b | grep -E "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
return 0 return 0
} }
...@@ -5022,7 +5098,7 @@ query_package_url() ...@@ -5022,7 +5098,7 @@ query_package_url()
get_locale() get_locale()
{ {
local loc local loc
loc=$(a= natspec --locale 2>/dev/null) loc=$(a='' natspec --locale 2>/dev/null)
[ -n "$loc" ] || loc=$LANG [ -n "$loc" ] || loc=$LANG
echo $loc echo $loc
} }
...@@ -5225,7 +5301,7 @@ epm_upgrade() ...@@ -5225,7 +5301,7 @@ epm_upgrade()
;; ;;
homebrew) homebrew)
#CMD="brew upgrade" #CMD="brew upgrade"
docmd "brew upgrade `brew outdated`" docmd "brew upgrade $(brew outdated)"
return return
;; ;;
ipkg) ipkg)
...@@ -5238,6 +5314,7 @@ epm_upgrade() ...@@ -5238,6 +5314,7 @@ epm_upgrade()
CMD="guix package -u" CMD="guix package -u"
;; ;;
aptcyg) aptcyg)
# shellcheck disable=SC2046
docmd_foreach "epm install" $(short=1 epm packages) docmd_foreach "epm install" $(short=1 epm packages)
return return
;; ;;
...@@ -5261,7 +5338,7 @@ epm_Upgrade() ...@@ -5261,7 +5338,7 @@ epm_Upgrade()
yum-rpm) yum-rpm)
;; ;;
*) *)
pkg_filenames= epm_update || return pkg_filenames='' epm_update || return
;; ;;
esac esac
...@@ -5396,7 +5473,7 @@ rpmvendor() ...@@ -5396,7 +5473,7 @@ 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 "[A-Z]" "[a-z]" echo "$DISTRIB_ID" | tr "[:lower:]"
} }
# 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)
...@@ -5409,7 +5486,7 @@ pkgvendor() ...@@ -5409,7 +5486,7 @@ pkgvendor()
# Print pkgtype (need DISTRIB_ID var) # Print pkgtype (need DISTRIB_ID var)
pkgtype() pkgtype()
{ {
case `pkgvendor` in case $(pkgvendor) in
freebsd) echo "tbz" ;; freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;; sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;; slackware|mopslinux) echo "tgz" ;;
...@@ -5449,9 +5526,9 @@ DISTRIB_CODENAME="" ...@@ -5449,9 +5526,9 @@ DISTRIB_CODENAME=""
# Default with LSB # Default with LSB
if distro lsb-release ; then if distro lsb-release ; then
DISTRIB_ID=`cat $DISTROFILE | get_var DISTRIB_ID` DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE=`cat $DISTROFILE | get_var DISTRIB_RELEASE` DISTRIB_RELEASE=$(cat $DISTROFILE | get_var DISTRIB_RELEASE)
DISTRIB_CODENAME=`cat $DISTROFILE | get_var DISTRIB_CODENAME` DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
fi fi
# ALT Linux based # ALT Linux based
...@@ -5459,6 +5536,7 @@ if distro altlinux-release ; then ...@@ -5459,6 +5536,7 @@ if distro altlinux-release ; then
DISTRIB_ID="ALTLinux" DISTRIB_ID="ALTLinux"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus" if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7" elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux t7." ; then DISTRIB_RELEASE="t7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8" elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8" elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6" elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
...@@ -5483,8 +5561,8 @@ if distro altlinux-release ; then ...@@ -5483,8 +5561,8 @@ if distro altlinux-release ; then
elif distro gentoo-release ; then 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 # Slackware based
elif distro mopslinux-version ; then elif distro mopslinux-version ; then
...@@ -5497,19 +5575,22 @@ elif distro mopslinux-version ; then ...@@ -5497,19 +5575,22 @@ elif distro mopslinux-version ; then
fi 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 && which apk 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="$ID" DISTRIB_ID="$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 && which tce-ab 2>/dev/null >/dev/null ; then
# 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 && which xbps-query 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux" DISTRIB_ID="VoidLinux"
DISTRIB_RELEASE="Live" DISTRIB_RELEASE="Live"
...@@ -5632,32 +5713,32 @@ elif distro SuSe-release || distro SuSE-release ; then ...@@ -5632,32 +5713,32 @@ elif distro SuSe-release || distro SuSE-release ; then
fi fi
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname` = "FreeBSD" ] ; then elif [ "$(uname)" = "FreeBSD" ] ; then
DISTRIB_ID="FreeBSD" DISTRIB_ID="FreeBSD"
UNAME=$(uname -r) UNAME=$(uname -r)
DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g") DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g")
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname` = "SunOS" ] ; then elif [ "$(uname)" = "SunOS" ] ; then
DISTRIB_ID="SunOS" DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname -s 2>/dev/null` = "Darwin" ] ; then elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
DISTRIB_ID="MacOS" DISTRIB_ID="MacOS"
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" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix" DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: move to up # fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then elif [ "$(uname)" = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android" DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]') DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then elif [ "$(uname -o 2>/dev/null)" = "Cygwin" ] ; then
DISTRIB_ID="Cygwin" DISTRIB_ID="Cygwin"
DISTRIB_RELEASE="all" DISTRIB_RELEASE="all"
...@@ -5796,7 +5877,7 @@ create_fake_files() ...@@ -5796,7 +5877,7 @@ create_fake_files()
DIRALLFILES="$MYTMPDIR/files/" DIRALLFILES="$MYTMPDIR/files/"
mkdir -p "$DIRALLFILES" mkdir -p "$DIRALLFILES"
print_files | while read line ; do print_files | while read -r line ; do
touch $DIRALLFILES/$(basename "$line") touch $DIRALLFILES/$(basename "$line")
done done
} }
...@@ -6054,7 +6135,7 @@ $(get_help HELPOPT) ...@@ -6054,7 +6135,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "EPM package manager version 2.0.5" echo "EPM package manager version 2.1.0"
echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)" echo "Running on $($DISTRVENDOR) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
echo "Copyright (c) Etersoft 2012-2017" echo "Copyright (c) Etersoft 2012-2017"
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."
...@@ -6149,7 +6230,7 @@ check_command() ...@@ -6149,7 +6230,7 @@ check_command()
-i|install|add|i) # HELPCMD: install package(s) from remote repositories or from local file -i|install|add|i) # HELPCMD: install package(s) from remote repositories or from local file
epm_cmd=install epm_cmd=install
;; ;;
-e|-P|remove|delete|uninstall|erase|e) # HELPCMD: remove (delete) package(s) from the database and the system -e|-P|rm|del|remove|delete|uninstall|erase|e) # HELPCMD: remove (delete) package(s) from the database and the system
epm_cmd=remove epm_cmd=remove
;; ;;
-s|search|s) # HELPCMD: search in remote package repositories -s|search|s) # HELPCMD: search in remote package repositories
...@@ -6181,7 +6262,7 @@ check_command() ...@@ -6181,7 +6262,7 @@ check_command()
check|fix|verify) # HELPCMD: check local package base integrity and fix it check|fix|verify) # HELPCMD: check local package base integrity and fix it
epm_cmd=check epm_cmd=check
;; ;;
changelog|cl|-cl) # HELPCMD: show changelog for package -cl|cl|changelog) # HELPCMD: show changelog for package
epm_cmd=changelog epm_cmd=changelog
;; ;;
-qi|qi|info|show) # HELPCMD: print package detail info -qi|qi|info|show) # HELPCMD: print package detail info
...@@ -6202,13 +6283,13 @@ check_command() ...@@ -6202,13 +6283,13 @@ check_command()
conflicts) # HELPCMD: print package conflicts conflicts) # HELPCMD: print package conflicts
epm_cmd=conflicts epm_cmd=conflicts
;; ;;
-qa|list|packages|-l|qa) # HELPCMD: print list of installed package(s) -qa|qa|-l|list|packages) # HELPCMD: print list of installed package(s)
epm_cmd=packages epm_cmd=packages
;; ;;
programs) # HELPCMD: print list of installed GUI program(s) programs) # HELPCMD: print list of installed GUI program(s) (they have .desktop files)
epm_cmd=programs epm_cmd=programs
;; ;;
assure) # HELPCMD: <command> [package]: install package if command does not exists assure) # HELPCMD: <command> [package]: install package if command does not exist
epm_cmd=assure epm_cmd=assure
;; ;;
policy) # HELPCMD: print detailed information about the priority selection of package policy) # HELPCMD: print detailed information about the priority selection of package
...@@ -6275,7 +6356,7 @@ check_command() ...@@ -6275,7 +6356,7 @@ check_command()
site|url) # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site) site|url) # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
epm_cmd=site epm_cmd=site
;; ;;
ei|epminstall|epm-install|selfinstall) # HELPCMD: install or update eepm from all in one script ei|epminstall|epm-install|selfinstall) # HELPCMD: install or update eepm package from all in one script
epm_cmd=epm_install epm_cmd=epm_install
;; ;;
print) # HELPCMD: print various info, run epm print help for details print) # HELPCMD: print various info, run epm print help for details
...@@ -6347,7 +6428,7 @@ check_option() ...@@ -6347,7 +6428,7 @@ check_option()
check_filenames() check_filenames()
{ {
local opt local opt
for opt in $* ; do for opt in "$@" ; do
# files can be with full path or have extension via . # files can be with full path or have extension via .
if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then
pkg_files="$pkg_files $opt" pkg_files="$pkg_files $opt"
...@@ -6397,7 +6478,7 @@ pkg_filenames=$(strip_spaces "$pkg_files $pkg_names") ...@@ -6397,7 +6478,7 @@ pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
if [ -z "$epm_cmd" ] ; then if [ -z "$epm_cmd" ] ; then
print_version print_version
echo echo
fatstr="Unknown command in $@ arg(s)" fatstr="Unknown command in $* arg(s)"
[ -n "$*" ] || fatstr="That program needs be running with some command" [ -n "$*" ] || fatstr="That program needs be running with some command"
fatal "$fatstr. Run $ $PROGNAME --help to get help." fatal "$fatstr. Run $ $PROGNAME --help to get help."
fi fi
......
...@@ -62,7 +62,7 @@ check_tty() ...@@ -62,7 +62,7 @@ check_tty()
# egrep from busybox may not --color # egrep from busybox may not --color
# egrep from MacOS print help to stderr # egrep from MacOS print help to stderr
if egrep --help 2>&1 | grep -q -- "--color" ; then if grep -E --help 2>&1 | grep -q -- "--color" ; then
export EGREPCOLOR="--color" export EGREPCOLOR="--color"
fi fi
...@@ -102,7 +102,7 @@ echover() ...@@ -102,7 +102,7 @@ echover()
echon() echon()
{ {
# default /bin/sh on MacOS does not recognize -n # default /bin/sh on MacOS does not recognize -n
/bin/echo -n "$@" /bin/echo -n "$*"
} }
...@@ -120,14 +120,14 @@ showcmd() ...@@ -120,14 +120,14 @@ showcmd()
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
[ "$EFFUID" = 0 ] && PROMTSIG="#" [ "$EFFUID" = 0 ] && PROMTSIG="#"
echo " $PROMTSIG $@" echo " $PROMTSIG $*"
restore_color restore_color
fi >&2 fi >&2
} }
docmd() docmd()
{ {
showcmd "$@$EXTRA_SHOWDOCMD" showcmd "$*$EXTRA_SHOWDOCMD"
$@ $@
} }
...@@ -144,7 +144,7 @@ docmd_foreach() ...@@ -144,7 +144,7 @@ docmd_foreach()
sudocmd() sudocmd()
{ {
showcmd "$SUDO $@" showcmd "$SUDO $*"
$SUDO $@ $SUDO $@
} }
...@@ -174,11 +174,10 @@ get_firstarg() ...@@ -174,11 +174,10 @@ get_firstarg()
get_lastarg() get_lastarg()
{ {
local lastarg local lastarg
eval lastarg=\${$#} eval "lastarg=\${$#}"
echon "$lastarg" echon "$lastarg"
} }
filter_strip_spaces() filter_strip_spaces()
{ {
# possible use just # possible use just
...@@ -205,7 +204,7 @@ store_output() ...@@ -205,7 +204,7 @@ store_output()
echo 1 >$CMDSTATUS echo 1 >$CMDSTATUS
#RC_STDERR=$(mktemp) #RC_STDERR=$(mktemp)
( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT ( $@ 2>&1 ; echo $? >$CMDSTATUS ) | tee $RC_STDOUT
return $(cat $CMDSTATUS) return "$(cat $CMDSTATUS)"
# bashism # bashism
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
#return $PIPESTATUS #return $PIPESTATUS
...@@ -231,7 +230,7 @@ epm() ...@@ -231,7 +230,7 @@ epm()
fatal() fatal()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Error: $@" >&2 echo "Error: $*" >&2
fi fi
exit 1 exit 1
} }
...@@ -239,7 +238,7 @@ fatal() ...@@ -239,7 +238,7 @@ fatal()
warning() warning()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Warning: $@" >&2 echo "Warning: $*" >&2
fi fi
} }
...@@ -250,9 +249,9 @@ info() ...@@ -250,9 +249,9 @@ info()
# print message to stderr if stderr forwarded to (a file) # print message to stderr if stderr forwarded to (a file)
if isatty2 ; then if isatty2 ; then
isatty || return 0 isatty || return 0
echo "$@" echo "$*"
else else
echo "$@" >&2 echo "$*" >&2
fi fi
} }
...@@ -266,7 +265,7 @@ set_sudo() ...@@ -266,7 +265,7 @@ set_sudo()
return return
fi fi
EFFUID=`id -u` EFFUID=$(id -u)
# do not need sudo # do not need sudo
[ $EFFUID = "0" ] && return [ $EFFUID = "0" ] && return
...@@ -402,7 +401,7 @@ get_help() ...@@ -402,7 +401,7 @@ get_help()
return return
fi fi
grep -v -- "^#" $0 | grep -- "# $1" | while read n ; do grep -v -- "^#" $0 | grep -- "# $1" | while read -r n ; do
opt=$(echo $n | sed -e "s|) # $1:.*||g") opt=$(echo $n | sed -e "s|) # $1:.*||g")
desc=$(echo $n | sed -e "s|.*) # $1:||g") desc=$(echo $n | sed -e "s|.*) # $1:||g")
printf " %-20s %s\n" $opt "$desc" printf " %-20s %s\n" $opt "$desc"
...@@ -506,9 +505,10 @@ is_active_systemd() ...@@ -506,9 +505,10 @@ is_active_systemd()
SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd
[ -x "$SYSTEMCTL" ] || return [ -x "$SYSTEMCTL" ] || return
[ -d "$SYSTEMD_CGROUP_DIR" ] || return [ -d "$SYSTEMD_CGROUP_DIR" ] || return
a= mountpoint -q "$SYSTEMD_CGROUP_DIR" || return a='' mountpoint -q "$SYSTEMD_CGROUP_DIR" || return
readlink /sbin/init | grep -q 'systemd' || return readlink /sbin/init | grep -q 'systemd' || return
# some hack # some hack
# shellcheck disable=SC2009
ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev' ps ax | grep '[s]ystemd' | grep -q -v 'systemd-udev'
} }
...@@ -873,13 +873,13 @@ is_service_autostart() ...@@ -873,13 +873,13 @@ is_service_autostart()
LANG=C $SUDO chkconfig $1 --list | grep -q "[35]:on" LANG=C $SUDO chkconfig $1 --list | grep -q "[35]:on"
;; ;;
service-initd|service-update) service-initd|service-update)
test -L $(echo /etc/rc5.d/S??$1) test -L "$(echo /etc/rc5.d/S??$1)"
;; ;;
systemd) systemd)
$SUDO systemctl is-enabled $1 $SUDO systemctl is-enabled $1
;; ;;
runit) runit)
test -L /var/service/$SERVICE test -L "/var/service/$SERVICE"
;; ;;
*) *)
fatal "Have no suitable command for $SERVICETYPE" fatal "Have no suitable command for $SERVICETYPE"
...@@ -906,7 +906,7 @@ serv_status() ...@@ -906,7 +906,7 @@ serv_status()
sudocmd $INITDIR/$SERVICE status "$@" sudocmd $INITDIR/$SERVICE status "$@"
;; ;;
systemd) systemd)
sudocmd systemctl status $SERVICE "$@" sudocmd systemctl -l status $SERVICE "$@"
;; ;;
runit) runit)
sudocmd sv status "$SERVICE" sudocmd sv status "$SERVICE"
...@@ -1036,7 +1036,7 @@ rpmvendor() ...@@ -1036,7 +1036,7 @@ 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 "[A-Z]" "[a-z]" echo "$DISTRIB_ID" | tr "[:lower:]"
} }
# 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)
...@@ -1049,7 +1049,7 @@ pkgvendor() ...@@ -1049,7 +1049,7 @@ pkgvendor()
# Print pkgtype (need DISTRIB_ID var) # Print pkgtype (need DISTRIB_ID var)
pkgtype() pkgtype()
{ {
case `pkgvendor` in case $(pkgvendor) in
freebsd) echo "tbz" ;; freebsd) echo "tbz" ;;
sunos) echo "pkg.gz" ;; sunos) echo "pkg.gz" ;;
slackware|mopslinux) echo "tgz" ;; slackware|mopslinux) echo "tgz" ;;
...@@ -1089,9 +1089,9 @@ DISTRIB_CODENAME="" ...@@ -1089,9 +1089,9 @@ DISTRIB_CODENAME=""
# Default with LSB # Default with LSB
if distro lsb-release ; then if distro lsb-release ; then
DISTRIB_ID=`cat $DISTROFILE | get_var DISTRIB_ID` DISTRIB_ID=$(cat $DISTROFILE | get_var DISTRIB_ID)
DISTRIB_RELEASE=`cat $DISTROFILE | get_var DISTRIB_RELEASE` DISTRIB_RELEASE=$(cat $DISTROFILE | get_var DISTRIB_RELEASE)
DISTRIB_CODENAME=`cat $DISTROFILE | get_var DISTRIB_CODENAME` DISTRIB_CODENAME=$(cat $DISTROFILE | get_var DISTRIB_CODENAME)
fi fi
# ALT Linux based # ALT Linux based
...@@ -1099,6 +1099,7 @@ if distro altlinux-release ; then ...@@ -1099,6 +1099,7 @@ if distro altlinux-release ; then
DISTRIB_ID="ALTLinux" DISTRIB_ID="ALTLinux"
if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus" if has Sisyphus ; then DISTRIB_RELEASE="Sisyphus"
elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7" elif has "ALT Linux 7." ; then DISTRIB_RELEASE="p7"
elif has "ALT Linux t7." ; then DISTRIB_RELEASE="t7"
elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8" elif has "ALT Linux 8." ; then DISTRIB_RELEASE="p8"
elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8" elif has "ALT .*8.[0-9]" ; then DISTRIB_RELEASE="p8"
elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6" elif has "Simply Linux 6." ; then DISTRIB_RELEASE="p6"
...@@ -1123,8 +1124,8 @@ if distro altlinux-release ; then ...@@ -1123,8 +1124,8 @@ if distro altlinux-release ; then
elif distro gentoo-release ; then 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 # Slackware based
elif distro mopslinux-version ; then elif distro mopslinux-version ; then
...@@ -1137,19 +1138,22 @@ elif distro mopslinux-version ; then ...@@ -1137,19 +1138,22 @@ elif distro mopslinux-version ; then
fi 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 && which apk 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="$ID" DISTRIB_ID="$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 && which tce-ab 2>/dev/null >/dev/null ; then
# 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 && which xbps-query 2>/dev/null >/dev/null ; then
# shellcheck disable=SC1090
. $ROOTDIR/etc/os-release . $ROOTDIR/etc/os-release
DISTRIB_ID="VoidLinux" DISTRIB_ID="VoidLinux"
DISTRIB_RELEASE="Live" DISTRIB_RELEASE="Live"
...@@ -1272,32 +1276,32 @@ elif distro SuSe-release || distro SuSE-release ; then ...@@ -1272,32 +1276,32 @@ elif distro SuSe-release || distro SuSE-release ; then
fi fi
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname` = "FreeBSD" ] ; then elif [ "$(uname)" = "FreeBSD" ] ; then
DISTRIB_ID="FreeBSD" DISTRIB_ID="FreeBSD"
UNAME=$(uname -r) UNAME=$(uname -r)
DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g") DISTRIB_RELEASE=$(echo "$UNAME" | grep RELEASE | sed -e "s|\([0-9]\.[0-9]\)-RELEASE|\1|g")
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname` = "SunOS" ] ; then elif [ "$(uname)" = "SunOS" ] ; then
DISTRIB_ID="SunOS" DISTRIB_ID="SunOS"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: can we detect by some file? # fixme: can we detect by some file?
elif [ `uname -s 2>/dev/null` = "Darwin" ] ; then elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] ; then
DISTRIB_ID="MacOS" DISTRIB_ID="MacOS"
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" ] && which guix 2>/dev/null >/dev/null ; then
DISTRIB_ID="GNU/Linux/Guix" DISTRIB_ID="GNU/Linux/Guix"
DISTRIB_RELEASE=$(uname -r) DISTRIB_RELEASE=$(uname -r)
# fixme: move to up # fixme: move to up
elif [ `uname` = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then elif [ "$(uname)" = "Linux" ] && [ -x $ROOTDIR/system/bin/getprop ] ; then
DISTRIB_ID="Android" DISTRIB_ID="Android"
DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]') DISTRIB_RELEASE=$(getprop | awk -F": " '/build.version.release/ { print $2 }' | tr -d '[]')
elif [ `uname -o 2>/dev/null` = "Cygwin" ] ; then elif [ "$(uname -o 2>/dev/null)" = "Cygwin" ] ; then
DISTRIB_ID="Cygwin" DISTRIB_ID="Cygwin"
DISTRIB_RELEASE="all" DISTRIB_RELEASE="all"
...@@ -1436,7 +1440,7 @@ create_fake_files() ...@@ -1436,7 +1440,7 @@ create_fake_files()
DIRALLFILES="$MYTMPDIR/files/" DIRALLFILES="$MYTMPDIR/files/"
mkdir -p "$DIRALLFILES" mkdir -p "$DIRALLFILES"
print_files | while read line ; do print_files | while read -r line ; do
touch $DIRALLFILES/$(basename "$line") touch $DIRALLFILES/$(basename "$line")
done done
} }
...@@ -1767,7 +1771,7 @@ $(get_help HELPOPT) ...@@ -1767,7 +1771,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Service manager version 2.0.5" echo "Service manager version 2.1.0"
echo "Running on $($DISTRVENDOR) with $SERVICETYPE" echo "Running on $($DISTRVENDOR) with $SERVICETYPE"
echo "Copyright (c) Etersoft 2012, 2013, 2016" echo "Copyright (c) Etersoft 2012, 2013, 2016"
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