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