Commit b3b03826 authored by Vitaly Lipatov's avatar Vitaly Lipatov

introduce try_assure_exists() and use it

parent 301a18ca
......@@ -66,7 +66,7 @@ __epm_filelist_remote()
case $PMTYPE in
apt-dpkg)
assure_exists apt-file || return
try_assure_exists apt-file || return
if sudo_allowed ; then
sudocmd apt-file update
else
......@@ -78,11 +78,11 @@ __epm_filelist_remote()
docmd pkcon get-files "$@"
;;
yum-rpm)
assure_exists yum-utils || return
assure_exists yum-utils
docmd repoquery -q -l "$@"
;;
dnf-rpm)
assure_exists dnf-plugins-core || return
assure_exists dnf-plugins-core
docmd dnf repoquery -l "$@"
;;
*)
......
......@@ -20,8 +20,8 @@
# TODO: is it different from rpm --rebuilddb?
__repack_rpm_base()
{
assure_exists db_dump || fatal
assure_exists db_load || fatal
assure_exists db_dump
assure_exists db_load
cd /var/lib/rpm || fatal
mv Packages Packages.BACKUP || fatal
# mask dependencies with a=
......
......@@ -130,7 +130,7 @@ __epm_repack_to_rpm()
local pkg="$1"
# Note: install epm-repack for static (package based) dependencies
assure_exists alien || fatal
assure_exists alien
assure_exists fakeroot
# will set RPMBUILD
......@@ -141,10 +141,10 @@ __epm_repack_to_rpm()
# TODO: check for all systems
case $PKGFORMAT in
rpm)
assure_exists $RPMBUILD rpm-build || fatal
assure_exists $RPMBUILD rpm-build
;;
deb)
assure_exists $RPMBUILD rpm || fatal
assure_exists $RPMBUILD rpm
;;
esac
fi
......@@ -153,7 +153,7 @@ __epm_repack_to_rpm()
# TODO: improve
if echo "$pkg" | grep -q "\.deb" ; then
assure_exists dpkg || fatal
assure_exists dpkg
# TODO: Для установки требует: /usr/share/debconf/confmodule но пакет не может быть установлен
# assure_exists debconf
fi
......
......@@ -480,7 +480,7 @@ __epm_restore_npm()
{
local req_file="$1"
assure_exists jq || fatal
assure_exists jq
if [ -n "$dryrun" ] ; then
local lt
......@@ -544,7 +544,7 @@ __epm_restore_perl_shyaml()
{
local req_file="$1"
assure_exists shyaml || fatal
assure_exists shyaml
if [ -n "$dryrun" ] ; then
local lt
......
......@@ -54,7 +54,7 @@ rsync_alt_contents_index()
local URL="$1"
local TD="$2"
local res
assure_exists rsync || return
try_assure_exists rsync || return
if ! __rsync_check "$URL" ; then
warning "$URL is not accessible via rsync, skipping contents index update..."
......
......@@ -654,8 +654,8 @@ regexp_subst()
sed -i -r -e "$expression" "$@"
}
# TODO: we we can't use epm directly?
assure_exists()
# TODO: why we can't use epm directly?
try_assure_exists()
{
load_helper epm-assure
local package="$2"
......@@ -665,9 +665,15 @@ assure_exists()
local ask=''
[ -n "$non_interactive" ] || ask=1
( verbose='' direct='' interactive=$ask epm_assure "$1" $package $3 ) || fatal
( verbose='' direct='' interactive=$ask epm_assure "$1" $package $3 )
}
assure_exists()
{
try_assure_exists "$@" || fatal
}
assure_exists_erc()
{
load_helper epm-assure
......@@ -762,8 +768,8 @@ onefile_eget()
{
# check for both
# we really need that cross here,
is_command curl || assure_exists wget
is_command wget || assure_exists curl
is_command curl || try_assure_exists wget
is_command wget || try_assure_exists curl
internal_tools_eget "$@"
}
......
......@@ -72,7 +72,7 @@ esac
case $PMTYPE in
apt-dpkg)
is_command apt-file || return 0
assure_exists apt-file || return 0
try_assure_exists apt-file || return 0
sudocmd apt-file update
;;
esac
......
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