Commit f204e69b authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm: replace tab with 4 spaces

parent 4bc2d877
...@@ -67,7 +67,7 @@ check_tty ...@@ -67,7 +67,7 @@ check_tty
phelp() phelp()
{ {
echo "$Descr echo "$Descr
$Usage $Usage
Options: Options:
......
...@@ -22,6 +22,6 @@ load_helper epm-upgrade ...@@ -22,6 +22,6 @@ load_helper epm-upgrade
epm_Upgrade() epm_Upgrade()
{ {
epm_update epm_update
epm_upgrade "$@" epm_upgrade "$@"
} }
...@@ -24,79 +24,79 @@ ALTLINUXPUBURL=http://ftp.altlinux.org/pub/distributions ...@@ -24,79 +24,79 @@ ALTLINUXPUBURL=http://ftp.altlinux.org/pub/distributions
__epm_addrepo_rhel() __epm_addrepo_rhel()
{ {
local repo="$*" local repo="$*"
if [ -z "$repo" ] ; then if [ -z "$repo" ] ; then
echo "Add repo." echo "Add repo."
echo "1. Use with repository URL, f.i. http://www.example.com/example.repo" echo "1. Use with repository URL, f.i. http://www.example.com/example.repo"
echo "2. Use with epel to add EPEL repository" echo "2. Use with epel to add EPEL repository"
echo "3. Use with powertools to add PowerTools repository" echo "3. Use with powertools to add PowerTools repository"
echo "4. Use with crb to add Rocky Linux CRB repository" echo "4. Use with crb to add Rocky Linux CRB repository"
return 1 return 1
fi fi
case "$1" in case "$1" in
epel) epel)
# dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm # dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
epm install epel-release epm install epel-release
return 1 return 1
;; ;;
powertools) powertools)
# https://serverfault.com/questions/997896/how-to-enable-powertools-repository-in-centos-8 # https://serverfault.com/questions/997896/how-to-enable-powertools-repository-in-centos-8
epm install --skip-installed dnf-plugins-core epm install --skip-installed dnf-plugins-core
sudocmd dnf config-manager --set-enabled powertools sudocmd dnf config-manager --set-enabled powertools
return 1 return 1
;; ;;
crb) crb)
# https://wiki.rockylinux.org/rocky/repo/ # https://wiki.rockylinux.org/rocky/repo/
epm install --skip-installed dnf-plugins-core epm install --skip-installed dnf-plugins-core
sudocmd dnf config-manager --set-enabled crb sudocmd dnf config-manager --set-enabled crb
return 1 return 1
;; ;;
esac esac
return 0 return 0
} }
__epm_addrepo_etersoft_addon() __epm_addrepo_etersoft_addon()
{ {
epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold || fatal epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold || fatal
# TODO: ignore only error code 22 (skipped) || fatal # TODO: ignore only error code 22 (skipped) || fatal
local pb="$DISTRVERSION/branch" local pb="$DISTRVERSION/branch"
[ "$DISTRVERSION" = "Sisyphus" ] && pb="$DISTRVERSION" [ "$DISTRVERSION" = "Sisyphus" ] && pb="$DISTRVERSION"
# FIXME # FIXME
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION" [ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/noarch addon" docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/noarch addon"
docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/$DISTRARCH addon" docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/$DISTRARCH addon"
if [ "$DISTRARCH" = "x86_64" ] ; then if [ "$DISTRARCH" = "x86_64" ] ; then
docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/x86_64-i586 addon" docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/x86_64-i586 addon"
fi fi
} }
__epm_addrepo_altsp() __epm_addrepo_altsp()
{ {
local comp local comp
local repo="$1" local repo="$1"
case "$repo" in case "$repo" in
c9f2) c9f2)
comp="CF2" comp="CF2"
;; ;;
c9f1) c9f1)
comp="CF1" comp="CF1"
;; ;;
c9) c9)
comp="cf" comp="cf"
;; ;;
*) *)
fatal "Uknown CF comp $repo" fatal "Uknown CF comp $repo"
;; ;;
esac esac
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/$DISTRARCH classic" || return epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/$DISTRARCH classic" || return
if [ "$DISTRARCH" = "x86_64" ] ; then if [ "$DISTRARCH" = "x86_64" ] ; then
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/x86_64-i586 classic" || return epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/x86_64-i586 classic" || return
fi fi
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/noarch classic" || return epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/noarch classic" || return
} }
get_archlist() get_archlist()
...@@ -113,173 +113,173 @@ get_archlist() ...@@ -113,173 +113,173 @@ get_archlist()
# 'rpm protocol:/path/to/repo component' # 'rpm protocol:/path/to/repo component'
__epm_addrepo_altlinux_short() __epm_addrepo_altlinux_short()
{ {
[ -n "$1" ] || fatal "only for rpm repo" [ -n "$1" ] || fatal "only for rpm repo"
local url="$2" local url="$2"
local REPO_NAME="$3" local REPO_NAME="$3"
local arch local arch
arch="$(basename "$url")" arch="$(basename "$url")"
url="$(dirname "$url")" url="$(dirname "$url")"
docmd epm repo add "rpm $url $arch $REPO_NAME" docmd epm repo add "rpm $url $arch $REPO_NAME"
} }
__epm_addrepo_altlinux_url() __epm_addrepo_altlinux_url()
{ {
local url="$1" local url="$1"
local arch local arch
local base local base
# URL to path/RPMS.addon # URL to path/RPMS.addon
base="$(basename "$url")" base="$(basename "$url")"
if echo "$base" | grep -q "^RPMS\." ; then if echo "$base" | grep -q "^RPMS\." ; then
REPO_NAME="$(echo $base | sed -e 's|.*\.||')" REPO_NAME="$(echo $base | sed -e 's|.*\.||')"
url="$(dirname $url)" url="$(dirname $url)"
docmd epm repo add "rpm $url $REPO_NAME" docmd epm repo add "rpm $url $REPO_NAME"
return return
fi fi
# TODO: add to eget file:/ support and use here # TODO: add to eget file:/ support and use here
# URL to path (where RPMS.addon is exists) # URL to path (where RPMS.addon is exists)
local baseurl="$(eget --list "$url/RPMS.*")" local baseurl="$(eget --list "$url/RPMS.*")"
base="$(basename "$baseurl")" base="$(basename "$baseurl")"
if echo "$base" | grep -q "^RPMS\." ; then if echo "$base" | grep -q "^RPMS\." ; then
REPO_NAME="$(echo $base | sed -e 's|.*\.||')" REPO_NAME="$(echo $base | sed -e 's|.*\.||')"
docmd epm repo add "rpm $url $REPO_NAME" docmd epm repo add "rpm $url $REPO_NAME"
return return
fi fi
# URL to {i586,x86_64,noarch}/RPMS.addon # URL to {i586,x86_64,noarch}/RPMS.addon
local res='' local res=''
for arch in $(get_archlist) ; do for arch in $(get_archlist) ; do
local rd="$(eget --list $url/$arch/RPMS.*)" local rd="$(eget --list $url/$arch/RPMS.*)"
[ -d "$rd" ] || continue [ -d "$rd" ] || continue
local REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" local REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')"
docmd epm repo add "rpm $url $arch $REPO_NAME" docmd epm repo add "rpm $url $arch $REPO_NAME"
res='1' res='1'
done done
[ -n "$res" ] || warning "There is no arch repos in $url" [ -n "$res" ] || warning "There is no arch repos in $url"
} }
__epm_addrepo_altlinux_help() __epm_addrepo_altlinux_help()
{ {
#sudocmd apt-repo $dryrun add branch #sudocmd apt-repo $dryrun add branch
cat <<EOF cat <<EOF
epm repo add - add branch repo. Use follow params: epm repo add - add branch repo. Use follow params:
etersoft - for LINUX@Etersoft repo" etersoft - for LINUX@Etersoft repo"
basealt - for BaseALT repo" basealt - for BaseALT repo"
yandex - for BaseALT repo mirror hosted by Yandex (recommended)" yandex - for BaseALT repo mirror hosted by Yandex (recommended)"
altsp - add ALT SP repo" altsp - add ALT SP repo"
autoimports - for BaseALT autoimports repo" autoimports - for BaseALT autoimports repo"
altlinuxclub - for altlinuxclub repo (http://altlinuxclub.ru/)" altlinuxclub - for altlinuxclub repo (http://altlinuxclub.ru/)"
<task number> - add task repo" <task number> - add task repo"
archive 2018/02/09 - add archive of the repo from that date" 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" /dir/to/repo [component] - add repo dir generated with epm repo index --init"
URL [arch] [component] - add repo by URL" URL [arch] [component] - add repo by URL"
Examples: Examples:
# epm repo add yandex # epm repo add yandex
# epm repo add "rpm http://somesite/pub/product x86_64 addon" # epm repo add "rpm http://somesite/pub/product x86_64 addon"
# epm repo add /var/ftp/pub/altlinux/p10 # epm repo add /var/ftp/pub/altlinux/p10
EOF EOF
return return
} }
__epm_addrepo_altlinux() __epm_addrepo_altlinux()
{ {
local repo="$*" local repo="$*"
if [ -z "$repo" ] || [ "$repo" == "-h" ] || [ "$repo" == "--list" ] || [ "$repo" == "--help" ] ; then if [ -z "$repo" ] || [ "$repo" == "-h" ] || [ "$repo" == "--list" ] || [ "$repo" == "--help" ] ; then
__epm_addrepo_altlinux_help __epm_addrepo_altlinux_help
return return
fi fi
# 'rpm protocol:/path/to/repo component' # 'rpm protocol:/path/to/repo component'
if [ "$1" = "rpm" ] && [ -n "$2" ] && [ -n "$3" ] && [ -z "$4" ] ; then if [ "$1" = "rpm" ] && [ -n "$2" ] && [ -n "$3" ] && [ -z "$4" ] ; then
__epm_addrepo_altlinux_short "$@" __epm_addrepo_altlinux_short "$@"
return return
fi fi
# /path/to/repo # /path/to/repo
if [ -d "$1" ] ; then if [ -d "$1" ] ; then
__epm_addrepo_altlinux_url "file:$1" __epm_addrepo_altlinux_url "file:$1"
return return
fi fi
# file:/path/to/repo or http://path/to/repo # file:/path/to/repo or http://path/to/repo
if is_url "$1" ; then if is_url "$1" ; then
__epm_addrepo_altlinux_url "$1" __epm_addrepo_altlinux_url "$1"
return return
fi fi
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")" local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
[ -n "$branch" ] || fatal "Empty DISTRVERSION" [ -n "$branch" ] || fatal "Empty DISTRVERSION"
case "$1" in case "$1" in
etersoft) etersoft)
# TODO: return when Etersoft improved its repos # TODO: return when Etersoft improved its repos
#info "add Etersoft's addon repo" #info "add Etersoft's addon repo"
#__epm_addrepo_etersoft_addon #__epm_addrepo_etersoft_addon
epm repo add $branch epm repo add $branch
epm repofix etersoft epm repofix etersoft
return 0 return 0
;; ;;
basealt|alt|altsp) basealt|alt|altsp)
repo="$branch" repo="$branch"
;; ;;
yandex) yandex)
epm repo add $branch epm repo add $branch
epm repofix yandex epm repofix yandex
return 0 return 0
;; ;;
autoimports) autoimports)
repo="autoimports.$branch" repo="autoimports.$branch"
;; ;;
altlinuxclub) altlinuxclub)
repo="altlinuxclub.$branch" repo="altlinuxclub.$branch"
;; ;;
autoimports.*|altlinuxclub.*) autoimports.*|altlinuxclub.*)
repo="$1" 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"
local rpmsign='[alt]' local rpmsign='[alt]'
[ "$branch" != "sisyphus" ] && rpmsign="[$branch]" [ "$branch" != "sisyphus" ] && rpmsign="[$branch]"
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/$DISTRARCH classic" epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/$DISTRARCH classic"
if [ "$DISTRARCH" = "x86_64" ] ; then if [ "$DISTRARCH" = "x86_64" ] ; then
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/x86_64-i586 classic" epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/x86_64-i586 classic"
fi fi
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/noarch classic" epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/noarch classic"
return 0 return 0
;; ;;
esac esac
assure_exists apt-repo assure_exists apt-repo
if tasknumber "$repo" >/dev/null ; then if tasknumber "$repo" >/dev/null ; then
sudocmd_foreach "apt-repo $dryrun add" $(tasknumber "$repo") sudocmd_foreach "apt-repo $dryrun add" $(tasknumber "$repo")
return return
fi fi
case "$repo" in case "$repo" in
c9f2|c9f1|c9) c9f2|c9f1|c9)
__epm_addrepo_altsp "$repo" __epm_addrepo_altsp "$repo"
return return
;; ;;
esac 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
sudocmd apt-repo $dryrun add "$repo" sudocmd apt-repo $dryrun add "$repo"
} }
...@@ -333,115 +333,115 @@ epm_addkey() ...@@ -333,115 +333,115 @@ epm_addkey()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__epm_addkey_altlinux "$@" __epm_addkey_altlinux "$@"
return return
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
__epm_addkey_deb "$@" __epm_addkey_deb "$@"
;; ;;
esac esac
} }
__epm_addrepo_astra() __epm_addrepo_astra()
{ {
local repo="$*" local repo="$*"
if [ -z "$repo" ] || [ "$repo" = "--help" ]; then if [ -z "$repo" ] || [ "$repo" = "--help" ]; then
info "Add repo. You can use follow params:" info "Add repo. You can use follow params:"
echo " distribution component name" echo " distribution component name"
echo " full sources list line" echo " full sources list line"
echo " URL version component" echo " URL version component"
return return
fi fi
local reponame="$(epm print info --repo-name)" local reponame="$(epm print info --repo-name)"
# keywords # keywords
# https://wiki.astralinux.ru/pages/viewpage.action?pageId=3276859 # https://wiki.astralinux.ru/pages/viewpage.action?pageId=3276859
case "$1-$reponame" in case "$1-$reponame" in
astra-1.7_x86_64) astra-1.7_x86_64)
# TODO epm repo change http / https # TODO epm repo change http / https
epm install --skip-installed apt-transport-https ca-certificates || fatal epm install --skip-installed apt-transport-https ca-certificates || fatal
# https://wiki.astralinux.ru/pages/viewpage.action?pageId=158598882 # https://wiki.astralinux.ru/pages/viewpage.action?pageId=158598882
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-main/ 1.7_x86-64 main contrib non-free" epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-main/ 1.7_x86-64 main contrib non-free"
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-update/ 1.7_x86-64 main contrib non-free" epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-update/ 1.7_x86-64 main contrib non-free"
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-base/ 1.7_x86-64 main contrib non-free" epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-base/ 1.7_x86-64 main contrib non-free"
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended/ 1.7_x86-64 main contrib non-free" epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended/ 1.7_x86-64 main contrib non-free"
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended/ 1.7_x86-64 astra-ce" epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended/ 1.7_x86-64 astra-ce"
return return
;; ;;
astra-orel) astra-orel)
# TODO epm repo change http / https # TODO epm repo change http / https
epm install --skip-installed apt-transport-https ca-certificates || fatal epm install --skip-installed apt-transport-https ca-certificates || fatal
# https://wiki.astralinux.ru/pages/viewpage.action?pageId=158605543 # https://wiki.astralinux.ru/pages/viewpage.action?pageId=158605543
epm repo add "deb [arch=amd64] https://dl.astralinux.ru/astra/frozen/$(epm print info -v)_x86-64/$(epm print info --full-version)/repository stable main contrib non-free" epm repo add "deb [arch=amd64] https://dl.astralinux.ru/astra/frozen/$(epm print info -v)_x86-64/$(epm print info --full-version)/repository stable main contrib non-free"
#epm repo add "deb https://download.astralinux.ru/astra/stable/orel/repository/ orel main contrib non-free" #epm repo add "deb https://download.astralinux.ru/astra/stable/orel/repository/ orel main contrib non-free"
return return
;; ;;
astra-*) astra-*)
fatal "Unsupported distro version $reponame, see '# epm print info' output." fatal "Unsupported distro version $reponame, see '# epm print info' output."
;; ;;
esac esac
echo "Use workaround for AstraLinux ..." echo "Use workaround for AstraLinux ..."
# aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel # aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel
# 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
[ -z "$(tail -n1 /etc/apt/sources.list)" ] || echo "" | sudocmd tee -a /etc/apt/sources.list [ -z "$(tail -n1 /etc/apt/sources.list)" ] || echo "" | sudocmd tee -a /etc/apt/sources.list
echo "$repo" | sudocmd tee -a /etc/apt/sources.list echo "$repo" | sudocmd tee -a /etc/apt/sources.list
return return
} }
__epm_addrepo_deb() __epm_addrepo_deb()
{ {
assure_exists apt-add-repository software-properties-common assure_exists apt-add-repository software-properties-common
local ad="$($DISTRVENDOR --distro-arch)" local ad="$($DISTRVENDOR --distro-arch)"
# TODO: move to distro_info # TODO: move to distro_info
local nd="$(lsb_release -cs)" local nd="$(lsb_release -cs)"
local repo="$*" local repo="$*"
if [ -z "$repo" ] || [ "$repo" = "--help" ]; then if [ -z "$repo" ] || [ "$repo" = "--help" ]; then
info "Add repo. You can use follow params:" info "Add repo. You can use follow params:"
echo " docker - add official docker repo" echo " docker - add official docker repo"
echo " ppa:<user>/<ppa-name> - add PPA repo" echo " ppa:<user>/<ppa-name> - add PPA repo"
echo " distribution component name" echo " distribution component name"
echo " full sources list line" echo " full sources list line"
echo " URL version component" echo " URL version component"
return return
fi fi
# keywords # keywords
case "$1" in case "$1" in
docker) docker)
__epm_addkey_deb https://download.docker.com/linux/$PKGVENDOR/gpg "9DC858229FC7DD38854AE2D88D81803C0EBFCD88" __epm_addkey_deb https://download.docker.com/linux/$PKGVENDOR/gpg "9DC858229FC7DD38854AE2D88D81803C0EBFCD88"
repo="https://download.docker.com/linux/$PKGVENDOR $nd stable" repo="https://download.docker.com/linux/$PKGVENDOR $nd stable"
;; ;;
esac esac
# if started from url, use heroistic # if started from url, use heroistic
if echo "$repo" | grep -E -q "^https?://" ; then if echo "$repo" | grep -E -q "^https?://" ; then
repo="deb [arch=$ad] $repo" repo="deb [arch=$ad] $repo"
fi fi
if echo "$repo" | grep -q "https://" ; then if echo "$repo" | grep -q "https://" ; then
assure_exists /usr/share/doc/apt-transport-https apt-transport-https assure_exists /usr/share/doc/apt-transport-https apt-transport-https
assure_exists /usr/sbin/update-ca-certificates ca-certificates assure_exists /usr/sbin/update-ca-certificates ca-certificates
fi fi
if [ -d "$repo" ] ; then if [ -d "$repo" ] ; then
sudocmd epm repo add "deb file:$repo ./" sudocmd epm repo add "deb file:$repo ./"
return return
fi fi
# FIXME: quotes in showcmd/sudocmd # FIXME: quotes in showcmd/sudocmd
showcmd apt-add-repository "$repo" showcmd apt-add-repository "$repo"
sudorun apt-add-repository "$repo" sudorun apt-add-repository "$repo"
info "Check file /etc/apt/sources.list if needed" info "Check file /etc/apt/sources.list if needed"
} }
epm_addrepo() epm_addrepo()
...@@ -449,59 +449,59 @@ epm_addrepo() ...@@ -449,59 +449,59 @@ epm_addrepo()
local repo="$*" local repo="$*"
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
# Note! Don't use quotes here # Note! Don't use quotes here
__epm_addrepo_altlinux $repo __epm_addrepo_altlinux $repo
return return
;; ;;
"astra") "astra")
__epm_addrepo_astra $repo __epm_addrepo_astra $repo
return return
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
# Note! Don't use quotes here # Note! Don't use quotes here
__epm_addrepo_deb $repo __epm_addrepo_deb $repo
;; ;;
aptitude-dpkg) aptitude-dpkg)
info "You need manually add repo to /etc/apt/sources.list (TODO)" info "You need manually add repo to /etc/apt/sources.list (TODO)"
;; ;;
yum-rpm) yum-rpm)
assure_exists yum-utils assure_exists yum-utils
__epm_addrepo_rhel "$repo" || return __epm_addrepo_rhel "$repo" || return
sudocmd yum-config-manager --add-repo "$repo" sudocmd yum-config-manager --add-repo "$repo"
;; ;;
dnf-rpm) dnf-rpm)
__epm_addrepo_rhel "$repo" || return __epm_addrepo_rhel "$repo" || return
sudocmd dnf config-manager --add-repo "$repo" sudocmd dnf config-manager --add-repo "$repo"
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi.addmedia "$@" sudocmd urpmi.addmedia "$@"
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper ar "$repo" sudocmd zypper ar "$repo"
;; ;;
emerge) emerge)
sudocmd layman -a "$repo" sudocmd layman -a "$repo"
;; ;;
pacman) pacman)
info "You need manually add repo to /etc/pacman.conf" info "You need manually add repo to /etc/pacman.conf"
# Only for alone packages: # Only for alone packages:
#sudocmd repo-add $pkg_filenames #sudocmd repo-add $pkg_filenames
;; ;;
npackd) npackd)
sudocmd npackdcl add-repo --url="$repo" sudocmd npackdcl add-repo --url="$repo"
;; ;;
winget) winget)
sudocmd winget source add "$repo" sudocmd winget source add "$repo"
;; ;;
slackpkg) slackpkg)
info "You need manually add repo to /etc/slackpkg/mirrors" info "You need manually add repo to /etc/slackpkg/mirrors"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -23,12 +23,12 @@ epm_audit() ...@@ -23,12 +23,12 @@ epm_audit()
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here" [ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in case $PMTYPE in
pkgng) pkgng)
sudocmd pkg audit -F sudocmd pkg audit -F
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
__epm_orphan_altrpm() __epm_orphan_altrpm()
{ {
docmd apt-cache list-extras docmd apt-cache list-extras
} }
epm_autoorphans() epm_autoorphans()
...@@ -29,113 +29,113 @@ epm_autoorphans() ...@@ -29,113 +29,113 @@ epm_autoorphans()
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# ALT Linux only # ALT Linux only
assure_exists /usr/share/apt/scripts/list-extras.lua apt-scripts assure_exists /usr/share/apt/scripts/list-extras.lua apt-scripts
if [ -z "$dryrun" ] ; then if [ -z "$dryrun" ] ; then
echo "We will try remove all installed packages which are missed in repositories" echo "We will try remove all installed packages which are missed in repositories"
warning "Use with caution!" warning "Use with caution!"
fi fi
epm Upgrade || fatal epm Upgrade || fatal
local PKGLIST=$(__epm_orphan_altrpm \ local PKGLIST=$(__epm_orphan_altrpm \
| sed -e "s/\.32bit//g" \ | sed -e "s/\.32bit//g" \
| grep -v -- "^eepm$" \ | grep -v -- "^eepm$" \
| grep -v -- "^distro_info$" \ | grep -v -- "^distro_info$" \
| grep -v -- "^kernel") | grep -v -- "^kernel")
local play_installed="$(epm play --list-installed-packages)" local play_installed="$(epm play --list-installed-packages)"
if [ -n "$play_installed" ] ; then if [ -n "$play_installed" ] ; then
echo "Skip follow packages installed via epm play: $play_installed" echo "Skip follow packages installed via epm play: $play_installed"
fi fi
PKGLIST="$(estrlist exclude "$play_installed" "$PKGLIST")" PKGLIST="$(estrlist exclude "$play_installed" "$PKGLIST")"
if [ -z "$dryrun" ] && [ -n "$PKGLIST" ] ; then if [ -z "$dryrun" ] && [ -n "$PKGLIST" ] ; then
showcmd epm remove $dryrun $force $PKGLIST showcmd epm remove $dryrun $force $PKGLIST
confirm_info "We will remove packages above." confirm_info "We will remove packages above."
fi fi
# if [ -n "$dryrun" ] ; then # if [ -n "$dryrun" ] ; then
# echo "$PKGLIST" # echo "$PKGLIST"
# else # else
docmd epm remove $dryrun $force $(subst_option non_interactive --auto) $PKGLIST docmd epm remove $dryrun $force $(subst_option non_interactive --auto) $PKGLIST
# fi # fi
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
assure_exists deborphan assure_exists deborphan
showcmd deborphan showcmd deborphan
a='' deborphan | docmd epm remove $dryrun a='' deborphan | docmd epm remove $dryrun
;; ;;
#aura) #aura)
# sudocmd aura -Oj # sudocmd aura -Oj
# ;; # ;;
yum-rpm) yum-rpm)
docmd epm upgrade docmd epm upgrade
assure_exists package-cleanup yum-utils assure_exists package-cleanup yum-utils
showcmd package-cleanup --orphans showcmd package-cleanup --orphans
local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-") local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-")
docmd epm remove $dryrun $PKGLIST docmd epm remove $dryrun $PKGLIST
;; ;;
dnf-rpm) dnf-rpm)
# TODO: dnf list extras # TODO: dnf list extras
docmd epm upgrade docmd epm upgrade
assure_exists package-cleanup dnf-utils assure_exists package-cleanup dnf-utils
showcmd package-cleanup --orphans showcmd package-cleanup --orphans
local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-") local PKGLIST=$(package-cleanup -q --orphans | grep -v "^eepm-")
docmd epm remove $dryrun $PKGLIST docmd epm remove $dryrun $PKGLIST
;; ;;
urpm-rpm) urpm-rpm)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet" fatal "--dry-run is not supported yet"
else else
showcmd urpme --report-orphans showcmd urpme --report-orphans
sudocmd urpme --auto-orphans sudocmd urpme --auto-orphans
fi fi
;; ;;
#emerge) #emerge)
# sudocmd emerge --depclean # sudocmd emerge --depclean
# assure_exists revdep-rebuild # assure_exists revdep-rebuild
# sudocmd revdep-rebuild # sudocmd revdep-rebuild
# ;; # ;;
pacman) pacman)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
info "Autoorphans packages list:" info "Autoorphans packages list:"
sudocmd pacman -Qdtq sudocmd pacman -Qdtq
else else
sudocmd pacman -Qdtq | sudocmd pacman -Rs - sudocmd pacman -Qdtq | sudocmd pacman -Rs -
fi fi
;; ;;
slackpkg) slackpkg)
# clean-system removes non official packages # clean-system removes non official packages
sudocmd slackpkg clean-system sudocmd slackpkg clean-system
;; ;;
eopkg) eopkg)
sudocmd eopkg remove-orphans sudocmd eopkg remove-orphans
;; ;;
#guix) #guix)
# sudocmd guix gc # sudocmd guix gc
# ;; # ;;
#pkgng) #pkgng)
# sudocmd pkg autoremove # sudocmd pkg autoremove
# ;; # ;;
zypper-rpm) zypper-rpm)
# https://www.linux.org.ru/forum/desktop/11931830 # https://www.linux.org.ru/forum/desktop/11931830
assure_exists zypper zypper 1.9.2 assure_exists zypper zypper 1.9.2
# For zypper < 1.9.2: zypper se -si | grep 'System Packages' # For zypper < 1.9.2: zypper se -si | grep 'System Packages'
sudocmd zypper packages --orphaned sudocmd zypper packages --orphaned
# FIXME: x86_64/i586 are duplicated # FIXME: x86_64/i586 are duplicated
local PKGLIST=$(zypper packages --orphaned | tail -n +5 | cut -d \| -f 3 | sort -u) local PKGLIST=$(zypper packages --orphaned | tail -n +5 | cut -d \| -f 3 | sort -u)
docmd epm remove $dryrun --clean-deps $PKGLIST docmd epm remove $dryrun --clean-deps $PKGLIST
;; ;;
xbps) xbps)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet" fatal "--dry-run is not supported yet"
else else
sudocmd xbps-remove -o sudocmd xbps-remove -o
fi fi
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -21,126 +21,126 @@ load_helper epm-check_updated_repo ...@@ -21,126 +21,126 @@ load_helper epm-check_updated_repo
__epm_print_excluded() __epm_print_excluded()
{ {
local pkgs="$1" local pkgs="$1"
local fullpkgs="$2" local fullpkgs="$2"
local excluded local excluded
excluded="$(estrlist exclude "$pkgs" "$fullpkgs")" excluded="$(estrlist exclude "$pkgs" "$fullpkgs")"
if [ -n "$excluded" ] ; then if [ -n "$excluded" ] ; then
echo "Skipped manually installed:" echo "Skipped manually installed:"
estrlist union $excluded estrlist union $excluded
fi fi
} }
__epm_autoremove_altrpm_pp() __epm_autoremove_altrpm_pp()
{ {
local pkgs fullpkgs local pkgs fullpkgs
info "Removing unused python/perl modules..." info "Removing unused python/perl modules..."
local libexclude="$1" local libexclude="$1"
local flag= local flag=
showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\"" showcmd "apt-cache list-nodeps | grep -E -- \"$libexclude\""
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" ) fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libexclude" )
pkgs=$(skip_manually_installed $fullpkgs) pkgs=$(skip_manually_installed $fullpkgs)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
info "Packages for autoremoving:" info "Packages for autoremoving:"
echo "$pkgs" echo "$pkgs"
__epm_print_excluded "$pkgs" "$fullpkgs" __epm_print_excluded "$pkgs" "$fullpkgs"
return 0 return 0
fi fi
if [ -n "$pkgs" ] ; then if [ -n "$pkgs" ] ; then
info "The command we will run:" info "The command we will run:"
showcmd rpm -v -e $pkgs showcmd rpm -v -e $pkgs
__epm_print_excluded "$pkgs" "$fullpkgs" __epm_print_excluded "$pkgs" "$fullpkgs"
confirm_info "We will remove unused (without dependencies) packages above." confirm_info "We will remove unused (without dependencies) packages above."
sudocmd rpm -v -e $pkgs && flag=1 sudocmd rpm -v -e $pkgs && flag=1
fi fi
if [ -n "$flag" ] ; then if [ -n "$flag" ] ; then
info "" info ""
info "call again for next cycle until all modules will be removed" info "call again for next cycle until all modules will be removed"
__epm_autoremove_altrpm_pp "$libexclude" __epm_autoremove_altrpm_pp "$libexclude"
fi fi
return 0 return 0
} }
__epm_autoremove_altrpm_package_group() __epm_autoremove_altrpm_package_group()
{ {
if epmqp "$*" ; then if epmqp "$*" ; then
confirm_info "We will remove unused (without dependencies) packages above." confirm_info "We will remove unused (without dependencies) packages above."
docmd epm remove $(epmqp --short "$*") docmd epm remove $(epmqp --short "$*")
fi fi
} }
__epm_autoremove_altrpm_lib() __epm_autoremove_altrpm_lib()
{ {
local pkgs fullpkgs local pkgs fullpkgs
local flag='' local flag=''
local opt="$1" local opt="$1"
local libgrep='' local libgrep=''
info info
case "$opt" in case "$opt" in
libs) libs)
info "Removing all non -devel/-debuginfo libs packages not need by anything..." info "Removing all non -devel/-debuginfo libs packages not need by anything..."
local develrule='-(devel|devel-static)$' local develrule='-(devel|devel-static)$'
libgrep='^(lib|bzlib|zlib)' libgrep='^(lib|bzlib|zlib)'
;; ;;
i586-libs) i586-libs)
info "Removing all non -devel/-debuginfo i586-libs packages not need by anything..." info "Removing all non -devel/-debuginfo i586-libs packages not need by anything..."
local develrule='-(devel|devel-static)$' local develrule='-(devel|devel-static)$'
libgrep='^(i586-lib|i586-bzlib|i586-zlib)' libgrep='^(i586-lib|i586-bzlib|i586-zlib)'
;; ;;
devel) devel)
info "Removing all non -debuginfo libs packages (-devel too) not need by anything..." info "Removing all non -debuginfo libs packages (-devel too) not need by anything..."
local develrule='-(NONONO)$' local develrule='-(NONONO)$'
libgrep='^(lib|bzlib|zlib)' libgrep='^(lib|bzlib|zlib)'
;; ;;
*) *)
fatal "Internal error: unsupported opt $opt" fatal "Internal error: unsupported opt $opt"
esac esac
# https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps # https://www.altlinux.org/APT_в_ALT_Linux/Советы_по_использованию#apt-cache_list-nodeps
showcmd "apt-cache list-nodeps | grep -E -- \"$libgrep\"" showcmd "apt-cache list-nodeps | grep -E -- \"$libgrep\""
fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libgrep" \ fullpkgs=$(apt-cache list-nodeps | grep -E -- "$libgrep" \
| sed -e "s/[-\.]32bit$//g" \ | sed -e "s/[-\.]32bit$//g" \
| grep -E -v -- "$develrule" \ | grep -E -v -- "$develrule" \
| grep -E -v -- "-(debuginfo)$" \ | grep -E -v -- "-(debuginfo)$" \
| grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \ | grep -E -v -- "-(util|utils|tool|tools|plugin|daemon|help)$" \
| grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm|distro_info)" ) | grep -E -v -- "^(libsystemd|libreoffice|libnss|libvirt-client|libvirt-daemon|libsasl2-plugin|eepm|distro_info)" )
pkgs=$(skip_manually_installed $fullpkgs) pkgs=$(skip_manually_installed $fullpkgs)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
info "Packages for autoremoving:" info "Packages for autoremoving:"
echo "$pkgs" echo "$pkgs"
__epm_print_excluded "$pkgs" "$fullpkgs" __epm_print_excluded "$pkgs" "$fullpkgs"
return 0 return 0
fi fi
if [ -n "$pkgs" ] ; then if [ -n "$pkgs" ] ; then
info "The command we will run:" info "The command we will run:"
showcmd rpm -v -e $pkgs showcmd rpm -v -e $pkgs
__epm_print_excluded "$pkgs" "$fullpkgs" __epm_print_excluded "$pkgs" "$fullpkgs"
confirm_info "We will remove unused (without dependencies) packages above." confirm_info "We will remove unused (without dependencies) packages above."
sudocmd rpm -v -e $pkgs && flag=1 sudocmd rpm -v -e $pkgs && flag=1
fi fi
if [ -n "$flag" ] ; then if [ -n "$flag" ] ; then
info "" info ""
info "call again for next cycle until all libs will be removed" info "call again for next cycle until all libs will be removed"
__epm_autoremove_altrpm_lib $opt __epm_autoremove_altrpm_lib $opt
fi fi
return 0 return 0
} }
...@@ -148,67 +148,67 @@ epm_autoremove_default_groups="python2 python3 perl gem ruby libs" ...@@ -148,67 +148,67 @@ epm_autoremove_default_groups="python2 python3 perl gem ruby libs"
__epm_autoremove_altrpm() __epm_autoremove_altrpm()
{ {
local i local i
load_helper epm-packages load_helper epm-packages
assure_exists /usr/share/apt/scripts/list-nodeps.lua apt-scripts assure_exists /usr/share/apt/scripts/list-nodeps.lua apt-scripts
if [ -z "$pkg_names" ] ; then if [ -z "$pkg_names" ] ; then
pkg_names="$epm_autoremove_default_groups" pkg_names="$epm_autoremove_default_groups"
elif [ "$pkg_names" = "python" ] ; then elif [ "$pkg_names" = "python" ] ; then
pkg_names="python2 python3" pkg_names="python2 python3"
fi fi
for i in $pkg_names ; do for i in $pkg_names ; do
case $i in case $i in
libs) libs)
__epm_autoremove_altrpm_lib libs __epm_autoremove_altrpm_lib libs
;; ;;
i586-libs) i586-libs)
__epm_autoremove_altrpm_lib i586-libs __epm_autoremove_altrpm_lib i586-libs
;; ;;
debuginfo) debuginfo)
__epm_autoremove_altrpm_package_group '-debuginfo-' __epm_autoremove_altrpm_package_group '-debuginfo-'
;; ;;
devel) devel)
__epm_autoremove_altrpm_package_group '^(rpm-build-|gcc-|glibc-devel-)' __epm_autoremove_altrpm_package_group '^(rpm-build-|gcc-|glibc-devel-)'
;; ;;
python2) python2)
__epm_autoremove_altrpm_pp '^(python-module-|python-modules-)' __epm_autoremove_altrpm_pp '^(python-module-|python-modules-)'
;; ;;
python3) python3)
__epm_autoremove_altrpm_pp '^(python3-module-|python3-modules-)' __epm_autoremove_altrpm_pp '^(python3-module-|python3-modules-)'
;; ;;
php) php)
__epm_autoremove_altrpm_pp '^(php7-|php5-|php8-)' __epm_autoremove_altrpm_pp '^(php7-|php5-|php8-)'
;; ;;
gem) gem)
__epm_autoremove_altrpm_pp '^(gem-)' __epm_autoremove_altrpm_pp '^(gem-)'
;; ;;
ruby) ruby)
__epm_autoremove_altrpm_pp '^(ruby-)' __epm_autoremove_altrpm_pp '^(ruby-)'
;; ;;
perl) perl)
__epm_autoremove_altrpm_pp '^(perl-)' __epm_autoremove_altrpm_pp '^(perl-)'
;; ;;
libs-devel) libs-devel)
__epm_autoremove_altrpm_lib devel __epm_autoremove_altrpm_lib devel
;; ;;
*) *)
fatal "autoremove: unsupported '$i'. Use epm autoremove --help to list supported ones" fatal "autoremove: unsupported '$i'. Use epm autoremove --help to list supported ones"
;; ;;
esac esac
done done
return 0 return 0
} }
epm_autoremove_print_help() epm_autoremove_print_help()
{ {
echo "epm autoremove removes unneeded packages from the system" echo "epm autoremove removes unneeded packages from the system"
echo "run 'epm autoremove' to use apt-get autoremove" echo "run 'epm autoremove' to use apt-get autoremove"
echo "or run 'epm autoremove --direct [group1] [group2] ...' to use epm implementation" echo "or run 'epm autoremove --direct [group1] [group2] ...' to use epm implementation"
echo "Default groups: $epm_autoremove_default_groups" echo "Default groups: $epm_autoremove_default_groups"
cat <<EOF cat <<EOF
Supported package groups: Supported package groups:
libs - unused libraries libs - unused libraries
libs-devel - unused -devel packages libs-devel - unused -devel packages
...@@ -233,125 +233,125 @@ epm_autoremove() ...@@ -233,125 +233,125 @@ epm_autoremove()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] ; then if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "help" ] ; then
epm_autoremove_print_help epm_autoremove_print_help
return 0 return 0
fi fi
if [ -z "$direct" ] ; then if [ -z "$direct" ] ; then
[ -n "$1" ] && fatal "Run autoremove without args or with --direct. Check epm autoremove --help to available commands." [ -n "$1" ] && fatal "Run autoremove without args or with --direct. Check epm autoremove --help to available commands."
sudocmd apt-get $(subst_option non_interactive -y) autoremove $dryrun sudocmd apt-get $(subst_option non_interactive -y) autoremove $dryrun
local RET=$? local RET=$?
if [ "$RET" != 0 ] ; then if [ "$RET" != 0 ] ; then
echo echo
info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)" info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)"
return return
fi fi
else else
__epm_autoremove_altrpm "$@" __epm_autoremove_altrpm "$@"
fi fi
#[ -n "$dryrun" ] && return #[ -n "$dryrun" ] && return
# remove old kernels only by a default way # remove old kernels only by a default way
[ -n "$1" ] && return [ -n "$1" ] && return
docmd epm remove-old-kernels $dryrun docmd epm remove-old-kernels $dryrun
if [ -z "$direct" ] ; then if [ -z "$direct" ] ; then
echo echo
info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)" info "Also you can run 'epm autoremove --direct' to use epm implementation of autoremove (see --help)"
fi fi
return return
;; ;;
*) *)
;; ;;
esac esac
[ -z "$pkg_filenames" ] || fatal "No arguments are allowed here" [ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
case $PMTYPE in case $PMTYPE in
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
sudocmd apt-get autoremove $(subst_option non_interactive -y) $dryrun sudocmd apt-get autoremove $(subst_option non_interactive -y) $dryrun
;; ;;
aura) aura)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet" fatal "--dry-run is not supported yet"
fi fi
sudocmd aura -Oj sudocmd aura -Oj
;; ;;
packagekit) packagekit)
docmd pkcon repair --autoremove docmd pkcon repair --autoremove
;; ;;
yum-rpm) yum-rpm)
# cleanup orphanes? # cleanup orphanes?
while true ; do while true ; do
# shellcheck disable=SC2046 # 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-")
[ -n "$PKGLIST" ] || break [ -n "$PKGLIST" ] || break
docmd epm remove $PKGLIST docmd epm remove $PKGLIST
done done
;; ;;
dnf-rpm) dnf-rpm)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet" fatal "--dry-run is not supported yet"
fi fi
sudocmd dnf autoremove sudocmd dnf autoremove
;; ;;
# see autoorhans # see autoorhans
#urpm-rpm) #urpm-rpm)
# sudocmd urpme --auto-orphans # sudocmd urpme --auto-orphans
# ;; # ;;
emerge) emerge)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet" fatal "--dry-run is not supported yet"
fi fi
sudocmd emerge --depclean sudocmd emerge --depclean
assure_exists revdep-rebuild assure_exists revdep-rebuild
sudocmd revdep-rebuild sudocmd revdep-rebuild
;; ;;
# see autoorhans # see autoorhans
#pacman) #pacman)
# sudocmd pacman -Qdtq | sudocmd pacman -Rs - # sudocmd pacman -Qdtq | sudocmd pacman -Rs -
# ;; # ;;
slackpkg) slackpkg)
# clean-system removes non official packages # clean-system removes non official packages
#sudocmd slackpkg clean-system #sudocmd slackpkg clean-system
;; ;;
guix) guix)
sudocmd guix gc sudocmd guix gc
;; ;;
pkgng) pkgng)
sudocmd pkg autoremove sudocmd pkg autoremove
;; ;;
zypper-rpm) zypper-rpm)
# https://www.linux.org.ru/forum/desktop/11931830 # https://www.linux.org.ru/forum/desktop/11931830
assure_exists zypper zypper 1.9.3 assure_exists zypper zypper 1.9.3
sudocmd zypper packages --unneeded sudocmd zypper packages --unneeded
# FIXME: x86_64/i586 are duplicated # FIXME: x86_64/i586 are duplicated
local PKGLIST=$(zypper packages --unneeded | tail -n +5 | cut -d \| -f 3 | sort -u) local PKGLIST=$(zypper packages --unneeded | tail -n +5 | cut -d \| -f 3 | sort -u)
showcmd epm remove --clean-deps $PKGLIST showcmd epm remove --clean-deps $PKGLIST
;; ;;
xbps) xbps)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
fatal "--dry-run is not supported yet" fatal "--dry-run is not supported yet"
fi fi
sudocmd xbps-remove -O sudocmd xbps-remove -O
;; ;;
opkg) opkg)
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
sudocmd opkg --noaction --autoremove sudocmd opkg --noaction --autoremove
else else
sudocmd opkg --autoremove sudocmd opkg --autoremove
fi fi
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -21,101 +21,101 @@ load_helper epm-query ...@@ -21,101 +21,101 @@ load_helper epm-query
__epm_changelog_apt() __epm_changelog_apt()
{ {
local i local i
for i in $@ ; do for i in $@ ; do
docmd apt-cache show $i | grep -A 1000 "^Changelog:" docmd apt-cache show $i | grep -A 1000 "^Changelog:"
done done
} }
__epm_changelog_files() __epm_changelog_files()
{ {
[ -z "$*" ] && return [ -z "$*" ] && return
# TODO: detect every file # TODO: detect every file
case $(get_package_type $1) in case $(get_package_type $1) in
rpm) rpm)
assure_exists rpm assure_exists rpm
docmd_foreach "rpm -q -p --changelog" $@ docmd_foreach "rpm -q -p --changelog" $@
;; ;;
# deb) # deb)
# #
# ;; # ;;
*) *)
fatal "Have no suitable command for $1" fatal "Have no suitable command for $1"
;; ;;
esac esac
} }
__epm_changelog_local_names() __epm_changelog_local_names()
{ {
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in case $PMTYPE in
apt-rpm|yum-rpm|dnf-rpm|urpm-rpm|zypper-rpm) apt-rpm|yum-rpm|dnf-rpm|urpm-rpm|zypper-rpm)
docmd_foreach "rpm -q --changelog" $@ docmd_foreach "rpm -q --changelog" $@
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
docmd zcat /usr/share/doc/$1/changelog.Debian.gz docmd zcat /usr/share/doc/$1/changelog.Debian.gz
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
docmd equery changes -f $1 docmd equery changes -f $1
;; ;;
pacman) pacman)
docmd pacman -Qc $1 docmd pacman -Qc $1
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
__epm_changelog_unlocal_names() __epm_changelog_unlocal_names()
{ {
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_changelog_apt "$1" __epm_changelog_apt "$1"
;; ;;
#apt-dpkg) #apt-dpkg)
# # FIXME: only first pkg # # FIXME: only first pkg
# docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less # docmd zcat /usr/share/doc/$1/changelog.Debian.gz | less
# ;; # ;;
#yum-rpm) #yum-rpm)
# sudocmd yum clean all # sudocmd yum clean all
# ;; # ;;
urpm-rpm) urpm-rpm)
docmd urpmq --changelog "$1" docmd urpmq --changelog "$1"
;; ;;
#zypper-rpm) #zypper-rpm)
# sudocmd zypper clean # sudocmd zypper clean
# ;; # ;;
emerge) emerge)
assure_exists equery assure_exists equery
docmd equery changes -f "$1" docmd equery changes -f "$1"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE. Try install the package firstly." fatal "Have no suitable command for $PMTYPE. Try install the package firstly."
;; ;;
esac esac
} }
epm_changelog() epm_changelog()
{ {
[ -n "$pkg_filenames" ] || fatal "Changelog: Missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Changelog: Missing package(s) name"
__epm_changelog_files $pkg_files __epm_changelog_files $pkg_files
# TODO: add less or bat # TODO: add less or bat
local pkg local pkg
for pkg in $pkg_names ; do for pkg in $pkg_names ; do
if is_installed $pkg ; then if is_installed $pkg ; then
__epm_changelog_local_names $pkg __epm_changelog_local_names $pkg
else else
__epm_changelog_unlocal_names $pkg __epm_changelog_unlocal_names $pkg
fi fi
done done
} }
...@@ -25,60 +25,60 @@ update_repo_if_needed ...@@ -25,60 +25,60 @@ update_repo_if_needed
local APTOPTIONS="$(subst_option non_interactive -y)" local APTOPTIONS="$(subst_option non_interactive -y)"
local DNFOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose --verbose) " local DNFOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose --verbose) "
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
#sudocmd apt-get check || exit #sudocmd apt-get check || exit
#sudocmd apt-get update || exit #sudocmd apt-get update || exit
sudocmd apt-get -f $APTOPTIONS install || return sudocmd apt-get -f $APTOPTIONS install || return
info "You can use epm dedup also" info "You can use epm dedup also"
;; ;;
apt-dpkg) apt-dpkg)
#sudocmd apt-get check || exit #sudocmd apt-get check || exit
#sudocmd apt-get update || exit #sudocmd apt-get update || exit
sudocmd apt-get -f $APTOPTIONS install || return sudocmd apt-get -f $APTOPTIONS install || return
;; ;;
packagekit) packagekit)
docmd pkcon repair docmd pkcon repair
;; ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude -f $APTOPTIONS install || return sudocmd aptitude -f $APTOPTIONS install || return
#sudocmd apt-get autoremove #sudocmd apt-get autoremove
;; ;;
yum-rpm) yum-rpm)
docmd yum check $DNFOPTIONS docmd yum check $DNFOPTIONS
docmd package-cleanup --problems docmd package-cleanup --problems
#docmd package-cleanup --dupes #docmd package-cleanup --dupes
sudocmd package-cleanup --cleandupes sudocmd package-cleanup --cleandupes
docmd rpm -Va --nofiles --nodigest docmd rpm -Va --nofiles --nodigest
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf check $DNFOPTIONS sudocmd dnf check $DNFOPTIONS
;; ;;
emerge) emerge)
sudocmd revdep-rebuild sudocmd revdep-rebuild
;; ;;
#urpm-rpm) #urpm-rpm)
# sudocmd urpme --auto-orphans # sudocmd urpme --auto-orphans
# ;; # ;;
zypper-rpm) zypper-rpm)
sudocmd zypper $(subst_option non_interactive --non-interactive) verify sudocmd zypper $(subst_option non_interactive --non-interactive) verify
;; ;;
conary) conary)
sudocmd conary verify sudocmd conary verify
;; ;;
pkgng) pkgng)
sudocmd pkg check -d -a sudocmd pkg check -d -a
;; ;;
homebrew) homebrew)
docmd brew doctor docmd brew doctor
;; ;;
xbps) xbps)
sudocmd xbps-pkgdb -a sudocmd xbps-pkgdb -a
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -74,21 +74,21 @@ update_repo_if_needed() ...@@ -74,21 +74,21 @@ update_repo_if_needed()
# save manually installed packages # save manually installed packages
save_installed_packages() save_installed_packages()
{ {
[ -d /var/lib/rpm ] || return 0 [ -d /var/lib/rpm ] || return 0
estrlist list "$@" | sudorun tee /var/lib/rpm/EPM-installed >/dev/null estrlist list "$@" | sudorun tee /var/lib/rpm/EPM-installed >/dev/null
} }
check_manually_installed() check_manually_installed()
{ {
[ -r /var/lib/rpm/EPM-installed ] || return 1 [ -r /var/lib/rpm/EPM-installed ] || return 1
grep -q -- "^$1\$" /var/lib/rpm/EPM-installed grep -q -- "^$1\$" /var/lib/rpm/EPM-installed
} }
skip_manually_installed() skip_manually_installed()
{ {
local i local i
for i in "$@" ; do for i in "$@" ; do
check_manually_installed "$i" && continue check_manually_installed "$i" && continue
echo "$i" echo "$i"
done done
} }
...@@ -25,82 +25,82 @@ __rpm_allows_nosignature() ...@@ -25,82 +25,82 @@ __rpm_allows_nosignature()
check_pkg_integrity() check_pkg_integrity()
{ {
local PKG="$1" local PKG="$1"
local RET local RET
local NOSIGNATURE local NOSIGNATURE
case $(get_package_type $PKG) in case $(get_package_type $PKG) in
rpm) rpm)
assure_exists rpm assure_exists rpm
__rpm_allows_nosignature && NOSIGNATURE="--nosignature" || NOSIGNATURE="--nogpg" __rpm_allows_nosignature && NOSIGNATURE="--nosignature" || NOSIGNATURE="--nogpg"
docmd rpm --checksig $NOSIGNATURE $PKG docmd rpm --checksig $NOSIGNATURE $PKG
;; ;;
deb) deb)
assure_exists dpkg assure_exists dpkg
# FIXME: debsums -ca package ? # FIXME: debsums -ca package ?
docmd dpkg --contents $PKG >/dev/null && echo "Package $PKG is correct." docmd dpkg --contents $PKG >/dev/null && echo "Package $PKG is correct."
;; ;;
exe) exe)
file $PKG | grep -q "executable for MS Windows" file $PKG | grep -q "executable for MS Windows"
;; ;;
msi) msi)
# TODO: add to patool via cabextract # TODO: add to patool via cabextract
assure_exists cabextract assure_exists cabextract
#file $PKG | grep -q "Microsoft Office Document" #file $PKG | grep -q "Microsoft Office Document"
docmd cabextract -t $PKG docmd cabextract -t $PKG
;; ;;
ebuild) ebuild)
true true
;; ;;
*) *)
docmd erc test "$PKG" && return docmd erc test "$PKG" && return
;; ;;
esac esac
} }
__epm_check_all_pkgs() __epm_check_all_pkgs()
{ {
case $PMTYPE in case $PMTYPE in
eopkg) eopkg)
sudocmd eopkg check sudocmd eopkg check
return return
;; ;;
esac esac
local j cl local j cl
#local play_installed="$(epm play --list-installed-packages)" #local play_installed="$(epm play --list-installed-packages)"
epm qa --short | xargs -n20 | while read cl ; do epm qa --short | xargs -n20 | while read cl ; do
#cl="$(estrlist exclude "$play_installed" "$i")" #cl="$(estrlist exclude "$play_installed" "$i")"
__epm_check_installed_pkg $cl && continue __epm_check_installed_pkg $cl && continue
# check each package # check each package
for j in $cl ; do for j in $cl ; do
__epm_check_installed_pkg $j && continue __epm_check_installed_pkg $j && continue
# TODO: check play installed too # TODO: check play installed too
epm --auto reinstall $j </dev/null || exit epm --auto reinstall $j </dev/null || exit
done done
done done
} }
__epm_check_installed_pkg() __epm_check_installed_pkg()
{ {
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
docmd rpm -V $@ docmd rpm -V $@
;; ;;
*-dpkg) *-dpkg)
assure_exists debsums assure_exists debsums
docmd debsums $@ docmd debsums $@
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
docmd equery check $@ docmd equery check $@
;; ;;
eopkg) eopkg)
sudocmd eopkg check $@ sudocmd eopkg check $@
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -108,37 +108,37 @@ esac ...@@ -108,37 +108,37 @@ esac
epm_checkpkg() epm_checkpkg()
{ {
if [ "$1" = "--all" ] ; then if [ "$1" = "--all" ] ; then
__epm_check_all_pkgs __epm_check_all_pkgs
return return
fi fi
if [ -n "$pkg_names" ] ; then if [ -n "$pkg_names" ] ; then
# TODO: если есть / или расширение, это отсутствующий файл # TODO: если есть / или расширение, это отсутствующий файл
info "Suggest $pkg_names are name(s) of installed package(s)" info "Suggest $pkg_names are name(s) of installed package(s)"
__epm_check_installed_pkg $pkg_names __epm_check_installed_pkg $pkg_names
return return
fi fi
# if possible, it will put pkg_urls into pkg_files or pkg_names # if possible, it will put pkg_urls into pkg_files or pkg_names
if [ -n "$pkg_urls" ] ; then if [ -n "$pkg_urls" ] ; then
load_helper epm-download load_helper epm-download
__handle_pkg_urls_to_checking __handle_pkg_urls_to_checking
fi fi
[ -n "$pkg_files" ] || fatal "Checkpkg: filename(s) is missed" [ -n "$pkg_files" ] || fatal "Checkpkg: filename(s) is missed"
local RETVAL=0 local RETVAL=0
local pkg local pkg
for pkg in $pkg_files ; do for pkg in $pkg_files ; do
check_pkg_integrity $pkg || RETVAL=1 check_pkg_integrity $pkg || RETVAL=1
done done
# TODO: reinvent # TODO: reinvent
[ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files [ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
[ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null [ -n "$to_remove_pkg_files" ] && rmdir -v $(dirname $to_remove_pkg_files | head -n1) 2>/dev/null
#fatal "Broken package $pkg" #fatal "Broken package $pkg"
return $RETVAL return $RETVAL
} }
...@@ -21,23 +21,23 @@ ...@@ -21,23 +21,23 @@
__alt_fix_triggers() __alt_fix_triggers()
{ {
local TDIR=$(mktemp -d) local TDIR=$(mktemp -d)
assure_exists time assure_exists time
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
echo "Count lines:" echo "Count lines:"
wc -l /var/lib/rpm/files-awaiting-filetriggers wc -l /var/lib/rpm/files-awaiting-filetriggers
} }
epm_checksystem_ALTLinux() epm_checksystem_ALTLinux()
{ {
fatal "Not yet implemented" fatal "Not yet implemented"
#__alt_fix_triggers #__alt_fix_triggers
} }
...@@ -47,27 +47,27 @@ epm_checksystem() ...@@ -47,27 +47,27 @@ epm_checksystem()
is_root && fatal "Do not use checksystem under root" is_root && fatal "Do not use checksystem under root"
case $PMTYPE in case $PMTYPE in
homebrew) homebrew)
sudocmd brew doctor sudocmd brew doctor
return return
;; ;;
esac esac
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
epm_checksystem_$DISTRNAME epm_checksystem_$DISTRNAME
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
# direct debug run # direct debug run
if [ "$1" = "--debug" ] ; then if [ "$1" = "--debug" ] ; then
shift shift
SUDO=sudo SUDO=sudo
DISTRNAME=ALTLinux DISTRNAME=ALTLinux
epm_checksystem epm_checksystem
fi fi
...@@ -19,19 +19,19 @@ ...@@ -19,19 +19,19 @@
__remove_alt_apt_cache_file() __remove_alt_apt_cache_file()
{ {
sudocmd rm -vf /var/cache/apt/*.bin sudocmd rm -vf /var/cache/apt/*.bin
sudocmd rm -vf /var/cache/apt/partial/* sudocmd rm -vf /var/cache/apt/partial/*
sudocmd rm -vf /var/lib/apt/lists/*pkglist* sudocmd rm -vf /var/lib/apt/lists/*pkglist*
sudocmd rm -vf /var/lib/apt/lists/*release* sudocmd rm -vf /var/lib/apt/lists/*release*
} }
__remove_deb_apt_cache_file() __remove_deb_apt_cache_file()
{ {
sudocmd rm -vf /var/cache/apt/*.bin sudocmd rm -vf /var/cache/apt/*.bin
sudocmd rm -vf /var/cache/apt/archives/partial/* sudocmd rm -vf /var/cache/apt/archives/partial/*
sudocmd rm -vf /var/lib/apt/lists/*Packages* sudocmd rm -vf /var/lib/apt/lists/*Packages*
sudocmd rm -vf /var/lib/apt/lists/*Release* sudocmd rm -vf /var/lib/apt/lists/*Release*
sudocmd rm -vf /var/lib/apt/lists/*Translation* sudocmd rm -vf /var/lib/apt/lists/*Translation*
} }
epm_clean() epm_clean()
...@@ -41,58 +41,58 @@ epm_clean() ...@@ -41,58 +41,58 @@ epm_clean()
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
sudocmd apt-get clean sudocmd apt-get clean
[ -n "$force" ] && __remove_alt_apt_cache_file [ -n "$force" ] && __remove_alt_apt_cache_file
;; ;;
apt-dpkg) apt-dpkg)
sudocmd apt-get clean sudocmd apt-get clean
[ -n "$force" ] && __remove_deb_apt_cache_file [ -n "$force" ] && __remove_deb_apt_cache_file
;; ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude clean sudocmd aptitude clean
[ -n "$force" ] && __remove_deb_apt_cache_file [ -n "$force" ] && __remove_deb_apt_cache_file
;; ;;
yum-rpm) yum-rpm)
sudocmd yum clean all sudocmd yum clean all
#sudocmd yum makecache #sudocmd yum makecache
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf clean all sudocmd dnf clean all
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi --clean sudocmd urpmi --clean
;; ;;
homebrew) homebrew)
sudocmd brew cleanup -s sudocmd brew cleanup -s
;; ;;
pacman) pacman)
sudocmd pacman -Sc --noconfirm sudocmd pacman -Sc --noconfirm
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper clean sudocmd zypper clean
;; ;;
nix) nix)
sudocmd nix-collect-garbage sudocmd nix-collect-garbage
;; ;;
slackpkg) slackpkg)
;; ;;
eopkg) eopkg)
sudocmd eopkg delete-cache sudocmd eopkg delete-cache
;; ;;
pkgng) pkgng)
sudocmd pkg clean -a sudocmd pkg clean -a
;; ;;
appget|winget) appget|winget)
sudocmd $PMTYPE clean sudocmd $PMTYPE clean
;; ;;
xbps) xbps)
sudocmd xbps-remove -O sudocmd xbps-remove -O
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
info "Note: Also you can try (with CAUTION) '# epm autoremove' and '# epm autoorphans' commands to remove obsoleted and unused packages." info "Note: Also you can try (with CAUTION) '# epm autoremove' and '# epm autoorphans' commands to remove obsoleted and unused packages."
} }
...@@ -21,75 +21,75 @@ load_helper epm-query ...@@ -21,75 +21,75 @@ load_helper epm-query
epm_conflicts_files() epm_conflicts_files()
{ {
[ -n "$pkg_files" ] || return [ -n "$pkg_files" ] || return
case $(get_package_type $pkg_files) in case $(get_package_type $pkg_files) in
rpm) rpm)
assure_exists rpm assure_exists rpm
docmd rpm -q --conflicts -p $pkg_files docmd rpm -q --conflicts -p $pkg_files
;; ;;
#deb) #deb)
# 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 $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
epm_conflicts_names() epm_conflicts_names()
{ {
local CMD local CMD
[ -n "$pkg_names" ] || return [ -n "$pkg_names" ] || return
# by package name # by package name
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so) # FIXME: too low level of requires name (libSOME.so)
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --conflicts" CMD="rpm -q --conflicts"
else else
EXTRA_SHOWDOCMD=' | grep "Conflicts:"' EXTRA_SHOWDOCMD=' | grep "Conflicts:"'
docmd apt-cache show $pkg_names | grep "Conflicts:" docmd apt-cache show $pkg_names | grep "Conflicts:"
return return
fi fi
;; ;;
urpm-rpm|zypper-rpm) urpm-rpm|zypper-rpm)
# FIXME: use hi level commands # FIXME: use hi level commands
CMD="rpm -q --conflicts" CMD="rpm -q --conflicts"
;; ;;
#yum-rpm) #yum-rpm)
# CMD="yum deplist" # CMD="yum deplist"
# ;; # ;;
#pacman) #pacman)
# CMD="pactree" # CMD="pactree"
# ;; # ;;
apt-dpkg) apt-dpkg)
# 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:"'
docmd apt-cache show $pkg_names | grep "Conflicts:" docmd apt-cache show $pkg_names | grep "Conflicts:"
return return
fi fi
;; ;;
# TODO: why-not show who conflicts with us # TODO: why-not show who conflicts with us
#aptitude-dpkg) #aptitude-dpkg)
# docmd aptitude why-not $pkg_names # docmd aptitude why-not $pkg_names
# ;; # ;;
#emerge) #emerge)
# assure_exists equery # assure_exists equery
# CMD="equery depgraph" # CMD="equery depgraph"
# ;; # ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
...@@ -99,7 +99,7 @@ docmd $CMD $pkg_names ...@@ -99,7 +99,7 @@ docmd $CMD $pkg_names
epm_conflicts() epm_conflicts()
{ {
[ -n "$pkg_filenames" ] || fatal "Conflicts: Missing package(s) name" [ -n "$pkg_filenames" ] || fatal "Conflicts: Missing package(s) name"
epm_conflicts_files epm_conflicts_files
epm_conflicts_names epm_conflicts_names
} }
...@@ -20,49 +20,49 @@ ...@@ -20,49 +20,49 @@
# remove duplicates # remove duplicates
try_fix_apt_rpm_dupls() try_fix_apt_rpm_dupls()
{ {
info "Check for duplicates (internal implementation) ..." info "Check for duplicates (internal implementation) ..."
local TESTPKG="ignoreflock" local TESTPKG="ignoreflock"
local has_testpkg="" local has_testpkg=""
if epm --quiet installed $TESTPKG ; then if epm --quiet installed $TESTPKG ; then
has_testpkg=1 has_testpkg=1
sudocmd epm remove --auto $TESTPKG || return sudocmd epm remove --auto $TESTPKG || return
fi fi
local PKGLIST local PKGLIST
PKGLIST=$(LANG=C sudorun apt-get install $TESTPKG 2>&1 | grep "W: There are multiple versions of" | \ PKGLIST=$(LANG=C sudorun apt-get install $TESTPKG 2>&1 | grep "W: There are multiple versions of" | \
sed -e 's|W: There are multiple versions of "\(.*\)" in your system.|\1|') sed -e 's|W: There are multiple versions of "\(.*\)" in your system.|\1|')
local TODEL local TODEL
for i in $PKGLIST ; do for i in $PKGLIST ; do
local pkg=${i/.32bit/} local pkg=${i/.32bit/}
local todel="$(rpm -q $pkg | head -n1)" local todel="$(rpm -q $pkg | head -n1)"
local todel2="$(rpm -q $pkg | head -n2 | tail -n1)" local todel2="$(rpm -q $pkg | head -n2 | tail -n1)"
if [ "$todel" = "$todel2" ] ; then if [ "$todel" = "$todel2" ] ; then
echo "Fix the same name duplicates for $pkg..." echo "Fix the same name duplicates for $pkg..."
sudocmd rpm -e "$todel" --allmatches --nodeps --justdb && epm install $pkg && continue sudocmd rpm -e "$todel" --allmatches --nodeps --justdb && epm install $pkg && continue
fi fi
# first use older package # first use older package
[ "$(rpmevrcmp "$todel" "$todel2")" = "1" ] && todel="$todel2" [ "$(rpmevrcmp "$todel" "$todel2")" = "1" ] && todel="$todel2"
sudocmd rpm -e "$todel" || TODEL="$TODEL $todel" sudocmd rpm -e "$todel" || TODEL="$TODEL $todel"
done done
[ -n "$TODEL" ] && sudocmd rpm -e $TODEL [ -n "$TODEL" ] && sudocmd rpm -e $TODEL
[ -n "$has_testpkg" ] && epm install $TESTPKG [ -n "$has_testpkg" ] && epm install $TESTPKG
} }
epm_dedup() epm_dedup()
{ {
case "$BASEDISTRNAME" in case "$BASEDISTRNAME" in
"alt") "alt")
assure_exists /usr/share/apt/scripts/dedup.lua apt-scripts assure_exists /usr/share/apt/scripts/dedup.lua apt-scripts
if [ -z "$direct" ] && [ -f /usr/share/apt/scripts/dedup.lua ] ; then if [ -z "$direct" ] && [ -f /usr/share/apt/scripts/dedup.lua ] ; then
info "Check for duplicates via apt-get dedup from apt-scripts (also you can use internal EPM dedup implementation with --direct option)" info "Check for duplicates via apt-get dedup from apt-scripts (also you can use internal EPM dedup implementation with --direct option)"
sudocmd apt-get dedup sudocmd apt-get dedup
else else
info "You can use dedup from apt-scripts package" info "You can use dedup from apt-scripts package"
try_fix_apt_rpm_dupls try_fix_apt_rpm_dupls
fi fi
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -21,8 +21,8 @@ load_helper epm-check_updated_repo ...@@ -21,8 +21,8 @@ load_helper epm-check_updated_repo
__epm_add_alt_apt_downgrade_preferences() __epm_add_alt_apt_downgrade_preferences()
{ {
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists" [ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
cat <<EOF | sudocmd tee /etc/apt/preferences cat <<EOF | sudocmd tee /etc/apt/preferences
# classic repo # classic repo
Package: * Package: *
Pin: release c=classic Pin: release c=classic
...@@ -48,9 +48,9 @@ EOF ...@@ -48,9 +48,9 @@ EOF
# See https://wiki.debian.org/ru/AptPreferences # See https://wiki.debian.org/ru/AptPreferences
__epm_add_deb_apt_downgrade_preferences() __epm_add_deb_apt_downgrade_preferences()
{ {
[ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists" [ -r /etc/apt/preferences ] && fatal "/etc/apt/preferences already exists"
info "Running with /etc/apt/preferences:" info "Running with /etc/apt/preferences:"
cat <<EOF | sudorun tee /etc/apt/preferences cat <<EOF | sudorun tee /etc/apt/preferences
Package: * Package: *
Pin: release a=stable Pin: release a=stable
Pin-Priority: 1001 Pin-Priority: 1001
...@@ -67,67 +67,67 @@ EOF ...@@ -67,67 +67,67 @@ EOF
__epm_remove_apt_downgrade_preferences() __epm_remove_apt_downgrade_preferences()
{ {
sudocmd rm -f /etc/apt/preferences sudocmd rm -f /etc/apt/preferences
} }
epm_downgrade() epm_downgrade()
{ {
local CMD local CMD
# it is useful for first time running # it is useful for first time running
update_repo_if_needed update_repo_if_needed
info "Running command for downgrade packages" info "Running command for downgrade packages"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# pass pkg_filenames too # pass pkg_filenames too
if [ -n "$pkg_names" ] ; then if [ -n "$pkg_names" ] ; then
__epm_add_alt_apt_downgrade_preferences || return __epm_add_alt_apt_downgrade_preferences || return
load_helper epm-install load_helper epm-install
(pkg_names=$(get_only_installed_packages $pkg_names) epm_install) (pkg_names=$(get_only_installed_packages $pkg_names) epm_install)
__epm_remove_apt_downgrade_preferences __epm_remove_apt_downgrade_preferences
elif [ -n "$pkg_files" ] ; then elif [ -n "$pkg_files" ] ; then
load_helper epm-install load_helper epm-install
(pkg_files=$pkg_files force="$force -F --oldpackage" epm_install) (pkg_files=$pkg_files force="$force -F --oldpackage" epm_install)
else else
__epm_add_alt_apt_downgrade_preferences || return __epm_add_alt_apt_downgrade_preferences || return
load_helper epm-upgrade load_helper epm-upgrade
epm_upgrade "$@" epm_upgrade "$@"
__epm_remove_apt_downgrade_preferences __epm_remove_apt_downgrade_preferences
fi fi
;; ;;
apt-dpkg) apt-dpkg)
local APTOPTIONS="$(subst_option non_interactive -y) $force_yes" local APTOPTIONS="$(subst_option non_interactive -y) $force_yes"
__epm_add_deb_apt_downgrade_preferences || return __epm_add_deb_apt_downgrade_preferences || return
if [ -n "$pkg_filenames" ] ; then if [ -n "$pkg_filenames" ] ; then
sudocmd apt-get $APTOPTIONS install $pkg_filenames sudocmd apt-get $APTOPTIONS install $pkg_filenames
else else
sudocmd apt-get $APTOPTIONS dist-upgrade sudocmd apt-get $APTOPTIONS dist-upgrade
fi fi
__epm_remove_apt_downgrade_preferences __epm_remove_apt_downgrade_preferences
;; ;;
yum-rpm) yum-rpm)
# can do update repobase automagically # can do update repobase automagically
if [ -n "$pkg_filenames" ] ; then if [ -n "$pkg_filenames" ] ; then
sudocmd yum downgrade $pkg_filenames sudocmd yum downgrade $pkg_filenames
else else
sudocmd yum distro-sync sudocmd yum distro-sync
fi fi
;; ;;
dnf-rpm) dnf-rpm)
if [ -n "$pkg_filenames" ] ; then if [ -n "$pkg_filenames" ] ; then
sudocmd dnf downgrade $pkg_filenames sudocmd dnf downgrade $pkg_filenames
else else
sudocmd dnf distro-sync sudocmd dnf distro-sync
fi fi
;; ;;
urpm-rpm) urpm-rpm)
assure_exists urpm-reposync urpm-tools assure_exists urpm-reposync urpm-tools
sudocmd urpm-reposync -v sudocmd urpm-reposync -v
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -21,267 +21,267 @@ alt_base_dist_url="http://ftp.basealt.ru/pub/distributions" ...@@ -21,267 +21,267 @@ alt_base_dist_url="http://ftp.basealt.ru/pub/distributions"
__use_url_install() __use_url_install()
{ {
# force download if wildcard is used # force download if wildcard is used
echo "$pkg_urls" | grep -q "[?*]" && return 1 echo "$pkg_urls" | grep -q "[?*]" && return 1
# install of remote files has a side affect # install of remote files has a side affect
# (more fresh package from a repo can be installed instead of the file) # (more fresh package from a repo can be installed instead of the file)
#case $DISTRNAME in #case $DISTRNAME in
# "ALTLinux") # "ALTLinux")
# # do not support https yet # # do not support https yet
# echo "$pkg_urls" | grep -q "https://" && return 1 # echo "$pkg_urls" | grep -q "https://" && return 1
# pkg_names="$pkg_names $pkg_urls" # pkg_names="$pkg_names $pkg_urls"
# return 0 # return 0
# ;; # ;;
#esac #esac
case $PMTYPE in case $PMTYPE in
#apt-rpm) #apt-rpm)
# pkg_names="$pkg_names $pkg_urls" # pkg_names="$pkg_names $pkg_urls"
# ;; # ;;
#deepsolver-rpm) #deepsolver-rpm)
# pkg_names="$pkg_names $pkg_urls" # pkg_names="$pkg_names $pkg_urls"
# ;; # ;;
#urpm-rpm) #urpm-rpm)
# pkg_names="$pkg_names $pkg_urls" # pkg_names="$pkg_names $pkg_urls"
# ;; # ;;
pacman) pacman)
pkg_names="$pkg_names $pkg_urls" pkg_names="$pkg_names $pkg_urls"
;; ;;
yum-rpm|dnf-rpm) yum-rpm|dnf-rpm)
pkg_names="$pkg_names $pkg_urls" pkg_names="$pkg_names $pkg_urls"
;; ;;
#zypper-rpm) #zypper-rpm)
# pkg_names="$pkg_names $pkg_urls" # pkg_names="$pkg_names $pkg_urls"
# ;; # ;;
*) *)
return 1 return 1
;; ;;
esac esac
return 0 return 0
} }
# for download before install / checking # for download before install / checking
__download_pkg_urls() __download_pkg_urls()
{ {
local url local url
[ -z "$pkg_urls" ] && return [ -z "$pkg_urls" ] && return
for url in $pkg_urls ; do for url in $pkg_urls ; do
local tmppkg=$(mktemp -d) || fatal "failed mktemp -d" local tmppkg=$(mktemp -d) || fatal "failed mktemp -d"
docmd chmod $verbose a+rX $tmppkg docmd chmod $verbose a+rX $tmppkg
showcmd cd $tmppkg showcmd cd $tmppkg
cd $tmppkg || fatal cd $tmppkg || fatal
local latest='--latest' local latest='--latest'
# hack: download all if mask is *.something # hack: download all if mask is *.something
basename "$url" | grep -q "^\*\." && latest='' basename "$url" | grep -q "^\*\." && latest=''
# download packages # download packages
if docmd eget $latest "$url" ; then if docmd eget $latest "$url" ; then
local i local i
for i in *.* ; do for i in *.* ; do
[ -s "$tmppkg/$i" ] || continue [ -s "$tmppkg/$i" ] || continue
chmod $verbose a+r "$tmppkg/$i" chmod $verbose a+r "$tmppkg/$i"
pkg_files="$pkg_files $tmppkg/$i" pkg_files="$pkg_files $tmppkg/$i"
to_remove_pkg_files="$to_remove_pkg_files $tmppkg/$i" to_remove_pkg_files="$to_remove_pkg_files $tmppkg/$i"
done done
else else
warning "Failed to download $url, ignoring" warning "Failed to download $url, ignoring"
fi fi
cd - >/dev/null cd - >/dev/null
done done
# reconstruct # reconstruct
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names") pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
} }
# NOTE: call __clean_downloaded_pkg_files after # NOTE: call __clean_downloaded_pkg_files after
__handle_pkg_urls_to_install() __handle_pkg_urls_to_install()
{ {
#[ -n "$pkg_urls" ] || return #[ -n "$pkg_urls" ] || return
# TODO: do it correctly # TODO: do it correctly
to_remove_pkg_files= to_remove_pkg_files=
# FIXME: check type of pkg_urls separately? # FIXME: check type of pkg_urls separately?
if [ "$(get_package_type "$pkg_urls")" != $PKGFORMAT ] || ! __use_url_install ; then if [ "$(get_package_type "$pkg_urls")" != $PKGFORMAT ] || ! __use_url_install ; then
# use workaround with eget: download and put in pkg_files # use workaround with eget: download and put in pkg_files
__download_pkg_urls __download_pkg_urls
fi fi
pkg_urls= pkg_urls=
} }
__handle_pkg_urls_to_checking() __handle_pkg_urls_to_checking()
{ {
#[ -n "$pkg_urls" ] || return #[ -n "$pkg_urls" ] || return
# TODO: do it correctly # TODO: do it correctly
to_remove_pkg_files= to_remove_pkg_files=
# use workaround with eget: download and put in pkg_files # use workaround with eget: download and put in pkg_files
__download_pkg_urls __download_pkg_urls
pkg_urls= pkg_urls=
} }
#__clean_downloaded_pkg_files() #__clean_downloaded_pkg_files()
#{ #{
# [ -z "$to_remove_pkg_files" ] && return # [ -z "$to_remove_pkg_files" ] && return
# rm -fv $to_remove_pkg_files # rm -fv $to_remove_pkg_files
#} #}
# obsoleted # obsoleted
__epm_get_altpkg_url() __epm_get_altpkg_url()
{ {
info "TODO: https://packages.altlinux.org/api/branches" info "TODO: https://packages.altlinux.org/api/branches"
load_helper epm-site load_helper epm-site
local arch=$(paoapi packages/$1 | get_pao_var arch) local arch=$(paoapi packages/$1 | get_pao_var arch)
# FIXME: arch can be list # FIXME: arch can be list
[ "$arch" = "noarch" ] || arch=$(arch) [ "$arch" = "noarch" ] || arch=$(arch)
# HACK: filename can be list # HACK: filename can be list
local filename=$(paoapi packages/$1 | get_pao_var filename | grep $arch) local filename=$(paoapi packages/$1 | get_pao_var filename | grep $arch)
[ -n "$filename" ] || fatal "Can't get filename" [ -n "$filename" ] || fatal "Can't get filename"
# fixme: get from /branches # fixme: get from /branches
local dv=$DISTRNAME/$DISTRVERSION/branch local dv=$DISTRNAME/$DISTRVERSION/branch
[ "$DISTRVERSION" = "Sisyphus" ] && dv=$DISTRNAME/$DISTRVERSION [ "$DISTRVERSION" = "Sisyphus" ] && dv=$DISTRNAME/$DISTRVERSION
echo "$alt_base_dist_url/$dv/$arch/RPMS.classic/$filename" echo "$alt_base_dist_url/$dv/$arch/RPMS.classic/$filename"
} }
# obsoleted # obsoleted
__epm_print_url_alt() __epm_print_url_alt()
{ {
local url="$1" local url="$1"
echo "$url" echo "$url"
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://mirror.yandex.ru/altlinux|g" echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://mirror.yandex.ru/altlinux|g"
echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://download.etersoft.ru/pub/ALTLinux|g" echo "$url" | sed -e "s|$alt_base_dist_url/$DISTRNAME|http://download.etersoft.ru/pub/ALTLinux|g"
} }
__epm_print_url_alt_check() __epm_print_url_alt_check()
{ {
local pkg=$1 local pkg=$1
shift shift
local tm=$(mktemp) local tm=$(mktemp)
assure_exists curl assure_exists curl
load_helper epm-site load_helper epm-site
quiet=1 quiet=1
local buildtime=$(paoapi packages/$pkg | get_pao_var buildtime) local buildtime=$(paoapi packages/$pkg | get_pao_var buildtime)
echo echo
echo "Latest release: $(paoapi packages/$pkg | get_pao_var sourcepackage) $buildtime" echo "Latest release: $(paoapi packages/$pkg | get_pao_var sourcepackage) $buildtime"
__epm_print_url_alt "$1" | while read url ; do __epm_print_url_alt "$1" | while read url ; do
a='' curl -s --head $url >$tm || { echo "$url: missed" ; continue ; } a='' curl -s --head $url >$tm || { echo "$url: missed" ; continue ; }
local http=$(cat $tm | grep "^HTTP" | sed -e "s|\r||g") local http=$(cat $tm | grep "^HTTP" | sed -e "s|\r||g")
local lastdate=$(cat $tm | grep "^Last-Modified:" | sed -e "s|\r||g") local lastdate=$(cat $tm | grep "^Last-Modified:" | sed -e "s|\r||g")
local size=$(cat $tm | grep "^Content-Length:" | sed -e "s|^Content-Length: ||g" | sed -e "s|\r||g") local size=$(cat $tm | grep "^Content-Length:" | sed -e "s|^Content-Length: ||g" | sed -e "s|\r||g")
echo "$url ($http $lastdate) Size: $size" echo "$url ($http $lastdate) Size: $size"
done done
rm -f $tm rm -f $tm
} }
__epm_download_alt() __epm_download_alt()
{ {
local pkg local pkg
if [ "$1" = "--check" ] ; then if [ "$1" = "--check" ] ; then
local checkflag="$1" local checkflag="$1"
shift shift
fi fi
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
# TODO: enable if install --download-only will works # TODO: enable if install --download-only will works
if tasknumber "$@" >/dev/null ; then if tasknumber "$@" >/dev/null ; then
load_helper epm-addrepo load_helper epm-addrepo
load_helper epm-reposave load_helper epm-reposave
load_helper epm-removerepo load_helper epm-removerepo
load_helper epm-Install load_helper epm-Install
local installlist="$(get_task_packages $*)" local installlist="$(get_task_packages $*)"
# hack: drop -devel packages to avoid package provided by multiple packages # hack: drop -devel packages to avoid package provided by multiple packages
installlist="$(estrlist reg_exclude ".*-devel .*-devel-static .*-checkinstall .*-debuginfo" "$installlist")" installlist="$(estrlist reg_exclude ".*-devel .*-devel-static .*-checkinstall .*-debuginfo" "$installlist")"
[ -n "$verbose" ] && info "Packages from task(s): $installlist" [ -n "$verbose" ] && info "Packages from task(s): $installlist"
try_change_alt_repo try_change_alt_repo
epm_addrepo "$@" epm_addrepo "$@"
epm update epm update
[ -n "$verbose" ] && epm repo list [ -n "$verbose" ] && epm repo list
docmd epm download $print_url $installlist docmd epm download $print_url $installlist
epm_removerepo "$@" epm_removerepo "$@"
end_change_alt_repo end_change_alt_repo
return return
fi fi
# old systems ignore reinstall ? # old systems ignore reinstall ?
for pkg in "$@" ; do for pkg in "$@" ; do
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
# old code: # old code:
for pkg in "$@" ; do for pkg in "$@" ; do
local url=$(__epm_get_altpkg_url $pkg) local url=$(__epm_get_altpkg_url $pkg)
[ -n "$url" ] || warning "Can't get URL for $pkg" [ -n "$url" ] || warning "Can't get URL for $pkg"
if [ -n "$checkflag" ] ; then if [ -n "$checkflag" ] ; then
__epm_print_url_alt_check "$pkg" "$url" __epm_print_url_alt_check "$pkg" "$url"
else else
docmd eget $url || return docmd eget $url || return
fi fi
done done
} }
epm_download() epm_download()
{ {
local CMD local CMD
case "$BASEDISTRNAME" in case "$BASEDISTRNAME" in
"alt") "alt")
__epm_download_alt $* __epm_download_alt $*
return return
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
if [ -n "$print_url" ] ; then if [ -n "$print_url" ] ; then
docmd apt-get download --print-uris $* | cut -f1 -d " " | grep ".deb'$" | sed -e "s|^'||" -e "s|'$||" docmd apt-get download --print-uris $* | cut -f1 -d " " | grep ".deb'$" | sed -e "s|^'||" -e "s|'$||"
return return
fi fi
docmd apt-get download $* docmd apt-get download $*
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf download $print_url $* sudocmd dnf download $print_url $*
;; ;;
aptcyg) aptcyg)
sudocmd apt-cyg download $* sudocmd apt-cyg download $*
;; ;;
packagekit) packagekit)
docmd pkcon download $* docmd pkcon download $*
;; ;;
yum-rpm) yum-rpm)
# TODO: check yum install --downloadonly --downloaddir=/tmp <package-name> # TODO: check yum install --downloadonly --downloaddir=/tmp <package-name>
assure_exists yumdownloader yum-utils assure_exists yumdownloader yum-utils
sudocmd yumdownloader $* sudocmd yumdownloader $*
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf download $* sudocmd dnf download $*
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi --no-install $URPMOPTIONS $@ sudocmd urpmi --no-install $URPMOPTIONS $@
;; ;;
tce) tce)
sudocmd tce-load -w $* sudocmd tce-load -w $*
;; ;;
opkg) opkg)
docmd opkg $* docmd opkg $*
;; ;;
eopkg) eopkg)
docmd eopkg fetch $* docmd eopkg fetch $*
;; ;;
homebrew) homebrew)
docmd brew fetch $* docmd brew fetch $*
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -65,9 +65,9 @@ __epm_korinf_install() { ...@@ -65,9 +65,9 @@ __epm_korinf_install() {
epm_epm_install_help() epm_epm_install_help()
{ {
echo "epm ei [packages] - install packages from EPM based Korinf repository" echo "epm ei [packages] - install packages from EPM based Korinf repository"
get_help HELPCMD $SHAREDIR/epm-epm_install get_help HELPCMD $SHAREDIR/epm-epm_install
cat <<EOF cat <<EOF
Default Korinf repository: $EPM_KORINF_REPO_URL Default Korinf repository: $EPM_KORINF_REPO_URL
......
...@@ -52,144 +52,144 @@ __deb_local_content_filelist() ...@@ -52,144 +52,144 @@ __deb_local_content_filelist()
__epm_filelist_remote() __epm_filelist_remote()
{ {
[ -z "$*" ] && return [ -z "$*" ] && return
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_allowed ; then if sudo_allowed ; then
sudocmd apt-file update sudocmd apt-file update
else else
info "sudo requires a password, skip apt-file update" info "sudo requires a password, skip apt-file update"
fi fi
docmd_foreach __deb_local_content_filelist "$@" docmd_foreach __deb_local_content_filelist "$@"
;; ;;
packagekit) packagekit)
docmd pkcon get-files "$@" docmd pkcon get-files "$@"
;; ;;
yum-rpm) yum-rpm)
assure_exists yum-utils || return assure_exists yum-utils || return
docmd repoquery -q -l "$@" docmd repoquery -q -l "$@"
;; ;;
dnf-rpm) dnf-rpm)
assure_exists dnf-plugins-core || return assure_exists dnf-plugins-core || return
docmd dnf repoquery -l "$@" 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."
;; ;;
esac esac
} }
__epm_filelist_file() __epm_filelist_file()
{ {
local CMD local CMD
[ -z "$*" ] && return [ -z "$*" ] && return
# TODO: allow a new packages # TODO: allow a new packages
case $(get_package_type $1) in case $(get_package_type $1) in
rpm) rpm)
assure_exists rpm assure_exists rpm
CMD="rpm -qlp" CMD="rpm -qlp"
;; ;;
deb) deb)
assure_exists dpkg assure_exists dpkg
CMD="dpkg --contents" CMD="dpkg --contents"
;; ;;
eopkg) eopkg)
assure_exists eopkg assure_exists eopkg
CMD="eopkg --files info" CMD="eopkg --files info"
;; ;;
*) *)
fatal "Have no suitable query command for $PMTYPE" fatal "Have no suitable query command for $PMTYPE"
;; ;;
esac esac
# TODO: add less # TODO: add less
docmd $CMD $@ docmd $CMD $@
} }
__epm_filelist_name() __epm_filelist_name()
{ {
local CMD local CMD
[ -z "$*" ] && return [ -z "$*" ] && return
warmup_lowbase warmup_lowbase
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
CMD="rpm -ql" CMD="rpm -ql"
;; ;;
*-dpkg) *-dpkg)
CMD="dpkg -L" CMD="dpkg -L"
;; ;;
packagekit) packagekit)
CMD="pkcon get-files" CMD="pkcon get-files"
;; ;;
android) android)
CMD="pm list packages -f" CMD="pm list packages -f"
;; ;;
conary) conary)
CMD="conary query --ls" CMD="conary query --ls"
;; ;;
pacman) pacman)
docmd pacman -Ql $@ | sed -e "s|.* ||g" docmd pacman -Ql $@ | sed -e "s|.* ||g"
return return
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
CMD="equery files" CMD="equery files"
;; ;;
homebrew) homebrew)
CMD="brew list" CMD="brew list"
;; ;;
pkgng) pkgng)
CMD="pkg info -l" CMD="pkg info -l"
;; ;;
opkg) opkg)
CMD="opkg files" CMD="opkg files"
;; ;;
eopkg) eopkg)
docmd eopkg --files -s info $@ | grep "^/" docmd eopkg --files -s info $@ | grep "^/"
return return
;; ;;
xbps) xbps)
CMD="xbps-query -f" CMD="xbps-query -f"
;; ;;
aptcyg) aptcyg)
docmd apt-cyg listfiles $@ | sed -e "s|^|/|g" docmd apt-cyg listfiles $@ | sed -e "s|^|/|g"
return return
;; ;;
slackpkg) slackpkg)
is_installed $@ || fatal "Query filelist for non installed packages is not implemented yet" is_installed $@ || fatal "Query filelist for non installed packages is not implemented yet"
docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}* docmd awk 'BEGIN{desk=1}{if(/^FILE LIST:$/){desk=0} else if (desk==0) {print}}' /var/log/packages/${pkg_filenames}*
return return
;; ;;
*) *)
fatal "Have no suitable query command for $PMTYPE" fatal "Have no suitable query command for $PMTYPE"
;; ;;
esac esac
# TODO: add less or bat (for any output in the function) # TODO: add less or bat (for any output in the function)
docmd $CMD $@ && return docmd $CMD $@ && return
# TODO: may be we need check is installed before prev. line? # TODO: may be we need check is installed before prev. line?
is_installed $@ || __epm_filelist_remote $@ is_installed $@ || __epm_filelist_remote $@
} }
epm_filelist() epm_filelist()
{ {
[ -n "$pkg_filenames" ] || fatal "Filelist: package name is missed" [ -n "$pkg_filenames" ] || fatal "Filelist: package name is missed"
__epm_filelist_file $pkg_files || return __epm_filelist_file $pkg_files || return
# shellcheck disable=SC2046 # shellcheck disable=SC2046
__epm_filelist_name $(print_name $pkg_names) || return __epm_filelist_name $(print_name $pkg_names) || return
} }
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
epm_full_upgrade_help() epm_full_upgrade_help()
{ {
get_help HELPCMD $SHAREDIR/epm-full_upgrade get_help HELPCMD $SHAREDIR/epm-full_upgrade
cat <<EOF cat <<EOF
Also you can comment out full_upgrade parts in /etc/eepm/eepm.conf config. Also you can comment out full_upgrade parts in /etc/eepm/eepm.conf config.
Examples: Examples:
epm full-upgrade epm full-upgrade
...@@ -32,60 +32,60 @@ EOF ...@@ -32,60 +32,60 @@ EOF
epm_full_upgrade() epm_full_upgrade()
{ {
while [ -n "$1" ] ; do while [ -n "$1" ] ; do
case "$1" in case "$1" in
"-h"|"--help"|"help") # HELPCMD: help "-h"|"--help"|"help") # HELPCMD: help
epm_full_upgrade_help epm_full_upgrade_help
return return
;; ;;
"--no-epm-play") # HELPCMD: skip epm play during full upgrade "--no-epm-play") # HELPCMD: skip epm play during full upgrade
full_upgrade_no_epm_play=1 full_upgrade_no_epm_play=1
;; ;;
"--no-flatpack") # HELPCMD: skip flatpack update during full upgrade "--no-flatpack") # HELPCMD: skip flatpack update during full upgrade
full_upgrade_no_flatpack=1 full_upgrade_no_flatpack=1
;; ;;
"--no-snap") # HELPCMD: skip snap update during full upgrade "--no-snap") # HELPCMD: skip snap update during full upgrade
full_upgrade_no_snap=1 full_upgrade_no_snap=1
;; ;;
"--no-kernel-update") # HELPCMD: skip kernel update during full upgrade "--no-kernel-update") # HELPCMD: skip kernel update during full upgrade
full_upgrade_no_kernel_update=1 full_upgrade_no_kernel_update=1
;; ;;
esac esac
shift shift
done done
docmd epm update || fatal "repository updating is failed." docmd epm update || fatal "repository updating is failed."
[ -n "$quiet" ] || echo [ -n "$quiet" ] || echo
docmd epm upgrade || fatal "upgrading of the system is failed." docmd epm upgrade || fatal "upgrading of the system is failed."
if [ -z "$full_upgrade_no_kernel_update" ] ; then if [ -z "$full_upgrade_no_kernel_update" ] ; then
[ -n "$quiet" ] || echo [ -n "$quiet" ] || echo
docmd epm update-kernel || fatal "updating of the kernel is failed." docmd epm update-kernel || fatal "updating of the kernel is failed."
fi fi
# disable epm play --update for non ALT Systems # disable epm play --update for non ALT Systems
[ "$BASEDISTRNAME" = "alt" ] || full_upgrade_no_epm_play=1 [ "$BASEDISTRNAME" = "alt" ] || full_upgrade_no_epm_play=1
if [ -z "$full_upgrade_no_epm_play" ] ; then if [ -z "$full_upgrade_no_epm_play" ] ; then
[ -n "$quiet" ] || echo [ -n "$quiet" ] || echo
docmd epm play --update all || fatal "updating of applications installed via epm play is failed." docmd epm play --update all || fatal "updating of applications installed via epm play is failed."
fi fi
if [ -z "$full_upgrade_no_flatpack" ] ; then if [ -z "$full_upgrade_no_flatpack" ] ; then
if is_command flatpak ; 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 is_command snap && serv snapd exists && serv snapd status >/dev/null ; 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
fi fi
[ -n "$quiet" ] || echo [ -n "$quiet" ] || echo
docmd epm clean docmd epm clean
} }
...@@ -22,86 +22,86 @@ JCHAN='-t apt-get -t rpm' ...@@ -22,86 +22,86 @@ JCHAN='-t apt-get -t rpm'
__alt_epm_history_journal() __alt_epm_history_journal()
{ {
a= journalctl $JCHAN a= journalctl $JCHAN
} }
__alt_epm_history_uniq() __alt_epm_history_uniq()
{ {
__alt_epm_history_journal | grep "$EHOG\[[0-9][0-9]*\]:" | sed -e "s@.*$EHOG\[\([0-9][0-9]*\)\]: .*@\2@" | uniq | tac __alt_epm_history_journal | grep "$EHOG\[[0-9][0-9]*\]:" | sed -e "s@.*$EHOG\[\([0-9][0-9]*\)\]: .*@\2@" | uniq | tac
} }
# args: pid, removed|installed # args: pid, removed|installed
__alt_epm_history_select() __alt_epm_history_select()
{ {
local pid="$1" local pid="$1"
local verb="$2" local verb="$2"
__alt_epm_history_journal | grep "$EHOG\[$pid\]: .*$verb" | sed -e "s@.*$EHOG\[[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"
__alt_epm_history_journal | grep "$EHOG\[$pid\]: " | head -n1 | cut -d" " -f 1-3,5 | sed -e 's|:$||' __alt_epm_history_journal | grep "$EHOG\[$pid\]: " | head -n1 | cut -d" " -f 1-3,5 | sed -e 's|:$||'
} }
_alt_epm_history_print_group() _alt_epm_history_print_group()
{ {
local i local i
if [ -n "$2" ] ; then if [ -n "$2" ] ; then
echo echo
echo "$1 session:" echo "$1 session:"
shift shift
else else
return return
fi fi
for i in $* ; do for i in $* ; do
echo " $i" echo " $i"
done 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)"
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") )"
_alt_epm_history_print_group "$date" $(estrlist exclude "$installed" "$removed") _alt_epm_history_print_group "$date" $(estrlist exclude "$installed" "$removed")
done done
} }
__alt_epm_history_installed() __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
date="$(_alt_epm_history_date $pid)" date="$(_alt_epm_history_date $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") )"
_alt_epm_history_print_group "$date" $(estrlist exclude "$removed" "$installed") _alt_epm_history_print_group "$date" $(estrlist exclude "$removed" "$installed")
done done
} }
__alt_epm_history_updated() __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
date="$(_alt_epm_history_date $pid)" date="$(_alt_epm_history_date $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") )"
_alt_epm_history_print_group "$date" $(estrlist intersection "$removed" "$installed") _alt_epm_history_print_group "$date" $(estrlist intersection "$removed" "$installed")
done done
} }
epm_history_help() epm_history_help()
{ {
echo "package management history" echo "package management history"
get_help HELPCMD $SHAREDIR/epm-history get_help HELPCMD $SHAREDIR/epm-history
cat <<EOF cat <<EOF
Examples: Examples:
epm history epm history
epm history --removed epm history --removed
...@@ -113,61 +113,61 @@ epm_history() ...@@ -113,61 +113,61 @@ epm_history()
{ {
if [ $PMTYPE = "apt-rpm" ] ; then if [ $PMTYPE = "apt-rpm" ] ; then
case "$1" in case "$1" in
"-h"|"--help"|"help") # HELPCMD: help "-h"|"--help"|"help") # HELPCMD: help
epm_history_help epm_history_help
return return
;; ;;
--installed) # HELPCMD: print only new installed packages --installed) # HELPCMD: print only new installed packages
__alt_epm_history_installed __alt_epm_history_installed
return return
;; ;;
--removed) # HELPCMD: print only removed packages --removed) # HELPCMD: print only removed packages
__alt_epm_history_removed __alt_epm_history_removed
return return
;; ;;
--updated) # HELPCMD: print only updated packages --updated) # HELPCMD: print only updated packages
__alt_epm_history_updated __alt_epm_history_updated
return return
;; ;;
--list) # HELPCMD: (or empty) print all history entries --list) # HELPCMD: (or empty) print all history entries
docmd journalctl $JCHAN docmd journalctl $JCHAN
return return
;; ;;
"") "")
;; ;;
*) *)
fatal "Unknown option $1. Use epm history --help to get help." fatal "Unknown option $1. Use epm history --help to get help."
esac esac
fi fi
[ -z "$*" ] || fatal "No arguments are allowed here" [ -z "$*" ] || fatal "No arguments are allowed here"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
docmd journalctl $JCHAN -r docmd journalctl $JCHAN -r
;; ;;
apt-dpkg) apt-dpkg)
docmd cat /var/log/dpkg.log docmd cat /var/log/dpkg.log
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf history sudocmd dnf history
;; ;;
eopkg) eopkg)
sudocmd eopkg history sudocmd eopkg history
;; ;;
zypper-rpm) zypper-rpm)
docmd cat /var/log/zypp/history docmd cat /var/log/zypp/history
;; ;;
pacman) pacman)
docmd cat /var/log/pacman.log docmd cat /var/log/pacman.log
;; ;;
emerge) emerge)
docmd cat /var/log/portage docmd cat /var/log/portage
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -21,131 +21,131 @@ load_helper epm-query ...@@ -21,131 +21,131 @@ load_helper epm-query
__epm_info_rpm_low() __epm_info_rpm_low()
{ {
if [ -n "$pkg_files" ] ; then if [ -n "$pkg_files" ] ; then
docmd rpm -qip $pkg_files docmd rpm -qip $pkg_files
fi fi
[ -z "$pkg_names" ] && return [ -z "$pkg_names" ] && return
is_installed $pkg_names && docmd rpm -qi $pkg_names && return is_installed $pkg_names && docmd rpm -qi $pkg_names && return
} }
__epm_info_by_pkgtype() __epm_info_by_pkgtype()
{ {
[ -n "$pkg_files" ] || return 1 [ -n "$pkg_files" ] || return 1
case $(get_package_type $pkg_files) in case $(get_package_type $pkg_files) in
rpm) rpm)
__epm_info_rpm_low && return __epm_info_rpm_low && return
;; ;;
deb) deb)
docmd dpkg -I $pkg_files docmd dpkg -I $pkg_files
;; ;;
*) *)
return 1 return 1
;; ;;
esac esac
} }
__epm_info_by_pmtype() __epm_info_by_pmtype()
{ {
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
if [ -n "$pkg_files" ] ; then if [ -n "$pkg_files" ] ; then
docmd dpkg -I $pkg_files docmd dpkg -I $pkg_files
fi fi
[ -z "$pkg_names" ] && return [ -z "$pkg_names" ] && return
is_installed $pkg_names && docmd dpkg -p $pkg_names && return is_installed $pkg_names && docmd dpkg -p $pkg_names && return
docmd apt-cache show $pkg_names docmd apt-cache show $pkg_names
;; ;;
aptitude-dpkg) aptitude-dpkg)
if [ -n "$pkg_files" ] ; then if [ -n "$pkg_files" ] ; then
docmd dpkg -I $pkg_files docmd dpkg -I $pkg_files
fi fi
[ -z "$pkg_names" ] && return [ -z "$pkg_names" ] && return
docmd aptitude show $pkg_names docmd aptitude show $pkg_names
;; ;;
*-rpm) *-rpm)
__epm_info_rpm_low && return __epm_info_rpm_low && return
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
docmd apt-cache show $pkg_names docmd apt-cache show $pkg_names
;; ;;
packagekit) packagekit)
docmd pkcon get-details $pkg_names docmd pkcon get-details $pkg_names
;; ;;
yum-rpm) yum-rpm)
docmd yum info $pkg_names docmd yum info $pkg_names
;; ;;
urpmi-rpm) urpmi-rpm)
docmd urpmq -i $pkg_names docmd urpmq -i $pkg_names
;; ;;
dnf-rpm) dnf-rpm)
docmd dnf info $pkg_names docmd dnf info $pkg_names
;; ;;
zypper-rpm) zypper-rpm)
docmd zypper info $pkg_names docmd zypper info $pkg_names
;; ;;
*) *)
warning "Unknown command for $PMTYPE" warning "Unknown command for $PMTYPE"
;; ;;
esac esac
;; ;;
packagekit) packagekit)
# TODO: get-details-local # TODO: get-details-local
docmd pkcon get-details $pkg_names docmd pkcon get-details $pkg_names
;; ;;
pacman) pacman)
is_installed $pkg_names && docmd pacman -Qi $pkg_names && return is_installed $pkg_names && docmd pacman -Qi $pkg_names && return
docmd pacman -Si $pkg_names docmd pacman -Si $pkg_names
;; ;;
aura) aura)
is_installed $pkg_names && docmd pacman -Qi $pkg_names && return is_installed $pkg_names && docmd pacman -Qi $pkg_names && return
docmd aura -Ai $pkg_names docmd aura -Ai $pkg_names
;; ;;
npackd) npackd)
# FIXME: --version= # FIXME: --version=
docmd npackdcl info --package=$pkg_names docmd npackdcl info --package=$pkg_names
;; ;;
conary) conary)
is_installed $pkg_names && docmd conary query $pkg_names --info && return is_installed $pkg_names && docmd conary query $pkg_names --info && return
docmd conary repquery $pkg_names --info docmd conary repquery $pkg_names --info
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
docmd equery meta $pkg_names docmd equery meta $pkg_names
docmd equery which $pkg_names docmd equery which $pkg_names
docmd equery uses $pkg_names docmd equery uses $pkg_names
docmd equery size $pkg_names docmd equery size $pkg_names
;; ;;
slackpkg) slackpkg)
docmd /usr/sbin/slackpkg info $pkg_names docmd /usr/sbin/slackpkg info $pkg_names
;; ;;
opkg) opkg)
docmd opkg info $pkg_names docmd opkg info $pkg_names
;; ;;
pkgng) pkgng)
docmd pkg info $pkg_names docmd pkg info $pkg_names
;; ;;
xbps) xbps)
docmd xbps-query --show $pkg_names docmd xbps-query --show $pkg_names
;; ;;
homebrew) homebrew)
docmd brew info $pkg_names docmd brew info $pkg_names
;; ;;
aptcyg) aptcyg)
docmd apt-cyg show $pkg_names docmd apt-cyg show $pkg_names
;; ;;
winget) winget)
docmd winget show $pkg_names docmd winget show $pkg_names
;; ;;
eopkg) eopkg)
docmd eopkg info $pkg_files $pkg_names docmd eopkg info $pkg_files $pkg_names
;; ;;
appget) appget)
docmd appget view $pkg_names docmd appget view $pkg_names
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
......
...@@ -67,213 +67,213 @@ __separate_sudocmd() ...@@ -67,213 +67,213 @@ __separate_sudocmd()
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg # copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_install_names() epm_install_names()
{ {
[ -z "$1" ] && return [ -z "$1" ] && return
warmup_hibase warmup_hibase
if [ -n "$download_only" ] ; then if [ -n "$download_only" ] ; then
epm download "$@" epm download "$@"
return return
fi fi
if [ -n "$non_interactive" ] ; then if [ -n "$non_interactive" ] ; then
epm_ni_install_names "$@" epm_ni_install_names "$@"
return return
fi fi
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
APTOPTIONS="$APTOPTIONS $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")" APTOPTIONS="$APTOPTIONS $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
sudocmd apt-get $APTOPTIONS $noremove install $@ && save_installed_packages $@ sudocmd apt-get $APTOPTIONS $noremove install $@ && save_installed_packages $@
return ;; return ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude install $@ sudocmd aptitude install $@
return ;; return ;;
deepsolver-rpm) deepsolver-rpm)
sudocmd ds-install $@ sudocmd ds-install $@
return ;; return ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi $URPMOPTIONS $@ sudocmd urpmi $URPMOPTIONS $@
return ;; return ;;
packagekit) packagekit)
docmd pkcon install $@ docmd pkcon install $@
return ;; return ;;
pkgsrc) pkgsrc)
sudocmd pkg_add -r $@ sudocmd pkg_add -r $@
return ;; return ;;
pkgng) pkgng)
sudocmd pkg install $@ sudocmd pkg install $@
return ;; return ;;
emerge) emerge)
sudocmd emerge -uD $@ sudocmd emerge -uD $@
return ;; return ;;
pacman) pacman)
sudocmd pacman -S $nodeps $@ sudocmd pacman -S $nodeps $@
return ;; return ;;
aura) aura)
sudocmd aura -A $force $nodeps $@ sudocmd aura -A $force $nodeps $@
return ;; return ;;
yum-rpm) yum-rpm)
sudocmd yum $YUMOPTIONS install $(echo "$*" | exp_with_arch_suffix) sudocmd yum $YUMOPTIONS install $(echo "$*" | exp_with_arch_suffix)
return ;; return ;;
dnf-rpm) dnf-rpm)
sudocmd dnf install $(echo "$*" | exp_with_arch_suffix) sudocmd dnf install $(echo "$*" | exp_with_arch_suffix)
return ;; return ;;
snappy) snappy)
sudocmd snappy install $@ sudocmd snappy install $@
return ;; return ;;
zypper-rpm) zypper-rpm)
sudocmd zypper install $ZYPPEROPTIONS $@ sudocmd zypper install $ZYPPEROPTIONS $@
return ;; return ;;
mpkg) mpkg)
sudocmd mpkg install $@ sudocmd mpkg install $@
return ;; return ;;
eopkg) eopkg)
sudocmd eopkg $(subst_option nodeps --ignore-dependency) install $@ sudocmd eopkg $(subst_option nodeps --ignore-dependency) install $@
return ;; return ;;
conary) conary)
sudocmd conary update $@ sudocmd conary update $@
return ;; return ;;
npackd) npackd)
# FIXME: correct arg # FIXME: correct arg
__separate_sudocmd_foreach "npackdcl add --package=" "npackdcl update --package=" $@ __separate_sudocmd_foreach "npackdcl add --package=" "npackdcl update --package=" $@
return ;; return ;;
slackpkg) slackpkg)
__separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@ __separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@
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 ;;
opkg) opkg)
[ -n "$force" ] && force=-force-depends [ -n "$force" ] && force=-force-depends
sudocmd opkg $force install $@ sudocmd opkg $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 $@
return ;; return ;;
tce) tce)
sudocmd tce-load -wi $@ sudocmd tce-load -wi $@
return ;; return ;;
guix) guix)
__separate_sudocmd "guix package -i" "guix package -i" $@ __separate_sudocmd "guix package -i" "guix package -i" $@
return ;; return ;;
android) android)
fatal "We still have no idea how to use package repository, ever if it is F-Droid." fatal "We still have no idea how to use package repository, ever if it is F-Droid."
return ;; return ;;
aptcyg) aptcyg)
sudocmd apt-cyg install $@ sudocmd apt-cyg install $@
return ;; return ;;
xbps) xbps)
sudocmd xbps-install $@ sudocmd xbps-install $@
return ;; return ;;
appget|winget) appget|winget)
sudocmd $PMTYPE install $@ sudocmd $PMTYPE install $@
return ;; return ;;
*) *)
fatal "Have no suitable install command for $PMTYPE" fatal "Have no suitable install command for $PMTYPE"
;; ;;
esac esac
} }
# Non interactive install # Non interactive install
epm_ni_install_names() epm_ni_install_names()
{ {
[ -z "$1" ] && return [ -z "$1" ] && return
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
sudocmd apt-get -y $noremove --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@ sudocmd apt-get -y $noremove --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
return ;; return ;;
apt-dpkg) apt-dpkg)
sudocmd env ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive apt-get -y $noremove --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@ sudocmd env ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive apt-get -y $noremove --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $APTOPTIONS install $@
return ;; return ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd env ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive aptitude -y install $@ sudocmd env ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive aptitude -y install $@
return ;; return ;;
yum-rpm) yum-rpm)
sudocmd yum -y $YUMOPTIONS install $(echo "$*" | exp_with_arch_suffix) sudocmd yum -y $YUMOPTIONS install $(echo "$*" | exp_with_arch_suffix)
return ;; return ;;
dnf-rpm) dnf-rpm)
sudocmd dnf -y --allowerasing $YUMOPTIONS install $(echo "$*" | exp_with_arch_suffix) sudocmd dnf -y --allowerasing $YUMOPTIONS install $(echo "$*" | exp_with_arch_suffix)
return ;; return ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi --auto $URPMOPTIONS $@ sudocmd urpmi --auto $URPMOPTIONS $@
return ;; return ;;
zypper-rpm) zypper-rpm)
# FIXME: returns true ever no package found, need check for "no found", "Nothing to do." # FIXME: returns true ever no package found, need check for "no found", "Nothing to do."
yes | sudocmd zypper --non-interactive $ZYPPEROPTIONS install $@ yes | sudocmd zypper --non-interactive $ZYPPEROPTIONS install $@
return ;; return ;;
packagekit) packagekit)
docmd pkcon install --noninteractive $@ docmd pkcon install --noninteractive $@
return ;; return ;;
pkgsrc) pkgsrc)
sudocmd pkg_add -r $@ sudocmd pkg_add -r $@
return ;; return ;;
pkgng) pkgng)
sudocmd pkg install -y $@ sudocmd pkg install -y $@
return ;; return ;;
emerge) emerge)
sudocmd emerge -uD $@ sudocmd emerge -uD $@
return ;; return ;;
pacman) pacman)
sudocmd pacman -S --noconfirm $nodeps $@ sudocmd pacman -S --noconfirm $nodeps $@
return ;; return ;;
aura) aura)
sudocmd aura -A $force $nodeps $@ sudocmd aura -A $force $nodeps $@
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 $@
return ;; return ;;
opkg) opkg)
sudocmd opkg -force-defaults install $@ sudocmd opkg -force-defaults install $@
return ;; return ;;
eopkg) eopkg)
sudocmd eopkg --yes-all install $@ sudocmd eopkg --yes-all install $@
return ;; return ;;
nix) nix)
sudocmd nix-env --install $@ sudocmd nix-env --install $@
return ;; return ;;
apk) apk)
sudocmd apk add $@ sudocmd apk add $@
return ;; return ;;
tce) tce)
sudocmd tce-load -wi $@ sudocmd tce-load -wi $@
return ;; return ;;
xbps) xbps)
sudocmd xbps-install -y $@ sudocmd xbps-install -y $@
return ;; return ;;
appget|winget) appget|winget)
sudocmd $PMTYPE -s install $@ sudocmd $PMTYPE -s install $@
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 $@
# return ;; # return ;;
slackpkg) slackpkg)
# FIXME: broken status when use batch and default answer # FIXME: broken status when use batch and default answer
__separate_sudocmd_foreach "/usr/sbin/slackpkg -batch=on -default_answer=yes install" "/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade" $@ __separate_sudocmd_foreach "/usr/sbin/slackpkg -batch=on -default_answer=yes install" "/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade" $@
return ;; return ;;
*) *)
fatal "Have no suitable appropriate install command for $PMTYPE" fatal "Have no suitable appropriate install command for $PMTYPE"
;; ;;
esac esac
} }
__epm_check_if_rpm_already_installed() __epm_check_if_rpm_already_installed()
{ {
# Not: we can make optimize if just check version? # Not: we can make optimize if just check version?
LANG=C sudorun rpm -Uvh --test "$@" 2>&1 | grep -q "is already installed" LANG=C sudorun rpm -Uvh --test "$@" 2>&1 | grep -q "is already installed"
} }
__handle_direct_install() __handle_direct_install()
...@@ -618,54 +618,54 @@ epm_print_install_command() ...@@ -618,54 +618,54 @@ epm_print_install_command()
epm_print_install_names_command() epm_print_install_names_command()
{ {
# check for pkg_files to support print out command without pkg names in args # check for pkg_files to support print out command without pkg names in args
#[ -z "$1" ] && [ -n "$pkg_files" ] && return #[ -z "$1" ] && [ -n "$pkg_files" ] && return
[ -z "$1" ] && return [ -z "$1" ] && return
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
echo "apt-get -y --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true $APTOPTIONS install $*" echo "apt-get -y --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true $APTOPTIONS install $*"
return ;; return ;;
apt-dpkg) apt-dpkg)
# this command not for complex use. ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive # this command not for complex use. ACCEPT_EULA=y DEBIAN_FRONTEND=noninteractive
echo "apt-get -y --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true $APTOPTIONS install $*" echo "apt-get -y --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true $APTOPTIONS install $*"
return ;; return ;;
aptitude-dpkg) aptitude-dpkg)
echo "aptitude -y install $*" echo "aptitude -y install $*"
return ;; return ;;
yum-rpm) yum-rpm)
echo "yum -y $YUMOPTIONS install $*" echo "yum -y $YUMOPTIONS install $*"
return ;; return ;;
dnf-rpm) dnf-rpm)
echo "dnf -y $YUMOPTIONS --allowerasing install $*" echo "dnf -y $YUMOPTIONS --allowerasing install $*"
return ;; return ;;
urpm-rpm) urpm-rpm)
echo "urpmi --auto $URPMOPTIONS $*" echo "urpmi --auto $URPMOPTIONS $*"
return ;; return ;;
zypper-rpm) zypper-rpm)
echo "zypper --non-interactive $ZYPPEROPTIONS install $*" echo "zypper --non-interactive $ZYPPEROPTIONS install $*"
return ;; return ;;
packagekit) packagekit)
echo "pkcon --noninteractive $*" echo "pkcon --noninteractive $*"
return ;; return ;;
pacman) pacman)
echo "pacman -S --noconfirm $*" echo "pacman -S --noconfirm $*"
return ;; return ;;
chocolatey) chocolatey)
echo "chocolatey install $*" echo "chocolatey install $*"
return ;; return ;;
nix) nix)
echo "nix-env --install $*" echo "nix-env --install $*"
return ;; return ;;
eopkg) eopkg)
echo "eopkg install $*" echo "eopkg install $*"
return ;; return ;;
appget|winget) appget|winget)
echo "$PMTYPE install $*" echo "$PMTYPE install $*"
return ;; return ;;
*) *)
fatal "Have no suitable appropriate install command for $PMTYPE" fatal "Have no suitable appropriate install command for $PMTYPE"
;; ;;
esac esac
} }
# apt-repo with non_interactive support # apt-repo with non_interactive support
......
...@@ -26,73 +26,73 @@ ...@@ -26,73 +26,73 @@
# install one ebuild # install one ebuild
__emerge_install_ebuild() __emerge_install_ebuild()
{ {
local EBUILD="$1" local EBUILD="$1"
[ -s "$EBUILD" ] || fatal ".ebuild file '$EBUILD' is missed" [ -s "$EBUILD" ] || fatal ".ebuild file '$EBUILD' is missed"
# load ebuild and get vars # load ebuild and get vars
. $(pwd)/$EBUILD . $(pwd)/$EBUILD
[ -n "$SRC_URI" ] || fatal "Can't load SRC_URI from $EBUILD" [ -n "$SRC_URI" ] || fatal "Can't load SRC_URI from $EBUILD"
# try to detect tarballs # try to detect tarballs
local TARBALLS= local TARBALLS=
local BASEDIR=$(dirname $EBUILD) local BASEDIR=$(dirname $EBUILD)
for i in $SRC_URI ; do for i in $SRC_URI ; do
[ -s "$BASEDIR/$(basename $i)" ] || continue [ -s "$BASEDIR/$(basename $i)" ] || continue
TARBALLS="$TARBALLS $BASEDIR/$(basename $i)" TARBALLS="$TARBALLS $BASEDIR/$(basename $i)"
done done
local PORTAGENAME=epm local PORTAGENAME=epm
local LP=/usr/local/portage/$PORTAGENAME local LP=/usr/local/portage/$PORTAGENAME
docmd mkdir -p $LP/ docmd mkdir -p $LP/
MAKECONF=/etc/portage/make.conf MAKECONF=/etc/portage/make.conf
[ -r "$MAKECONF" ] || MAKECONF=/etc/make.conf [ -r "$MAKECONF" ] || MAKECONF=/etc/make.conf
if ! grep -v "^#" $MAKECONF | grep -q $LP ; then if ! grep -v "^#" $MAKECONF | grep -q $LP ; then
echo "PORTDIR_OVERLAY=\"$LP \${PORTDIR_OVERLAY}\"" >>$MAKECONF echo "PORTDIR_OVERLAY=\"$LP \${PORTDIR_OVERLAY}\"" >>$MAKECONF
# Overlay name # Overlay name
mkdir -p $LP/profiles/ mkdir -p $LP/profiles/
echo "$PORTAGENAME" > $LP/profiles/repo_name echo "$PORTAGENAME" > $LP/profiles/repo_name
fi fi
# copy tarballs # copy tarballs
local DDIR=/usr/portage/distfiles local DDIR=/usr/portage/distfiles
# FIXME: use independent dir # FIXME: use independent dir
[ -d /var/calculate/remote/distfiles ] && DDIR=/var/calculate/remote/distfiles [ -d /var/calculate/remote/distfiles ] && DDIR=/var/calculate/remote/distfiles
docmd cp -f $TARBALLS $DDIR/ || return docmd cp -f $TARBALLS $DDIR/ || return
# copy ebuild # copy ebuild
docmd cp -f $EBUILD $LP/ || return docmd cp -f $EBUILD $LP/ || return
cd $LP cd $LP
docmd ebuild $(basename $EBUILD) digest docmd ebuild $(basename $EBUILD) digest
cd - cd -
# FIXME: more correcty get name # FIXME: more correcty get name
local PKGNAME=$(echo $EBUILD | sed -e "s|-[0-9].*||g") local PKGNAME=$(echo $EBUILD | sed -e "s|-[0-9].*||g")
docmd emerge -av $PKGNAME || return docmd emerge -av $PKGNAME || return
} }
# install one ebuild # install one ebuild
__emerge_install_tbz2() __emerge_install_tbz2()
{ {
local TGDIR=/usr/portage/packages/app-arch local TGDIR=/usr/portage/packages/app-arch
mkdir -p $TGDIR mkdir -p $TGDIR
cp $i $TGDIR || return cp $i $TGDIR || return
docmd emerge --usepkg $TGDIR/$(basename $i) || return docmd emerge --usepkg $TGDIR/$(basename $i) || return
} }
# install ebuild list # install ebuild list
epm_install_emerge() epm_install_emerge()
{ {
local EBUILD= local EBUILD=
#local TARBALLS= #local TARBALLS=
local i local i
# search ebuild in the args # search ebuild in the args
for i in $* ; do for i in $* ; do
if echo $i | grep -q ebuild ; then if echo $i | grep -q ebuild ; then
__emerge_install_ebuild $i || return __emerge_install_ebuild $i || return
elif echo $i | grep -q "\.tbz2$" ; then elif echo $i | grep -q "\.tbz2$" ; then
__emerge_install_tbz2 $i || return __emerge_install_tbz2 $i || return
# else # else
# TARBALLS="$TARBALLS $i" # TARBALLS="$TARBALLS $i"
fi fi
done done
} }
...@@ -23,15 +23,15 @@ load_helper epm-query ...@@ -23,15 +23,15 @@ load_helper epm-query
# fill pkg_installed and pkg_noninstalled # fill pkg_installed and pkg_noninstalled
separate_installed() 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
} }
epm_installed() epm_installed()
{ {
[ -n "$pkg_names" ] || fatal "is_installed: package name is missed" [ -n "$pkg_names" ] || fatal "is_installed: package name is missed"
is_installed "$pkg_names" is_installed "$pkg_names"
} }
...@@ -22,30 +22,30 @@ load_helper epm-sh-warmup ...@@ -22,30 +22,30 @@ load_helper epm-sh-warmup
epm_kernel_update() epm_kernel_update()
{ {
warmup_bases warmup_bases
info "Updating system kernel to the latest version..." info "Updating system kernel to the latest version..."
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
load_helper epm-query_package load_helper epm-query_package
if ! __epm_query_package kernel-image >/dev/null ; then if ! __epm_query_package kernel-image >/dev/null ; then
info "No installed kernel packages, skipping update" info "No installed kernel packages, skipping update"
return return
fi fi
assure_exists update-kernel update-kernel 0.9.9 assure_exists update-kernel update-kernel 0.9.9
update_repo_if_needed update_repo_if_needed
sudocmd update-kernel $dryrun $(subst_option non_interactive -y) "$@" || return sudocmd update-kernel $dryrun $(subst_option non_interactive -y) "$@" || return
#docmd epm remove-old-kernels "$@" || fatal #docmd epm remove-old-kernels "$@" || fatal
return ;; return ;;
esac esac
case $PMTYPE in case $PMTYPE in
dnf-rpm) dnf-rpm)
docmd epm install kernel docmd epm install kernel
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -20,94 +20,94 @@ ...@@ -20,94 +20,94 @@
# TODO: move to a common place and use # TODO: move to a common place and use
__is_wildcard() __is_wildcard()
{ {
echo "$1" | grep -q "[*?]" echo "$1" | grep -q "[*?]"
} }
__alt_mark_hold_package() __alt_mark_hold_package()
{ {
local pkg="$1" local pkg="$1"
showcmd "echo \"RPM::Hold {\"^$pkg\";};\" > /etc/apt/apt.conf.d/hold-$pkg.conf" showcmd "echo \"RPM::Hold {\"^$pkg\";};\" > /etc/apt/apt.conf.d/hold-$pkg.conf"
echo "RPM::Hold {\"^$pkg\";};" | sudorun tee "/etc/apt/apt.conf.d/hold-$pkg.conf" >/dev/null echo "RPM::Hold {\"^$pkg\";};" | sudorun tee "/etc/apt/apt.conf.d/hold-$pkg.conf" >/dev/null
} }
__alt_test_glob() __alt_test_glob()
{ {
echo "$*" | grep -q "\.[*?]" && warning "Only glob symbols * and ? are supported. Don't use regexp here!" echo "$*" | grep -q "\.[*?]" && warning "Only glob symbols * and ? are supported. Don't use regexp here!"
} }
__alt_mark_hold() __alt_mark_hold()
{ {
# TODO: do more long checking via apt # TODO: do more long checking via apt
local pkg local pkg
local i local i
__alt_test_glob "$*" __alt_test_glob "$*"
for i in "$@" ; do for i in "$@" ; do
if __is_wildcard "$i" ; then if __is_wildcard "$i" ; then
local pkglist local pkglist
pkglist="$(epm qp --short "^$i")" || continue pkglist="$(epm qp --short "^$i")" || continue
for pkg in $pkglist ; do for pkg in $pkglist ; do
__alt_mark_hold_package $pkg __alt_mark_hold_package $pkg
done done
return return
else else
pkg="$(epm query --short "$i")" || continue pkg="$(epm query --short "$i")" || continue
fi fi
__alt_mark_hold_package $pkg __alt_mark_hold_package $pkg
done done
} }
__alt_mark_unhold() __alt_mark_unhold()
{ {
# TODO: do more long checking via apt # TODO: do more long checking via apt
local pkg local pkg
local i local i
__alt_test_glob "$*" __alt_test_glob "$*"
for i in "$@" ; do for i in "$@" ; do
pkg="$(epm query --short "$i")" || pkg="$i" pkg="$(epm query --short "$i")" || pkg="$i"
sudocmd rm -fv /etc/apt/apt.conf.d/hold-$pkg.conf sudocmd rm -fv /etc/apt/apt.conf.d/hold-$pkg.conf
done done
} }
__alt_mark_showhold() __alt_mark_showhold()
{ {
grep -h "RPM::Hold" /etc/apt/apt.conf.d/hold-*.conf 2>/dev/null | sed -e 's|RPM::Hold {"^\(.*\)";};|\1|' grep -h "RPM::Hold" /etc/apt/apt.conf.d/hold-*.conf 2>/dev/null | sed -e 's|RPM::Hold {"^\(.*\)";};|\1|'
} }
__dnf_assure_versionlock() __dnf_assure_versionlock()
{ {
epm assure /etc/dnf/plugins/versionlock.conf 'dnf-command(versionlock)' epm assure /etc/dnf/plugins/versionlock.conf 'dnf-command(versionlock)'
} }
epm_mark_hold() epm_mark_hold()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__alt_mark_hold "$@" __alt_mark_hold "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark hold "$@" sudocmd apt-mark hold "$@"
;; ;;
dnf-rpm) dnf-rpm)
__dnf_assure_versionlock __dnf_assure_versionlock
sudocmd dnf versionlock add "$@" sudocmd dnf versionlock add "$@"
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper al "$@" sudocmd zypper al "$@"
;; ;;
emerge) emerge)
info "Check /etc/portage/package.mask" info "Check /etc/portage/package.mask"
;; ;;
pacman) pacman)
info "Manually: edit /etc/pacman.conf modifying IgnorePkg array" info "Manually: edit /etc/pacman.conf modifying IgnorePkg array"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -117,32 +117,32 @@ epm_mark_unhold() ...@@ -117,32 +117,32 @@ epm_mark_unhold()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__alt_mark_unhold "$@" __alt_mark_unhold "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark unhold "$@" sudocmd apt-mark unhold "$@"
;; ;;
dnf-rpm) dnf-rpm)
__dnf_assure_versionlock __dnf_assure_versionlock
sudocmd dnf versionlock delete "$@" sudocmd dnf versionlock delete "$@"
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper rl "$@" sudocmd zypper rl "$@"
;; ;;
emerge) emerge)
info "Check /etc/portage/package.mask (package.unmask)" info "Check /etc/portage/package.mask (package.unmask)"
;; ;;
pacman) pacman)
info "Manually: edit /etc/pacman.conf removing package from IgnorePkg line" info "Manually: edit /etc/pacman.conf removing package from IgnorePkg line"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -152,32 +152,32 @@ epm_mark_showhold() ...@@ -152,32 +152,32 @@ epm_mark_showhold()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__alt_mark_showhold "$@" __alt_mark_showhold "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark showhold "$@" sudocmd apt-mark showhold "$@"
;; ;;
dnf-rpm) dnf-rpm)
__dnf_assure_versionlock __dnf_assure_versionlock
sudocmd dnf versionlock list sudocmd dnf versionlock list
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper ll "$@" sudocmd zypper ll "$@"
;; ;;
emerge) emerge)
cat /etc/portage/package.mask cat /etc/portage/package.mask
;; ;;
pacman) pacman)
cat /etc/pacman.conf cat /etc/pacman.conf
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -187,28 +187,28 @@ epm_mark_auto() ...@@ -187,28 +187,28 @@ epm_mark_auto()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
sudocmd apt-mark auto "$@" sudocmd apt-mark auto "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark auto "$@" sudocmd apt-mark auto "$@"
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf mark remove "$@" sudocmd dnf mark remove "$@"
;; ;;
pacman) pacman)
sudocmd pacman -D --asdeps "$@" sudocmd pacman -D --asdeps "$@"
;; ;;
emerge) emerge)
sudocmd emerge --oneshot "$@" sudocmd emerge --oneshot "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -218,28 +218,28 @@ epm_mark_manual() ...@@ -218,28 +218,28 @@ epm_mark_manual()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
sudocmd apt-mark manual "$@" sudocmd apt-mark manual "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark manual "$@" sudocmd apt-mark manual "$@"
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf mark install "$@" sudocmd dnf mark install "$@"
;; ;;
pacman) pacman)
sudocmd pacman -D --asexplicit "$@" sudocmd pacman -D --asexplicit "$@"
;; ;;
emerge) emerge)
sudocmd emerge --select "$@" sudocmd emerge --select "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -249,22 +249,22 @@ epm_mark_showauto() ...@@ -249,22 +249,22 @@ epm_mark_showauto()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
sudocmd apt-mark showauto "$@" sudocmd apt-mark showauto "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark showauto "$@" sudocmd apt-mark showauto "$@"
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf repoquery --unneeded sudocmd dnf repoquery --unneeded
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -273,31 +273,31 @@ epm_mark_showmanual() ...@@ -273,31 +273,31 @@ epm_mark_showmanual()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
sudocmd apt-mark showmanual "$@" sudocmd apt-mark showmanual "$@"
exit exit
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-mark showmanual "$@" sudocmd apt-mark showmanual "$@"
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf repoquery --userinstalled sudocmd dnf repoquery --userinstalled
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
epm_mark_help() epm_mark_help()
{ {
echo "mark is the interface for marking packages" echo "mark is the interface for marking packages"
get_help HELPCMD $SHAREDIR/epm-mark get_help HELPCMD $SHAREDIR/epm-mark
cat <<EOF cat <<EOF
Examples: Examples:
epm mark hold mc epm mark hold mc
epm manual mc epm manual mc
...@@ -306,36 +306,36 @@ EOF ...@@ -306,36 +306,36 @@ EOF
epm_mark() epm_mark()
{ {
local CMD="$1" local CMD="$1"
[ -n "$CMD" ] && shift [ -n "$CMD" ] && shift
case "$CMD" in case "$CMD" in
""|"-h"|"--help"|help) # HELPCMD: help ""|"-h"|"--help"|help) # HELPCMD: help
epm_mark_help epm_mark_help
;; ;;
hold) # HELPCMD: mark the given package(s) as held back hold) # HELPCMD: mark the given package(s) as held back
epm_mark_hold "$@" epm_mark_hold "$@"
;; ;;
unhold) # HELPCMD: unset the given package(s) as held back unhold) # HELPCMD: unset the given package(s) as held back
epm_mark_unhold "$@" epm_mark_unhold "$@"
;; ;;
showhold) # HELPCMD: print the list of packages on hold showhold) # HELPCMD: print the list of packages on hold
epm_mark_showhold "$@" epm_mark_showhold "$@"
;; ;;
auto) # HELPCMD: mark the given package(s) as automatically installed auto) # HELPCMD: mark the given package(s) as automatically installed
epm_mark_auto "$@" epm_mark_auto "$@"
;; ;;
manual) # HELPCMD: mark the given package(s) as manually installed manual) # HELPCMD: mark the given package(s) as manually installed
epm_mark_manual "$@" epm_mark_manual "$@"
;; ;;
showauto) # HELPCMD: print the list of automatically installed packages showauto) # HELPCMD: print the list of automatically installed packages
epm_mark_showauto "$@" epm_mark_showauto "$@"
;; ;;
showmanual) # HELPCMD: print the list of manually installed packages showmanual) # HELPCMD: print the list of manually installed packages
epm_mark_showmanual "$@" epm_mark_showmanual "$@"
;; ;;
*) *)
fatal "Unknown command $ epm repo '$CMD'" fatal "Unknown command $ epm repo '$CMD'"
;; ;;
esac esac
} }
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
# TODO: is it different from rpm --rebuilddb? # TODO: is it different from rpm --rebuilddb?
__repack_rpm_base() __repack_rpm_base()
{ {
assure_exists db_dump || fatal assure_exists db_dump || fatal
assure_exists db_load || fatal assure_exists db_load || fatal
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
} }
epm_optimize() epm_optimize()
...@@ -35,14 +35,14 @@ epm_optimize() ...@@ -35,14 +35,14 @@ epm_optimize()
[ -z "$*" ] || fatal "No arguments are allowed here" [ -z "$*" ] || fatal "No arguments are allowed here"
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
#__repack_rpm_base #__repack_rpm_base
#rm -f /var/lib/rpm/__db* #rm -f /var/lib/rpm/__db*
a= rpm --rebuilddb a= rpm --rebuilddb
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -26,73 +26,73 @@ load_helper epm-repack ...@@ -26,73 +26,73 @@ load_helper epm-repack
__epm_pack() __epm_pack()
{ {
local packname="$1" local packname="$1"
local tarname="$2" local tarname="$2"
returntarname='' returntarname=''
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." [ -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"
trap "rm -rf $tmpdir" EXIT trap "rm -rf $tmpdir" EXIT
set_sudo set_sudo
export SUDO export SUDO
# TODO: inside () ? # TODO: inside () ?
export PATH=$PROGDIR:$PATH export PATH=$PROGDIR:$PATH
local bashopt='' local bashopt=''
[ -n "$verbose" ] && bashopt='-x' [ -n "$verbose" ] && bashopt='-x'
#info "Running $($script --description 2>/dev/null) ..." #info "Running $($script --description 2>/dev/null) ..."
( unset EPMCURDIR ; docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" ) || fatal ( unset EPMCURDIR ; docmd $CMDSHELL $bashopt $repackcode "$tarname" "$filefortarname" ) || fatal
returntarname="$(cat "$filefortarname")" || fatal "pack script $repackcode didn't set tarname" returntarname="$(cat "$filefortarname")" || fatal "pack script $repackcode didn't set tarname"
rm -rf $tmpdir rm -rf $tmpdir
[ -s "$returntarname" ] || fatal "pack script $repackcode didn't return tarname" [ -s "$returntarname" ] || fatal "pack script $repackcode didn't return tarname"
#local newname="$(basename "$returntarname")" #local newname="$(basename "$returntarname")"
# now it is by default in the current dir # now it is by default in the current dir
#if [ "$returntarname" != "$(realpath $newname)" ; then #if [ "$returntarname" != "$(realpath $newname)" ; then
# # repack put its result to the current dir # # repack put its result to the current dir
# mv -v $returntarname . || fatal # mv -v $returntarname . || fatal
#fi #fi
if [ -n "$download_only" ] ; then if [ -n "$download_only" ] ; then
return return
fi fi
trap "rm -v $returntarname" EXIT trap "rm -v $returntarname" EXIT
# FIXME: __epm_repack will drop trap # FIXME: __epm_repack will drop trap
repacked_pkgs='' repacked_pkgs=''
# repack to our target # repack to our target
if __epm_repack_if_needed $returntarname ; then if __epm_repack_if_needed $returntarname ; then
[ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname" [ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname"
# if repack is forced or repack rule (not disabled) is exists # if repack is forced or repack rule (not disabled) is exists
elif [ -n "$repack" ] || [ -z "$norepack" ] && __epm_have_repack_rule $returntarname ; then elif [ -n "$repack" ] || [ -z "$norepack" ] && __epm_have_repack_rule $returntarname ; then
__epm_repack "$returntarname" __epm_repack "$returntarname"
[ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname" [ -n "$repacked_pkgs" ] || fatal "Can't repack $returntarname"
fi fi
if [ -n "$repacked_pkgs" ] ; then if [ -n "$repacked_pkgs" ] ; then
rm -v $returntarname rm -v $returntarname
mv -v $repacked_pkgs . || fatal mv -v $repacked_pkgs . || fatal
pkgname=$(pwd)/"$(basename $repacked_pkgs)" pkgname=$(pwd)/"$(basename $repacked_pkgs)"
else else
pkgname="$returntarname" pkgname="$returntarname"
fi fi
if [ -n "$install" ] ; then if [ -n "$install" ] ; then
trap "rm -v $pkgname" EXIT trap "rm -v $pkgname" EXIT
docmd epm install $pkgname docmd epm install $pkgname
return return
fi fi
trap "" EXIT trap "" EXIT
} }
......
...@@ -23,169 +23,169 @@ __epm_packages_sort() ...@@ -23,169 +23,169 @@ __epm_packages_sort()
{ {
# FIXME: sort depends on --sort value # FIXME: sort depends on --sort value
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
# FIXME: space with quotes problems, use point instead # FIXME: space with quotes problems, use point instead
warmup_rpmbase warmup_rpmbase
docmd rpm -qa --queryformat "%{size}@%{name}-%{version}-%{release}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1 docmd rpm -qa --queryformat "%{size}@%{name}-%{version}-%{release}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1
;; ;;
*-dpkg) *-dpkg)
warmup_dpkgbase warmup_dpkgbase
docmd dpkg-query -W --showformat="\${Installed-Size}@\${Package}-\${Version}:\${Architecture}\n" $pkg_filenames | sed -e "s|@| |g" | sort -n -k1 docmd dpkg-query -W --showformat="\${Installed-Size}@\${Package}-\${Version}:\${Architecture}\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"
;; ;;
esac esac
} }
__aptcyg_print_full() __aptcyg_print_full()
{ {
#showcmd apt-cyg show #showcmd apt-cyg show
local VERSION=$(apt-cyg show "$1" | grep -m1 "^version: " | sed -e "s|^version: ||g") local VERSION=$(apt-cyg show "$1" | grep -m1 "^version: " | sed -e "s|^version: ||g")
echo "$1-$VERSION" echo "$1-$VERSION"
} }
__fo_pfn() __fo_pfn()
{ {
grep -v "^$" | grep -- "$pkg_filenames" grep -v "^$" | grep -- "$pkg_filenames"
} }
# TODO: we have a problem with error status here # TODO: we have a problem with error status here
epm_packages() epm_packages()
{ {
local CMD local CMD
[ -n "$sort" ] && __epm_packages_sort && return [ -n "$sort" ] && __epm_packages_sort && return
case $PMTYPE in case $PMTYPE in
*-dpkg) *-dpkg)
warmup_dpkgbase warmup_dpkgbase
# FIXME: strong equal # FIXME: strong equal
#CMD="dpkg -l $pkg_filenames" #CMD="dpkg -l $pkg_filenames"
CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}-\${Version}:\${Architecture}\n $pkg_filenames" CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}-\${Version}:\${Architecture}\n $pkg_filenames"
# TODO: ${Architecture} # TODO: ${Architecture}
[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}\n $pkg_filenames" [ -n "$short" ] && CMD="dpkg-query -W --showformat=\${db:Status-Abbrev}\${Package}\n $pkg_filenames"
showcmd $CMD showcmd $CMD
$CMD | grep "^i" | sed -e "s|.* ||g" | __fo_pfn $CMD | grep "^i" | sed -e "s|.* ||g" | __fo_pfn
return ;; return ;;
*-rpm) *-rpm)
warmup_rpmbase warmup_rpmbase
# FIXME: strong equal # FIXME: strong equal
CMD="rpm -qa $pkg_filenames" CMD="rpm -qa $pkg_filenames"
[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames" [ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
docmd $CMD docmd $CMD
return ;; return ;;
packagekit) packagekit)
docmd pkcon get-packages --filter installed docmd pkcon get-packages --filter installed
;; ;;
snappy) snappy)
CMD="snappy info" CMD="snappy info"
;; ;;
emerge) emerge)
CMD="qlist -I -C" CMD="qlist -I -C"
# print with colors for console output # print with colors for console output
isatty && CMD="qlist -I" isatty && CMD="qlist -I"
;; ;;
pkgsrc) pkgsrc)
CMD="pkg_info" CMD="pkg_info"
showcmd $CMD showcmd $CMD
$CMD | sed -e "s| .*||g" | __fo_pfn $CMD | sed -e "s| .*||g" | __fo_pfn
return ;; return ;;
pkgng) pkgng)
if [ -n "$pkg_filenames" ] ; then if [ -n "$pkg_filenames" ] ; then
CMD="pkg info -E $pkg_filenames" CMD="pkg info -E $pkg_filenames"
else else
CMD="pkg info" CMD="pkg info"
fi fi
showcmd $CMD showcmd $CMD
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
$CMD | sed -e "s| .*||g" | sed -e "s|-[0-9].*||g" | __fo_pfn $CMD | sed -e "s| .*||g" | sed -e "s|-[0-9].*||g" | __fo_pfn
else else
$CMD | sed -e "s| .*||g" | __fo_pfn $CMD | sed -e "s| .*||g" | __fo_pfn
fi fi
return ;; return ;;
pacman) pacman)
CMD="pacman -Qs $pkg_filenames" CMD="pacman -Qs $pkg_filenames"
showcmd $CMD showcmd $CMD
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
$CMD | sed -e "s| .*||g" -e "s|.*/||g" | __fo_pfn $CMD | sed -e "s| .*||g" -e "s|.*/||g" | __fo_pfn
return return
fi fi
;; ;;
npackd) npackd)
CMD="npackdcl list --status=installed" CMD="npackdcl list --status=installed"
# TODO: use search if pkg_filenames is not empty # TODO: use search if pkg_filenames is not empty
;; ;;
conary) conary)
CMD="conary query" CMD="conary query"
;; ;;
eopkg) eopkg)
CMD="eopkg list-installed" CMD="eopkg list-installed"
;; ;;
chocolatey) chocolatey)
CMD="chocolatey list" CMD="chocolatey list"
;; ;;
slackpkg) slackpkg)
CMD="ls -1 /var/log/packages/" CMD="ls -1 /var/log/packages/"
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
# FIXME: does not work for libjpeg-v8a # FIXME: does not work for libjpeg-v8a
# TODO: remove last 3 elements (if arch is second from the last?) # TODO: remove last 3 elements (if arch is second from the last?)
# FIXME this hack # FIXME this hack
docmd ls -1 /var/log/packages/ | sed -e "s|-[0-9].*||g" | sed -e "s|libjpeg-v8a.*|libjpeg|g" | __fo_pfn docmd ls -1 /var/log/packages/ | sed -e "s|-[0-9].*||g" | sed -e "s|libjpeg-v8a.*|libjpeg|g" | __fo_pfn
return return
fi fi
;; ;;
homebrew) homebrew)
docmd brew list | xargs -n1 echo docmd brew list | xargs -n1 echo
;; ;;
opkg) opkg)
CMD="opkg list-installed" CMD="opkg list-installed"
;; ;;
apk) apk)
CMD="apk info" CMD="apk info"
;; ;;
tce) tce)
CMD="ls -1 /usr/local/tce.installed" CMD="ls -1 /usr/local/tce.installed"
;; ;;
guix) guix)
CMD="guix package -I" CMD="guix package -I"
;; ;;
appget) appget)
CMD="appget list" CMD="appget list"
;; ;;
winget) winget)
info "Use appget instead of winget" info "Use appget instead of winget"
return 0 return 0
;; ;;
xbps) xbps)
CMD="xbps-query -l" CMD="xbps-query -l"
showcmd $CMD showcmd $CMD
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
$CMD | sed -e "s|^ii ||g" -e "s| .*||g" -e "s|\(.*\)-.*|\1|g" | __fo_pfn $CMD | sed -e "s|^ii ||g" -e "s| .*||g" -e "s|\(.*\)-.*|\1|g" | __fo_pfn
else else
$CMD | sed -e "s|^ii ||g" -e "s| .*||g" | __fo_pfn $CMD | sed -e "s|^ii ||g" -e "s| .*||g" | __fo_pfn
fi fi
return 0 return 0
;; ;;
android) android)
CMD="pm list packages" CMD="pm list packages"
showcmd $CMD showcmd $CMD
$CMD | sed -e "s|^package:||g" | __fo_pfn $CMD | sed -e "s|^package:||g" | __fo_pfn
return return
;; ;;
aptcyg) aptcyg)
CMD="apt-cyg list $pkg_filenames" CMD="apt-cyg list $pkg_filenames"
if [ -z "$short" ] ; then if [ -z "$short" ] ; then
showcmd $CMD showcmd $CMD
# TODO: fix this slow way # TODO: fix this slow way
for i in $($CMD) ; do for i in $($CMD) ; do
__aptcyg_print_full $i __aptcyg_print_full $i
done done
return return
fi fi
;; ;;
*) *)
fatal "Have no suitable query command for $PMTYPE" fatal "Have no suitable query command for $PMTYPE"
;; ;;
esac esac
docmd $CMD | __fo_pfn docmd $CMD | __fo_pfn
......
...@@ -23,48 +23,48 @@ epm_vardir=/var/lib/eepm ...@@ -23,48 +23,48 @@ epm_vardir=/var/lib/eepm
__check_installed_app() __check_installed_app()
{ {
[ -s $epm_vardir/installed-app ] || return 1 [ -s $epm_vardir/installed-app ] || return 1
grep -q -- "^$1\$" $epm_vardir/installed-app grep -q -- "^$1\$" $epm_vardir/installed-app
} }
__save_installed_app() __save_installed_app()
{ {
[ -d "$epm_vardir" ] || return 0 [ -d "$epm_vardir" ] || return 0
__check_installed_app "$1" && return 0 __check_installed_app "$1" && return 0
echo "$1" | sudorun tee -a $epm_vardir/installed-app >/dev/null echo "$1" | sudorun tee -a $epm_vardir/installed-app >/dev/null
} }
__remove_installed_app() __remove_installed_app()
{ {
[ -s $epm_vardir/installed-app ] || return 0 [ -s $epm_vardir/installed-app ] || return 0
local i local i
for i in $* ; do for i in $* ; do
sudorun sed -i "/^$i$/d" $epm_vardir/installed-app sudorun sed -i "/^$i$/d" $epm_vardir/installed-app
done done
return 0 return 0
} }
__is_app_installed() __is_app_installed()
{ {
__run_script "$1" --installed "$2" __run_script "$1" --installed "$2"
return return
} }
__run_script() __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." [ -f "$script.rpmnew" ] && warning "There is .rpmnew file(s) in $psdir dir. The play script can be outdated."
shift shift
( unset EPMCURDIR ; export PATH=$PROGDIR:$PATH ; $script "$@" ) ( unset EPMCURDIR ; export PATH=$PROGDIR:$PATH ; $script "$@" )
return return
} }
__get_app_package() __get_app_package()
{ {
__run_script "$1" --package-name "$2" 2>/dev/null __run_script "$1" --package-name "$2" 2>/dev/null
} }
......
...@@ -31,15 +31,15 @@ warmup_bases ...@@ -31,15 +31,15 @@ warmup_bases
pkg_names=$(__epm_get_hilevel_name $pkg_names) pkg_names=$(__epm_get_hilevel_name $pkg_names)
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
docmd apt-cache policy $pkg_names docmd apt-cache policy $pkg_names
;; ;;
packagekit) packagekit)
docmd pkcon resolve $pkg_names docmd pkcon resolve $pkg_names
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -22,21 +22,21 @@ ...@@ -22,21 +22,21 @@
# TODO: rpm only # TODO: rpm only
rpm_query_package_format_field() rpm_query_package_format_field()
{ {
local FORMAT="$1\n" local FORMAT="$1\n"
shift shift
local INSTALLED="" local INSTALLED=""
# if a file, ad -p for get from rpm base # if a file, ad -p for get from rpm base
if [ -f "$1" ] ; then if [ -f "$1" ] ; then
INSTALLED="-p" INSTALLED="-p"
fi fi
a= rpmquery $INSTALLED --queryformat "$FORMAT" "$@" a= rpmquery $INSTALLED --queryformat "$FORMAT" "$@"
} }
rpm_query_package_field() rpm_query_package_field()
{ {
local FORMAT="%{$1}" local FORMAT="%{$1}"
shift shift
rpm_query_package_format_field "$FORMAT" "$@" rpm_query_package_format_field "$FORMAT" "$@"
} }
dpkg_query_package_format_field() dpkg_query_package_format_field()
...@@ -141,13 +141,13 @@ print_pkg_name() ...@@ -141,13 +141,13 @@ print_pkg_name()
# algorithm: list all files in PKGDIR, print packages with our source pkg name # algorithm: list all files in PKGDIR, print packages with our source pkg name
print_binpkgfilelist() print_binpkgfilelist()
{ {
local PKGDIR=$1 local PKGDIR=$1
local PKGNAME=$(basename $2) local PKGNAME=$(basename $2)
find "$PKGDIR" ! -name '*\.src\.rpm' -name '*\.rpm' -execdir \ find "$PKGDIR" ! -name '*\.src\.rpm' -name '*\.rpm' -execdir \
rpmquery -p --qf='%{sourcerpm}\t%{name}-%{version}-%{release}.%{arch}.rpm\n' "{}" \; \ rpmquery -p --qf='%{sourcerpm}\t%{name}-%{version}-%{release}.%{arch}.rpm\n' "{}" \; \
| grep "^$PKGNAME[[:space:]].*" \ | grep "^$PKGNAME[[:space:]].*" \
| cut -f2 \ | cut -f2 \
| xargs -n1 -I "{}" echo -n "$PKGDIR/{} " | xargs -n1 -I "{}" echo -n "$PKGDIR/{} "
} }
# TODO: need try detect more strict # TODO: need try detect more strict
......
...@@ -22,18 +22,18 @@ load_helper epm-query_file ...@@ -22,18 +22,18 @@ load_helper epm-query_file
# Inspired by http://www.altlinux.org/Tips # Inspired by http://www.altlinux.org/Tips
epm_programs() epm_programs()
{ {
case $DISTRNAME in case $DISTRNAME in
FreeBSD|NetBSD|OpenBSD|Solaris) FreeBSD|NetBSD|OpenBSD|Solaris)
local DESKTOPDIR=/usr/local/share/applications local DESKTOPDIR=/usr/local/share/applications
;; ;;
*) *)
local DESKTOPDIR=/usr/share/applications local DESKTOPDIR=/usr/share/applications
;; ;;
esac esac
[ -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 -print0 -name "*.desktop" | xargs -0 $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 -print0 -name "*.desktop" | \ find $DESKTOPDIR -type f -print0 -name "*.desktop" | \
xargs -0 $0 -qf --quiet --short | sort -u xargs -0 $0 -qf --quiet --short | sort -u
} }
...@@ -22,79 +22,79 @@ load_helper epm-print ...@@ -22,79 +22,79 @@ load_helper epm-print
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)"
case $PKGTYPE in case $PKGTYPE in
rpm) rpm)
assure_exists rpm assure_exists rpm
docmd rpm -q --provides -p $pkg_files docmd rpm -q --provides -p $pkg_files
;; ;;
deb) deb)
assure_exists dpkg assure_exists dpkg
# FIXME: will we provide ourself? # FIXME: will we provide ourself?
docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g" docmd dpkg -I $pkg_files | grep "^ *Provides:" | sed "s|^ *Provides:||g"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
epm_provides_names() epm_provides_names()
{ {
local pkg_names="$*" local pkg_names="$*"
local CMD local CMD
[ -n "$pkg_names" ] || return [ -n "$pkg_names" ] || return
# by package name # by package name
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
# TODO: separate this function to two section # TODO: separate this function to two section
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --provides" CMD="rpm -q --provides"
else else
EXTRA_SHOWDOCMD=' | grep "Provides:"' EXTRA_SHOWDOCMD=' | grep "Provides:"'
docmd apt-cache show $pkg_names | grep "Provides:" docmd apt-cache show $pkg_names | grep "Provides:"
return return
fi fi
;; ;;
urpm-rpm|zypper-rpm|yum-rpm|dnf-rpm) urpm-rpm|zypper-rpm|yum-rpm|dnf-rpm)
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --provides" CMD="rpm -q --provides"
else else
fatal "FIXME: use hi level commands" fatal "FIXME: use hi level commands"
fi fi
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
CMD="equery files" CMD="equery files"
;; ;;
# yum-rpm) # yum-rpm)
# CMD="yum deplist" # CMD="yum deplist"
# ;; # ;;
pkgng) pkgng)
CMD="pkg info -b" CMD="pkg info -b"
;; ;;
apt-dpkg) apt-dpkg)
# 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 "^Provides:" | sed "s|^Provides:||g" a='' dpkg -s $pkg_names | grep "^Provides:" | sed "s|^Provides:||g"
return return
else else
EXTRA_SHOWDOCMD=' | grep "Provides:"' EXTRA_SHOWDOCMD=' | grep "Provides:"'
docmd apt-cache show $pkg_names | grep "Provides:" | sed -e 's|, |\n|g' | grep -v "^Provides:" docmd apt-cache show $pkg_names | grep "Provides:" | sed -e 's|, |\n|g' | grep -v "^Provides:"
return return
fi fi
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
docmd $CMD $pkg_names docmd $CMD $pkg_names
...@@ -103,9 +103,9 @@ docmd $CMD $pkg_names ...@@ -103,9 +103,9 @@ docmd $CMD $pkg_names
epm_provides() epm_provides()
{ {
[ -n "$pkg_filenames" ] || fatal "Provides: package name is missed" [ -n "$pkg_filenames" ] || fatal "Provides: package name is missed"
epm_provides_files $pkg_files epm_provides_files $pkg_files
# shellcheck disable=SC2046 # shellcheck disable=SC2046
epm_provides_names $(print_name $pkg_names) epm_provides_names $(print_name $pkg_names)
} }
...@@ -23,309 +23,309 @@ load_helper epm-print ...@@ -23,309 +23,309 @@ load_helper epm-print
# pkg suffix # pkg suffix
__print_with_arch_suffix() __print_with_arch_suffix()
{ {
local pkg="$1" local pkg="$1"
local suffix="$2" local suffix="$2"
[ -n "$pkg" ] || return 1 [ -n "$pkg" ] || return 1
# do not change if some suffix already exists # do not change if some suffix already exists
echo "$pkg" | grep -q "(x86-32)$" && echo "$pkg" | sed -e "s|(x86-32)$|.i686|" && return 1 echo "$pkg" | grep -q "(x86-32)$" && echo "$pkg" | sed -e "s|(x86-32)$|.i686|" && return 1
echo "$pkg" | grep "\.x86_64$" && return 1 echo "$pkg" | grep "\.x86_64$" && return 1
echo "$pkg" | grep "\.noarch$" && return 1 echo "$pkg" | grep "\.noarch$" && return 1
echo "$pkg" | grep "\.i[56]86$" && return 1 echo "$pkg" | grep "\.i[56]86$" && return 1
echo "$pkg$suffix" echo "$pkg$suffix"
} }
# add suffix .x86_64 if we have 64 arch # add suffix .x86_64 if we have 64 arch
exp_with_arch_suffix() exp_with_arch_suffix()
{ {
local suffix local suffix
[ "$($DISTRVENDOR -a)" = "x86_64" ] || { cat ; return ; } [ "$($DISTRVENDOR -a)" = "x86_64" ] || { cat ; return ; }
[ "$DISTRNAME" = "ROSA" ] && { cat ; return ; } [ "$DISTRNAME" = "ROSA" ] && { cat ; return ; }
# TODO: it is ok for ALT rpm to remove with this suffix # TODO: it is ok for ALT rpm to remove with this suffix
# TODO: separate install and remove? # TODO: separate install and remove?
case $PMTYPE in case $PMTYPE in
yum-rpm|dnf-rpm) yum-rpm|dnf-rpm)
suffix=".x86_64" suffix=".x86_64"
;; ;;
*) *)
cat cat
return return
;; ;;
esac esac
# TODO: use estrlist or some function to do it # TODO: use estrlist or some function to do it
local pkg local pkg
for pkg in $(cat) ; do for pkg in $(cat) ; do
local p local p
# check only packages without arch # check only packages without arch
p="$(__print_with_arch_suffix "$pkg" .i686)" || { echo "$pkg" ; continue ; } p="$(__print_with_arch_suffix "$pkg" .i686)" || { echo "$pkg" ; continue ; }
# add arch suffix only if arch package already installed (otherwise we don't know package arch) # add arch suffix only if arch package already installed (otherwise we don't know package arch)
is_installed "$p" || { echo "$pkg" ; continue ; } is_installed "$p" || { echo "$pkg" ; continue ; }
echo "$pkg.x86_64" echo "$pkg.x86_64"
done done
} }
_get_grep_exp() _get_grep_exp()
{ {
local def="^$1$" local def="^$1$"
[ "$PMTYPE" != "emerge" ] && echo "$def" && return [ "$PMTYPE" != "emerge" ] && echo "$def" && return
# Gentoo hack: support for short package form # Gentoo hack: support for short package form
echo "$1" | grep -q "/" && echo "$def" && return echo "$1" | grep -q "/" && echo "$def" && return
echo "/$1$" echo "/$1$"
} }
# TODO: combine with -qa (the difference only in return status now) # TODO: combine with -qa (the difference only in return status now)
_shortquery_via_packages_list() _shortquery_via_packages_list()
{ {
local res=1 local res=1
local grepexp local grepexp
local firstpkg=$1 local firstpkg=$1
shift shift
grepexp=$(_get_grep_exp $firstpkg) grepexp=$(_get_grep_exp $firstpkg)
# TODO: we miss status due grep # TODO: we miss status due grep
# Note: double call due stderr redirect # Note: double call due stderr redirect
# Note: we use short=1 here due grep by ^name$ # Note: we use short=1 here due grep by ^name$
# separate first line for print out command # separate first line for print out command
(short=1 pkg_filenames=$firstpkg epm_packages | grep -- "$grepexp") && res=0 || res=1 (short=1 pkg_filenames=$firstpkg epm_packages | grep -- "$grepexp") && res=0 || res=1
local pkg local pkg
for pkg in "$@" ; do for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg) grepexp=$(_get_grep_exp $pkg)
(short=1 pkg_filenames=$pkg epm_packages 2>/dev/null) | grep -- "$grepexp" || res=1 (short=1 pkg_filenames=$pkg epm_packages 2>/dev/null) | grep -- "$grepexp" || res=1
done done
# TODO: print in query (for user): 'warning: package $pkg is not installed' # TODO: print in query (for user): 'warning: package $pkg is not installed'
return $res return $res
} }
# Note: modified from _shortquery_via_packages_list # Note: modified from _shortquery_via_packages_list
# TODO: non optimal double epm packages call # TODO: non optimal double epm packages call
_query_via_packages_list() _query_via_packages_list()
{ {
local res=1 local res=1
local grepexp local grepexp
local firstpkg=$1 local firstpkg=$1
shift shift
grepexp=$(_get_grep_exp $firstpkg) grepexp=$(_get_grep_exp $firstpkg)
# TODO: we miss status due grep # TODO: we miss status due grep
# TODO: grep correctly # TODO: grep correctly
# Note: double call due stderr redirect # Note: double call due stderr redirect
# Note: we use short=1 here due grep by ^name$ # Note: we use short=1 here due grep by ^name$
# separate first line for print out command # separate first line for print out command
(short=1 pkg_filenames=$firstpkg epm_packages) | grep -q -- "$grepexp" && (quiet=1 pkg_filenames=$firstpkg epm_packages) && res=0 || res=1 (short=1 pkg_filenames=$firstpkg epm_packages) | grep -q -- "$grepexp" && (quiet=1 pkg_filenames=$firstpkg epm_packages) && res=0 || res=1
local pkg local pkg
for pkg in "$@" ; do for pkg in "$@" ; do
grepexp=$(_get_grep_exp $pkg) grepexp=$(_get_grep_exp $pkg)
(short=1 pkg_filenames=$pkg epm_packages 2>/dev/null) | grep -q -- "$grepexp" && (quiet=1 pkg_filenames=$pkg epm_packages) || res=1 (short=1 pkg_filenames=$pkg epm_packages 2>/dev/null) | grep -q -- "$grepexp" && (quiet=1 pkg_filenames=$pkg epm_packages) || res=1
done done
return $res return $res
} }
# internal use only, for installed package # internal use only, for installed package
__epm_get_hilevel_nameform() __epm_get_hilevel_nameform()
{ {
[ -n "$*" ] || return [ -n "$*" ] || return
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# use # as delimeter for apt # use # as delimeter for apt
local pkg local pkg
pkg=$(rpm -q --queryformat "%{NAME}=%{SERIAL}:%{VERSION}-%{RELEASE}\n" -- $1) pkg=$(rpm -q --queryformat "%{NAME}=%{SERIAL}:%{VERSION}-%{RELEASE}\n" -- $1)
# for case if serial is missed # for case if serial is missed
echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}#%{VERSION}-%{RELEASE}\n" -- $1) echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}#%{VERSION}-%{RELEASE}\n" -- $1)
# HACK: can use only for multiple install packages like kernel # HACK: can use only for multiple install packages like kernel
echo $pkg | grep -q kernel || return 1 echo $pkg | grep -q kernel || return 1
echo $pkg echo $pkg
return return
;; ;;
yum-rpm|dnf-rpm) yum-rpm|dnf-rpm)
# just use strict version with Epoch and Serial # just use strict version with Epoch and Serial
local pkg local pkg
#pkg=$(rpm -q --queryformat "%{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" -- $1) #pkg=$(rpm -q --queryformat "%{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" -- $1)
#echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" -- $1) #echo $pkg | grep -q "(none)" && pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" -- $1)
pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" -- $1) pkg=$(rpm -q --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" -- $1)
echo $pkg echo $pkg
return return
;; ;;
*) *)
return 1 return 1
;; ;;
esac esac
} }
# for local installed packages only # for local installed packages only
# used from epm remove # used from epm remove
__epm_get_hilevel_name() __epm_get_hilevel_name()
{ {
local i local i
for i in $@ ; do for i in $@ ; do
local pkg local pkg
# get short form in pkg # get short form in pkg
# FIXME: where we use it? continue or pkg=$i? # FIXME: where we use it? continue or pkg=$i?
quiet=1 pkg=$(__epm_query_shortname "$i") || pkg="$i" #continue # drop not installed packages 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
} }
__epm_query_file() __epm_query_file()
{ {
local CMD local CMD
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
CMD="rpm -qp" CMD="rpm -qp"
[ -n "$short" ] && CMD="rpm -qp --queryformat %{name}\n" [ -n "$short" ] && CMD="rpm -qp --queryformat %{name}\n"
;; ;;
*-dpkg) *-dpkg)
CMD="dpkg-deb --show --showformat=\${Package}-\${Version}\n" CMD="dpkg-deb --show --showformat=\${Package}-\${Version}\n"
[ -n "$short" ] && CMD="dpkg-query --show --showformat=\${Package}\n" [ -n "$short" ] && CMD="dpkg-query --show --showformat=\${Package}\n"
;; ;;
*) *)
fatal "Do not know command for query file package" fatal "Do not know command for query file package"
;; ;;
esac esac
docmd $CMD -- $@ docmd $CMD -- $@
} }
# hack: dpkg -W will print names for removed packages too (until newest Ubuntu) # hack: dpkg -W will print names for removed packages too (until newest Ubuntu)
__epm_query_dpkg_check() __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
} }
__epm_query_name() __epm_query_name()
{ {
local CMD local CMD
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
CMD="rpm -q" CMD="rpm -q"
;; ;;
*-dpkg) *-dpkg)
#docmd dpkg -l $@ | grep "^ii" #docmd dpkg -l $@ | grep "^ii"
#CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n" #CMD="dpkg-query -W --showformat=\${Package}-\${Version}\n"
docmd dpkg-query -W "--showformat=\${Package}-\${Version}\n" -- $@ || return docmd dpkg-query -W "--showformat=\${Package}-\${Version}\n" -- $@ || return
__epm_query_dpkg_check $@ || return __epm_query_dpkg_check $@ || return
return return
;; ;;
npackd) npackd)
docmd npackdcl path --package=$1 docmd npackdcl path --package=$1
return return
;; ;;
conary) conary)
CMD="conary query" CMD="conary query"
;; ;;
eopkg) eopkg)
showcmd eopkg blame $1 showcmd eopkg blame $1
local str local str
str="$(a= eopkg blame $1 | grep "^Name")" str="$(a= eopkg blame $1 | grep "^Name")"
[ -n "$str" ] || return 1 [ -n "$str" ] || return 1
echo "$str" | sed -e "s|Name[[:space:]]*: \(.*\), version: \(.*\), release: \(.*\)|\1-\2-\3|" echo "$str" | sed -e "s|Name[[:space:]]*: \(.*\), version: \(.*\), release: \(.*\)|\1-\2-\3|"
return return
;; ;;
#homebrew) #homebrew)
# showcmd "brew info $1" # showcmd "brew info $1"
# local HBRESULT # local HBRESULT
# HBRESULT="$(brew info "$1" 2>/dev/null)" || return # HBRESULT="$(brew info "$1" 2>/dev/null)" || return
# echo "$HBRESULT" | grep -q "Not installed" && return 1 # echo "$HBRESULT" | grep -q "Not installed" && return 1
# echo "$1" # echo "$1"
# return 0 # return 0
# ;; # ;;
pacman) pacman)
docmd pacman -Q $@ docmd pacman -Q $@
return 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"
# ;; # ;;
# Note: slackpkg info pkgname # Note: slackpkg info pkgname
*) *)
# default slow workaround # default slow workaround
_query_via_packages_list $@ _query_via_packages_list $@
return return
;; ;;
esac esac
docmd $CMD $@ docmd $CMD $@
} }
__epm_query_shortname() __epm_query_shortname()
{ {
local CMD local CMD
[ -z "$*" ] && return [ -z "$*" ] && return
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
showcmd rpm -q --queryformat '%{name}\n' -- $@ showcmd rpm -q --queryformat '%{name}\n' -- $@
a='' rpm -q --queryformat '%{name}\n' -- $@ a='' rpm -q --queryformat '%{name}\n' -- $@
return return
;; ;;
*-dpkg) *-dpkg)
#CMD="dpkg-query -W --showformat=\${Package}\n" #CMD="dpkg-query -W --showformat=\${Package}\n"
docmd dpkg-query -W "--showformat=\${Package}\n" -- $@ || return docmd dpkg-query -W "--showformat=\${Package}\n" -- $@ || return
__epm_query_dpkg_check $@ || return __epm_query_dpkg_check $@ || return
return return
;; ;;
npackd) npackd)
docmd npackdcl path --package=$1 docmd npackdcl path --package=$1
return return
;; ;;
conary) conary)
CMD="conary query" CMD="conary query"
;; ;;
eopkg) eopkg)
showcmd eopkg blame $1 showcmd eopkg blame $1
local str local str
str="$(a= eopkg blame $1 | grep "^Name")" str="$(a= eopkg blame $1 | grep "^Name")"
[ -n "$str" ] || return 1 [ -n "$str" ] || return 1
echo "$str" | sed -e "s|Name[[:space:]]*: \(.*\), version: \(.*\), release: \(.*\)|\1|" echo "$str" | sed -e "s|Name[[:space:]]*: \(.*\), version: \(.*\), release: \(.*\)|\1|"
return return
;; ;;
homebrew) homebrew)
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 # TODO: check status
#pacman) #pacman)
# docmd pacman -Q $@ | sed -e "s| .*||g" # docmd pacman -Q $@ | sed -e "s| .*||g"
# return # 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"
# ;; # ;;
# Note: slackpkg info pkgname # Note: slackpkg info pkgname
*) *)
# default slow workaround # default slow workaround
_shortquery_via_packages_list $@ _shortquery_via_packages_list $@
return return
;; ;;
esac esac
docmd $CMD $@ docmd $CMD $@
} }
...@@ -335,21 +335,21 @@ __epm_query_shortname() ...@@ -335,21 +335,21 @@ __epm_query_shortname()
# check if pkg is installed # check if pkg is installed
is_installed() is_installed()
{ {
(quiet=1 __epm_query_name "$@") >/dev/null 2>/dev/null (quiet=1 __epm_query_name "$@") >/dev/null 2>/dev/null
} }
epm_query() epm_query()
{ {
[ -n "$pkg_filenames" ] || fatal "Query: package name is missed" [ -n "$pkg_filenames" ] || fatal "Query: package name is missed"
__epm_query_file $pkg_files || return __epm_query_file $pkg_files || return
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
# shellcheck disable=SC2046 # shellcheck disable=SC2046
__epm_query_shortname $(print_name $pkg_names) || return __epm_query_shortname $(print_name $pkg_names) || return
else else
# shellcheck disable=SC2046 # shellcheck disable=SC2046
__epm_query_name $(print_name $pkg_names) || return __epm_query_name $(print_name $pkg_names) || return
fi fi
} }
...@@ -22,67 +22,67 @@ ...@@ -22,67 +22,67 @@
# TODO: check for lib64/name situations # TODO: check for lib64/name situations
__abs_filename() __abs_filename()
{ {
if echo "$1" | grep -q "/" ; then if echo "$1" | grep -q "/" ; then
echo "$1" echo "$1"
return return
fi fi
if [ -e "$1" ] ; then if [ -e "$1" ] ; then
echo "$(pwd)/$1" echo "$(pwd)/$1"
return return
fi fi
echo "$1" echo "$1"
} }
__do_query_real_file() __do_query_real_file()
{ {
local TOFILE local TOFILE
# get canonical path # get canonical path
if [ -e "$1" ] ; then if [ -e "$1" ] ; then
TOFILE="$(__abs_filename "$1")" TOFILE="$(__abs_filename "$1")"
else else
TOFILE=$(print_command_path "$1" || 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
fi fi
[ -n "$TOFILE" ] || return [ -n "$TOFILE" ] || return
local RES local RES
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
__do_short_query "$TOFILE" __do_short_query "$TOFILE"
RES=$? RES=$?
else else
__do_query "$TOFILE" __do_query "$TOFILE"
RES=$? RES=$?
fi fi
# get value of symbolic link # get value of symbolic link
if [ -L "$TOFILE" ] ; then if [ -L "$TOFILE" ] ; then
local LINKTO local LINKTO
LINKTO=$(readlink -- "$TOFILE") LINKTO=$(readlink -- "$TOFILE")
info " > $TOFILE is link to $LINKTO" info " > $TOFILE is link to $LINKTO"
LINKTO=$(readlink -f -- "$TOFILE") LINKTO=$(readlink -f -- "$TOFILE")
__do_query_real_file "$LINKTO" __do_query_real_file "$LINKTO"
return return
else else
return $RES return $RES
fi fi
} }
dpkg_print_name_version() dpkg_print_name_version()
{ {
local ver i local ver i
for i in "$@" ; do for i in "$@" ; do
[ -n "$i" ] || continue [ -n "$i" ] || continue
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"
else else
echo "$i-$ver" echo "$i-$ver"
fi fi
done done
} }
......
...@@ -22,16 +22,16 @@ load_helper epm-search ...@@ -22,16 +22,16 @@ load_helper epm-search
__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()
{ {
[ -n "$pkg_filenames" ] || fatal "Please, use search with some argument or run epmqa for get all packages." [ -n "$pkg_filenames" ] || fatal "Please, use search with some argument or run epmqa for get all packages."
# FIXME: do it better # FIXME: do it better
local MGS local MGS
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")
} }
...@@ -23,45 +23,45 @@ load_helper epm-sh-warmup ...@@ -23,45 +23,45 @@ load_helper epm-sh-warmup
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg # copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
epm_reinstall_names() epm_reinstall_names()
{ {
[ -n "$1" ] || return [ -n "$1" ] || return
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
local APTOPTIONS="$(subst_option non_interactive -y)" local APTOPTIONS="$(subst_option non_interactive -y)"
sudocmd apt-get --reinstall $APTOPTIONS install $@ sudocmd apt-get --reinstall $APTOPTIONS install $@
return ;; return ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude reinstall $@ sudocmd aptitude reinstall $@
return ;; return ;;
packagekit) packagekit)
warning "Please send me the correct command form for it" warning "Please send me the correct command form for it"
docmd pkcon install --allow-reinstall $@ docmd pkcon install --allow-reinstall $@
return ;; return ;;
yum-rpm) yum-rpm)
sudocmd yum reinstall $@ sudocmd yum reinstall $@
return ;; return ;;
dnf-rpm) dnf-rpm)
sudocmd dnf reinstall $@ sudocmd dnf reinstall $@
return ;; return ;;
homebrew) homebrew)
sudocmd brew reinstall $@ sudocmd brew reinstall $@
return ;; return ;;
pkgng) pkgng)
sudocmd pkg install -f $@ sudocmd pkg install -f $@
return ;; return ;;
opkg) opkg)
sudocmd opkg --force-reinstall install $@ sudocmd opkg --force-reinstall install $@
return ;; return ;;
eopkg) eopkg)
sudocmd eopkg --reinstall install $@ sudocmd eopkg --reinstall install $@
return ;; return ;;
slackpkg) slackpkg)
sudocmd_foreach "/usr/sbin/slackpkg reinstall" $@ sudocmd_foreach "/usr/sbin/slackpkg reinstall" $@
return ;; return ;;
esac esac
# fallback to generic install # fallback to generic install
epm_install_names $@ epm_install_names $@
} }
epm_reinstall_files() epm_reinstall_files()
......
...@@ -21,151 +21,151 @@ load_helper epm-release_upgrade ...@@ -21,151 +21,151 @@ load_helper epm-release_upgrade
get_prev_release() get_prev_release()
{ {
local FROM="$1" local FROM="$1"
case "$FROM" in case "$FROM" in
"p8") "p8")
echo "p7" ;; echo "p7" ;;
"p9") "p9")
echo "p8" ;; echo "p8" ;;
"p10") "p10")
echo "p9" ;; echo "p9" ;;
"c7") "c7")
echo "c6" ;; echo "c6" ;;
"c8") "c8")
echo "c7" ;; echo "c7" ;;
"c8.1") "c8.1")
echo "c8" ;; echo "c8" ;;
"c8.2") "c8.2")
echo "c8.1" ;; echo "c8.1" ;;
"c9f1") "c9f1")
echo "c8" ;; echo "c8" ;;
"c9f2") "c9f2")
echo "c9f1" ;; echo "c9f1" ;;
"10") "10")
echo "9" ;; echo "9" ;;
*) *)
echo "$FROM" ;; echo "$FROM" ;;
esac esac
} }
# FIXME: see epm_release_upgrade # FIXME: see epm_release_upgrade
epm_release_downgrade() epm_release_downgrade()
{ {
assure_root assure_root
assure_safe_run assure_safe_run
info "Starting upgrade/switch whole system to other release" info "Starting upgrade/switch whole system to other release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux" info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
cd /tmp || fatal cd /tmp || fatal
# TODO: it is possible eatmydata does not do his work # TODO: it is possible eatmydata does not do his work
export EPMNOEATMYDATA=1 export EPMNOEATMYDATA=1
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__epm_ru_update || fatal __epm_ru_update || fatal
# try to detect current release by repo # try to detect current release by repo
if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
local dv local dv
dv="$(__detect_alt_release_by_repo)" dv="$(__detect_alt_release_by_repo)"
if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then
DISTRVERSION="$dv" DISTRVERSION="$dv"
info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)" info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)"
fi fi
fi fi
TARGET="" TARGET=""
[ -n "$3" ] && fatal "Too many args: $*" [ -n "$3" ] && fatal "Too many args: $*"
if [ -n "$2" ] ; then if [ -n "$2" ] ; then
DISTRVERSION="$1" DISTRVERSION="$1"
info "Force current distro version as $DISTRVERSION" info "Force current distro version as $DISTRVERSION"
TARGET="$2" TARGET="$2"
elif [ -n "$1" ] ; then elif [ -n "$1" ] ; then
TARGET="$1" TARGET="$1"
fi fi
[ -n "$TARGET" ] || TARGET="$(get_prev_release $DISTRVERSION)" [ -n "$TARGET" ] || TARGET="$(get_prev_release $DISTRVERSION)"
__alt_repofix __alt_repofix
__switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully downgraded to the previous release '$TARGET'." __switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully downgraded to the previous release '$TARGET'."
return 0 return 0
;; ;;
*) *)
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
#docmd epm update #docmd epm update
info "Have no idea how to downgrade $DISTRNAME" info "Have no idea how to downgrade $DISTRNAME"
;; ;;
*-dpkg) *-dpkg)
assure_exists do-release-upgrade update-manager-core assure_exists do-release-upgrade update-manager-core
sudocmd do-release-upgrade sudocmd do-release-upgrade
;; ;;
packagekit) packagekit)
docmd pkcon upgrade-system "$@" docmd pkcon upgrade-system "$@"
;; ;;
yum-rpm) yum-rpm)
docmd epm install rpm yum docmd epm install rpm yum
sudocmd yum clean all sudocmd yum clean all
info "Try manually:" info "Try manually:"
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
showcmd epm Upgrade showcmd epm Upgrade
;; ;;
dnf-rpm) dnf-rpm)
info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info" info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info"
docmd epm install dnf docmd epm install dnf
#docmd epm install epel-release yum-utils #docmd epm install epel-release yum-utils
sudocmd dnf --refresh upgrade sudocmd dnf --refresh upgrade
sudocmd dnf clean all sudocmd dnf clean all
assure_exists dnf-plugin-system-upgrade assure_exists dnf-plugin-system-upgrade
sudocmd dnf upgrade --refresh sudocmd dnf upgrade --refresh
local RELEASEVER="$1" local RELEASEVER="$1"
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1)) [ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
#[ -n "$RELEASEVER" ] || fatal "Run me with new version" #[ -n "$RELEASEVER" ] || fatal "Run me with new version"
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER" confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
# TODO: from docs: # TODO: from docs:
# dnf system-upgrade reboot # dnf system-upgrade reboot
# FIXME: download all packages again # FIXME: download all packages again
sudocmd dnf distro-sync --releasever=$RELEASEVER sudocmd dnf distro-sync --releasever=$RELEASEVER
info "Run epm autoorphans to remove orphaned packages" info "Run epm autoorphans to remove orphaned packages"
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi.removemedia -av sudocmd urpmi.removemedia -av
info "Try do manually:" info "Try do manually:"
showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/ showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
sudocmd urpmi --auto-update --replacefiles sudocmd urpmi --auto-update --replacefiles
;; ;;
zypper-rpm) zypper-rpm)
docmd epm repolist docmd epm repolist
# TODO # TODO
# 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
showcmd zypper ref showcmd zypper ref
docmd epm update docmd epm update
docmd epm install rpm zypper docmd epm install rpm zypper
docmd epm upgrade docmd epm upgrade
;; ;;
pacman) pacman)
epm Upgrade epm Upgrade
;; ;;
conary) conary)
epm Upgrade epm Upgrade
;; ;;
emerge) emerge)
epm Upgrade epm Upgrade
;; ;;
guix) guix)
sudocmd guix pull --verbose sudocmd guix pull --verbose
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -23,185 +23,185 @@ load_helper epm-reposave ...@@ -23,185 +23,185 @@ load_helper epm-reposave
assure_safe_run() assure_safe_run()
{ {
if [ "$TERM" = "linux" ] ; then if [ "$TERM" = "linux" ] ; then
echo "You have the best choise to run the '# epm release-upgrade' from text console." echo "You have the best choise to run the '# epm release-upgrade' from text console."
return return
fi fi
if [ "$TERM" != "screen" ] ; then if [ "$TERM" != "screen" ] ; then
if [ -n "$force" ] ; then if [ -n "$force" ] ; then
echo "You force me running not under screen (TERM=$TERM now)! You can lost your system!" echo "You force me running not under screen (TERM=$TERM now)! You can lost your system!"
return return
else else
warning "It is very dangerous to upgrade to next release from a GUI (your TERM=$TERM)." warning "It is very dangerous to upgrade to next release from a GUI (your TERM=$TERM)."
if is_installed screen ; then if is_installed screen ; then
warning "You have 'screen' already installed, just run upgrade via screen (check https://losst.ru/komanda-screen-linux if needed)." warning "You have 'screen' already installed, just run upgrade via screen (check https://losst.ru/komanda-screen-linux if needed)."
else else
warning "It is recommended install 'screen' and run upgrade via screen (check https://losst.ru/komanda-screen-linux if needed)." warning "It is recommended install 'screen' and run upgrade via screen (check https://losst.ru/komanda-screen-linux if needed)."
fi fi
fatal "or run me with --force if you understand the risk." fatal "or run me with --force if you understand the risk."
fi fi
fi fi
# run under screen, check if systemd will not kill our processes # run under screen, check if systemd will not kill our processes
local res local res
if ! is_active_systemd systemd ; then if ! is_active_systemd systemd ; then
return return
fi fi
res="$(busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager KillUserProcesses)" res="$(busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager KillUserProcesses)"
if [ "$res" = "b false" ] ; then if [ "$res" = "b false" ] ; then
echo "Good news: systemd-logind will not kill your screen processes (KillUserProcesses=false)" echo "Good news: systemd-logind will not kill your screen processes (KillUserProcesses=false)"
return return
else else
if [ -n "$force" ] ; then if [ -n "$force" ] ; then
warning "You force runnning even if systemd-logind kills screen on disconnect" warning "You force runnning even if systemd-logind kills screen on disconnect"
else else
if ! epm installed systemd-settings-disable-kill-user-processes ; then if ! epm installed systemd-settings-disable-kill-user-processes ; then
docmd epm install systemd-settings-disable-kill-user-processes || fatal "Can't install the package above. Fix it or run with --force." docmd epm install systemd-settings-disable-kill-user-processes || fatal "Can't install the package above. Fix it or run with --force."
fi fi
# commented, will kick off the user from the system (ALT issue 50580) # commented, will kick off the user from the system (ALT issue 50580)
#docmd serv systemd-logind restart || fatal "Can't restart systemd-logind service. Fix it or run with --force." #docmd serv systemd-logind restart || fatal "Can't restart systemd-logind service. Fix it or run with --force."
fatal "Now you need relogin to the system. In this session your screen still will be killed." fatal "Now you need relogin to the system. In this session your screen still will be killed."
fi fi
fi fi
# check too: KillExcludeUsers # check too: KillExcludeUsers
# can continue # can continue
return 0 return 0
} }
__wcount() __wcount()
{ {
echo "$*" | wc -w echo "$*" | wc -w
} }
# TODO: remove it or move to distro_info # TODO: remove it or move to distro_info
__detect_alt_release_by_repo() __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 -E "[tpc][5-9]\.?[0-9]?/branch/" \ | grep -E "[tpc][5-9]\.?[0-9]?/branch/" \
| sed -e "s|.*\([tpc][5-9]\.\?[0-9]\?\)/branch.*|\1|g" \ | sed -e "s|.*\([tpc][5-9]\.\?[0-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
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 "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
return 1 return 1
} }
__get_conflict_release_pkg() __get_conflict_release_pkg()
{ {
epm qf --quiet --short /etc/fedora-release | head -n1 epm qf --quiet --short /etc/fedora-release | head -n1
} }
get_fix_release_pkg() get_fix_release_pkg()
{ {
local TOINSTALL='' local TOINSTALL=''
local FORCE='' local FORCE=''
if [ "$1" == "--force" ] ; then if [ "$1" == "--force" ] ; then
FORCE="$1" FORCE="$1"
shift shift
fi fi
local TO="$1" local TO="$1"
if [ "$TO" = "Sisyphus" ] ; then if [ "$TO" = "Sisyphus" ] ; then
TO="sisyphus" TO="sisyphus"
echo "apt-conf-$TO" echo "apt-conf-$TO"
# apt-conf-sisyphus and apt-conf-branch conflicts # apt-conf-sisyphus and apt-conf-branch conflicts
epm installed apt-conf-branch && echo "apt-conf-branch-" epm installed apt-conf-branch && echo "apt-conf-branch-"
else else
epm installed apt-conf-branch && echo "apt-conf-branch apt-conf-sisyphus-" epm installed apt-conf-branch && echo "apt-conf-branch apt-conf-sisyphus-"
fi fi
if [ "$FORCE" == "--force" ] ; then if [ "$FORCE" == "--force" ] ; then
# assure we have set needed release # assure we have set needed release
TOINSTALL="altlinux-release-$TO" TOINSTALL="altlinux-release-$TO"
else else
# just assure we have /etc/altlinux-release and switched from sisyphus # just assure we have /etc/altlinux-release and switched from sisyphus
if [ ! -s /etc/altlinux-release ] || epm qf /etc/altlinux-release | grep -q sisyphus ; then if [ ! -s /etc/altlinux-release ] || epm qf /etc/altlinux-release | grep -q sisyphus ; then
TOINSTALL="altlinux-release-$TO" TOINSTALL="altlinux-release-$TO"
fi fi
fi fi
#local AR="$(epm --short qf /etc/altlinux-release)" #local AR="$(epm --short qf /etc/altlinux-release)"
#if [ -n "$AR" ] && [ "$AR" != "$TOINSTALL" ] ; then #if [ -n "$AR" ] && [ "$AR" != "$TOINSTALL" ] ; then
# echo "$AR-" # echo "$AR-"
#fi #fi
# TODO: add bug? # TODO: add bug?
# workaround against obsoleted altlinux-release-sisyphus package from 2008 year # workaround against obsoleted altlinux-release-sisyphus package from 2008 year
[ "$TOINSTALL" = "altlinux-release-sisyphus" ] && TOINSTALL="branding-alt-sisyphus-release" [ "$TOINSTALL" = "altlinux-release-sisyphus" ] && TOINSTALL="branding-alt-sisyphus-release"
if epm installed etersoft-gpgkeys ; then if epm installed etersoft-gpgkeys ; then
# TODO: we don't support LINUX@Etersoft for now # TODO: we don't support LINUX@Etersoft for now
# leave etersoft-gpgkeys only if we have LINUX@Etersoft repo # leave etersoft-gpgkeys only if we have LINUX@Etersoft repo
#epm repo list | grep -q "LINUX@Etersoft" && echo "etersoft-gpgkeys" || echo "alt-gpgkeys" #epm repo list | grep -q "LINUX@Etersoft" && echo "etersoft-gpgkeys" || echo "alt-gpgkeys"
epm --quiet repo comment "LINUX@Etersoft" epm --quiet repo comment "LINUX@Etersoft"
echo "alt-gpgkeys" echo "alt-gpgkeys"
else else
# update if installed (just print package name here to include in the install list) # update if installed (just print package name here to include in the install list)
epm query --short alt-gpgkeys 2>/dev/null epm query --short alt-gpgkeys 2>/dev/null
fi fi
if [ -n "$TOINSTALL" ] ; then if [ -n "$TOINSTALL" ] ; then
echo "$TOINSTALL" echo "$TOINSTALL"
# workaround against # workaround against
# file /etc/fedora-release from install of altlinux-release-p8-20160414-alt1 conflicts with file from package branding-simply-linux-release-8.2.0-alt1 # file /etc/fedora-release from install of altlinux-release-p8-20160414-alt1 conflicts with file from package branding-simply-linux-release-8.2.0-alt1
# problem # problem
local AR="$(__get_conflict_release_pkg)" local AR="$(__get_conflict_release_pkg)"
if [ -n "$AR" ] && [ "$TOINSTALL" != "$AR" ] ; then if [ -n "$AR" ] && [ "$TOINSTALL" != "$AR" ] ; then
#echo $AR- #echo $AR-
# remove conflicts package right here to workaround against asking 'Yes, do as I say!' later # remove conflicts package right here to workaround against asking 'Yes, do as I say!' later
epm remove --nodeps $AR >/dev/null epm remove --nodeps $AR >/dev/null
fi fi
fi fi
} }
__check_system() __check_system()
{ {
local TO="$1" local TO="$1"
shift shift
# sure we have systemd if systemd is running # sure we have systemd if systemd is running
if is_active_systemd systemd ; then if is_active_systemd systemd ; then
docmd epm --skip-installed install systemd || fatal docmd epm --skip-installed install systemd || fatal
fi fi
if [ "$TO" != "Sisyphus" ] ; then if [ "$TO" != "Sisyphus" ] ; then
# we could miss DISTRVENDOR script during downgrade, reread # we could miss DISTRVENDOR script during downgrade, reread
set_distro_info set_distro_info
if [ "$($DISTRVENDOR -v)" != "$TO" ] || epm installed altlinux-release-sisyphus >/dev/null ; then if [ "$($DISTRVENDOR -v)" != "$TO" ] || epm installed altlinux-release-sisyphus >/dev/null ; then
warning "Current distro still is not $TO, or altlinux-release-sisyphus package is installed." warning "Current distro still is not $TO, or altlinux-release-sisyphus package is installed."
warning "Trying to fix with altlinux-release-$TO" warning "Trying to fix with altlinux-release-$TO"
docmd epm install altlinux-release-$TO docmd epm install altlinux-release-$TO
fi fi
fi fi
# switch from prefdm: https://bugzilla.altlinux.org/show_bug.cgi?id=26405#c47 # switch from prefdm: https://bugzilla.altlinux.org/show_bug.cgi?id=26405#c47
if is_active_systemd systemd ; then if is_active_systemd systemd ; then
if serv display-manager exists || serv prefdm exists ; then if serv display-manager exists || serv prefdm exists ; then
# don't stop running X server! # don't stop running X server!
# docmd serv dm off # docmd serv dm off
docmd serv disable prefdm docmd serv disable prefdm
docmd serv disable display-manager docmd serv disable display-manager
docmd serv enable display-manager docmd serv enable display-manager
# $ epm sf dm.service # $ epm sf dm.service
# xinitrc: /lib/systemd/system/dm.service # xinitrc: /lib/systemd/system/dm.service
...@@ -210,12 +210,12 @@ __check_system() ...@@ -210,12 +210,12 @@ __check_system()
# lxde-lxdm: /lib/systemd/system/lxdm.service # lxde-lxdm: /lib/systemd/system/lxdm.service
# xinitrc: /lib/systemd/system/prefdm.service # xinitrc: /lib/systemd/system/prefdm.service
# sddm: /lib/systemd/system/sddm.service # sddm: /lib/systemd/system/sddm.service
# enable first available DM # enable first available DM
for i in lightdm sddm lxde-lxdm gdm ; do for i in lightdm sddm lxde-lxdm gdm ; do
serv $i exists && docmd serv enable $i && break serv $i exists && docmd serv enable $i && break
done done
fi fi
fi fi
} }
...@@ -237,397 +237,397 @@ __switch_repo_to() ...@@ -237,397 +237,397 @@ __switch_repo_to()
get_next_release() get_next_release()
{ {
local FROM="$1" local FROM="$1"
case "$FROM" in case "$FROM" in
"p6") "p6")
echo "p7" ;; echo "p7" ;;
"p7") "p7")
echo "p8" ;; echo "p8" ;;
"p8") "p8")
echo "p9" ;; echo "p9" ;;
"p9") "p9")
echo "p10" ;; echo "p10" ;;
"c6") "c6")
echo "c7" ;; echo "c7" ;;
"c7") "c7")
echo "c8" ;; echo "c8" ;;
"c8") "c8")
echo "c8.1" ;; echo "c8.1" ;;
"c8.1") "c8.1")
echo "c8.2" ;; echo "c8.2" ;;
"c8") "c8")
echo "c9f2" ;; echo "c9f2" ;;
"c9f1") "c9f1")
echo "c9f2" ;; echo "c9f2" ;;
*) *)
echo "$FROM" ;; echo "$FROM" ;;
esac esac
} }
__do_upgrade() __do_upgrade()
{ {
docmd epm $non_interactive $force_yes upgrade || fatal "Check the errors and run '# $0' again" docmd epm $non_interactive $force_yes upgrade || fatal "Check the errors and run '# $0' again"
} }
# TODO: install new conf without signs? # TODO: install new conf without signs?
__switch_alt_to_distro() __switch_alt_to_distro()
{ {
local TO="$2" local TO="$2"
local FROM="$1" local FROM="$1"
info info
try_change_alt_repo try_change_alt_repo
case "$*" in case "$*" in
"p6"|"p6 p7"|"t6 p7"|"c6 c7") "p6"|"p6 p7"|"t6 p7"|"c6 c7")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
__switch_repo_to $TO __switch_repo_to $TO
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
end_change_alt_repo end_change_alt_repo
__do_upgrade __do_upgrade
docmd epm update-kernel docmd epm update-kernel
info "Run epm release-upgrade again for update to p8" info "Run epm release-upgrade again for update to p8"
;; ;;
"p7"|"p7 p8"|"t7 p8"|"c7 c8") "p7"|"p7 p8"|"t7 p8"|"c7 c8")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
__switch_repo_to $TO __switch_repo_to $TO
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
end_change_alt_repo end_change_alt_repo
__do_upgrade __do_upgrade
__check_system "$TO" __check_system "$TO"
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
info "Run epm release-upgrade again for update to p9" info "Run epm release-upgrade again for update to p9"
;; ;;
"c8"|"c8.1"|"c8.2"|"c8 c8.1"|"c8.1 c8.2"|"c8 c8.2") "c8"|"c8.1"|"c8.2"|"c8 c8.1"|"c8.1 c8.2"|"c8 c8.2")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
__switch_repo_to $TO __switch_repo_to $TO
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
end_change_alt_repo end_change_alt_repo
__do_upgrade __do_upgrade
__check_system "$TO" __check_system "$TO"
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
;; ;;
"p8 c8"|"p8 c8.1"|"p8 c8.2") "p8 c8"|"p8 c8.1"|"p8 c8.2")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
__switch_repo_to $TO __switch_repo_to $TO
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
if epm installed libcrypt ; then if epm installed libcrypt ; then
# glibc-core coflicts libcrypt # glibc-core coflicts libcrypt
docmd epm downgrade apt pam pam0_passwdqc glibc-core libcrypt- || fatal docmd epm downgrade apt pam pam0_passwdqc glibc-core libcrypt- || fatal
fi fi
docmd epm $non_interactive $force_yes downgrade || fatal docmd epm $non_interactive $force_yes downgrade || fatal
end_change_alt_repo end_change_alt_repo
__do_upgrade __do_upgrade
__check_system "$TO" __check_system "$TO"
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
;; ;;
"p8"|"p8 p9"|"t8 p9"|"c8 c9"|"c8 p9"|"c8.1 p9"|"c8.2 p9"|"p9 p9"|"p9 c9f2") "p8"|"p8 p9"|"t8 p9"|"c8 c9"|"c8 p9"|"c8.1 p9"|"c8.2 p9"|"p9 p9"|"p9 c9f2")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
info "Workaround for https://bugzilla.altlinux.org/show_bug.cgi?id=35492 ..." info "Workaround for https://bugzilla.altlinux.org/show_bug.cgi?id=35492 ..."
if epm installed gdb >/dev/null ; then if epm installed gdb >/dev/null ; then
docmd epm remove gdb || fatal docmd epm remove gdb || fatal
fi fi
__switch_repo_to $TO __switch_repo_to $TO
end_change_alt_repo end_change_alt_repo
__do_upgrade __do_upgrade
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
__check_system "$TO" __check_system "$TO"
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
info "Run epm release-upgrade again for update to p10" info "Run epm release-upgrade again for update to p10"
;; ;;
"p9"|"p9 p10"|"p10 p10") "p9"|"p9 p10"|"p10 p10")
info "Upgrade all packages to current $FROM repository" info "Upgrade all packages to current $FROM repository"
__do_upgrade __do_upgrade
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
__switch_repo_to $TO __switch_repo_to $TO
end_change_alt_repo end_change_alt_repo
__do_upgrade __do_upgrade
docmd epm install rpm apt $(get_fix_release_pkg "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
__check_system "$TO" __check_system "$TO"
docmd epm update-kernel -t std-def || fatal docmd epm update-kernel -t std-def || fatal
;; ;;
"p9 p8"|"c8.1 c8"|"c8.1 p8"|"p8 p8") "p9 p8"|"c8.1 c8"|"c8.1 p8"|"p8 p8")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install $(get_fix_release_pkg "$FROM") docmd epm install $(get_fix_release_pkg "$FROM")
__switch_repo_to $TO __switch_repo_to $TO
docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
if epm installed libcrypt >/dev/null ; then if epm installed libcrypt >/dev/null ; then
# glibc-core coflicts libcrypt # glibc-core coflicts libcrypt
docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal
fi fi
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'" docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
end_change_alt_repo end_change_alt_repo
__check_system "$TO" __check_system "$TO"
docmd epm upgrade || fatal docmd epm upgrade || fatal
;; ;;
"p9 c8"|"p9 c8.1"|"p9 c8.2") "p9 c8"|"p9 c8.1"|"p9 c8.2")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install $(get_fix_release_pkg "$FROM") docmd epm install $(get_fix_release_pkg "$FROM")
__switch_repo_to $TO __switch_repo_to $TO
docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
#if epm installed libcrypt >/dev/null ; then #if epm installed libcrypt >/dev/null ; then
# # glibc-core coflicts libcrypt # # glibc-core coflicts libcrypt
# docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal # docmd epm downgrade apt rpm pam pam0_passwdqc glibc-core libcrypt- || fatal
#fi #fi
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'" docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
end_change_alt_repo end_change_alt_repo
__check_system "$TO" __check_system "$TO"
docmd epm upgrade || fatal docmd epm upgrade || fatal
;; ;;
"p10 p9") "p10 p9")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install $(get_fix_release_pkg "$FROM") docmd epm install $(get_fix_release_pkg "$FROM")
__switch_repo_to $TO __switch_repo_to $TO
docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm downgrade rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'" docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
end_change_alt_repo end_change_alt_repo
__check_system "$TO" __check_system "$TO"
docmd epm upgrade || fatal docmd epm upgrade || fatal
;; ;;
"Sisyphus p8"|"Sisyphus p9"|"Sisyphus p10"|"Sisyphus c8"|"Sisyphus c8.1"|"Sisyphus c9f2") "Sisyphus p8"|"Sisyphus p9"|"Sisyphus p10"|"Sisyphus c8"|"Sisyphus c8.1"|"Sisyphus c9f2")
confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Downgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install $(get_fix_release_pkg "$FROM") docmd epm install $(get_fix_release_pkg "$FROM")
__switch_repo_to $TO __switch_repo_to $TO
docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install rpm apt $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'" docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
end_change_alt_repo end_change_alt_repo
__check_system "$TO" __check_system "$TO"
docmd epm upgrade || fatal docmd epm upgrade || fatal
;; ;;
"p8 Sisyphus"|"p9 Sisyphus"|"p10 Sisyphus"|"10 Sisyphus"|"Sisyphus Sisyphus") "p8 Sisyphus"|"p9 Sisyphus"|"p10 Sisyphus"|"10 Sisyphus"|"Sisyphus Sisyphus")
confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..." confirm_info "Upgrade $DISTRNAME from $FROM to $TO ..."
docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal docmd epm install rpm apt $(get_fix_release_pkg "$FROM") || fatal
docmd epm upgrade || fatal docmd epm upgrade || fatal
# TODO: epm_reposwitch?? # TODO: epm_reposwitch??
__replace_alt_version_in_repo "$FROM/branch/" "$TO/" __replace_alt_version_in_repo "$FROM/branch/" "$TO/"
__alt_repofix "alt" __alt_repofix "alt"
[ -s /etc/rpm/macros.d/p10 ] && rm -fv /etc/rpm/macros.d/p10 [ -s /etc/rpm/macros.d/p10 ] && rm -fv /etc/rpm/macros.d/p10
__epm_ru_update || fatal __epm_ru_update || fatal
docmd epm fix || fatal docmd epm fix || fatal
docmd epm install $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again" docmd epm install $(get_fix_release_pkg --force "$TO") || fatal "Check the errors and run '# epm release-upgrade' again"
#local ADDPKG #local ADDPKG
#ADDPKG=$(epm -q --short make-initrd sssd-ad 2>/dev/null) #ADDPKG=$(epm -q --short make-initrd sssd-ad 2>/dev/null)
#docmd epm install librpm7 librpm rpm apt $ADDPKG $(get_fix_release_pkg --force "$TO") ConsoleKit2- || fatal "Check an error and run again" #docmd epm install librpm7 librpm rpm apt $ADDPKG $(get_fix_release_pkg --force "$TO") ConsoleKit2- || fatal "Check an error and run again"
end_change_alt_repo end_change_alt_repo
docmd epm $force_yes $non_interactive upgrade || fatal "Check the error and run '# epm release-upgrade' again or just '# epm upgrade'" docmd epm $force_yes $non_interactive upgrade || fatal "Check the error and run '# epm release-upgrade' again or just '# epm upgrade'"
docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'" docmd epm $force_yes $non_interactive downgrade || fatal "Check the error and run '# epm downgrade'"
__check_system "$TO" __check_system "$TO"
docmd epm update-kernel || fatal docmd epm update-kernel || fatal
;; ;;
*) *)
if [ "$FROM" = "$TO" ] ; then if [ "$FROM" = "$TO" ] ; then
info "It seems your system is already $DISTRNAME $TO" info "It seems your system is already $DISTRNAME $TO"
else else
warning "Unknown distro version. Have no idea how to switch from $DISTRNAME $FROM to $DISTRNAME $TO." warning "Unknown distro version. Have no idea how to switch from $DISTRNAME $FROM to $DISTRNAME $TO."
fi fi
end_change_alt_repo end_change_alt_repo
info "Try run f.i. '# epm release-upgrade p10' or '# epm release-downgrade p9' or '# epm release-upgrade Sisyphus'" info "Try run f.i. '# epm release-upgrade p10' or '# epm release-downgrade p9' 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
esac esac
docmd epm clean docmd epm clean
docmd epm update docmd epm update
} }
epm_release_upgrade() epm_release_upgrade()
{ {
assure_root assure_root
assure_safe_run assure_safe_run
info "Starting upgrade/switch whole system to other release" info "Starting upgrade/switch whole system to other release"
info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux" info "Check also http://wiki.etersoft.ru/Admin/UpdateLinux"
cd / || fatal cd / || fatal
# TODO: it is possible eatmydata does not do his work # TODO: it is possible eatmydata does not do his work
export EPMNOEATMYDATA=1 export EPMNOEATMYDATA=1
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__epm_ru_update || fatal __epm_ru_update || fatal
# TODO: remove this hack (or move it to distro_info) # TODO: remove this hack (or move it to distro_info)
# try to detect current release by repo # try to detect current release by repo
if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then if [ "$DISTRVERSION" = "Sisyphus" ] || [ -z "$DISTRVERSION" ] ; then
local dv local dv
dv="$(__detect_alt_release_by_repo)" dv="$(__detect_alt_release_by_repo)"
if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then if [ -n "$dv" ] && [ "$dv" != "$DISTRVERSION" ] ; then
DISTRVERSION="$dv" DISTRVERSION="$dv"
info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)" info "Detected running $DISTRNAME $DISTRVERSION (according to using repos)"
fi fi
fi fi
TARGET="" TARGET=""
[ -n "$3" ] && fatal "Too many args: $*" [ -n "$3" ] && fatal "Too many args: $*"
if [ -n "$2" ] ; then if [ -n "$2" ] ; then
DISTRVERSION="$1" DISTRVERSION="$1"
info "Force current distro version as $DISTRVERSION" info "Force current distro version as $DISTRVERSION"
TARGET="$2" TARGET="$2"
elif [ -n "$1" ] ; then elif [ -n "$1" ] ; then
TARGET="$1" TARGET="$1"
fi fi
[ "$TARGET" = "Sisyphus" && info "Check also https://www.altlinux.org/Update/Sisyphus" [ "$TARGET" = "Sisyphus" && info "Check also https://www.altlinux.org/Update/Sisyphus"
[ -n "$TARGET" ] || TARGET="$(get_next_release $DISTRVERSION)" [ -n "$TARGET" ] || TARGET="$(get_next_release $DISTRVERSION)"
__alt_repofix __alt_repofix
__switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully upgraded to the next release '$TO'." __switch_alt_to_distro $DISTRVERSION $TARGET && info "Done. The system has been successfully upgraded to the next release '$TO'."
return 0 return 0
;; ;;
*) *)
;; ;;
esac esac
case $DISTRNAME in case $DISTRNAME in
"Mageia") "Mageia")
epm repo remove all epm repo remove all
sudocmd urpmi.addmedia --distrib --mirrorlist 'http://mirrors.mageia.org/api/mageia.8.$DISTRARCH.list' sudocmd urpmi.addmedia --distrib --mirrorlist 'http://mirrors.mageia.org/api/mageia.8.$DISTRARCH.list'
sudocmd urpmi --auto-update $non_interactive $force sudocmd urpmi --auto-update $non_interactive $force
return return
;; ;;
"ROSA") "ROSA")
# TODO: move to distro related upgrade # TODO: move to distro related upgrade
#epm repo remove all #epm repo remove all
# FIXME: don't work: # FIXME: don't work:
#epm repo add "http://mirror.rosalinux.ru/rosa/rosa2021.1/repository/$DISTRARCH" #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/ #showcmd urpmi.addmedia --distrib http://mirror.yandex.ru/mandriva/devel/2010.2/i586/
#sudocmd urpmi --auto-update --replacefiles #sudocmd urpmi --auto-update --replacefiles
return return
;; ;;
*) *)
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
#docmd epm update #docmd epm update
info "Have no idea how to upgrade $DISTRNAME. It is possible you need use 'release-downgrade'" info "Have no idea how to upgrade $DISTRNAME. It is possible you need use 'release-downgrade'"
;; ;;
*-dpkg) *-dpkg)
assure_exists do-release-upgrade update-manager-core assure_exists do-release-upgrade update-manager-core
sudocmd do-release-upgrade sudocmd do-release-upgrade
;; ;;
packagekit) packagekit)
docmd pkcon upgrade-system "$@" docmd pkcon upgrade-system "$@"
;; ;;
yum-rpm) yum-rpm)
docmd epm install rpm yum docmd epm install rpm yum
sudocmd yum clean all sudocmd yum clean all
info "Try do manually:" info "Try do manually:"
showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm showcmd rpm -Uvh http://mirror.yandex.ru/fedora/linux/releases/16/Fedora/x86_64/os/Packages/fedora-release-16-1.noarch.rpm
showcmd epm Upgrade showcmd epm Upgrade
;; ;;
dnf-rpm) dnf-rpm)
if [ "$DISTRNAME/$DISTRVERSION" = "CentOS/8" ] ; then if [ "$DISTRNAME/$DISTRVERSION" = "CentOS/8" ] ; then
if [ "$1" = "RockyLinux" ] ; then if [ "$1" = "RockyLinux" ] ; then
info "https://github.com/rocky-linux/rocky-tools/tree/main/migrate2rocky/" info "https://github.com/rocky-linux/rocky-tools/tree/main/migrate2rocky/"
confirm_info "Switch to Rocky Linux 8.x" confirm_info "Switch to Rocky Linux 8.x"
cd /tmp cd /tmp
docmd epm install git docmd epm install git
sudocmd git clone https://github.com/rocky-linux/rocky-tools.git || fatal sudocmd git clone https://github.com/rocky-linux/rocky-tools.git || fatal
sudocmd bash rocky-tools/migrate2rocky/migrate2rocky.sh -r sudocmd bash rocky-tools/migrate2rocky/migrate2rocky.sh -r
exit exit
fi fi
if [ "$1" = "OracleLinux" ] ; then if [ "$1" = "OracleLinux" ] ; then
info "Check https://t.me/srv_admin/1630" info "Check https://t.me/srv_admin/1630"
confirm_info "Switch to Oracle Linux 8.x" confirm_info "Switch to Oracle Linux 8.x"
cd /tmp cd /tmp
docmd epm install git docmd epm install git
sudocmd sed -i -r \ sudocmd sed -i -r \
-e 's!^mirrorlist=!#mirrorlist=!' \ -e 's!^mirrorlist=!#mirrorlist=!' \
-e 's!^#?baseurl=http://(mirror|vault).centos.org/\$contentdir/\$releasever/!baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/!i' \ -e 's!^#?baseurl=http://(mirror|vault).centos.org/\$contentdir/\$releasever/!baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/!i' \
/etc/yum.repos.d/CentOS-*.repo /etc/yum.repos.d/CentOS-*.repo
sudocmd git clone https://github.com/oracle/centos2ol.git || fatal sudocmd git clone https://github.com/oracle/centos2ol.git || fatal
a= bash centos2ol/centos2ol.sh a= bash centos2ol/centos2ol.sh
exit exit
fi fi
info "Check https://www.cyberciti.biz/howto/upgrade-migrate-from-centos-8-to-centos-stream-conversion/" info "Check https://www.cyberciti.biz/howto/upgrade-migrate-from-centos-8-to-centos-stream-conversion/"
confirm_info "Switch to CentOS Stream?" confirm_info "Switch to CentOS Stream?"
sudocmd sed -i -r \ sudocmd sed -i -r \
-e 's!^mirrorlist=!#mirrorlist=!' \ -e 's!^mirrorlist=!#mirrorlist=!' \
-e 's!^#?baseurl=http://(mirror|vault).centos.org/\$contentdir/\$releasever/!baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/!i' \ -e 's!^#?baseurl=http://(mirror|vault).centos.org/\$contentdir/\$releasever/!baseurl=https://dl.rockylinux.org/vault/centos/8.5.2111/!i' \
/etc/yum.repos.d/CentOS-*.repo /etc/yum.repos.d/CentOS-*.repo
docmd epm install centos-release-stream docmd epm install centos-release-stream
sudocmd dnf swap centos-{linux,stream}-repos sudocmd dnf swap centos-{linux,stream}-repos
sudocmd dnf distro-sync sudocmd dnf distro-sync
info "You can run '# epm autoorphans' to remove orphaned packages" info "You can run '# epm autoorphans' to remove orphaned packages"
exit exit
fi fi
if [ "$DISTRNAME" = "RockyLinux" ] ; then if [ "$DISTRNAME" = "RockyLinux" ] ; then
sudocmd dnf --refresh upgrade || fatal sudocmd dnf --refresh upgrade || fatal
sudocmd dnf clean all sudocmd dnf clean all
info "Check https://www.centlinux.com/2022/07/upgrade-your-servers-from-rocky-linux-8-to-9.html" info "Check https://www.centlinux.com/2022/07/upgrade-your-servers-from-rocky-linux-8-to-9.html"
info "For upgrading your yum repositories from Rocky Linux 8 to 9 ..." info "For upgrading your yum repositories from Rocky Linux 8 to 9 ..."
epm install "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-gpg-keys*.rpm" || fatal epm install "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-gpg-keys*.rpm" || fatal
epm install "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-repos*.rpm" "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-release*.rpm" || fatal epm install "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-repos*.rpm" "https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/r/rocky-release*.rpm" || fatal
# hack (TODO) # hack (TODO)
DV=$(echo "$DISTRVERSION" | sed -e "s|\..*||") DV=$(echo "$DISTRVERSION" | sed -e "s|\..*||")
local RELEASEVER="$1" local RELEASEVER="$1"
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DV + 1)) [ -n "$RELEASEVER" ] || RELEASEVER=$(($DV + 1))
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER" confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
sudocmd dnf -y --releasever=$RELEASEVER --allowerasing --setopt=deltarpm=false distro-sync sudocmd dnf -y --releasever=$RELEASEVER --allowerasing --setopt=deltarpm=false distro-sync
sudocmd rpm --rebuilddb sudocmd rpm --rebuilddb
epm upgrade epm upgrade
info "You can run '# epm autoorphans' to remove orphaned packages" info "You can run '# epm autoorphans' to remove orphaned packages"
info "Use # dnf module reset <module> to resolve 'nothing provides module' error" info "Use # dnf module reset <module> to resolve 'nothing provides module' error"
exit exit
fi fi
info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info" info "Check https://fedoraproject.org/wiki/DNF_system_upgrade for an additional info"
#docmd epm install epel-release yum-utils #docmd epm install epel-release yum-utils
sudocmd dnf --refresh upgrade || fatal sudocmd dnf --refresh upgrade || fatal
sudocmd dnf clean all sudocmd dnf clean all
assure_exists dnf-plugin-system-upgrade assure_exists dnf-plugin-system-upgrade
sudocmd dnf upgrade --refresh sudocmd dnf upgrade --refresh
local RELEASEVER="$1" local RELEASEVER="$1"
[ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1)) [ -n "$RELEASEVER" ] || RELEASEVER=$(($DISTRVERSION + 1))
#[ -n "$RELEASEVER" ] || fatal "Run me with new version" #[ -n "$RELEASEVER" ] || fatal "Run me with new version"
confirm_info "Upgrade to $DISTRNAME/$RELEASEVER" confirm_info "Upgrade to $DISTRNAME/$RELEASEVER"
sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER sudocmd dnf system-upgrade download --refresh --releasever=$RELEASEVER
# TODO: from docs: # TODO: from docs:
# dnf system-upgrade reboot # dnf system-upgrade reboot
# FIXME: download all packages again # FIXME: download all packages again
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"
;; ;;
zypper-rpm) zypper-rpm)
docmd epm repolist docmd epm repolist
# TODO: move to distro related upgrade # 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
showcmd zypper ref showcmd zypper ref
docmd epm update docmd epm update
docmd epm install rpm zypper docmd epm install rpm zypper
docmd epm upgrade docmd epm upgrade
;; ;;
pacman) pacman)
docmd epm Upgrade docmd epm Upgrade
;; ;;
conary) conary)
docmd epm Upgrade docmd epm Upgrade
;; ;;
emerge) emerge)
docmd epm Upgrade docmd epm Upgrade
;; ;;
guix) guix)
sudocmd guix pull --verbose sudocmd guix pull --verbose
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -35,323 +35,323 @@ __check_rpm_e_result() ...@@ -35,323 +35,323 @@ __check_rpm_e_result()
# Try remove with low level removing # Try remove with low level removing
epm_remove_low() epm_remove_low()
{ {
[ -z "$1" ] && return [ -z "$1" ] && return
warmup_lowbase warmup_lowbase
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
cd /tmp || fatal cd /tmp || fatal
__epm_check_vendor $@ __epm_check_vendor $@
store_output sudocmd rpm -ev $noscripts $nodeps $@ store_output sudocmd rpm -ev $noscripts $nodeps $@
# rpm returns number of packages if failed on removing # rpm returns number of packages if failed on removing
__check_rpm_e_result $RC_STDOUT $? __check_rpm_e_result $RC_STDOUT $?
RES=$? RES=$?
clean_store_output clean_store_output
cd - >/dev/null cd - >/dev/null
return $RES ;; return $RES ;;
*-dpkg|-dpkg) *-dpkg|-dpkg)
# shellcheck disable=SC2046 # 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)
sudocmd pkg_delete -r $@ sudocmd pkg_delete -r $@
return ;; return ;;
pkgng) pkgng)
sudocmd pkg delete -R $@ sudocmd pkg delete -R $@
return ;; return ;;
emerge) emerge)
sudocmd emerge --unmerge $@ sudocmd emerge --unmerge $@
return ;; return ;;
pacman) pacman)
sudocmd pacman -R $@ sudocmd pacman -R $@
return ;; return ;;
eopkg) eopkg)
sudocmd eopkg $(subst_option nodeps --ignore-dependency) remove $@ sudocmd eopkg $(subst_option nodeps --ignore-dependency) remove $@
return ;; return ;;
appget|winget) appget|winget)
sudocmd $PMTYPE uninstall $@ sudocmd $PMTYPE uninstall $@
return ;; return ;;
slackpkg) slackpkg)
sudocmd /sbin/removepkg $@ sudocmd /sbin/removepkg $@
return ;; return ;;
esac esac
return 1 return 1
} }
epm_remove_names() epm_remove_names()
{ {
[ -z "$1" ] && return [ -z "$1" ] && return
warmup_bases warmup_bases
local APTOPTIONS="$(subst_option non_interactive -y)" local APTOPTIONS="$(subst_option non_interactive -y)"
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-get remove --purge $APTOPTIONS $@ sudocmd apt-get remove --purge $APTOPTIONS $@
return ;; return ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude purge $@ sudocmd aptitude purge $@
return ;; return ;;
apt-rpm) apt-rpm)
sudocmd apt-get remove $APTOPTIONS $@ sudocmd apt-get remove $APTOPTIONS $@
return ;; return ;;
packagekit) packagekit)
docmd pkcon remove $@ docmd pkcon remove $@
return ;; return ;;
deepsolver-rpm) deepsolver-rpm)
sudocmd ds-remove $@ sudocmd ds-remove $@
return ;; return ;;
urpm-rpm) urpm-rpm)
sudocmd urpme $@ sudocmd urpme $@
return ;; return ;;
pkgsrc) # without dependencies pkgsrc) # without dependencies
sudocmd pkg_delete $@ sudocmd pkg_delete $@
return ;; return ;;
pkgng) pkgng)
sudocmd pkg delete -R $@ sudocmd pkg delete -R $@
return ;; return ;;
emerge) emerge)
#sudocmd emerge --unmerge $@ #sudocmd emerge --unmerge $@
sudocmd emerge -aC $@ sudocmd emerge -aC $@
return ;; return ;;
pacman) pacman)
sudocmd pacman -Rc $@ sudocmd pacman -Rc $@
return ;; return ;;
yum-rpm) yum-rpm)
sudocmd yum remove $@ sudocmd yum remove $@
return ;; return ;;
dnf-rpm) dnf-rpm)
sudocmd dnf remove $@ sudocmd dnf remove $@
return ;; return ;;
snappy) snappy)
sudocmd snappy uninstall $@ sudocmd snappy uninstall $@
return ;; return ;;
zypper-rpm) zypper-rpm)
sudocmd zypper remove --clean-deps $@ sudocmd zypper remove --clean-deps $@
return ;; return ;;
mpkg) mpkg)
sudocmd mpkg remove $@ sudocmd mpkg remove $@
return ;; return ;;
eopkg) eopkg)
sudocmd eopkg $(subst_option nodeps --ignore-dependency) remove $@ sudocmd eopkg $(subst_option nodeps --ignore-dependency) remove $@
return ;; return ;;
conary) conary)
sudocmd conary erase $@ sudocmd conary erase $@
return ;; return ;;
npackd) npackd)
sudocmd npackdcl remove --package=$1 sudocmd npackdcl remove --package=$1
return ;; return ;;
nix) nix)
sudocmd nix-env --uninstall $@ sudocmd nix-env --uninstall $@
return ;; return ;;
apk) apk)
sudocmd apk del $@ sudocmd apk del $@
return ;; return ;;
guix) guix)
sudocmd guix package -r $@ sudocmd guix package -r $@
return ;; return ;;
android) android)
sudocmd pm uninstall $@ sudocmd pm uninstall $@
return ;; return ;;
chocolatey) chocolatey)
sudocmd chocolatey uninstall $@ sudocmd chocolatey uninstall $@
return ;; return ;;
slackpkg) slackpkg)
sudocmd /usr/sbin/slackpkg remove $@ sudocmd /usr/sbin/slackpkg remove $@
return ;; return ;;
homebrew) homebrew)
docmd brew remove $@ docmd brew remove $@
return ;; return ;;
aptcyg) aptcyg)
sudocmd apt-cyg remove $@ sudocmd apt-cyg remove $@
return ;; return ;;
xbps) xbps)
sudocmd xbps remove -R $@ sudocmd xbps remove -R $@
return ;; return ;;
appget|winget) appget|winget)
sudocmd $PMTYPE uninstall $@ sudocmd $PMTYPE uninstall $@
return ;; return ;;
opkg) opkg)
# shellcheck disable=SC2046 # shellcheck disable=SC2046
sudocmd opkg $(subst_option force -force-depends) remove $@ sudocmd opkg $(subst_option force -force-depends) remove $@
return ;; return ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
# TODO # TODO
epm_remove_nonint() epm_remove_nonint()
{ {
warmup_bases warmup_bases
case $PMTYPE in case $PMTYPE in
apt-dpkg) apt-dpkg)
sudocmd apt-get -y --force-yes remove --purge $@ sudocmd apt-get -y --force-yes remove --purge $@
return ;; return ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude -y purge $@ sudocmd aptitude -y purge $@
return ;; return ;;
apt-rpm) apt-rpm)
sudocmd apt-get -y --force-yes remove $@ sudocmd apt-get -y --force-yes remove $@
return ;; return ;;
packagekit) packagekit)
docmd pkcon remove --noninteractive $@ docmd pkcon remove --noninteractive $@
return ;; return ;;
urpm-rpm) urpm-rpm)
sudocmd urpme --auto $@ sudocmd urpme --auto $@
return ;; return ;;
pacman) pacman)
sudocmd pacman -Rc --noconfirm $@ sudocmd pacman -Rc --noconfirm $@
return ;; return ;;
yum-rpm) yum-rpm)
sudocmd yum -y remove $@ sudocmd yum -y remove $@
return ;; return ;;
dnf-rpm) dnf-rpm)
sudocmd dnf remove --assumeyes $@ sudocmd dnf remove --assumeyes $@
return ;; return ;;
zypper-rpm) zypper-rpm)
sudocmd zypper --non-interactive remove --clean-deps $@ sudocmd zypper --non-interactive remove --clean-deps $@
return ;; return ;;
slackpkg) slackpkg)
sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@ sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes remove $@
return ;; return ;;
pkgng) pkgng)
sudocmd pkg delete -y -R $@ sudocmd pkg delete -y -R $@
return ;; return ;;
opkg) opkg)
sudocmd opkg -force-defaults remove $@ sudocmd opkg -force-defaults remove $@
return ;; return ;;
eopkg) eopkg)
sudocmd eopkg $(subst_option nodeps --ignore-dependency) --yes-all remove $@ sudocmd eopkg $(subst_option nodeps --ignore-dependency) --yes-all remove $@
return ;; return ;;
appget|winget) appget|winget)
sudocmd $PMTYPE uninstall -s $@ sudocmd $PMTYPE uninstall -s $@
return ;; return ;;
xbps) xbps)
sudocmd xbps remove -y $@ sudocmd xbps remove -y $@
return ;; return ;;
esac esac
return 5 return 5
} }
epm_print_remove_command() epm_print_remove_command()
{ {
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
echo "rpm -ev $nodeps $*" echo "rpm -ev $nodeps $*"
;; ;;
*-dpkg) *-dpkg)
echo "dpkg -P $*" echo "dpkg -P $*"
;; ;;
packagekit-*) packagekit-*)
echo "pkcon remove --noninteractive $*" echo "pkcon remove --noninteractive $*"
;; ;;
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 $*"
;; ;;
opkg) opkg)
echo "opkg remove $*" echo "opkg remove $*"
;; ;;
eopkg) eopkg)
echo "eopkg remove $*" echo "eopkg remove $*"
;; ;;
aptcyg) aptcyg)
echo "apt-cyg remove $*" echo "apt-cyg remove $*"
;; ;;
xbps) xbps)
echo "xbps remove -y $*" echo "xbps remove -y $*"
;; ;;
appget|winget) appget|winget)
echo "$PMTYPE uninstall -s $*" echo "$PMTYPE uninstall -s $*"
;; ;;
*) *)
fatal "Have no suitable appropriate remove command for $PMTYPE" fatal "Have no suitable appropriate remove command for $PMTYPE"
;; ;;
esac esac
} }
epm_remove() epm_remove()
{ {
if [ -n "$show_command_only" ] ; then if [ -n "$show_command_only" ] ; then
epm_print_remove_command $pkg_filenames epm_print_remove_command $pkg_filenames
return return
fi fi
if [ "$BASEDISTRNAME" = "alt" ] ; then if [ "$BASEDISTRNAME" = "alt" ] ; then
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
if tasknumber "$pkg_names" >/dev/null ; then if tasknumber "$pkg_names" >/dev/null ; then
assure_exists apt-repo assure_exists apt-repo
pkg_names="$(get_task_packages $pkg_names)" pkg_names="$(get_task_packages $pkg_names)"
fi fi
fi fi
# TODO: fix pkg_names override # TODO: fix pkg_names override
# get full package name(s) from the package file(s) # get full package name(s) from the package file(s)
[ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)" [ -n "$pkg_files" ] && pkg_names="$pkg_names $(epm query $pkg_files)"
pkg_files='' pkg_files=''
if [ -z "$pkg_names" ] ; then if [ -z "$pkg_names" ] ; then
warning "no package(s) to remove." warning "no package(s) to remove."
return return
fi fi
# remove according current arch (if x86_64) by default # remove according current arch (if x86_64) by default
pkg_names="$(echo $pkg_names | exp_with_arch_suffix)" pkg_names="$(echo $pkg_names | exp_with_arch_suffix)"
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
info "Packages for removing:" info "Packages for removing:"
echo "$pkg_names" echo "$pkg_names"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
nodeps="--test" nodeps="--test"
APTOPTIONS="--simulate" APTOPTIONS="--simulate"
;; ;;
apt-deb) apt-deb)
nodeps="--simulate" nodeps="--simulate"
APTOPTIONS="--simulate" APTOPTIONS="--simulate"
;; ;;
*) *)
return return
;; ;;
esac esac
fi fi
if [ -n "$skip_missed" ] ; then if [ -n "$skip_missed" ] ; then
pkg_names="$(get_only_installed_packages $pkg_names)" pkg_names="$(get_only_installed_packages $pkg_names)"
fi fi
epm_remove_low $pkg_names && return epm_remove_low $pkg_names && return
local STATUS=$? local STATUS=$?
if [ -n "$direct" ] || [ -n "$nodeps" ] || [ "$STATUS" = "$RPMISNOTINSTALLED" ]; then if [ -n "$direct" ] || [ -n "$nodeps" ] || [ "$STATUS" = "$RPMISNOTINSTALLED" ]; then
[ -n "$force" ] || return $STATUS [ -n "$force" ] || return $STATUS
fi fi
# get package name for hi level package management command (with version if supported and if possible) # get package name for hi level package management command (with version if supported and if possible)
pkg_names=$(__epm_get_hilevel_name $pkg_names) pkg_names=$(__epm_get_hilevel_name $pkg_names)
if [ -n "$non_interactive" ] ; then if [ -n "$non_interactive" ] ; then
epm_remove_nonint $pkg_names epm_remove_nonint $pkg_names
local RET=$? local RET=$?
# if not separate command, use usual command # if not separate command, use usual command
[ "$RET" = "5" ] || return $RET [ "$RET" = "5" ] || return $RET
fi fi
epm_remove_names $pkg_names epm_remove_names $pkg_names
} }
...@@ -22,64 +22,64 @@ load_helper epm-sh-warmup ...@@ -22,64 +22,64 @@ load_helper epm-sh-warmup
epm_remove_old_kernels() epm_remove_old_kernels()
{ {
warmup_bases warmup_bases
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
load_helper epm-query_package load_helper epm-query_package
if ! __epm_query_package kernel-image >/dev/null ; then if ! __epm_query_package kernel-image >/dev/null ; then
info "No installed kernel packages, skipping cleaning" info "No installed kernel packages, skipping cleaning"
return return
fi fi
assure_exists update-kernel update-kernel 0.9.9 assure_exists update-kernel update-kernel 0.9.9
sudocmd remove-old-kernels $dryrun $(subst_option non_interactive -y) "$@" sudocmd remove-old-kernels $dryrun $(subst_option non_interactive -y) "$@"
[ -n "$dryrun" ] && return [ -n "$dryrun" ] && return
# remove unused nvidia drivers # remove unused nvidia drivers
if is_command nvidia-clean-driver ; 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
sudocmd nvidia-clean-driver sudocmd nvidia-clean-driver
fi fi
fi fi
return ;; return ;;
esac esac
case $DISTRNAME in case $DISTRNAME in
Ubuntu) Ubuntu)
load_helper epm-query_package load_helper epm-query_package
if ! __epm_query_package linux-image >/dev/null ; then if ! __epm_query_package linux-image >/dev/null ; then
info "No installed kernel packages, skipping cleaning" info "No installed kernel packages, skipping cleaning"
return return
fi fi
info "Note: it is enough to use eepm autoremove for old kernel removing..." info "Note: it is enough to use eepm autoremove for old kernel removing..."
info "Check also http://ubuntuhandbook.org/index.php/2016/05/remove-old-kernels-ubuntu-16-04/" info "Check also http://ubuntuhandbook.org/index.php/2016/05/remove-old-kernels-ubuntu-16-04/"
# http://www.opennet.ru/tips/2980_ubuntu_apt_clean_kernel_packet.shtml # http://www.opennet.ru/tips/2980_ubuntu_apt_clean_kernel_packet.shtml
case $DISTRVERSION in case $DISTRVERSION in
10.04|12.04|14.04|15.04|15.10) 10.04|12.04|14.04|15.04|15.10)
assure_exists purge-old-kernels bikeshed assure_exists purge-old-kernels bikeshed
;; ;;
*) *)
# since Ubuntu 16.04 # since Ubuntu 16.04
assure_exists purge-old-kernels byobu assure_exists purge-old-kernels byobu
;; ;;
esac esac
sudocmd purge-old-kernels "$@" sudocmd purge-old-kernels "$@"
return ;; return ;;
Gentoo) Gentoo)
sudocmd emerge -P gentoo-sources sudocmd emerge -P gentoo-sources
return ;; return ;;
VoidLinux) VoidLinux)
sudocmd vkpurge rm all sudocmd vkpurge rm all
return ;; return ;;
esac esac
case $PMTYPE in case $PMTYPE in
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -22,73 +22,73 @@ load_helper epm-sh-altlinux ...@@ -22,73 +22,73 @@ load_helper epm-sh-altlinux
# remove grepped lines # remove grepped lines
__epm_removerepo_alt_grepremove() __epm_removerepo_alt_grepremove()
{ {
local rl local rl
# ^rpm means full string # ^rpm means full string
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")" 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
# TODO: print removed lines # TODO: print removed lines
if [ -n "$dryrun" ] ; then if [ -n "$dryrun" ] ; then
docmd apt-repo $dryrun rm "$rp" docmd apt-repo $dryrun rm "$rp"
continue continue
fi fi
if [ -z "$quiet" ] ; 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"
fi fi
done done
} }
__epm_removerepo_alt() __epm_removerepo_alt()
{ {
local repo="$*" local repo="$*"
[ -n "$repo" ] || fatal "No such repo or task. Use epm repo remove <regexp|autoimports|archive|tasks|TASKNUMBER>" [ -n "$repo" ] || fatal "No such repo or task. Use epm repo remove <regexp|autoimports|archive|tasks|TASKNUMBER>"
assure_exists apt-repo assure_exists apt-repo
if tasknumber "$repo" >/dev/null ; then if tasknumber "$repo" >/dev/null ; then
local tn local tn
for tn in $(tasknumber "$repo") ; do for tn in $(tasknumber "$repo") ; do
__epm_removerepo_alt_grepremove " repo/$tn/" __epm_removerepo_alt_grepremove " repo/$tn/"
done done
return return
fi fi
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")" 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.$branch" repo="autoimports.$branch"
sudocmd apt-repo $dryrun rm "$repo" sudocmd apt-repo $dryrun rm "$repo"
;; ;;
archive) archive)
info "remove archive repos" info "remove archive repos"
__epm_removerepo_alt_grepremove "archive/" __epm_removerepo_alt_grepremove "archive/"
;; ;;
tasks) tasks)
info "remove task repos" info "remove task repos"
__epm_removerepo_alt_grepremove " repo/[0-9]+/" __epm_removerepo_alt_grepremove " repo/[0-9]+/"
;; ;;
task) task)
shift shift
__epm_removerepo_alt_grepremove " repo/$1/" __epm_removerepo_alt_grepremove " repo/$1/"
;; ;;
-*) -*)
fatal "epm removerepo: no options are supported" fatal "epm removerepo: no options are supported"
;; ;;
*) *)
# TODO: if return empty for whole line, use grep # TODO: if return empty for whole line, use grep
# sudocmd apt-repo $dryrun rm "$*" # sudocmd apt-repo $dryrun rm "$*"
__epm_removerepo_alt_grepremove "$*" __epm_removerepo_alt_grepremove "$*"
;; ;;
esac esac
} }
...@@ -96,67 +96,67 @@ epm_removerepo() ...@@ -96,67 +96,67 @@ epm_removerepo()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
__epm_removerepo_alt "$@" __epm_removerepo_alt "$@"
return return
;; ;;
"astra") "astra")
echo "Use workaround for AstraLinux" echo "Use workaround for AstraLinux"
[ -n "$*" ] || fatal "empty repo name" [ -n "$*" ] || fatal "empty repo name"
# aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel # aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel
sudocmd sed -i -e "s|.*$*.*||" /etc/apt/sources.list 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 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 sudocmd sed -i -e "s|.*$*.*||" /etc/apt/sources.list.d/*.list
fi fi
return 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
# 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"
;; ;;
aptitude-dpkg) aptitude-dpkg)
info "You need remove repo from /etc/apt/sources.list" info "You need remove repo from /etc/apt/sources.list"
;; ;;
yum-rpm) yum-rpm)
assure_exists yum-utils assure_exists yum-utils
sudocmd yum-config-manager --disable "$@" sudocmd yum-config-manager --disable "$@"
;; ;;
urpm-rpm) urpm-rpm)
if [ "$1" = "all" ] ; then if [ "$1" = "all" ] ; then
sudocmd urpmi.removemedia -av sudocmd urpmi.removemedia -av
return return
fi fi
sudocmd urpmi.removemedia "$@" sudocmd urpmi.removemedia "$@"
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper removerepo "$@" sudocmd zypper removerepo "$@"
;; ;;
emerge) emerge)
sudocmd layman "-d$@" sudocmd layman "-d$@"
;; ;;
pacman) pacman)
info "You need remove repo from /etc/pacman.conf" info "You need remove repo from /etc/pacman.conf"
;; ;;
npackd) npackd)
sudocmd npackdcl remove-repo --url="$*" sudocmd npackdcl remove-repo --url="$*"
;; ;;
winget) winget)
sudocmd winget source remove "$@" sudocmd winget source remove "$@"
;; ;;
eopkg) eopkg)
sudocmd eopkg remove-repo "$@" sudocmd eopkg remove-repo "$@"
;; ;;
slackpkg) slackpkg)
info "You need remove repo from /etc/slackpkg/mirrors" info "You need remove repo from /etc/slackpkg/mirrors"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -48,18 +48,18 @@ __epm_check_if_needed_repack() ...@@ -48,18 +48,18 @@ __epm_check_if_needed_repack()
# fills split_replaced_pkgs with packages of that type # fills split_replaced_pkgs with packages of that type
__epm_split_by_pkg_type() __epm_split_by_pkg_type()
{ {
local type="$1" local type="$1"
shift shift
split_replaced_pkgs='' split_replaced_pkgs=''
for pkg in "$@" ; do for pkg in "$@" ; do
[ "$(get_package_type "$pkg")" = "$type" ] || return 1 [ "$(get_package_type "$pkg")" = "$type" ] || return 1
[ -e "$pkg" ] || fatal "Can't read $pkg" [ -e "$pkg" ] || fatal "Can't read $pkg"
split_replaced_pkgs="$split_replaced_pkgs $pkg" split_replaced_pkgs="$split_replaced_pkgs $pkg"
done done
[ -n "$split_replaced_pkgs" ] [ -n "$split_replaced_pkgs" ]
} }
...@@ -181,43 +181,43 @@ __prepare_source_package() ...@@ -181,43 +181,43 @@ __prepare_source_package()
# fill repacked_pkgs # fill repacked_pkgs
__epm_repack() __epm_repack()
{ {
repacked_pkgs='' repacked_pkgs=''
case $PKGFORMAT in case $PKGFORMAT in
rpm) rpm)
load_helper epm-repack-rpm load_helper epm-repack-rpm
__epm_repack_to_rpm "$@" || return __epm_repack_to_rpm "$@" || return
;; ;;
deb) deb)
# FIXME: only one package in $@ is supported # FIXME: only one package in $@ is supported
#local pkgname="$(epm print name from "$@")" #local pkgname="$(epm print name from "$@")"
__set_version_pkgname "$1" __set_version_pkgname "$1"
local repackcode="$EPM_REPACK_SCRIPTS_DIR/$PKGNAME.sh" local repackcode="$EPM_REPACK_SCRIPTS_DIR/$PKGNAME.sh"
if [ -x "$repackcode" ] ; then if [ -x "$repackcode" ] ; then
load_helper epm-repack-rpm load_helper epm-repack-rpm
load_helper epm-repack-deb load_helper epm-repack-deb
__epm_repack_to_rpm "$@" || return __epm_repack_to_rpm "$@" || return
[ -n "$repacked_pkgs" ] || return [ -n "$repacked_pkgs" ] || return
__epm_repack_to_deb $repacked_pkgs __epm_repack_to_deb $repacked_pkgs
else else
load_helper epm-repack-deb load_helper epm-repack-deb
__epm_repack_to_deb "$@" || return __epm_repack_to_deb "$@" || return
fi fi
;; ;;
*) *)
fatal "$PKGFORMAT is not supported for repack yet" fatal "$PKGFORMAT is not supported for repack yet"
;; ;;
esac esac
return 0 return 0
} }
__epm_repack_if_needed() __epm_repack_if_needed()
{ {
# return 1 if there is a package in host package format # return 1 if there is a package in host package format
__epm_split_by_pkg_type $PKGFORMAT "$@" && return 1 __epm_split_by_pkg_type $PKGFORMAT "$@" && return 1
__epm_repack "$@" __epm_repack "$@"
return 0 return 0
} }
epm_repack() epm_repack()
...@@ -242,7 +242,7 @@ epm_repack() ...@@ -242,7 +242,7 @@ epm_repack()
echo echo
echo "Adapted packages:" echo "Adapted packages:"
for i in $repacked_pkgs ; do for i in $repacked_pkgs ; do
echo " $EPMCURDIR/$(basename "$i")" echo " $EPMCURDIR/$(basename "$i")"
done done
fi fi
fi fi
......
...@@ -21,40 +21,40 @@ ...@@ -21,40 +21,40 @@
# fills repacked_pkgs # fills repacked_pkgs
__epm_repack_to_deb() __epm_repack_to_deb()
{ {
local pkg local pkg
local pkgs="$*" local pkgs="$*"
assure_exists alien assure_exists alien
assure_exists fakeroot assure_exists fakeroot
assure_exists rpm assure_exists rpm
repacked_pkgs='' repacked_pkgs=''
local TDIR=$(mktemp -d --tmpdir=$BIGTMPDIR) local TDIR=$(mktemp -d --tmpdir=$BIGTMPDIR)
to_clean_tmp_dirs="$to_clean_tmp_dirs $TDIR" to_clean_tmp_dirs="$to_clean_tmp_dirs $TDIR"
trap "__epm_remove_tmp_files" EXIT trap "__epm_remove_tmp_files" EXIT
for pkg in $pkgs ; do for pkg in $pkgs ; do
abspkg="$(realpath "$pkg")" abspkg="$(realpath "$pkg")"
info "Repacking $abspkg to local deb format (inside $TDIR) ..." info "Repacking $abspkg to local deb format (inside $TDIR) ..."
alpkg=$(basename $pkg) alpkg=$(basename $pkg)
# don't use abs package path: copy package to temp dir and use there # don't use abs package path: copy package to temp dir and use there
cp $verbose $pkg $TDIR/$alpkg cp $verbose $pkg $TDIR/$alpkg
cd $TDIR || fatal cd $TDIR || fatal
__prepare_source_package "$pkg" __prepare_source_package "$pkg"
showcmd_store_output fakeroot alien -d -k $scripts "$alpkg" showcmd_store_output fakeroot alien -d -k $scripts "$alpkg"
local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g") local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
if [ -n "$DEBCONVERTED" ] ; then if [ -n "$DEBCONVERTED" ] ; then
repacked_pkgs="$repacked_pkgs $(realpath $DEBCONVERTED)" repacked_pkgs="$repacked_pkgs $(realpath $DEBCONVERTED)"
to_remove_pkg_files="$to_remove_pkg_files $(realpath $DEBCONVERTED)" to_remove_pkg_files="$to_remove_pkg_files $(realpath $DEBCONVERTED)"
fi fi
clean_store_output clean_store_output
cd - >/dev/null cd - >/dev/null
done done
return 0 return 0
} }
...@@ -85,14 +85,14 @@ __create_rpmmacros() ...@@ -85,14 +85,14 @@ __create_rpmmacros()
[ -n "$TMPDIR" ] || TMPDIR=/tmp [ -n "$TMPDIR" ] || TMPDIR=/tmp
cat <<EOF >$HOME/.rpmmacros cat <<EOF >$HOME/.rpmmacros
%_topdir $HOME/RPM %_topdir $HOME/RPM
%_tmppath $TMPDIR %_tmppath $TMPDIR
%packager EPM <support@eepm.ru> %packager EPM <support@eepm.ru>
%_vendor EEPM %_vendor EEPM
%_gpg_name support@etersoft.ru %_gpg_name support@etersoft.ru
%_allow_root_build 1 %_allow_root_build 1
EOF EOF
to_remove_pkg_files="$to_remove_pkg_files $HOME/.rpmmacros" to_remove_pkg_files="$to_remove_pkg_files $HOME/.rpmmacros"
} }
...@@ -114,14 +114,14 @@ __epm_repack_to_rpm() ...@@ -114,14 +114,14 @@ __epm_repack_to_rpm()
assure_exists alien || fatal assure_exists alien || fatal
# TODO: check for all systems # TODO: check for all systems
case $PKGFORMAT in case $PKGFORMAT in
rpm) rpm)
assure_exists /usr/bin/rpmbuild rpm-build || fatal assure_exists /usr/bin/rpmbuild rpm-build || fatal
;; ;;
deb) deb)
assure_exists /usr/bin/rpmbuild rpm || fatal assure_exists /usr/bin/rpmbuild rpm || fatal
;; ;;
esac esac
# TODO: improve # TODO: improve
if echo "$pkgs" | grep -q "\.deb" ; then if echo "$pkgs" | grep -q "\.deb" ; then
......
...@@ -21,8 +21,8 @@ load_helper epm-sh-altlinux ...@@ -21,8 +21,8 @@ load_helper epm-sh-altlinux
epm_repo_help() epm_repo_help()
{ {
get_help HELPCMD $SHAREDIR/epm-repo get_help HELPCMD $SHAREDIR/epm-repo
cat <<EOF cat <<EOF
Examples: Examples:
epm repo set p9 epm repo set p9
epm repo add autoimports epm repo add autoimports
...@@ -34,97 +34,97 @@ EOF ...@@ -34,97 +34,97 @@ EOF
epm_repo() epm_repo()
{ {
local CMD="$1" local CMD="$1"
[ -n "$CMD" ] && shift [ -n "$CMD" ] && shift
case $CMD in case $CMD in
"-h"|"--help"|help) # HELPCMD: help "-h"|"--help"|help) # HELPCMD: help
epm_repo_help epm_repo_help
;; ;;
""|list) # HELPCMD: list packages ""|list) # HELPCMD: list packages
load_helper epm-repolist load_helper epm-repolist
epm_repolist "$@" epm_repolist "$@"
;; ;;
fix) # HELPCMD: fix paths in sources lists (ALT Linux only) fix) # HELPCMD: fix paths in sources lists (ALT Linux only)
load_helper epm-repofix load_helper epm-repofix
epm_repofix "$@" epm_repofix "$@"
;; ;;
change) # HELPCMD: <mirror>: switch sources to the mirror (supports etersoft/yandex/basealt): rewrite URLs to the specified server change) # HELPCMD: <mirror>: switch sources to the mirror (supports etersoft/yandex/basealt): rewrite URLs to the specified server
load_helper epm-repofix load_helper epm-repofix
epm_repofix "$@" epm_repofix "$@"
;; ;;
set) # HELPCMD: <mirror>: remove all existing sources and add mirror for the branch set) # HELPCMD: <mirror>: remove all existing sources and add mirror for the branch
epm repo rm all epm repo rm all
epm addrepo "$@" epm addrepo "$@"
;; ;;
switch) # HELPCMD: switch repo to <repo>: rewrite URLs to the repo switch) # HELPCMD: switch repo to <repo>: rewrite URLs to the repo
load_helper epm-repofix load_helper epm-repofix
epm_reposwitch "$@" epm_reposwitch "$@"
;; ;;
enable) # HELPCMD: enable <repo> enable) # HELPCMD: enable <repo>
load_helper epm-repoenable load_helper epm-repoenable
epm_repoenable "$@" epm_repoenable "$@"
;; ;;
disable) # HELPCMD: disable <repo> disable) # HELPCMD: disable <repo>
load_helper epm-repodisable load_helper epm-repodisable
epm_repodisable "$@" epm_repodisable "$@"
;; ;;
addkey) # HELPCMD: add repository gpg key addkey) # HELPCMD: add repository gpg key
load_helper epm-addrepo load_helper epm-addrepo
epm_addkey "$@" 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
;; ;;
save) save)
load_helper epm-reposave load_helper epm-reposave
epm_reposave "$@" epm_reposave "$@"
;; ;;
restore) restore)
load_helper epm-reposave load_helper epm-reposave
epm_reporestore "$@" epm_reporestore "$@"
;; ;;
reset) reset)
load_helper epm-reposave load_helper epm-reposave
epm_reporeset "$@" epm_reporeset "$@"
;; ;;
add) # HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list add) # HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list
load_helper epm-addrepo load_helper epm-addrepo
epm_addrepo "$@" epm_addrepo "$@"
;; ;;
Add) # HELPCMD: like add, but do update after add Add) # HELPCMD: like add, but do update after add
load_helper epm-addrepo load_helper epm-addrepo
epm_addrepo "$@" epm_addrepo "$@"
epm update epm update
;; ;;
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)
load_helper epm-removerepo load_helper epm-removerepo
epm_removerepo "$@" epm_removerepo "$@"
;; ;;
create) # HELPCMD: create (initialize) repo: [path] [name] create) # HELPCMD: create (initialize) repo: [path] [name]
load_helper epm-repoindex load_helper epm-repoindex
epm_repocreate "$@" epm_repocreate "$@"
;; ;;
index) # HELPCMD: index repo: [--init] [path] [name] index) # HELPCMD: index repo: [--init] [path] [name]
load_helper epm-repoindex load_helper epm-repoindex
epm_repoindex "$@" epm_repoindex "$@"
;; ;;
pkgadd) # HELPCMD: add to <dir> applied <package-filename1> [<package-filename2>...] pkgadd) # HELPCMD: add to <dir> applied <package-filename1> [<package-filename2>...]
load_helper epm-repopkg load_helper epm-repopkg
epm_repo_pkgadd "$@" epm_repo_pkgadd "$@"
;; ;;
pkgupdate) # HELPCMD: replace in <dir> with new <package-filename1> [<package-filename2>...] pkgupdate) # HELPCMD: replace in <dir> with new <package-filename1> [<package-filename2>...]
load_helper epm-repopkg load_helper epm-repopkg
epm_repo_pkgupdate "$@" epm_repo_pkgupdate "$@"
;; ;;
pkgdel) # HELPCMD: del from <dir> <package1> [<package2>...] pkgdel) # HELPCMD: del from <dir> <package1> [<package2>...]
load_helper epm-repopkg load_helper epm-repopkg
epm_repo_pkgdel "$@" epm_repo_pkgdel "$@"
;; ;;
*) *)
fatal "Unknown command $ epm repo '$CMD'" fatal "Unknown command $ epm repo '$CMD'"
;; ;;
esac esac
} }
...@@ -25,18 +25,18 @@ alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list' ...@@ -25,18 +25,18 @@ alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
__epm_repodisable_alt() __epm_repodisable_alt()
{ {
local rl local rl
# ^rpm means full string # ^rpm means full string
if rhas "$1" "\^rpm" ; then if rhas "$1" "\^rpm" ; then
rl="$(echo "$1" | sed -e 's|\^||')" rl="$(echo "$1" | sed -e 's|\^||')"
else else
rl="$( (epm --quiet repolist) 2>/dev/null | grep -F "$1" | head -n1 )" rl="$( (epm --quiet repolist) 2>/dev/null | grep -F "$1" | head -n1 )"
[ -z "$rl" ] && warning "Can't find '$1' entries in the repos (see '# epm repolist' output)" && return 1 [ -z "$rl" ] && warning "Can't find '$1' entries in the repos (see '# epm repolist' output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
[ -n "$dryrun" ] && echo "will comment $rp" && continue [ -n "$dryrun" ] && echo "will comment $rp" && continue
sed -i -e "s|^\($(sed_escape "$rl")\)|#\1|" $alt_LISTS sed -i -e "s|^\($(sed_escape "$rl")\)|#\1|" $alt_LISTS
done done
} }
...@@ -44,26 +44,26 @@ epm_repodisable() ...@@ -44,26 +44,26 @@ epm_repodisable()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
assure_root assure_root
__epm_repodisable_alt "$@" __epm_repodisable_alt "$@"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
print_apt_sources_list print_apt_sources_list
;; ;;
yum-rpm) yum-rpm)
docmd yum repolist $verbose docmd yum repolist $verbose
[ -n "$verbose" ] || info "Use --verbose if you need detail information." [ -n "$verbose" ] || info "Use --verbose if you need detail information."
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf config-manager --enable $verbose "$@" sudocmd dnf config-manager --enable $verbose "$@"
;; ;;
eoget) eoget)
docmd eoget disable-repo "$@" docmd eoget disable-repo "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -25,18 +25,18 @@ alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list' ...@@ -25,18 +25,18 @@ alt_LISTS='/etc/apt/sources.list /etc/apt/sources.list.d/*.list'
__epm_repoenable_alt() __epm_repoenable_alt()
{ {
local rl local rl
# ^rpm means full string # ^rpm means full string
if rhas "$1" "\^rpm" ; then if rhas "$1" "\^rpm" ; then
rl="$(echo "$1" | sed -e 's|\^||')" rl="$(echo "$1" | sed -e 's|\^||')"
else else
rl="$( epm --quiet --all repolist 2>/dev/null | grep -F "$1" | head -n1 | sed -e 's|[[:space:]]*#[[:space:]]*||' )" rl="$( epm --quiet --all repolist 2>/dev/null | grep -F "$1" | head -n1 | sed -e 's|[[:space:]]*#[[:space:]]*||' )"
[ -z "$rl" ] && warning "Can't find commented '$1' in the repos (see '# epm repolist' output)" && return 1 [ -z "$rl" ] && warning "Can't find commented '$1' in the repos (see '# epm repolist' output)" && return 1
fi fi
echo "$rl" | while read rp ; do echo "$rl" | while read rp ; do
[ -n "$dryrun" ] && echo "will uncomment $rp" && continue [ -n "$dryrun" ] && echo "will uncomment $rp" && continue
sed -i -e "s|^[[:space:]]*#[[:space:]]*\($(sed_escape "$rl")\)|\1|" $alt_LISTS sed -i -e "s|^[[:space:]]*#[[:space:]]*\($(sed_escape "$rl")\)|\1|" $alt_LISTS
done done
} }
...@@ -44,26 +44,26 @@ epm_repoenable() ...@@ -44,26 +44,26 @@ epm_repoenable()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
assure_root assure_root
__epm_repoenable_alt "$@" __epm_repoenable_alt "$@"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
print_apt_sources_list print_apt_sources_list
;; ;;
yum-rpm) yum-rpm)
docmd yum repolist $verbose docmd yum repolist $verbose
[ -n "$verbose" ] || info "Use --verbose if you need detail information." [ -n "$verbose" ] || info "Use --verbose if you need detail information."
;; ;;
dnf-rpm) dnf-rpm)
sudocmd dnf config-manager --disable $verbose "$@" sudocmd dnf config-manager --disable $verbose "$@"
;; ;;
eoget) eoget)
docmd eoget enable-repo "$@" docmd eoget enable-repo "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -22,104 +22,104 @@ load_helper epm-query ...@@ -22,104 +22,104 @@ load_helper epm-query
__replace_text_in_alt_repo() __replace_text_in_alt_repo()
{ {
local i local i
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
[ -s "$i" ] || continue [ -s "$i" ] || continue
# TODO: don't change file if untouched # TODO: don't change file if untouched
#grep -q -- "$1" "$i" || continue #grep -q -- "$1" "$i" || continue
regexp_subst "$1" "$i" regexp_subst "$1" "$i"
done done
} }
__repofix_check_vendor() __repofix_check_vendor()
{ {
local i local i
for i in /etc/apt/vendors.list.d/*.list; do for i in /etc/apt/vendors.list.d/*.list; do
[ -e "$i" ] || continue [ -e "$i" ] || continue
grep -q "^simple-key \"$1\"" $i && return grep -q "^simple-key \"$1\"" $i && return
done done
return 1 return 1
} }
__repofix_filter_vendor() __repofix_filter_vendor()
{ {
local br="$1" local br="$1"
br="$(echo "$br" | sed -e "s|\..*||")" br="$(echo "$br" | sed -e "s|\..*||")"
case $br in case $br in
c8*) c8*)
br="cert8" br="cert8"
;; ;;
c9*) c9*)
br="cert9" br="cert9"
;; ;;
Sisyphus) Sisyphus)
br="alt" br="alt"
;; ;;
esac esac
echo "$br" echo "$br"
} }
__replace_alt_version_in_repo() __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 ..."
a='' apt-repo list | sed -E -e "s|($1)|{\1}->{$2}|g" | grep -E --color -- "$1" a='' apt-repo list | sed -E -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 | grep -E -q -- "$1" ; then if a='' apt-repo list | grep -E -q -- "$1" ; then
__replace_text_in_alt_repo "/^ *#/! s!$1!$2!g" __replace_text_in_alt_repo "/^ *#/! s!$1!$2!g"
fi fi
#docmd apt-repo list #docmd apt-repo list
} }
__alt_replace_sign_name() __alt_replace_sign_name()
{ {
local TO="$1" local TO="$1"
__replace_text_in_alt_repo "/^ *#/! s!\[alt\]!$TO!g" __replace_text_in_alt_repo "/^ *#/! s!\[alt\]!$TO!g"
__replace_text_in_alt_repo "/^ *#/! s!\[sisyphus\]!$TO!g" __replace_text_in_alt_repo "/^ *#/! s!\[sisyphus\]!$TO!g"
__replace_text_in_alt_repo "/^ *#/! s!\[updates\]!$TO!g" __replace_text_in_alt_repo "/^ *#/! s!\[updates\]!$TO!g"
__replace_text_in_alt_repo "/^ *#/! s!\[cert[789]\]!$TO!g" __replace_text_in_alt_repo "/^ *#/! s!\[cert[789]\]!$TO!g"
__replace_text_in_alt_repo "/^ *#/! s!\[p10\.?[0-9]?\]!$TO!g" __replace_text_in_alt_repo "/^ *#/! s!\[p10\.?[0-9]?\]!$TO!g"
__replace_text_in_alt_repo "/^ *#/! s!\[[tpc][6-9]\.?[0-9]?\]!$TO!g" __replace_text_in_alt_repo "/^ *#/! s!\[[tpc][6-9]\.?[0-9]?\]!$TO!g"
} }
__alt_repofix() __alt_repofix()
{ {
local TO="$1" local TO="$1"
epm --quiet repo fix >/dev/null epm --quiet repo fix >/dev/null
if [ -n "$TO" ] ; then if [ -n "$TO" ] ; then
# TODO: switch it in repo code # TODO: switch it in repo code
TO="$(__repofix_filter_vendor "$TO")" TO="$(__repofix_filter_vendor "$TO")"
__alt_replace_sign_name "[$TO]" __alt_replace_sign_name "[$TO]"
fi fi
} }
#__switch_repo_to() #__switch_repo_to()
epm_reposwitch() epm_reposwitch()
{ {
local TO="$1" local TO="$1"
[ -n "$TO" ] || fatal "run repo switch with arg (p9, p10, Sisyphus)" [ -n "$TO" ] || fatal "run repo switch with arg (p9, p10, Sisyphus)"
[ "$TO" = "sisyphus" ] && TO="Sisyphus" [ "$TO" = "sisyphus" ] && TO="Sisyphus"
if [ "$TO" = "Sisyphus" ] ; then if [ "$TO" = "Sisyphus" ] ; then
__replace_alt_version_in_repo "[tpc][5-9]\.?[0-9]?/branch/" "$TO/" __replace_alt_version_in_repo "[tpc][5-9]\.?[0-9]?/branch/" "$TO/"
__replace_alt_version_in_repo "p10\.?[0-9]?/branch/" "$TO/" __replace_alt_version_in_repo "p10\.?[0-9]?/branch/" "$TO/"
else else
__replace_alt_version_in_repo "Sisyphus/" "$TO/branch/" __replace_alt_version_in_repo "Sisyphus/" "$TO/branch/"
__replace_alt_version_in_repo "[tpc][5-9]\.?[0-9]?/branch/" "$TO/branch/" __replace_alt_version_in_repo "[tpc][5-9]\.?[0-9]?/branch/" "$TO/branch/"
if [ "$TO" != "p10" ] ; then if [ "$TO" != "p10" ] ; then
__replace_alt_version_in_repo "p10\.?[0-9]?/branch/" "$TO/branch/" __replace_alt_version_in_repo "p10\.?[0-9]?/branch/" "$TO/branch/"
fi fi
fi fi
__alt_repofix "$TO" __alt_repofix "$TO"
if [ "$TO" = "p10" ] ; then if [ "$TO" = "p10" ] ; then
echo '%_priority_distbranch p10' >/etc/rpm/macros.d/p10 echo '%_priority_distbranch p10' >/etc/rpm/macros.d/p10
else else
rm -fv /etc/rpm/macros.d/p10 rm -fv /etc/rpm/macros.d/p10
fi fi
#epm repo list #epm repo list
} }
...@@ -127,107 +127,107 @@ epm_reposwitch() ...@@ -127,107 +127,107 @@ epm_reposwitch()
# example: /etc/apt/source.list p7 ALTLinux\/Sisyphus # example: /etc/apt/source.list p7 ALTLinux\/Sisyphus
__try_fix_apt_source_list() __try_fix_apt_source_list()
{ {
local list="$1" local list="$1"
local br="$(__repofix_filter_vendor "$2")" local br="$(__repofix_filter_vendor "$2")"
local path="$3" local path="$3"
if grep -q -e "^[^#].*$path" $list ; then if grep -q -e "^[^#].*$path" $list ; then
if __repofix_check_vendor $br ; then if __repofix_check_vendor $br ; then
regexp_subst "/$path/s/^rpm[[:space:]]*([fhr])/rpm [$br] \1/" $list regexp_subst "/$path/s/^rpm[[:space:]]*([fhr])/rpm [$br] \1/" $list
else else
warning "Skip set $br vendor key (it is missed) for $list" warning "Skip set $br vendor key (it is missed) for $list"
regexp_subst "/$path/s/^rpm[[:space:]]*\[$br\][[:space:]]*([fhr])/rpm \1/" $list regexp_subst "/$path/s/^rpm[[:space:]]*\[$br\][[:space:]]*([fhr])/rpm \1/" $list
fi fi
fi fi
} }
__fix_alt_sources_list() __fix_alt_sources_list()
{ {
# for beauty spaces # for beauty spaces
local SUBST_ALT_RULE1='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi' local SUBST_ALT_RULE1='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi'
local SUBST_ALT_RULE2='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*([tcp][6-9]\.?[0-9]?[/ ]branch|[tcp]1[012][/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi' local SUBST_ALT_RULE2='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*([tcp][6-9]\.?[0-9]?[/ ]branch|[tcp]1[012][/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch|aarch64) !\1 \2/\3/\4 !gi'
local i local i
for i in "$@" ; do for i in "$@" ; do
[ -s "$i" ] || continue [ -s "$i" ] || continue
#perl -i.bak -pe "$SUBST_ALT_RULE" $i #perl -i.bak -pe "$SUBST_ALT_RULE" $i
# TODO: only for uncommented strings # TODO: only for uncommented strings
#sed -i -r -e "$SUBST_ALT_RULE" $i #sed -i -r -e "$SUBST_ALT_RULE" $i
regexp_subst "/^ *#/! s| pub|/pub|" $i regexp_subst "/^ *#/! s| pub|/pub|" $i
regexp_subst "/^ *#/! $SUBST_ALT_RULE1" $i regexp_subst "/^ *#/! $SUBST_ALT_RULE1" $i
regexp_subst "/^ *#/! $SUBST_ALT_RULE2" $i regexp_subst "/^ *#/! $SUBST_ALT_RULE2" $i
# Sisyphus uses 'alt' vendor key # Sisyphus uses 'alt' vendor key
__try_fix_apt_source_list $i alt "ALTLinux\/Sisyphus" __try_fix_apt_source_list $i alt "ALTLinux\/Sisyphus"
__try_fix_apt_source_list $i etersoft "Etersoft\/Sisyphus" __try_fix_apt_source_list $i etersoft "Etersoft\/Sisyphus"
# skip branch replacement for ALT Linux Sisyphus # skip branch replacement for ALT Linux Sisyphus
[ "$DISTRVERSION" = "Sisyphus" ] && continue [ "$DISTRVERSION" = "Sisyphus" ] && continue
# add signs for branches # add signs for branches
__try_fix_apt_source_list $i $DISTRVERSION "ALTLinux\/$DISTRVERSION\/branch" __try_fix_apt_source_list $i $DISTRVERSION "ALTLinux\/$DISTRVERSION\/branch"
__try_fix_apt_source_list $i etersoft "Etersoft\/$DISTRVERSION\/branch" __try_fix_apt_source_list $i etersoft "Etersoft\/$DISTRVERSION\/branch"
done done
} }
__subst_with_etersoft_url() __subst_with_etersoft_url()
{ {
local NURL="http://download.etersoft.ru/pub ALTLinux" local NURL="http://download.etersoft.ru/pub ALTLinux"
echo "$1" | sed \ echo "$1" | sed \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" -e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|"
} }
__subst_with_yandex_url() __subst_with_yandex_url()
{ {
local NURL="http://mirror.yandex.ru altlinux" local NURL="http://mirror.yandex.ru altlinux"
echo "$1" | sed \ echo "$1" | sed \
-e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.altlinux.org/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.basealt.ru/pub/distributions/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|" -e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|"
} }
__subst_with_basealt_url() __subst_with_basealt_url()
{ {
local NURL="http://ftp.basealt.ru/pub/distributions ALTLinux" local NURL="http://ftp.basealt.ru/pub/distributions ALTLinux"
echo "$1" | sed \ echo "$1" | sed \
-e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \ -e "s|h\?f\?t\?tp://mirror.yandex.ru/* altlinux|$NURL|" \
-e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \ -e "s|h\?f\?t\?tp://ftp.etersoft.ru/pub/* ALTLinux|$NURL|" \
-e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|" -e "s|h\?f\?t\?tp://download.etersoft.ru/pub/* ALTLinux|$NURL|"
} }
__fix_repo_to_etersoft() __fix_repo_to_etersoft()
{ {
local NN local NN
a="" apt-repo list | grep -v debuginfo | grep -v etersoft | grep -v "file:/" | while read nn ; do a="" apt-repo list | grep -v debuginfo | grep -v etersoft | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_etersoft_url "$nn")" NN="$(__subst_with_etersoft_url "$nn")"
[ "$NN" = "$nn" ] && continue [ "$NN" = "$nn" ] && continue
epm removerepo "$nn" epm removerepo "$nn"
epm addrepo "$NN" epm addrepo "$NN"
done done
} }
__fix_repo_to_yandex() __fix_repo_to_yandex()
{ {
local NN local NN
a="" apt-repo list | grep -v debuginfo | grep -v mirror\.yandex | grep -v "file:/" | while read nn ; do a="" apt-repo list | grep -v debuginfo | grep -v mirror\.yandex | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_yandex_url "$nn")" NN="$(__subst_with_yandex_url "$nn")"
[ "$NN" = "$nn" ] && continue [ "$NN" = "$nn" ] && continue
epm removerepo "$nn" epm removerepo "$nn"
epm addrepo "$NN" epm addrepo "$NN"
done done
} }
__fix_repo_to_basealt() __fix_repo_to_basealt()
{ {
local NN local NN
a="" apt-repo list | grep -v debuginfo | grep -v ftp.basealt | grep -v "file:/" | while read nn ; do a="" apt-repo list | grep -v debuginfo | grep -v ftp.basealt | grep -v "file:/" | while read nn ; do
NN="$(__subst_with_basealt_url "$nn")" NN="$(__subst_with_basealt_url "$nn")"
[ "$NN" = "$nn" ] && continue [ "$NN" = "$nn" ] && continue
epm removerepo "$nn" epm removerepo "$nn"
epm addrepo "$NN" epm addrepo "$NN"
done done
} }
...@@ -235,38 +235,38 @@ epm_repofix() ...@@ -235,38 +235,38 @@ epm_repofix()
{ {
case $BASEDISTRNAME in case $BASEDISTRNAME in
"alt") "alt")
assure_exists apt-repo assure_exists apt-repo
[ -n "$quiet" ] || docmd apt-repo list [ -n "$quiet" ] || docmd apt-repo list
assure_root assure_root
__fix_alt_sources_list /etc/apt/sources.list __fix_alt_sources_list /etc/apt/sources.list
__fix_alt_sources_list /etc/apt/sources.list.d/*.list __fix_alt_sources_list /etc/apt/sources.list.d/*.list
# TODO: move to repo change # TODO: move to repo change
if [ "$1" = "etersoft" ] ; then if [ "$1" = "etersoft" ] ; then
__fix_repo_to_etersoft /etc/apt/sources.list __fix_repo_to_etersoft /etc/apt/sources.list
__fix_repo_to_etersoft /etc/apt/sources.list.d/*.list __fix_repo_to_etersoft /etc/apt/sources.list.d/*.list
fi fi
if [ "$1" = "yandex" ] ; then if [ "$1" = "yandex" ] ; then
__fix_repo_to_yandex /etc/apt/sources.list __fix_repo_to_yandex /etc/apt/sources.list
__fix_repo_to_yandex /etc/apt/sources.list.d/*.list __fix_repo_to_yandex /etc/apt/sources.list.d/*.list
fi fi
if [ "$1" = "basealt" ] ; then if [ "$1" = "basealt" ] ; then
__fix_repo_to_basealt /etc/apt/sources.list __fix_repo_to_basealt /etc/apt/sources.list
__fix_repo_to_basealt /etc/apt/sources.list.d/*.list __fix_repo_to_basealt /etc/apt/sources.list.d/*.list
fi fi
docmd apt-repo list docmd apt-repo list
return return
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
# apt-rpm) # apt-rpm)
# ;; # ;;
# yum-rpm|dnf-rpm) # yum-rpm|dnf-rpm)
# ;; # ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -34,60 +34,60 @@ get_archlist() ...@@ -34,60 +34,60 @@ get_archlist()
# https://www.altlinux.org/APT_%D0%B2_ALT_Linux/CreateRepository # https://www.altlinux.org/APT_%D0%B2_ALT_Linux/CreateRepository
__epm_repoindex_alt() __epm_repoindex_alt()
{ {
local archlist="i586 x86_64 aarch64 noarch" local archlist="i586 x86_64 aarch64 noarch"
local init='' local init=''
if [ "$1" = "--init" ] ; then if [ "$1" = "--init" ] ; then
init='--init' init='--init'
shift shift
fi fi
epm assure genbasedir apt-repo-tools || fatal epm assure genbasedir apt-repo-tools || fatal
REPO_DIR="$1" REPO_DIR="$1"
# TODO: check if we inside arch dir or RPMS.* # TODO: check if we inside arch dir or RPMS.*
[ -n "$REPO_DIR" ] || REPO_DIR="$(pwd)" [ -n "$REPO_DIR" ] || REPO_DIR="$(pwd)"
if [ -z "$init" ] ; then if [ -z "$init" ] ; then
[ -d "$REPO_DIR" ] || fatal "Repo dir $REPO_DIR does not exist" [ -d "$REPO_DIR" ] || fatal "Repo dir $REPO_DIR does not exist"
fi fi
REPO_NAME="$2" REPO_NAME="$2"
if [ -z "$REPO_NAME" ] ; then if [ -z "$REPO_NAME" ] ; then
# default name # default name
REPO_NAME="addon" REPO_NAME="addon"
# detect name if already exists # detect name if already exists
for arch in $archlist ; do for arch in $archlist ; do
local rd="$(echo $REPO_DIR/$arch/RPMS.*)" local rd="$(echo $REPO_DIR/$arch/RPMS.*)"
[ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break [ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break
done done
fi fi
if [ -n "$init" ] ; then if [ -n "$init" ] ; then
for arch in $(get_archlist); do for arch in $(get_archlist); do
mkdir -pv "$REPO_DIR/$arch/base/" mkdir -pv "$REPO_DIR/$arch/base/"
mkdir -pv "$REPO_DIR/$arch/RPMS.$REPO_NAME/" mkdir -pv "$REPO_DIR/$arch/RPMS.$REPO_NAME/"
done done
return return
fi fi
for arch in $archlist; do for arch in $archlist; do
[ -d "$REPO_DIR/$arch/RPMS.$REPO_NAME" ] || continue [ -d "$REPO_DIR/$arch/RPMS.$REPO_NAME" ] || continue
mkdir -pv "$REPO_DIR/$arch/base/" mkdir -pv "$REPO_DIR/$arch/base/"
sudocmd genbasedir --bloat --progress --topdir=$REPO_DIR $arch $REPO_NAME sudocmd genbasedir --bloat --progress --topdir=$REPO_DIR $arch $REPO_NAME
done done
} }
__epm_repoindex_deb() __epm_repoindex_deb()
{ {
local init='' local init=''
if [ "$1" = "--init" ] ; then if [ "$1" = "--init" ] ; then
init='--init' init='--init'
shift shift
fi fi
local dir="$1" local dir="$1"
sudocmd mkdir -pv "$dir" || fatal sudocmd mkdir -pv "$dir" || fatal
assure_exists gzip 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"
} }
...@@ -95,30 +95,30 @@ epm_repoindex() ...@@ -95,30 +95,30 @@ epm_repoindex()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_repoindex_alt "$@" __epm_repoindex_alt "$@"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
__epm_repoindex_deb "$@" __epm_repoindex_deb "$@"
;; ;;
yum-rpm) yum-rpm)
epm install --skip-installed yum-utils createrepo || fatal epm install --skip-installed yum-utils createrepo || fatal
sudocmd mkdir -pv "$@" sudocmd mkdir -pv "$@"
sudocmd createrepo -v -s md5 "$@" sudocmd createrepo -v -s md5 "$@"
sudocmd verifytree sudocmd verifytree
;; ;;
dnf-rpm) dnf-rpm)
epm install --skip-installed yum-utils createrepo || fatal epm install --skip-installed yum-utils createrepo || fatal
sudocmd mkdir -pv "$@" sudocmd mkdir -pv "$@"
sudocmd createrepo -v -s md5 "$@" sudocmd createrepo -v -s md5 "$@"
sudocmd verifytree sudocmd verifytree
;; ;;
eoget) eoget)
docmd eoget index "$@" docmd eoget index "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
......
...@@ -49,9 +49,9 @@ __print_apt_sources_list_list() ...@@ -49,9 +49,9 @@ __print_apt_sources_list_list()
__info_cyan() __info_cyan()
{ {
set_boldcolor $CYAN set_boldcolor $CYAN
echo "$*" >&2 echo "$*" >&2
restore_color restore_color
} }
__print_apt_sources_list_verbose() __print_apt_sources_list_verbose()
...@@ -101,60 +101,60 @@ epm_repolist() ...@@ -101,60 +101,60 @@ epm_repolist()
[ -z "$*" ] || [ "$PMTYPE" = "apt-rpm" ] || fatal "No arguments are allowed here" [ -z "$*" ] || [ "$PMTYPE" = "apt-rpm" ] || fatal "No arguments are allowed here"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
#assure_exists apt-repo #assure_exists apt-repo
if tasknumber "$1" >/dev/null ; then if tasknumber "$1" >/dev/null ; then
get_task_packages "$@" get_task_packages "$@"
else else
print_apt_sources_list "$@" print_apt_sources_list "$@"
#docmd apt-repo list #docmd apt-repo list
fi fi
;; ;;
deepsolver-rpm) deepsolver-rpm)
docmd ds-conf docmd ds-conf
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
print_apt_sources_list "$@" print_apt_sources_list "$@"
;; ;;
yum-rpm) yum-rpm)
docmd yum repolist $verbose docmd yum repolist $verbose
[ -n "$verbose" ] || info "Use --verbose if you need detail information." [ -n "$verbose" ] || info "Use --verbose if you need detail information."
;; ;;
dnf-rpm) dnf-rpm)
docmd dnf repolist $verbose docmd dnf repolist $verbose
[ -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-media active --list-url docmd urpmq --list-media active --list-url
;; ;;
zypper-rpm) zypper-rpm)
docmd zypper sl -d docmd zypper sl -d
;; ;;
packagekit) packagekit)
docmd pkcon repo-list docmd pkcon repo-list
;; ;;
emerge) emerge)
docmd eselect profile list docmd eselect profile list
docmd layman -L docmd layman -L
;; ;;
xbps) xbps)
docmd xbps-query -L docmd xbps-query -L
;; ;;
winget) winget)
docmd winget source list docmd winget source list
;; ;;
eoget) eoget)
docmd eoget list-repo docmd eoget list-repo
;; ;;
pacman) pacman)
docmd grep -v -- "^#\|^$" /etc/pacman.conf docmd grep -v -- "^#\|^$" /etc/pacman.conf
;; ;;
slackpkg) slackpkg)
docmd grep -v -- "^#\|^$" /etc/slackpkg/mirrors docmd grep -v -- "^#\|^$" /etc/slackpkg/mirrors
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -21,73 +21,73 @@ load_helper epm-sh-altlinux ...@@ -21,73 +21,73 @@ load_helper epm-sh-altlinux
__epm_repo_pkgadd_alt() __epm_repo_pkgadd_alt()
{ {
local archlist="i586 x86_64 aarch64 noarch" local archlist="i586 x86_64 aarch64 noarch"
local REPO_DIR="$1" local REPO_DIR="$1"
shift shift
[ -d "$REPO_DIR" ] || fatal "Can't find repo dir $REPO_DIR." [ -d "$REPO_DIR" ] || fatal "Can't find repo dir $REPO_DIR."
# default name # default name
REPO_NAME="addon" REPO_NAME="addon"
# detect if already exists # detect if already exists
for arch in $archlist ; do for arch in $archlist ; do
local rd="$(echo $REPO_DIR/$arch/RPMS.*)" local rd="$(echo $REPO_DIR/$arch/RPMS.*)"
[ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break [ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break
done done
[ -n "$1" ] || fatal "Missed package name" [ -n "$1" ] || fatal "Missed package name"
while [ -s "$1" ] ; do while [ -s "$1" ] ; do
arch="$(epm print arch from filename "$1")" || fatal arch="$(epm print arch from filename "$1")" || fatal
epm checkpkg "$1" || fatal epm checkpkg "$1" || fatal
cp -v "$1" $REPO_DIR/$arch/RPMS.$REPO_NAME || fatal cp -v "$1" $REPO_DIR/$arch/RPMS.$REPO_NAME || fatal
shift shift
done done
} }
__epm_repo_pkgdel_alt() __epm_repo_pkgdel_alt()
{ {
local archlist="i586 x86_64 aarch64 noarch" local archlist="i586 x86_64 aarch64 noarch"
local REPO_DIR="$1" local REPO_DIR="$1"
shift shift
[ -d "$REPO_DIR" ] || fatal "Can't find repo dir $REPO_DIR." [ -d "$REPO_DIR" ] || fatal "Can't find repo dir $REPO_DIR."
[ -n "$1" ] || fatal "Missed package name" [ -n "$1" ] || fatal "Missed package name"
# default name # default name
REPO_NAME="addon" REPO_NAME="addon"
# detect if already exists # detect if already exists
for arch in $archlist ; do for arch in $archlist ; do
local rd="$(echo $REPO_DIR/$arch/RPMS.*)" local rd="$(echo $REPO_DIR/$arch/RPMS.*)"
[ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break [ -d "$rd" ] && REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')" && break
done done
while [ -s "$1" ] ; do while [ -s "$1" ] ; do
for arch in $archlist ; do for arch in $archlist ; do
local rd="$REPO_DIR/$arch/RPMS.$REPO_NAME" local rd="$REPO_DIR/$arch/RPMS.$REPO_NAME"
for i in $rd/$1* ; do for i in $rd/$1* ; do
[ "$1" = "$(epm print name for package $i)" || continue [ "$1" = "$(epm print name for package $i)" || continue
rm -v $rd/$1* rm -v $rd/$1*
done done
done done
shift shift
done done
} }
__epm_repo_pkgupdate_alt() __epm_repo_pkgupdate_alt()
{ {
local dir="$1" local dir="$1"
shift shift
for i in "$@" ; do for i in "$@" ; do
pkg="$(epm print name for package $i)" || fatal pkg="$(epm print name for package $i)" || fatal
__epm_repo_pkgdel_alt "$dir" $pkg __epm_repo_pkgdel_alt "$dir" $pkg
done done
__epm_repo_pkgadd_alt "$dir" "$@" __epm_repo_pkgadd_alt "$dir" "$@"
} }
...@@ -96,12 +96,12 @@ epm_repo_pkgadd() ...@@ -96,12 +96,12 @@ epm_repo_pkgadd()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_repo_pkgadd_alt "$@" __epm_repo_pkgadd_alt "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -111,12 +111,12 @@ epm_repo_pkgupdate() ...@@ -111,12 +111,12 @@ epm_repo_pkgupdate()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_repo_pkgupdate_alt "$@" __epm_repo_pkgupdate_alt "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -126,12 +126,12 @@ epm_repo_pkgdel() ...@@ -126,12 +126,12 @@ epm_repo_pkgdel()
{ {
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__epm_repo_pkgdel_alt "$@" __epm_repo_pkgdel_alt "$@"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
......
...@@ -24,54 +24,54 @@ load_helper epm-sh-altlinux ...@@ -24,54 +24,54 @@ load_helper epm-sh-altlinux
SAVELISTDIR=/tmp/eepm-etc-save SAVELISTDIR=/tmp/eepm-etc-save
__save_alt_repo_lists() __save_alt_repo_lists()
{ {
assure_root assure_root
info "Creating copy of all sources lists to $SAVELISTDIR ..." info "Creating copy of all sources lists to $SAVELISTDIR ..."
local i local i
rm -rf $verbose $SAVELISTDIR 2>/dev/null rm -rf $verbose $SAVELISTDIR 2>/dev/null
mkdir -p $SAVELISTDIR/apt/ $SAVELISTDIR/apt/sources.list.d/ mkdir -p $SAVELISTDIR/apt/ $SAVELISTDIR/apt/sources.list.d/
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
[ -s "$i" ] || continue [ -s "$i" ] || continue
local DD="$(echo "$i" | sed -e "s|/etc|$SAVELISTDIR|")" local DD="$(echo "$i" | sed -e "s|/etc|$SAVELISTDIR|")"
cp -af $verbose "$i" "$DD" || fatal "Can't save apt source list files to $SAVELISTDIR" cp -af $verbose "$i" "$DD" || fatal "Can't save apt source list files to $SAVELISTDIR"
done done
} }
# under root only # under root only
__restore_alt_repo_lists() __restore_alt_repo_lists()
{ {
assure_root assure_root
info "Restoring copy of all sources lists from $SAVELISTDIR ..." info "Restoring copy of all sources lists from $SAVELISTDIR ..."
local i local i
[ -d "$SAVELISTDIR/apt" ] || return 0 [ -d "$SAVELISTDIR/apt" ] || return 0
mkdir -p $SAVELISTDIR/apt/ $SAVELISTDIR/apt/sources.list.d/ mkdir -p $SAVELISTDIR/apt/ $SAVELISTDIR/apt/sources.list.d/
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
[ -s "$i" ] || continue [ -s "$i" ] || continue
local DD="$(echo "$i" | sed -e "s|/etc|$SAVELISTDIR|")" local DD="$(echo "$i" | sed -e "s|/etc|$SAVELISTDIR|")"
# restore only if there are differences # restore only if there are differences
if diff -q "$DD" "$i" >/dev/null ; then if diff -q "$DD" "$i" >/dev/null ; then
rm -f $verbose "$DD" rm -f $verbose "$DD"
else else
mv $verbose "$DD" "$i" || warning "Can't restore $i file" mv $verbose "$DD" "$i" || warning "Can't restore $i file"
fi fi
done done
} }
# save and restore repo lists # save and restore repo lists
__on_error_restore_alt_repo_lists() __on_error_restore_alt_repo_lists()
{ {
warning "An error occurred..." warning "An error occurred..."
epm repo restore epm repo restore
} }
try_change_alt_repo() try_change_alt_repo()
{ {
epm repo save epm repo save
trap __on_error_restore_alt_repo_lists EXIT trap __on_error_restore_alt_repo_lists EXIT
} }
end_change_alt_repo() end_change_alt_repo()
{ {
trap - EXIT trap - EXIT
} }
...@@ -79,16 +79,16 @@ end_change_alt_repo() ...@@ -79,16 +79,16 @@ end_change_alt_repo()
epm_reposave() epm_reposave()
{ {
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
if ! is_root ; then if ! is_root ; then
sudoepm repo save sudoepm repo save
return return
fi fi
__save_alt_repo_lists __save_alt_repo_lists
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -96,16 +96,16 @@ esac ...@@ -96,16 +96,16 @@ esac
epm_reporestore() epm_reporestore()
{ {
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
if ! is_root ; then if ! is_root ; then
sudoepm repo restore sudoepm repo restore
return return
fi fi
__restore_alt_repo_lists __restore_alt_repo_lists
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -113,12 +113,12 @@ esac ...@@ -113,12 +113,12 @@ esac
epm_reporeset() epm_reporeset()
{ {
case $PMTYPE in case $PMTYPE in
winget) winget)
sudocmd winget source reset sudocmd winget source reset
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -22,143 +22,143 @@ load_helper epm-print ...@@ -22,143 +22,143 @@ load_helper epm-print
__epm_filter_out_base_alt_reqs() __epm_filter_out_base_alt_reqs()
{ {
grep -E -v "(^rpmlib\(|^/bin/sh|^/bin/bash|^rtld\(GNU_HASH\)|ld-linux)" grep -E -v "(^rpmlib\(|^/bin/sh|^/bin/bash|^rtld\(GNU_HASH\)|ld-linux)"
} }
__epm_alt_rpm_requires() __epm_alt_rpm_requires()
{ {
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
# TODO see also rpmreqs from etersoft-build-utils # TODO see also rpmreqs from etersoft-build-utils
docmd rpm -q --requires "$@" | __epm_filter_out_base_alt_reqs | sed -e "s| .*||" docmd rpm -q --requires "$@" | __epm_filter_out_base_alt_reqs | sed -e "s| .*||"
else else
docmd rpm -q --requires "$@" | __epm_filter_out_base_alt_reqs docmd rpm -q --requires "$@" | __epm_filter_out_base_alt_reqs
fi fi
} }
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)"
case "$PKGTYPE" in case "$PKGTYPE" in
rpm) rpm)
assure_exists rpm >/dev/null assure_exists rpm >/dev/null
__epm_alt_rpm_requires -p $pkg_files __epm_alt_rpm_requires -p $pkg_files
;; ;;
deb) deb)
assure_exists dpkg >/dev/null assure_exists dpkg >/dev/null
a='' docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g" a='' docmd dpkg -I $pkg_files | grep "^ *Depends:" | sed "s|^ *Depends:||g"
;; ;;
eopkg) eopkg)
showcmd eopkg info $pkg_files showcmd eopkg info $pkg_files
a= eopkg info $pkg_files | grep "^Dependencies" | head -n1 | sed -e "s|Dependencies[[:space:]]*: ||" a= eopkg info $pkg_files | grep "^Dependencies" | head -n1 | sed -e "s|Dependencies[[:space:]]*: ||"
;; ;;
*) *)
fatal "Have no suitable command for $PKGTYPE" fatal "Have no suitable command for $PKGTYPE"
;; ;;
esac esac
} }
epm_requires_names() epm_requires_names()
{ {
local pkg_names="$*" local pkg_names="$*"
local CMD local CMD
[ -n "$pkg_names" ] || return [ -n "$pkg_names" ] || return
# by package name # by package name
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# FIXME: need fix for a few names case # FIXME: need fix for a few names case
# FIXME: too low level of requires name (libSOME.so) # FIXME: too low level of requires name (libSOME.so)
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
assure_exists rpm >/dev/null assure_exists rpm >/dev/null
__epm_alt_rpm_requires $pkg_names __epm_alt_rpm_requires $pkg_names
return return
else else
if [ -n "$verbose" ] ; then if [ -n "$verbose" ] ; then
CMD="apt-cache depends" CMD="apt-cache depends"
else else
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
LANG=C docmd apt-cache depends $pkg_names | grep "Depends:" | sed -e "s|.*Depends: ||" -e "s|<\(.*\)>|\1|" | __epm_filter_out_base_alt_reqs | sed -e "s| .*||" LANG=C docmd apt-cache depends $pkg_names | grep "Depends:" | sed -e "s|.*Depends: ||" -e "s|<\(.*\)>|\1|" | __epm_filter_out_base_alt_reqs | sed -e "s| .*||"
else else
LANG=C docmd apt-cache depends $pkg_names | grep "Depends:" | sed -e "s|.*Depends: ||" -e "s|<\(.*\)>|\1|" | __epm_filter_out_base_alt_reqs LANG=C docmd apt-cache depends $pkg_names | grep "Depends:" | sed -e "s|.*Depends: ||" -e "s|<\(.*\)>|\1|" | __epm_filter_out_base_alt_reqs
fi fi
return return
fi fi
fi fi
;; ;;
packagekit) packagekit)
CMD="pkcon required-by" CMD="pkcon required-by"
;; ;;
#zypper-rpm) #zypper-rpm)
# # FIXME: use hi level commands # # FIXME: use hi level commands
# CMD="rpm -q --requires" # CMD="rpm -q --requires"
# ;; # ;;
urpm-rpm) urpm-rpm)
CMD="urpmq --requires" CMD="urpmq --requires"
;; ;;
yum-rpm) yum-rpm)
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --requires" CMD="rpm -q --requires"
else else
CMD="yum deplist" CMD="yum deplist"
fi fi
;; ;;
dnf-rpm) dnf-rpm)
if is_installed $pkg_names ; then if is_installed $pkg_names ; then
CMD="rpm -q --requires" CMD="rpm -q --requires"
else else
CMD="dnf repoquery --requires" CMD="dnf repoquery --requires"
fi fi
;; ;;
pacman) pacman)
CMD="pactree" CMD="pactree"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
# 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"
fi fi
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
CMD="equery depgraph" CMD="equery depgraph"
;; ;;
homebrew) homebrew)
#docmd brew info $pkg_names | grep "^Required: " | sed -s "|s|^Requires: ||" #docmd brew info $pkg_names | grep "^Required: " | sed -s "|s|^Requires: ||"
docmd brew deps $pkg_names docmd brew deps $pkg_names
return return
;; ;;
pkgng) pkgng)
#CMD="pkg rquery '%dn-%dv'" #CMD="pkg rquery '%dn-%dv'"
CMD="pkg info -d" CMD="pkg info -d"
;; ;;
opkg) opkg)
CMD="opkg depends" CMD="opkg depends"
;; ;;
eopkg) eopkg)
showcmd eopkg info $pkg_names showcmd eopkg info $pkg_names
a= eopkg info $pkg_names | grep "^Dependencies" | sed -e "s|Dependencies[[:space:]]*: ||" a= eopkg info $pkg_names | grep "^Dependencies" | sed -e "s|Dependencies[[:space:]]*: ||"
return return
;; ;;
xbps) xbps)
CMD="xbps-query -x" CMD="xbps-query -x"
;; ;;
aptcyg) aptcyg)
#CMD="apt-cyg depends" #CMD="apt-cyg depends"
# print show version # print show version
docmd apt-cyg show $pkg_names | grep "^requires: " | sed "s|^requires: ||g" docmd apt-cyg show $pkg_names | grep "^requires: " | sed "s|^requires: ||g"
return return
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
...@@ -168,8 +168,8 @@ docmd $CMD $pkg_names ...@@ -168,8 +168,8 @@ docmd $CMD $pkg_names
epm_requires() epm_requires()
{ {
[ -n "$pkg_filenames" ] || fatal "Requires: package name is missed" [ -n "$pkg_filenames" ] || fatal "Requires: package name is missed"
epm_requires_files $pkg_files epm_requires_files $pkg_files
# shellcheck disable=SC2046 # shellcheck disable=SC2046
epm_requires_names $(print_name $pkg_names) epm_requires_names $(print_name $pkg_names)
} }
...@@ -25,102 +25,102 @@ __epm_search_output() ...@@ -25,102 +25,102 @@ __epm_search_output()
local CMD local CMD
local string="$*" local string="$*"
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
CMD="apt-cache search --" CMD="apt-cache search --"
;; ;;
aptitude-dpkg) aptitude-dpkg)
CMD="aptitude search --" CMD="aptitude search --"
;; ;;
deepsolver-rpm) deepsolver-rpm)
CMD="ds-require --" CMD="ds-require --"
;; ;;
packagekit) packagekit)
CMD="pkcon search name" CMD="pkcon search name"
;; ;;
urpm-rpm) urpm-rpm)
# urpmq does not support -- # urpmq does not support --
CMD="urpmq -y" CMD="urpmq -y"
;; ;;
pkgsrc) pkgsrc)
CMD="pkg_info -x --" CMD="pkg_info -x --"
;; ;;
pkgng) pkgng)
CMD="pkg search -i --" CMD="pkg search -i --"
;; ;;
emerge) emerge)
CMD="emerge --search --" CMD="emerge --search --"
;; ;;
pacman) pacman)
CMD="pacman -Ss --" CMD="pacman -Ss --"
;; ;;
aura) aura)
CMD="aura -As --" CMD="aura -As --"
;; ;;
eopkg) eopkg)
CMD="eopkg search --" CMD="eopkg search --"
;; ;;
yum-rpm) yum-rpm)
CMD="yum search --" CMD="yum search --"
;; ;;
dnf-rpm) dnf-rpm)
CMD="dnf search --" CMD="dnf search --"
;; ;;
zypper-rpm) zypper-rpm)
CMD="zypper search -d --" CMD="zypper search -d --"
;; ;;
mpkg) mpkg)
CMD="mpkg search" CMD="mpkg search"
;; ;;
apk) apk)
CMD="apk search" CMD="apk search"
;; ;;
tce) tce)
CMD="tce-ab" CMD="tce-ab"
;; ;;
conary) conary)
CMD="conary repquery" CMD="conary repquery"
;; ;;
npackd) npackd)
docmd npackdcl search --query="$string" --status=all docmd npackdcl search --query="$string" --status=all
return return
;; ;;
chocolatey) chocolatey)
CMD="chocolatey list" CMD="chocolatey list"
;; ;;
slackpkg) slackpkg)
# FIXME # FIXME
echo "Note: case sensitive search" echo "Note: case sensitive search"
if [ -n "$verbose" ] ; then if [ -n "$verbose" ] ; then
CMD="/usr/sbin/slackpkg search" CMD="/usr/sbin/slackpkg search"
else else
LANG=C docmd /usr/sbin/slackpkg search $string | grep " - " | sed -e 's|.* - ||g' LANG=C docmd /usr/sbin/slackpkg search $string | grep " - " | sed -e 's|.* - ||g'
return return
fi fi
;; ;;
opkg) opkg)
CMD="opkg find" CMD="opkg find"
;; ;;
homebrew) homebrew)
CMD="brew search" CMD="brew search"
;; ;;
guix) guix)
CMD="guix package -A" CMD="guix package -A"
;; ;;
android) android)
CMD="pm list packages" CMD="pm list packages"
;; ;;
aptcyg) aptcyg)
CMD="apt-cyg searchall" CMD="apt-cyg searchall"
;; ;;
xbps) xbps)
CMD="xbps-query -s" CMD="xbps-query -s"
;; ;;
appget|winget) appget|winget)
CMD="$PMTYPE search" CMD="$PMTYPE search"
;; ;;
*) *)
fatal "Have no suitable search command for $PMTYPE" fatal "Have no suitable search command for $PMTYPE"
;; ;;
esac esac
LANG=C docmd $CMD $string LANG=C docmd $CMD $string
...@@ -131,123 +131,123 @@ epm play $short --list-all | sed -e 's|^ *||g' -e 's|[[:space:]]\+| |g' -e "s|\$ ...@@ -131,123 +131,123 @@ epm play $short --list-all | sed -e 's|^ *||g' -e 's|[[:space:]]\+| |g' -e "s|\$
# check man glob # check man glob
__convert_glob__to_regexp() __convert_glob__to_regexp()
{ {
# translate glob to regexp # translate glob to regexp
echo "$1" | sed -e "s|\*|.*|g" -e "s|?|.|g" echo "$1" | sed -e "s|\*|.*|g" -e "s|?|.|g"
} }
# ^mc.*ext -> mc # ^mc.*ext -> mc
_clean_from_regexp() _clean_from_regexp()
{ {
sed -e "s/[?\^.*]/ /g" sed -e "s/[?\^.*]/ /g"
} }
# ^mc*e?t -> mc # ^mc*e?t -> mc
__clean_from_glob() __clean_from_glob()
{ {
sed -e "s/[?*].*//" -e "s/[?\^.*]/ /g" sed -e "s/[?*].*//" -e "s/[?\^.*]/ /g"
} }
# produce grep sequence # produce grep sequence
__epm_search_make_grep() __epm_search_make_grep()
{ {
local i local i
[ -z "$*" ] && return [ -z "$*" ] && return
local list= local list=
local listN= local listN=
for i in $@ ; do for i in $@ ; do
case "$i" in case "$i" in
~*) ~*)
# will clean from ~ later (and have the bug here with empty arg if run with one ~ only) # will clean from ~ later (and have the bug here with empty arg if run with one ~ only)
listN="$listN $i" listN="$listN $i"
;; ;;
*) *)
list="$list $i" list="$list $i"
;; ;;
esac esac
done done
#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")
# TODO: only apt supports regexps? # TODO: only apt supports regexps?
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
;; ;;
*) *)
list=$(echo "$list" | sed -e "s/[?\^.]/ /g") list=$(echo "$list" | sed -e "s/[?\^.]/ /g")
listN=$(echo "$listN" | sed -e "s/[?\^.]/ /g") listN=$(echo "$listN" | sed -e "s/[?\^.]/ /g")
;; ;;
esac esac
list=$(__convert_glob__to_regexp "$list") list=$(__convert_glob__to_regexp "$list")
listN=$(__convert_glob__to_regexp "$listN") listN=$(__convert_glob__to_regexp "$listN")
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
echon " | sed -e \"s| .*||g\"" echon " | sed -e \"s| .*||g\""
fi fi
[ -n "$listN" ] && echon " | grep -E -i -v -- \"$listN\"" [ -n "$listN" ] && echon " | grep -E -i -v -- \"$listN\""
# FIXME: The World has not idea how to do grep both string # FIXME: The World has not idea how to do grep both string
# http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1 # http://stackoverflow.com/questions/10110051/grep-with-two-strings-logical-and-in-regex?rq=1
# Need only if we have more than one word (with one word we will grep for colorify) # Need only if we have more than one word (with one word we will grep for colorify)
if [ "$(echo "$list" | wc -w)" -gt 1 ] ; then if [ "$(echo "$list" | wc -w)" -gt 1 ] ; then
for i in $list ; do for i in $list ; do
# FIXME -n on MacOS? # FIXME -n on MacOS?
echon " | grep -E -i -- \"$i\"" echon " | grep -E -i -- \"$i\""
done done
fi fi
# FIXME: move from it # FIXME: move from it
#isatty || return #isatty || return
# TODO: sorts word by length from large to short # TODO: sorts word by length from large to short
local COLO="" local COLO=""
# rule for colorife # rule for colorife
for i in $list $listN; do for i in $list $listN; do
[ -n "$COLO" ] && COLO="$COLO|" [ -n "$COLO" ] && COLO="$COLO|"
COLO="$COLO$i" COLO="$COLO$i"
done done
# TODO: use some colorifer instead grep (check grep adove too) # TODO: use some colorifer instead grep (check grep adove too)
if [ -n "$list" ] ; then if [ -n "$list" ] ; then
echon " | grep -E -i $EGREPCOLOR -- \"($COLO)\"" echon " | grep -E -i $EGREPCOLOR -- \"($COLO)\""
fi fi
} }
__epm_search_internal() __epm_search_internal()
{ {
[ -n "$pkg_filenames" ] || fatal "Search: search argument(s) is missed" [ -n "$pkg_filenames" ] || fatal "Search: search argument(s) is missed"
# it is useful for first time running # it is useful for first time running
update_repo_if_needed soft update_repo_if_needed soft
warmup_bases warmup_bases
__epm_search_output $(get_firstarg $pkg_filenames) | grep "$pkg_filenames" __epm_search_output $(get_firstarg $pkg_filenames) | grep "$pkg_filenames"
} }
# copied from korinf/tools/run-script/scripts/search # copied from korinf/tools/run-script/scripts/search
epm_search() epm_search()
{ {
[ -n "$pkg_filenames" ] || fatal "Search: search argument(s) is missed" [ -n "$pkg_filenames" ] || fatal "Search: search argument(s) is missed"
# it is useful for first time running # it is useful for first time running
update_repo_if_needed soft update_repo_if_needed soft
warmup_bases warmup_bases
echo "$*" | grep -q "\.[*?]" && warning "Only glob symbols * and ? are supported. Don't use regexp here!" echo "$*" | grep -q "\.[*?]" && warning "Only glob symbols * and ? are supported. Don't use regexp here!"
# FIXME: do it better # FIXME: do it better
local MGS local MGS
MGS=$(eval __epm_search_make_grep $quoted_args) MGS=$(eval __epm_search_make_grep $quoted_args)
EXTRA_SHOWDOCMD="$MGS" EXTRA_SHOWDOCMD="$MGS"
# TODO: use search args for more optimal output # TODO: use search args for more optimal output
eval "__epm_search_output \"$(eval get_firstarg $quoted_args | __clean_from_glob)\" $MGS" eval "__epm_search_output \"$(eval get_firstarg $quoted_args | __clean_from_glob)\" $MGS"
} }
...@@ -46,59 +46,59 @@ __alt_local_content_search() ...@@ -46,59 +46,59 @@ __alt_local_content_search()
epm_search_file() epm_search_file()
{ {
local CMD local CMD
[ -n "$pkg_filenames" ] || fatal "Search file: file name is missed" [ -n "$pkg_filenames" ] || fatal "Search file: file name is missed"
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
__alt_local_content_search $pkg_filenames __alt_local_content_search $pkg_filenames
return ;; return ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
assure_exists apt-file assure_exists apt-file
sudocmd apt-file update sudocmd apt-file update
docmd apt-file search $pkg_filenames docmd apt-file search $pkg_filenames
return ;; return ;;
packagekit) packagekit)
CMD="pkcon search file" CMD="pkcon search file"
;; ;;
yum-rpm) yum-rpm)
# TODO # TODO
info "Search by full packages list is not implemented yet" info "Search by full packages list is not implemented yet"
CMD="yum provides" CMD="yum provides"
;; ;;
dnf-rpm) dnf-rpm)
# TODO # TODO
info "Search by full packages list is not implemented yet" info "Search by full packages list is not implemented yet"
CMD="dnf provides" CMD="dnf provides"
;; ;;
urpm-rpm) urpm-rpm)
CMD="urpmf" CMD="urpmf"
;; ;;
zypper-rpm) zypper-rpm)
CMD="zypper search --file-list" CMD="zypper search --file-list"
;; ;;
pacman) pacman)
CMD="pacman -Qo" CMD="pacman -Qo"
;; ;;
slackpkg) slackpkg)
CMD="/usr/sbin/slackpkg file-search" CMD="/usr/sbin/slackpkg file-search"
;; ;;
opkg) opkg)
CMD="opkg -A search" CMD="opkg -A search"
;; ;;
eopkg) eopkg)
CMD="eopkg search-file" CMD="eopkg search-file"
;; ;;
xbps) xbps)
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
;; ;;
*) *)
fatal "Have no suitable search file command for $PMTYPE" fatal "Have no suitable search file command for $PMTYPE"
;; ;;
esac esac
docmd $CMD $pkg_filenames docmd $CMD $pkg_filenames
......
...@@ -23,71 +23,71 @@ ...@@ -23,71 +23,71 @@
# FIXME on Android: FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:366 # FIXME on Android: FIX ME! implement ttyname_r() bionic/libc/bionic/stubs.c:366
inputisatty() inputisatty()
{ {
# check stdin # check stdin
#tty -s 2>/dev/null #tty -s 2>/dev/null
test -t 0 test -t 0
} }
isatty() isatty()
{ {
# check stdout # check stdout
test -t 1 test -t 1
} }
isatty2() isatty2()
{ {
# check stderr # check stderr
test -t 2 test -t 2
} }
check_tty() check_tty()
{ {
isatty2 || return isatty2 || return
# Set a sane TERM required for tput # Set a sane TERM required for tput
[ -n "$TERM" ] || TERM=dumb [ -n "$TERM" ] || TERM=dumb
export TERM export TERM
check_core_commands check_core_commands
# grep -E from busybox may not --color # grep -E from busybox may not --color
# grep -E from MacOS print help to stderr # grep -E from MacOS print help to stderr
if grep -E --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
is_command tput || return is_command tput || return
# FreeBSD does not support tput -S # FreeBSD does not support tput -S
echo | a= tput -S >/dev/null 2>/dev/null || return echo | a= tput -S >/dev/null 2>/dev/null || return
USETTY="tput -S" USETTY="tput -S"
} }
: ${BLACK:=0} ${RED:=1} ${GREEN:=2} ${YELLOW:=3} ${BLUE:=4} ${MAGENTA:=5} ${CYAN:=6} ${WHITE:=7} : ${BLACK:=0} ${RED:=1} ${GREEN:=2} ${YELLOW:=3} ${BLUE:=4} ${MAGENTA:=5} ${CYAN:=6} ${WHITE:=7}
set_boldcolor() set_boldcolor()
{ {
[ -n "$USETTY" ] || return [ -n "$USETTY" ] || return
{ {
echo bold echo bold
echo setaf $1 echo setaf $1
} | $USETTY } | $USETTY
} }
set_color() set_color()
{ {
[ -n "$USETTY" ] || return [ -n "$USETTY" ] || return
{ {
echo setaf $1 echo setaf $1
} | $USETTY } | $USETTY
} }
restore_color() restore_color()
{ {
[ -n "$USETTY" ] || return [ -n "$USETTY" ] || return
{ {
echo op; # set Original color Pair. echo op; # set Original color Pair.
echo sgr0; # turn off all special graphics mode (bold in our case). echo sgr0; # turn off all special graphics mode (bold in our case).
} | $USETTY } | $USETTY
} }
echover() echover()
...@@ -99,123 +99,123 @@ echover() ...@@ -99,123 +99,123 @@ echover()
# echo string without EOL # echo string without EOL
echon() echon()
{ {
# default /bin/sh on MacOS does not recognize -n # default /bin/sh on MacOS does not recognize -n
echo -n "$*" 2>/dev/null || a= /bin/echo -n "$*" echo -n "$*" 2>/dev/null || a= /bin/echo -n "$*"
} }
# Used DISTRNAME # Used DISTRNAME
set_target_pkg_env() set_target_pkg_env()
{ {
[ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env." [ -n "$DISTRNAME" ] || fatal "Missing DISTRNAME in set_target_pkg_env."
local ver="$DISTRVERSION" local ver="$DISTRVERSION"
[ -n "$ver" ] && ver="/$ver" [ -n "$ver" ] && ver="/$ver"
PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME$ver") PKGFORMAT=$($DISTRVENDOR -p "$DISTRNAME$ver")
PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME$ver") PKGVENDOR=$($DISTRVENDOR -s "$DISTRNAME$ver")
RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME$ver") RPMVENDOR=$($DISTRVENDOR -n "$DISTRNAME$ver")
} }
# Print command line and run command line # Print command line and run command line
showcmd() showcmd()
{ {
if [ -z "$quiet" ] ; then if [ -z "$quiet" ] ; then
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
is_root && PROMTSIG="#" is_root && PROMTSIG="#"
echo " $PROMTSIG $*" echo " $PROMTSIG $*"
restore_color restore_color
fi >&2 fi >&2
} }
# Print command # Print command
echocmd() echocmd()
{ {
set_boldcolor $GREEN set_boldcolor $GREEN
local PROMTSIG="\$" local PROMTSIG="\$"
is_root && PROMTSIG="#" is_root && PROMTSIG="#"
echo -n "$PROMTSIG $*" echo -n "$PROMTSIG $*"
restore_color restore_color
} }
# Print command line and run command line # Print command line and run command line
docmd() docmd()
{ {
showcmd "$*$EXTRA_SHOWDOCMD" showcmd "$*$EXTRA_SHOWDOCMD"
"$@" "$@"
} }
# Run every arg with docmd # Run every arg with docmd
docmd_foreach() docmd_foreach()
{ {
local cmd pkg local cmd pkg
cmd="$1" cmd="$1"
#showcmd "$@" #showcmd "$@"
shift shift
for pkg in "$@" ; do for pkg in "$@" ; do
docmd $cmd $pkg docmd $cmd $pkg
done done
} }
# run command line with SUDO # run command line with SUDO
sudorun() sudorun()
{ {
set_sudo set_sudo
if [ -z "$SUDO" ] ; then if [ -z "$SUDO" ] ; then
"$@" "$@"
return return
fi fi
$SUDO "$@" $SUDO "$@"
} }
# Print command line and run command line with SUDO # Print command line and run command line with SUDO
sudocmd() sudocmd()
{ {
set_sudo set_sudo
[ -n "$SUDO" ] && showcmd "$SUDO $*" || showcmd "$*" [ -n "$SUDO" ] && showcmd "$SUDO $*" || showcmd "$*"
sudorun "$@" sudorun "$@"
} }
# Run every arg with sudocmd # Run every arg with sudocmd
# Returns on any error # Returns on any error
sudocmd_foreach() sudocmd_foreach()
{ {
local cmd pkg local cmd pkg
cmd="$1" cmd="$1"
#showcmd "$@" #showcmd "$@"
shift shift
for pkg in "$@" ; do for pkg in "$@" ; do
# don't quote $cmd here: it can be a command with an args # don't quote $cmd here: it can be a command with an args
sudocmd $cmd $pkg || return sudocmd $cmd $pkg || return
done done
} }
# print full path to files # print full path to files
make_filepath() make_filepath()
{ {
local i local i
for i in "$@" ; do for i in "$@" ; do
[ -f "$i" ] || continue [ -f "$i" ] || continue
echo "$i" | grep -q "/" && echo "$i" && continue echo "$i" | grep -q "/" && echo "$i" && continue
echo "./$i" echo "./$i"
done done
} }
get_firstarg() get_firstarg()
{ {
echon "$1" echon "$1"
} }
get_lastarg() get_lastarg()
{ {
local lastarg local lastarg
eval "lastarg=\${$#}" eval "lastarg=\${$#}"
echon "$lastarg" echon "$lastarg"
} }
# TODO: see etersoft-build-utils/tests/test_isnumber.sh # TODO: see etersoft-build-utils/tests/test_isnumber.sh
isnumber() isnumber()
{ {
echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$" echo "$*" | filter_strip_spaces | grep -q "^[0-9]\+$"
} }
# copied from strings # copied from strings
...@@ -223,7 +223,7 @@ isnumber() ...@@ -223,7 +223,7 @@ isnumber()
# Note: used grep -E! write '[0-9]+(first|two)', not '[0-9]\+...' # Note: used grep -E! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas() rhas()
{ {
echo "$1" | grep -E -q -- "$2" echo "$1" | grep -E -q -- "$2"
} }
# copied from strings # copied from strings
...@@ -252,14 +252,14 @@ strip_spaces() ...@@ -252,14 +252,14 @@ strip_spaces()
# use for subst complex string with symbols treating as regexp # use for subst complex string with symbols treating as regexp
sed_escape() sed_escape()
{ {
echo "$*" | sed -e 's/[]()$*.^|[]/\\&/g' echo "$*" | sed -e 's/[]()$*.^|[]/\\&/g'
} }
# param true false # param true false
subst_option() subst_option()
{ {
eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3" eval "[ -n \"\$$1\" ]" && echo "$2" || echo "$3"
} }
store_output() store_output()
...@@ -290,61 +290,61 @@ clean_store_output() ...@@ -290,61 +290,61 @@ clean_store_output()
# run epm, possible from side repo # run epm, possible from side repo
epm() epm()
{ {
if [ -n "$PROGNAME" ] ; then if [ -n "$PROGNAME" ] ; then
local bashopt='' local bashopt=''
[ -n "$verbose" ] && bashopt='-x' [ -n "$verbose" ] && bashopt='-x'
$CMDSHELL $bashopt $PROGDIR/$PROGNAME --inscript "$@" $CMDSHELL $bashopt $PROGDIR/$PROGNAME --inscript "$@"
else else
epm_main --inscript "$@" epm_main --inscript "$@"
fi fi
} }
# run $SUDO epm, possible from side repo # run $SUDO epm, possible from side repo
sudoepm() sudoepm()
{ {
[ -n "$PROGNAME" ] || fatal "Can't use sudo epm call from the piped script" [ -n "$PROGNAME" ] || fatal "Can't use sudo epm call from the piped script"
local bashopt='' local bashopt=''
[ -n "$verbose" ] && bashopt='-x' [ -n "$verbose" ] && bashopt='-x'
sudorun $CMDSHELL $bashopt $PROGDIR/$PROGNAME --inscript "$@" sudorun $CMDSHELL $bashopt $PROGDIR/$PROGNAME --inscript "$@"
} }
# Print error message and stop the program # Print error message and stop the program
fatal() fatal()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Error: $* (you can discuss the problem in Telegram: https://t.me/useepm)" >&2 echo "Error: $* (you can discuss the problem in Telegram: https://t.me/useepm)" >&2
# else # else
# echog "Error in $0: $@" >&2 # echog "Error in $0: $@" >&2
fi fi
# [ "$TERM" = "screen" ] && echo "(screen detected: waiting ten seconds to exit ...)" >&2 && sleep 10 # [ "$TERM" = "screen" ] && echo "(screen detected: waiting ten seconds to exit ...)" >&2 && sleep 10
exit 1 exit 1
} }
# Print warning message # Print warning message
warning() warning()
{ {
if [ -z "$TEXTDOMAIN" ] ; then if [ -z "$TEXTDOMAIN" ] ; then
echo "Warning: $*" >&2 echo "Warning: $*" >&2
# else # else
# echog "Error in $0: $@" >&2 # echog "Error in $0: $@" >&2
fi fi
} }
info() info()
{ {
[ -n "$quiet" ] && return [ -n "$quiet" ] && return
# 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
} }
# if we have not sudo, returns 1 and set SUDO variable to fatal # if we have not sudo, returns 1 and set SUDO variable to fatal
...@@ -352,101 +352,101 @@ SUDO_TESTED='' ...@@ -352,101 +352,101 @@ SUDO_TESTED=''
SUDO_CMD='sudo' SUDO_CMD='sudo'
set_sudo() set_sudo()
{ {
local nofail="$1" local nofail="$1"
# cache the result # cache the result
[ -n "$SUDO_TESTED" ] && return "$SUDO_TESTED" [ -n "$SUDO_TESTED" ] && return "$SUDO_TESTED"
SUDO_TESTED="0" SUDO_TESTED="0"
SUDO="" SUDO=""
# skip SUDO if disabled # skip SUDO if disabled
[ -n "$EPMNOSUDO" ] && return [ -n "$EPMNOSUDO" ] && return
if [ "$DISTRNAME" = "Cygwin" ] || [ "$DISTRNAME" = "Windows" ] ; then if [ "$DISTRNAME" = "Cygwin" ] || [ "$DISTRNAME" = "Windows" ] ; then
# skip sudo using on Windows # skip sudo using on Windows
return return
fi fi
# if we are root, do not need sudo # if we are root, do not need sudo
is_root && return is_root && return
# start error section # start error section
SUDO_TESTED="1" SUDO_TESTED="1"
if ! is_command $SUDO_CMD ; 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
# if input is a console # if input is a console
if inputisatty && isatty && isatty2 ; then if inputisatty && isatty && isatty2 ; then
if ! $SUDO_CMD -l >/dev/null ; then if ! $SUDO_CMD -l >/dev/null ; then
[ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only passwordless sudo is supported in non interactive using). Please run epm under root.'" [ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only passwordless sudo is supported in non interactive using). Please run epm under root.'"
return "$SUDO_TESTED" return "$SUDO_TESTED"
fi fi
else else
# use sudo if one is tuned and tuned without password # use sudo if one is tuned and tuned without password
if ! $SUDO_CMD -l -n >/dev/null 2>/dev/null ; then if ! $SUDO_CMD -l -n >/dev/null 2>/dev/null ; then
[ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only passwordless sudo is supported). Please run epm under root or check http://altlinux.org/sudo '" [ "$nofail" = "nofail" ] || SUDO="fatal 'Can't use sudo (only passwordless sudo is supported). Please run epm under root or check http://altlinux.org/sudo '"
return "$SUDO_TESTED" return "$SUDO_TESTED"
fi fi
fi fi
SUDO_TESTED="0" SUDO_TESTED="0"
# FIXME: does not work: sudo -- VARIABLE=some command # FIXME: does not work: sudo -- VARIABLE=some command
SUDO="$SUDO_CMD" SUDO="$SUDO_CMD"
#SUDO="$SUDO_CMD --" #SUDO="$SUDO_CMD --"
# check for < 1.7 version which do not support -- (and --help possible too) # check for < 1.7 version which do not support -- (and --help possible too)
#$SUDO_CMD -h 2>/dev/null | grep -q " --" || SUDO="$SUDO_CMD" #$SUDO_CMD -h 2>/dev/null | grep -q " --" || SUDO="$SUDO_CMD"
} }
# return TRUE if we can run privileged command # return TRUE if we can run privileged command
sudo_allowed() sudo_allowed()
{ {
set_sudo nofail set_sudo nofail
} }
# wait for n seconds (if possible) during executing command # wait for n seconds (if possible) during executing command
# args: seconds command # args: seconds command
withtimeout() withtimeout()
{ {
local TO=$(print_command_path timeout || print_command_path gtimeout) local TO=$(print_command_path timeout || print_command_path gtimeout)
if [ -x "$TO" ] ; then if [ -x "$TO" ] ; then
$TO "$@" $TO "$@"
return return
fi fi
fatal "Possible indefinite wait due timeout command is missed" fatal "Possible indefinite wait due timeout command is missed"
# fallback: drop time arg and run without timeout # fallback: drop time arg and run without timeout
#shift #shift
#"$@" #"$@"
} }
set_eatmydata() set_eatmydata()
{ {
# don't use eatmydata (useless) # don't use eatmydata (useless)
return 0 return 0
# skip if disabled # skip if disabled
[ -n "$EPMNOEATMYDATA" ] && return [ -n "$EPMNOEATMYDATA" ] && return
# use if possible # use if possible
is_command eatmydata || 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"
[ -n "$verbose" ] && info "Uwaga! eatmydata is installed, we will use it for disable all sync operations." [ -n "$verbose" ] && info "Uwaga! eatmydata is installed, we will use it for disable all sync operations."
return 0 return 0
} }
# #
__get_package_for_command() __get_package_for_command()
{ {
case "$1" in case "$1" in
equery|revdep-rebuild) equery|revdep-rebuild)
echo 'gentoolkit' echo 'gentoolkit'
;; ;;
update-kernel|remove-old-kernels) update-kernel|remove-old-kernels)
echo 'update-kernel' echo 'update-kernel'
;; ;;
esac esac
} }
# TODO: # TODO:
...@@ -467,168 +467,168 @@ confirm() { ...@@ -467,168 +467,168 @@ confirm() {
confirm_info() confirm_info()
{ {
info "$*" info "$*"
if [ -z "$non_interactive" ] ; then if [ -z "$non_interactive" ] ; then
confirm "Are you sure? [y/N]" || fatal "Exiting" confirm "Are you sure? [y/N]" || fatal "Exiting"
fi fi
} }
is_root() is_root()
{ {
local EFFUID="$(id -u)" local EFFUID="$(id -u)"
[ "$EFFUID" = "0" ] [ "$EFFUID" = "0" ]
} }
assure_root() assure_root()
{ {
is_root || fatal "run me only under root" is_root || fatal "run me only under root"
} }
regexp_subst() regexp_subst()
{ {
local expression="$1" local expression="$1"
shift shift
sed -i -r -e "$expression" "$@" sed -i -r -e "$expression" "$@"
} }
# TODO: we we can't use epm directly? # TODO: we we can't use epm directly?
assure_exists() assure_exists()
{ {
load_helper epm-assure load_helper epm-assure
local package="$2" local package="$2"
local textpackage= local textpackage=
[ -n "$package" ] || package="$(__get_package_for_command "$1")" [ -n "$package" ] || package="$(__get_package_for_command "$1")"
[ -n "$3" ] && textpackage=" >= $3" [ -n "$3" ] && textpackage=" >= $3"
( direct='' epm_assure "$1" $package $3 ) || fatal "Can't assure in '$1' command from $package$textpackage package" ( direct='' epm_assure "$1" $package $3 ) || fatal "Can't assure in '$1' command from $package$textpackage package"
} }
assure_exists_erc() assure_exists_erc()
{ {
load_helper epm-assure load_helper epm-assure
local package="erc" local package="erc"
( direct='' epm_assure "$package" ) || epm ei erc || fatal "erc is not available to install." ( direct='' epm_assure "$package" ) || epm ei erc || fatal "erc is not available to install."
} }
# will replaced within disabled_eget in packaged version # will replaced within disabled_eget in packaged version
eget() eget()
{ {
local EGET local EGET
# use internal eget only if exists # use internal eget only if exists
if [ -s $SHAREDIR/tools_eget ] ; then if [ -s $SHAREDIR/tools_eget ] ; then
( EGET_BACKEND=$eget_backend $SHAREDIR/tools_eget "$@" ) ( EGET_BACKEND=$eget_backend $SHAREDIR/tools_eget "$@" )
return return
fi fi
fatal "Internal error: missed tools_eget" fatal "Internal error: missed tools_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=$(print_command_path eget) || fatal "Missed command eget from installed package eget" EGET=$(print_command_path eget) || fatal "Missed command eget from installed package eget"
$EGET "$@" $EGET "$@"
} }
# will replaced within disabled_erc in packaged version # will replaced within disabled_erc in packaged version
erc() erc()
{ {
local ERC local ERC
# use internal eget only if exists # use internal eget only if exists
if [ -s $SHAREDIR/tools_erc ] ; then if [ -s $SHAREDIR/tools_erc ] ; then
$SHAREDIR/tools_erc "$@" $SHAREDIR/tools_erc "$@"
return return
fi fi
fatal "Internal error: missed tools_erc" fatal "Internal error: missed tools_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=$(print_command_path erc) || fatal "Missed command erc from installed package erc" ERC=$(print_command_path erc) || fatal "Missed command erc from installed package erc"
$ERC "$@" $ERC "$@"
} }
# will replaced within disabled_ercat in packaged version # will replaced within disabled_ercat in packaged version
ercat() ercat()
{ {
local ERCAT local ERCAT
# use internal eget only if exists # use internal eget only if exists
if [ -s $SHAREDIR/tools_ercat ] ; then if [ -s $SHAREDIR/tools_ercat ] ; then
$SHAREDIR/tools_ercat "$@" $SHAREDIR/tools_ercat "$@"
return return
fi fi
fatal "Internal error: missed tools_ercat" fatal "Internal error: missed tools_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=$(print_command_path ercat) || fatal "Missed command ercat from installed package erc" ERCAT=$(print_command_path ercat) || fatal "Missed command ercat from installed package erc"
$ERCAT "$@" $ERCAT "$@"
} }
estrlist() estrlist()
{ {
if [ -s $SHAREDIR/tools_estrlist ] ; then if [ -s $SHAREDIR/tools_estrlist ] ; then
$SHAREDIR/tools_estrlist "$@" $SHAREDIR/tools_estrlist "$@"
return return
fi fi
fatal "missed tools_estrlist" fatal "missed tools_estrlist"
} }
onefile_estrlist() onefile_estrlist()
{ {
internal_tools_estrlist "$@" internal_tools_estrlist "$@"
} }
# will replaced within eget() in packed version # will replaced within eget() in packed version
onefile_eget() onefile_eget()
{ {
# check for both # check for both
# we really need that cross here, # we really need that cross here,
is_command curl || assure_exists wget is_command curl || assure_exists wget
is_command wget || assure_exists curl is_command wget || assure_exists curl
internal_tools_eget "$@" internal_tools_eget "$@"
} }
# TODO: improve and drop! # TODO: improve and drop!
get_package_type() get_package_type()
{ {
local i local i
case $1 in case $1 in
*.deb) *.deb)
echo "deb" echo "deb"
return return
;; ;;
*.rpm) *.rpm)
echo "rpm" echo "rpm"
return return
;; ;;
*.txz) *.txz)
echo "txz" echo "txz"
return return
;; ;;
*.tbz) *.tbz)
echo "tbz" echo "tbz"
return return
;; ;;
*.exe) *.exe)
echo "exe" echo "exe"
return return
;; ;;
*.msi) *.msi)
echo "msi" echo "msi"
return return
;; ;;
*.AppImage) *.AppImage)
echo "AppImage" echo "AppImage"
return return
;; ;;
*) *)
#fatal "Don't know type of $1" #fatal "Don't know type of $1"
# return package name for info # return package name for info
echo "$1" echo "$1"
return 1 return 1
;; ;;
esac esac
} }
...@@ -660,52 +660,52 @@ get_help() ...@@ -660,52 +660,52 @@ get_help()
# TODO: get all info by one request (too slow) # TODO: get all info by one request (too slow)
set_distro_info() set_distro_info()
{ {
# use external distro_info if internal one is missed # use external distro_info if internal one is missed
DISTRVENDOR=$PROGDIR/distr_info DISTRVENDOR=$PROGDIR/distr_info
[ -x $DISTRVENDOR ] || DISTRVENDOR=distro_info [ -x $DISTRVENDOR ] || DISTRVENDOR=distro_info
export DISTRVENDOR export DISTRVENDOR
[ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d) || fatal "Can't get distro name." [ -n "$DISTRNAME" ] || DISTRNAME=$($DISTRVENDOR -d) || fatal "Can't get distro name."
[ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v) [ -n "$DISTRVERSION" ] || DISTRVERSION=$($DISTRVENDOR -v)
if [ -z "$DISTRARCH" ] ; then if [ -z "$DISTRARCH" ] ; then
DISTRARCH=$($DISTRVENDOR --distro-arch) DISTRARCH=$($DISTRVENDOR --distro-arch)
fi fi
DISTRCONTROL="$($DISTRVENDOR -y)" DISTRCONTROL="$($DISTRVENDOR -y)"
[ -n "$BASEDISTRNAME" ] || BASEDISTRNAME=$($DISTRVENDOR -s) [ -n "$BASEDISTRNAME" ] || BASEDISTRNAME=$($DISTRVENDOR -s)
# TODO: improve BIGTMPDIR conception # TODO: improve BIGTMPDIR conception
# https://bugzilla.mozilla.org/show_bug.cgi?id=69938 # https://bugzilla.mozilla.org/show_bug.cgi?id=69938
# https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html # https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html
# https://geekpeach.net/ru/%D0%BA%D0%B0%D0%BA-systemd-tmpfiles-%D0%BE%D1%87%D0%B8%D1%89%D0%B0%D0%B5%D1%82-tmp-%D0%B8%D0%BB%D0%B8-var-tmp-%D0%B7%D0%B0%D0%BC%D0%B5%D0%BD%D0%B0-tmpwatch-%D0%B2-centos-rhel-7 # https://geekpeach.net/ru/%D0%BA%D0%B0%D0%BA-systemd-tmpfiles-%D0%BE%D1%87%D0%B8%D1%89%D0%B0%D0%B5%D1%82-tmp-%D0%B8%D0%BB%D0%B8-var-tmp-%D0%B7%D0%B0%D0%BC%D0%B5%D0%BD%D0%B0-tmpwatch-%D0%B2-centos-rhel-7
[ -n "$BIGTMPDIR" ] || [ -d "/var/tmp" ] && BIGTMPDIR="/var/tmp" || BIGTMPDIR="/tmp" [ -n "$BIGTMPDIR" ] || [ -d "/var/tmp" ] && BIGTMPDIR="/var/tmp" || BIGTMPDIR="/tmp"
} }
# FIXME: detect if not recognized # FIXME: detect if not recognized
set_pm_type() set_pm_type()
{ {
local CMD local CMD
set_distro_info set_distro_info
set_target_pkg_env set_target_pkg_env
# override package manager detection result # override package manager detection result
if [ -n "$FORCEPM" ] ; then if [ -n "$FORCEPM" ] ; then
PMTYPE=$FORCEPM PMTYPE=$FORCEPM
return return
fi fi
PMTYPE="$($DISTRVENDOR -g $DISTRNAME/$DISTRVERSION)" PMTYPE="$($DISTRVENDOR -g $DISTRNAME/$DISTRVERSION)"
} }
is_active_systemd() is_active_systemd()
{ {
[ "$DISTRCONTROL" = "systemd" ] [ "$DISTRCONTROL" = "systemd" ]
} }
assure_distr() assure_distr()
{ {
local TEXT="this option" local TEXT="this option"
[ -n "$2" ] && TEXT="$2" [ -n "$2" ] && TEXT="$2"
[ "$DISTRNAME" = "$1" ] || fatal "$TEXT supported only for $1 distro" [ "$DISTRNAME" = "$1" ] || fatal "$TEXT supported only for $1 distro"
} }
# return delimiter sign in depend of package type # return delimiter sign in depend of package type
...@@ -808,8 +808,8 @@ fi ...@@ -808,8 +808,8 @@ fi
check_core_commands() check_core_commands()
{ {
#which which >/dev/null || fatal "Can't find which command (which or debianutils package is missed?)" #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 grep || fatal "Can't find grep command (coreutils package is missed?)"
is_command sed || fatal "Can't find sed command (sed package is missed?)" is_command sed || fatal "Can't find sed command (sed package is missed?)"
} }
...@@ -22,43 +22,43 @@ load_helper epm-query ...@@ -22,43 +22,43 @@ load_helper epm-query
__fast_hack_for_filter_out_installed_rpm() __fast_hack_for_filter_out_installed_rpm()
{ {
LANG=C LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' | LANG=C LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' |
sed -e 's|^.*package \(.*\) is not installed.*|\1|g' sed -e 's|^.*package \(.*\) is not installed.*|\1|g'
} }
# pass only uninstalled packages # pass only uninstalled packages
filter_out_installed_packages() filter_out_installed_packages()
{ {
[ -z "$skip_installed" ] && cat && return [ -z "$skip_installed" ] && cat && return
case $PMTYPE in case $PMTYPE in
yum-rpm|dnf-rpm) yum-rpm|dnf-rpm)
if [ "$($DISTRVENDOR -a)" = "x86_64" ] && [ "$DISTRNAME" != "ROSA" ] ; then if [ "$($DISTRVENDOR -a)" = "x86_64" ] && [ "$DISTRNAME" != "ROSA" ] ; then
# shellcheck disable=SC2013 # shellcheck disable=SC2013
for i in $(cat) ; do for i in $(cat) ; do
is_installed "$(__print_with_arch_suffix $i .x86_64)" && continue is_installed "$(__print_with_arch_suffix $i .x86_64)" && continue
is_installed "$(__print_with_arch_suffix $i .noarch)" && continue is_installed "$(__print_with_arch_suffix $i .noarch)" && continue
echo $i echo $i
done done
else else
__fast_hack_for_filter_out_installed_rpm __fast_hack_for_filter_out_installed_rpm
fi fi
;; ;;
*-rpm) *-rpm)
__fast_hack_for_filter_out_installed_rpm __fast_hack_for_filter_out_installed_rpm
;; ;;
# dpkg -l lists some non ii status (un, etc) # dpkg -l lists some non ii status (un, etc)
#"deb") #"deb")
# LANG=C LC_ALL=C xargs -n1 dpkg -l 2>&1 | grep -i 'no packages found matching' | # LANG=C LC_ALL=C xargs -n1 dpkg -l 2>&1 | grep -i 'no packages found matching' |
# 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 # 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
;; ;;
esac | sed -e "s|rpm-build-altlinux-compat[^ ]*||g" | filter_strip_spaces esac | sed -e "s|rpm-build-altlinux-compat[^ ]*||g" | filter_strip_spaces
} }
get_only_installed_packages() get_only_installed_packages()
......
...@@ -60,84 +60,84 @@ _epm_do_simulate() ...@@ -60,84 +60,84 @@ _epm_do_simulate()
local filenames="$*" local filenames="$*"
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
CMD="apt-get --simulate install" CMD="apt-get --simulate install"
;; ;;
aptitude-dpkg) aptitude-dpkg)
CMD="aptitude -s install" CMD="aptitude -s install"
;; ;;
yum-rpm) yum-rpm)
if __use_yum_assumeno ; then if __use_yum_assumeno ; then
store_output sudocmd yum --assumeno install $filenames store_output sudocmd yum --assumeno install $filenames
__check_yum_result $RC_STDOUT $? __check_yum_result $RC_STDOUT $?
else else
store_output sudocmd yum install $filenames <<EOF store_output sudocmd yum install $filenames <<EOF
n n
EOF EOF
__check_yum_result $RC_STDOUT $? __check_yum_result $RC_STDOUT $?
fi fi
RES=$? RES=$?
clean_store_output clean_store_output
return $RES ;; return $RES ;;
dnf-rpm) dnf-rpm)
store_output sudocmd dnf --assumeno install $filenames store_output sudocmd dnf --assumeno install $filenames
__check_yum_result $RC_STDOUT $? __check_yum_result $RC_STDOUT $?
RES=$? RES=$?
clean_store_output clean_store_output
return $RES ;; return $RES ;;
urpm-rpm) urpm-rpm)
CMD="urpmi --test --auto" CMD="urpmi --test --auto"
;; ;;
eopkg) eopkg)
CMD="eopkg --dry-run install" CMD="eopkg --dry-run install"
;; ;;
zypper-rpm) zypper-rpm)
if ! __use_zypper_dry_run >/dev/null ; then if ! __use_zypper_dry_run >/dev/null ; then
fatal "zypper is too old: does not support --dry-run" fatal "zypper is too old: does not support --dry-run"
fi fi
CMD="zypper --non-interactive install --dry-run" CMD="zypper --non-interactive install --dry-run"
;; ;;
emerge) emerge)
local res=0 local res=0
for pkg in $filenames ; do for pkg in $filenames ; do
is_installed $pkg && continue is_installed $pkg && continue
docmd emerge --pretend $pkg && continue docmd emerge --pretend $pkg && continue
pkg=1 pkg=1
break break
done done
return $res ;; return $res ;;
opkg) opkg)
docmd --noaction install $filenames docmd --noaction install $filenames
return $res ;; return $res ;;
pacman) pacman)
store_output sudocmd pacman -v -S $filenames <<EOF store_output sudocmd pacman -v -S $filenames <<EOF
no no
EOF EOF
__check_pacman_result $RC_STDOUT $? __check_pacman_result $RC_STDOUT $?
RES=$? RES=$?
clean_store_output clean_store_output
return $RES ;; return $RES ;;
slackpkg) slackpkg)
#docmd /usr/sbin/slackpkg -batch=on -default_answer=yes download #docmd /usr/sbin/slackpkg -batch=on -default_answer=yes download
# just try search every package # just try search every package
# FIXME: epm_search have to return false status code if the package does not found # FIXME: epm_search have to return false status code if the package does not found
local pkg res local pkg res
res=0 res=0
for pkg in $filenames ; do for pkg in $filenames ; do
# FIXME: -[0-0] does not work in search! # FIXME: -[0-0] does not work in search!
# FIXME: we need strict search here (not find gst-plugins-base if search for gst-plugins # FIXME: we need strict search here (not find gst-plugins-base if search for gst-plugins
# TODO: use short? # TODO: use short?
# use verbose for get package status # use verbose for get package status
#pkg_filenames="$pkg-[0-9]" verbose=--verbose __epm_search_internal | grep -E "(installed|upgrade)" && continue #pkg_filenames="$pkg-[0-9]" verbose=--verbose __epm_search_internal | grep -E "(installed|upgrade)" && continue
#pkg_filenames="$pkg" verbose=--verbose __epm_search_internal | grep -E "(installed|upgrade)" && continue #pkg_filenames="$pkg" verbose=--verbose __epm_search_internal | grep -E "(installed|upgrade)" && continue
(pkg_filenames="$pkg" __epm_search_internal) | grep -q "^$pkg-[0-9]" && continue (pkg_filenames="$pkg" __epm_search_internal) | grep -q "^$pkg-[0-9]" && continue
res=1 res=1
info "Package '$pkg' does not found in repository." info "Package '$pkg' does not found in repository."
done done
return $res ;; return $res ;;
*) *)
fatal "Have no suitable simulate command for $PMTYPE" fatal "Have no suitable simulate command for $PMTYPE"
;; ;;
esac esac
sudocmd $CMD $filenames sudocmd $CMD $filenames
......
...@@ -24,105 +24,105 @@ PAOURL="https://packages.altlinux.org" ...@@ -24,105 +24,105 @@ PAOURL="https://packages.altlinux.org"
paoapi() paoapi()
{ {
# http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs # http://petstore.swagger.io/?url=http://packages.altlinux.org/api/docs
assure_exists curl || return 1 assure_exists 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"
} }
# TODO: use /home/lav/Projects/git/JSON.sh # TODO: use /home/lav/Projects/git/JSON.sh
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'
$SHAREDIR/tools_json -b | grep -E "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g' $SHAREDIR/tools_json -b | grep -E "\[.*\"$FIELD\"\]" | sed -e 's|.*[[:space:]]"\(.*\)"|\1|g'
return 0 return 0
} }
run_command_if_exists() run_command_if_exists()
{ {
local CMD="$1" local CMD="$1"
shift shift
if is_command "$CMD" ; then if is_command "$CMD" ; then
docmd $CMD "$@" docmd $CMD "$@"
return 0 return 0
fi fi
return 1 return 1
} }
# TODO: use something like xdg-browser # TODO: use something like xdg-browser
open_browser() open_browser()
{ {
local i local i
for i in xdg-open firefox chromium links ; do for i in xdg-open firefox chromium links ; do
run_command_if_exists $i "$@" && return run_command_if_exists $i "$@" && return
done done
} }
__query_package_hl_url() __query_package_hl_url()
{ {
case $DISTRNAME in case $DISTRNAME in
ALTLinux|ALTServer) ALTLinux|ALTServer)
paoapi srpms/$1 | get_pao_var url paoapi srpms/$1 | get_pao_var url
;; ;;
esac esac
return 1 return 1
} }
query_package_url() query_package_url()
{ {
local URL local URL
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
# TODO: for binary packages? # TODO: for binary packages?
query_package_field URL "$1" || __query_package_hl_url "$1" query_package_field URL "$1" || __query_package_hl_url "$1"
#LANG=C epm info "$1" #LANG=C epm info "$1"
return return
;; ;;
homebrew) homebrew)
docmd brew "$1" | grep "^From: " | sed -e "s|^From: ||" docmd brew "$1" | grep "^From: " | sed -e "s|^From: ||"
return return
;; ;;
esac esac
fatal "rpm based distro supported only. TODO: Realize via web service?" fatal "rpm based distro supported only. TODO: Realize via web service?"
} }
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
} }
get_pao_url() get_pao_url()
{ {
local loc local loc
loc=$(get_locale | cut -c1-2) loc=$(get_locale | cut -c1-2)
case $loc in case $loc in
en|ru|uk|br) en|ru|uk|br)
loc=$loc loc=$loc
;; ;;
*) *)
loc=en loc=en
esac esac
echo "$PAOURL/$loc/Sisyphus/srpms" echo "$PAOURL/$loc/Sisyphus/srpms"
} }
query_altlinux_url() query_altlinux_url()
{ {
local URL local URL
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
local srpm=$(print_srcname "$1") local srpm=$(print_srcname "$1")
[ -n "$srpm" ] || fatal "Can't get source name for $1" [ -n "$srpm" ] || fatal "Can't get source name for $1"
echo "$(get_pao_url)/$srpm" echo "$(get_pao_url)/$srpm"
return return
;; ;;
esac esac
fatal "rpm based distro supported only. TODO: Realize via web service?" fatal "rpm based distro supported only. TODO: Realize via web service?"
} }
epm_site() epm_site()
...@@ -132,18 +132,18 @@ epm_site() ...@@ -132,18 +132,18 @@ epm_site()
local PAO="" local PAO=""
for f in $pkg_names $pkg_files ; do for f in $pkg_names $pkg_files ; do
[ "$f" = "-p" ] && PAO="$f" && continue [ "$f" = "-p" ] && PAO="$f" && continue
if [ -n "$PAO" ] ; then if [ -n "$PAO" ] ; then
pkg_url=$(query_altlinux_url $f) pkg_url=$(query_altlinux_url $f)
else else
pkg_url=$(query_package_url $f) pkg_url=$(query_package_url $f)
fi fi
[ -n "$pkg_url" ] && open_browser "$pkg_url" && continue [ -n "$pkg_url" ] && open_browser "$pkg_url" && continue
warning "Can't get URL for $f package" warning "Can't get URL for $f package"
done done
#for f in $pkg_names ; do #for f in $pkg_names ; do
# LANG=C epm info $f # LANG=C epm info $f
#done #done
# TODO: -p for p.a.o (see rpmurl) # TODO: -p for p.a.o (see rpmurl)
......
...@@ -39,96 +39,96 @@ __check_for_epm_version() ...@@ -39,96 +39,96 @@ __check_for_epm_version()
epm_update() epm_update()
{ {
[ -z "$*" ] || fatal "No arguments are allowed here" [ -z "$*" ] || fatal "No arguments are allowed here"
info "Running command for update remote package repository database" info "Running command for update remote package repository database"
warmup_hibase warmup_hibase
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
# TODO: hack against cd to cwd in apt-get on ALT # TODO: hack against cd to cwd in apt-get on ALT
cd / cd /
sudocmd apt-get update sudocmd apt-get update
local ret="$?" local ret="$?"
cd - >/dev/null cd - >/dev/null
__check_for_epm_version __check_for_epm_version
return $ret return $ret
#sudocmd apt-get -f install || exit #sudocmd apt-get -f install || exit
;; ;;
apt-dpkg) apt-dpkg)
sudocmd apt-get update || return sudocmd apt-get update || return
#sudocmd apt-get -f install || exit #sudocmd apt-get -f install || exit
#sudocmd apt-get autoremove #sudocmd apt-get autoremove
;; ;;
packagekit) packagekit)
docmd pkcon refresh docmd pkcon refresh
;; ;;
#snappy) #snappy)
# sudocmd snappy # sudocmd snappy
# ;; # ;;
aptitude-dpkg) aptitude-dpkg)
sudocmd aptitude update || return sudocmd aptitude update || return
;; ;;
yum-rpm) yum-rpm)
# just skipped # just skipped
[ -z "$verbose" ] || info "update command is stubbed for yum" [ -z "$verbose" ] || info "update command is stubbed for yum"
;; ;;
dnf-rpm) dnf-rpm)
# just skipped # just skipped
[ -z "$verbose" ] || info "update command is stubbed for dnf" [ -z "$verbose" ] || info "update command is stubbed for dnf"
;; ;;
urpm-rpm) urpm-rpm)
sudocmd urpmi.update -a sudocmd urpmi.update -a
;; ;;
pacman) pacman)
sudocmd pacman -S -y sudocmd pacman -S -y
;; ;;
aura) aura)
sudocmd aura -A -y sudocmd aura -A -y
;; ;;
zypper-rpm) zypper-rpm)
sudocmd zypper $(subst_option non_interactive --non-interactive) refresh sudocmd zypper $(subst_option non_interactive --non-interactive) refresh
;; ;;
emerge) emerge)
sudocmd emerge --sync sudocmd emerge --sync
;; ;;
slackpkg) slackpkg)
sudocmd /usr/sbin/slackpkg -batch=on update sudocmd /usr/sbin/slackpkg -batch=on update
;; ;;
deepsolver-rpm) deepsolver-rpm)
sudocmd ds-update sudocmd ds-update
;; ;;
npackd) npackd)
sudocmd packdcl detect # get packages from MSI database sudocmd packdcl detect # get packages from MSI database
;; ;;
homebrew) homebrew)
docmd brew update docmd brew update
;; ;;
opkg) opkg)
sudocmd opkg update sudocmd opkg update
;; ;;
eopkg) eopkg)
sudocmd eopkg update-repo sudocmd eopkg update-repo
;; ;;
apk) apk)
sudocmd apk update sudocmd apk update
;; ;;
pkgsrc) pkgsrc)
# portsnap extract for the first time? # portsnap extract for the first time?
sudocmd portsnap fetch update sudocmd portsnap fetch update
;; ;;
aptcyg) aptcyg)
sudocmd apt-cyg update sudocmd apt-cyg update
;; ;;
xbps) xbps)
sudocmd xbps-install -S sudocmd xbps-install -S
;; ;;
winget) winget)
sudocmd winget source update sudocmd winget source update
;; ;;
*) *)
fatal "Have no suitable update command for $PMTYPE" fatal "Have no suitable update command for $PMTYPE"
;; ;;
esac esac
} }
...@@ -22,157 +22,160 @@ load_helper epm-sh-warmup ...@@ -22,157 +22,160 @@ load_helper epm-sh-warmup
epm_upgrade() epm_upgrade()
{ {
local CMD local CMD
# it is useful for first time running # it is useful for first time running
update_repo_if_needed update_repo_if_needed
warmup_bases warmup_bases
if [ "$BASEDISTRNAME" = "alt" ] ; then if [ "$BASEDISTRNAME" = "alt" ] ; then
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
if tasknumber "$@" >/dev/null ; then if tasknumber "$@" >/dev/null ; then
load_helper epm-addrepo load_helper epm-addrepo
load_helper epm-reposave load_helper epm-reposave
load_helper epm-removerepo load_helper epm-removerepo
load_helper epm-Install load_helper epm-Install
local installlist="$(get_task_packages $*)" local installlist="$(get_task_packages $*)"
# hack: drop -devel packages to avoid package provided by multiple packages # hack: drop -devel packages to avoid package provided by multiple packages
installlist="$(estrlist reg_exclude ".*-devel .*-devel-static" "$installlist")" installlist="$(estrlist reg_exclude ".*-devel .*-devel-static" "$installlist")"
[ -n "$verbose" ] && info "Packages from task(s): $installlist" [ -n "$verbose" ] && info "Packages from task(s): $installlist"
# install only installed packages (simulate upgrade packages) # install only installed packages (simulate upgrade packages)
installlist="$(get_only_installed_packages "$installlist")" installlist="$(get_only_installed_packages "$installlist")"
[ -n "$verbose" ] && info "Packages to upgrade: $installlist" [ -n "$verbose" ] && info "Packages to upgrade: $installlist"
if [ -z "$installlist" ] ; then if [ -z "$installlist" ] ; then
warning "There is no installed packages for upgrade from task $*" warning "There is no installed packages for upgrade from task $*"
return 22 return 22
fi fi
try_change_alt_repo try_change_alt_repo
epm_addrepo "$@" epm_addrepo "$@"
(pkg_names="$installlist" epm_Install) || fatal "Can't update repo" (pkg_names="$installlist" epm_Install) || fatal "Can't update repo"
epm_removerepo "$@" epm_removerepo "$@"
end_change_alt_repo end_change_alt_repo
return return
fi fi
fi fi
# Solus supports upgrade for a package (with all dependencies) # Solus supports upgrade for a package (with all dependencies)
if [ -n "$1" ] && [ "$DISTRNAME" = "Solus" ] ; then if [ -n "$1" ] && [ "$DISTRNAME" = "Solus" ] ; then
sudocmd eopkg upgrade "$@" sudocmd eopkg upgrade "$@"
return return
fi fi
info "Running command for upgrade packages" info "Running command for upgrade packages"
case $PMTYPE in case $PMTYPE in
*-rpm) *-rpm)
# upgrade only install files from the list # upgrade only install files from the list
if [ -n "$pkg_files" ] ; then if [ -n "$pkg_files" ] ; then
load_helper epm-install load_helper epm-install
#sudocmd rpm -Fvh $pkg_files #sudocmd rpm -Fvh $pkg_files
(pkg_files=$pkg_files force="$force -F" epm_install) (pkg_files=$pkg_files force="$force -F" epm_install)
return return
elif [ -n "$pkg_names" ] ; then elif [ -n "$pkg_names" ] ; then
# hack for https://bugzilla.altlinux.org/41225 # hack for https://bugzilla.altlinux.org/41225
case "$pkg_names" in case "$pkg_names" in
-*) -*)
fatal "Option $pkg_names is not allowed here" fatal "Option $pkg_names is not allowed here"
esac esac
load_helper epm-install load_helper epm-install
(pkg_names=$(get_only_installed_packages $pkg_names) epm_install) (pkg_names=$(get_only_installed_packages $pkg_names) epm_install)
return return
fi fi
;; ;;
esac esac
case $PMTYPE in case $PMTYPE in
apt-rpm|apt-dpkg) apt-rpm|apt-dpkg)
local APTOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")" local APTOPTIONS="$(subst_option non_interactive -y) $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
CMD="apt-get $APTOPTIONS $noremove $force_yes dist-upgrade" CMD="apt-get $APTOPTIONS $noremove $force_yes dist-upgrade"
;; ;;
aptitude-dpkg) aptitude-dpkg)
CMD="aptitude dist-upgrade" CMD="aptitude dist-upgrade"
;; ;;
packagekit) packagekit)
docmd pkcon update docmd pkcon update
return return
;; ;;
yum-rpm) yum-rpm)
local OPTIONS="$(subst_option non_interactive -y)" local OPTIONS="$(subst_option non_interactive -y)"
# can do update repobase automagically # can do update repobase automagically
CMD="yum $OPTIONS update $*" CMD="yum $OPTIONS update $*"
;; ;;
dnf-rpm) dnf-rpm)
local OPTIONS="$(subst_option non_interactive -y)" local OPTIONS="$(subst_option non_interactive -y)"
CMD="dnf $OPTIONS distro-sync $*" CMD="dnf $OPTIONS distro-sync $*"
;; ;;
snappy) snappy)
CMD="snappy update" CMD="snappy update"
;; ;;
urpm-rpm) urpm-rpm)
# or --auto-select --replace-files # or --auto-select --replace-files
CMD="urpmi --update --auto-select $*" CMD="urpmi --update --auto-select $*"
;; ;;
zypper-rpm) zypper-rpm)
CMD="zypper $(subst_option non_interactive --non-interactive) dist-upgrade" CMD="zypper $(subst_option non_interactive --non-interactive) dist-upgrade"
;; ;;
pacman) pacman)
CMD="pacman -S -u $force" CMD="pacman -S -u $force"
;; ;;
aura) aura)
CMD="aura -A -u" CMD="aura -A -u"
;; ;;
emerge) emerge)
CMD="emerge -NuDa world" CMD="emerge -NuDa world"
;; ;;
conary) conary)
CMD="conary updateall" CMD="conary updateall"
;; ;;
pkgsrc) pkgsrc)
CMD="freebsd-update fetch install" CMD="freebsd-update fetch install"
;; ;;
pkgng) pkgng)
CMD="pkg upgrade" CMD="pkg upgrade"
;; ;;
chocolatey) apk)
CMD="chocolatey update all" CMD="apk upgrade"
;; ;;
homebrew) chocolatey)
#CMD="brew upgrade" CMD="chocolatey update all"
docmd brew upgrade $(brew outdated) ;;
return homebrew)
;; #CMD="brew upgrade"
opkg) docmd brew upgrade $(brew outdated)
CMD="opkg upgrade" return
;; ;;
eopkg) opkg)
CMD="eopkg upgrade" CMD="opkg upgrade"
;; ;;
slackpkg) eopkg)
CMD="/usr/sbin/slackpkg upgrade-all" CMD="eopkg upgrade"
;; ;;
guix) slackpkg)
CMD="guix package -u" CMD="/usr/sbin/slackpkg upgrade-all"
;; ;;
appget|winget) guix)
CMD="$PMTYPE update-all" CMD="guix package -u"
;; ;;
aptcyg) appget|winget)
# shellcheck disable=SC2046 CMD="$PMTYPE update-all"
docmd_foreach "epm install" $(short=1 epm packages) ;;
return aptcyg)
;; # shellcheck disable=SC2046
xbps) docmd_foreach "epm install" $(short=1 epm packages)
CMD="xbps-install -Su" return
;; ;;
*) xbps)
fatal "Have no suitable command for $PMTYPE" CMD="xbps-install -Su"
;; ;;
esac *)
fatal "Have no suitable command for $PMTYPE"
;;
esac
sudocmd $CMD "$@" sudocmd $CMD "$@"
} }
...@@ -23,75 +23,75 @@ load_helper epm-print ...@@ -23,75 +23,75 @@ load_helper epm-print
epm_whatdepends() epm_whatdepends()
{ {
local CMD local CMD
[ -n "$pkg_files" ] && fatal "whatdepends does not handle files" [ -n "$pkg_files" ] && fatal "whatdepends does not handle files"
[ -n "$pkg_names" ] || fatal "whatdepends: package name is missed" [ -n "$pkg_names" ] || fatal "whatdepends: package name is missed"
local pkg=$(print_name $pkg_names) local pkg=$(print_name $pkg_names)
# by package name # by package name
case $PMTYPE in case $PMTYPE in
apt-rpm) apt-rpm)
if [ -z "$verbose" ] ; then if [ -z "$verbose" ] ; then
showcmd apt-cache whatdepends $pkg showcmd apt-cache whatdepends $pkg
if [ -n "$short" ] ; then if [ -n "$short" ] ; then
# TODO: use common converter from full name to short name # TODO: use common converter from full name to short name
# TODO: see print_pkgname # TODO: see print_pkgname
a= apt-cache whatdepends $pkg | grep "^ [^ ]" | sed -e "s|[0-9]*:||" | grep -E -v "(i586-|-debuginfo)" | sed -e 's|[@:].*||' -e "s|-[0-9].*||g" -e 's|^ *||' -e 's/\.32bit//g' a= apt-cache whatdepends $pkg | grep "^ [^ ]" | sed -e "s|[0-9]*:||" | grep -E -v "(i586-|-debuginfo)" | sed -e 's|[@:].*||' -e "s|-[0-9].*||g" -e 's|^ *||' -e 's/\.32bit//g'
else else
load_helper epm-query load_helper epm-query
a= apt-cache whatdepends $pkg | grep "^ [^ ]" | sed -e "s|[0-9]*:||" | grep -E -v "(i586-|-debuginfo)" a= apt-cache whatdepends $pkg | grep "^ [^ ]" | sed -e "s|[0-9]*:||" | grep -E -v "(i586-|-debuginfo)"
fi fi
return return
fi fi
CMD="apt-cache whatdepends" CMD="apt-cache whatdepends"
;; ;;
apt-dpkg|aptitude-dpkg) apt-dpkg|aptitude-dpkg)
CMD="apt-cache rdepends" CMD="apt-cache rdepends"
;; ;;
aptitude-dpkg) aptitude-dpkg)
CMD="aptitude why" CMD="aptitude why"
;; ;;
packagekit) packagekit)
CMD="pkcon depends-on" CMD="pkcon depends-on"
;; ;;
yum-rpm) yum-rpm)
CMD="repoquery --whatrequires" CMD="repoquery --whatrequires"
;; ;;
urpm-rpm) urpm-rpm)
CMD="urpmq --whatrequires" CMD="urpmq --whatrequires"
;; ;;
dnf-rpm) dnf-rpm)
# check command: dnf repoquery --whatrequires # check command: dnf repoquery --whatrequires
CMD="repoquery --whatrequires" CMD="repoquery --whatrequires"
;; ;;
emerge) emerge)
assure_exists equery assure_exists equery
CMD="equery depends -a" CMD="equery depends -a"
;; ;;
homebrew) homebrew)
CMD="brew uses" CMD="brew uses"
;; ;;
pkgng) pkgng)
CMD="pkg info -r" CMD="pkg info -r"
;; ;;
aptcyg) aptcyg)
CMD="apt-cyg rdepends" CMD="apt-cyg rdepends"
;; ;;
opkg) opkg)
CMD="opkg whatdepends" CMD="opkg whatdepends"
;; ;;
eopkg) eopkg)
showcmd eopkg info $pkg showcmd eopkg info $pkg
# eopkg info prints it only from repo info # eopkg info prints it only from repo info
a= eopkg info $pkg | grep "^Reverse Dependencies" | sed -e "s|Reverse Dependencies[[:space:]]*: ||" | grep -v "^$" a= eopkg info $pkg | grep "^Reverse Dependencies" | sed -e "s|Reverse Dependencies[[:space:]]*: ||" | grep -v "^$"
return return
;; ;;
xbps) xbps)
CMD="xbps-query -X" CMD="xbps-query -X"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
docmd $CMD $pkg docmd $CMD $pkg
......
...@@ -21,38 +21,38 @@ load_helper epm-print ...@@ -21,38 +21,38 @@ load_helper epm-print
epm_whatprovides() epm_whatprovides()
{ {
local CMD local CMD
[ -n "$pkg_files" ] && fatal "whatprovides does not handle files" [ -n "$pkg_files" ] && fatal "whatprovides does not handle files"
[ -n "$pkg_names" ] || fatal "whatprovides: package name is missed" [ -n "$pkg_names" ] || fatal "whatprovides: package name is missed"
local pkg=$(print_name $pkg_names) local pkg=$(print_name $pkg_names)
# by package name # by package name
case $PMTYPE in case $PMTYPE in
conary) conary)
CMD="conary repquery --what-provides" CMD="conary repquery --what-provides"
;; ;;
apt-rpm|apt-dpkg|aptitude-dpkg) apt-rpm|apt-dpkg|aptitude-dpkg)
LANG=C docmd apt-get install --print-uris $pkg | grep "^Selecting" | cut -f2 -d" " LANG=C docmd apt-get install --print-uris $pkg | grep "^Selecting" | cut -f2 -d" "
return return
;; ;;
yum-rpm) yum-rpm)
CMD="yum whatprovides" CMD="yum whatprovides"
;; ;;
urpm-rpm) urpm-rpm)
CMD="urpmq --whatprovides" CMD="urpmq --whatprovides"
;; ;;
dnf-rpm) dnf-rpm)
CMD="yum provides" CMD="yum provides"
;; ;;
zypper-rpm) zypper-rpm)
CMD="zypper what-provides" CMD="zypper what-provides"
;; ;;
opkg) opkg)
CMD="opkg whatprovides" CMD="opkg whatprovides"
;; ;;
*) *)
fatal "Have no suitable command for $PMTYPE" fatal "Have no suitable command for $PMTYPE"
;; ;;
esac esac
docmd $CMD $pkg docmd $CMD $pkg
......
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