Commit dc8f7abd authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm install/repack: big refactoring to support rpm/deb platform in common way

parent 996dcc92
...@@ -295,12 +295,13 @@ __epm_check_if_needed_repack() ...@@ -295,12 +295,13 @@ __epm_check_if_needed_repack()
local pkgname="$(epm print name from "$1")" local pkgname="$(epm print name from "$1")"
local repackcode="$CONFIGDIR/repack.d/$pkgname.sh" local repackcode="$CONFIGDIR/repack.d/$pkgname.sh"
[ -x "$repackcode" ] || return [ -x "$repackcode" ] || return
warning "There is exists repack rules for $pkgname package. It is better install this package via epm --repack install or epm play." warning "There is repack rule for $pkgname package. It is better install this package via 'epm --repack install' or 'epm play'."
} }
epm_install_files() epm_install_files()
{ {
[ -z "$1" ] && return local files="$@"
[ -z "$files" ] && return
# TODO: check read permissions # TODO: check read permissions
# sudo test -r FILE # sudo test -r FILE
...@@ -308,25 +309,31 @@ epm_install_files() ...@@ -308,25 +309,31 @@ epm_install_files()
case "$DISTRNAME" in case "$DISTRNAME" in
ALTLinux|ALTServer) ALTLinux|ALTServer)
# TODO: replace with name changed function if __epm_repack_if_needed $files ; then
__epm_check_if_try_install_pkgtype deb $@ && return $RES [ -n "$repacked_pkgs" ] || fatal "Can't convert $files"
__epm_check_if_try_install_pkgtype AppImage $@ && return $RES files="$repacked_pkgs"
__epm_check_if_src_rpm $@ # TODO
#__epm_remove_tmp_files
fi
__epm_check_if_src_rpm $files
# do not use low-level for install by file path (FIXME: reasons?) # do not use low-level for install by file path (FIXME: reasons?)
if ! is_dirpath "$@" || [ "$(get_package_type "$@")" = "rpm" ] ; then if ! is_dirpath "$files" || [ "$(get_package_type "$files")" = "rpm" ] ; then
__epm_check_vendor $@ if [ -z "$repacked_pkgs" ] ; then
__epm_check_if_needed_repack $@ __epm_check_vendor $files
sudocmd rpm -Uvh $force $noscripts $nodeps $@ && save_installed_packages $@ && return __epm_check_if_needed_repack $files
fi
sudocmd rpm -Uvh $force $noscripts $nodeps $files && save_installed_packages $files && return
local RES=$? local RES=$?
# TODO: check rpm result code and convert it to compatible format if possible # TODO: check rpm result code and convert it to compatible format if possible
__epm_check_if_rpm_already_installed $@ && return __epm_check_if_rpm_already_installed $files && return
# if run with --nodeps, do not fallback on hi level # if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return $RES [ -n "$nodeps" ] && return $RES
fi fi
epm_install_names "$@" epm_install_names $files
return return
;; ;;
esac esac
...@@ -338,23 +345,28 @@ epm_install_files() ...@@ -338,23 +345,28 @@ epm_install_files()
DPKGOPTIONS="--force-confdef --force-confold" DPKGOPTIONS="--force-confdef --force-confold"
fi fi
__epm_check_if_try_install_rpm $@ && return if __epm_repack_if_needed $files ; then
[ -n "$repacked_pkgs" ] || fatal "Can't convert $files"
files="$repacked_pkgs"
# TODO
#__epm_remove_tmp_files
fi
# TODO: if dpkg can't install due missed deps, trying with apt (as for now, --refuse-depends, --refuse-breaks don't help me) # TODO: if dpkg can't install due missed deps, trying with apt (as for now, --refuse-depends, --refuse-breaks don't help me)
if [ -n "$nodeps" ] ; then if [ -n "$nodeps" ] ; then
sudocmd dpkg $DPKGOPTIONS -i $@ sudocmd dpkg $DPKGOPTIONS -i $files
return return
fi fi
# TODO: don't resolve fuzzy dependencies () # TODO: don't resolve fuzzy dependencies ()
# are there apt that don't support dpkg files to install? # are there apt that don't support dpkg files to install?
epm_install_names $(make_filepath "$@") epm_install_names $(make_filepath $files)
return return
# old way: # old way:
sudocmd dpkg $DPKGOPTIONS -i $@ sudocmd dpkg $DPKGOPTIONS -i $files
local RES=$? local RES=$?
# return OK if all is OK # return OK if all is OK
...@@ -367,18 +379,23 @@ epm_install_files() ...@@ -367,18 +379,23 @@ epm_install_files()
epm_check epm_check
# repeat install for get correct status # repeat install for get correct status
sudocmd dpkg $DPKGOPTIONS -i $@ sudocmd dpkg $DPKGOPTIONS -i $files
return return
;; ;;
*-rpm) *-rpm)
__epm_check_if_try_install_pkgtype deb $@ && return $RES if __epm_repack_if_needed $files ; then
__epm_check_if_try_install_pkgtype AppImage $@ && return $RES [ -n "$repacked_pkgs" ] || fatal "Can't convert $files"
__epm_check_if_src_rpm $@ files="$repacked_pkgs"
sudocmd rpm -Uvh $force $noscripts $nodeps $@ && return # TODO
#__epm_remove_tmp_files
fi
__epm_check_if_src_rpm $files
sudocmd rpm -Uvh $force $noscripts $nodeps $files && return
local RES=$? local RES=$?
__epm_check_if_rpm_already_installed $@ && return __epm_check_if_rpm_already_installed $files && return
# if run with --nodeps, do not fallback on hi level # if run with --nodeps, do not fallback on hi level
[ -n "$nodeps" ] && return $RES [ -n "$nodeps" ] && return $RES
...@@ -402,45 +419,45 @@ epm_install_files() ...@@ -402,45 +419,45 @@ epm_install_files()
esac esac
;; ;;
packagekit) packagekit)
docmd pkcon install-local $@ docmd pkcon install-local $files
return ;; return ;;
pkgsrc) pkgsrc)
sudocmd pkg_add $@ sudocmd pkg_add $files
return ;; return ;;
pkgng) pkgng)
local PKGTYPE="$(get_package_type $@)" local PKGTYPE="$(get_package_type $files)"
case "$PKGTYPE" in case "$PKGTYPE" in
tbz) tbz)
sudocmd pkg_add $@ sudocmd pkg_add $files
;; ;;
*) *)
sudocmd pkg add $@ sudocmd pkg add $files
;; ;;
esac esac
return ;; return ;;
android) android)
sudocmd pm install $@ sudocmd pm install $files
return ;; return ;;
emerge) emerge)
load_helper epm-install-emerge load_helper epm-install-emerge
sudocmd epm_install_emerge $@ sudocmd epm_install_emerge $files
return ;; return ;;
pacman) pacman)
sudocmd pacman -U --noconfirm $nodeps $@ && return sudocmd pacman -U --noconfirm $nodeps $files && return
local RES=$? local RES=$?
[ -n "$nodeps" ] && return $RES [ -n "$nodeps" ] && return $RES
sudocmd pacman -U $@ sudocmd pacman -U $files
return ;; return ;;
slackpkg) slackpkg)
# FIXME: check for full package name # FIXME: check for full package name
# FIXME: broken status when use batch and default answer # FIXME: broken status when use batch and default answer
__separate_sudocmd_foreach "/sbin/installpkg" "/sbin/upgradepkg" $@ __separate_sudocmd_foreach "/sbin/installpkg" "/sbin/upgradepkg" $files
return ;; return ;;
esac esac
# other systems can install file package via ordinary command # other systems can install file package via ordinary command
epm_install_names "$@" epm_install_names $files
} }
epm_print_install_command() epm_print_install_command()
...@@ -604,20 +621,14 @@ epm_install() ...@@ -604,20 +621,14 @@ epm_install()
# repack binary files # repack binary files
if [ -n "$repack" ] ; then if [ -n "$repack" ] ; then
# FIXME: see to_remove below __epm_repack $files || return
__epm_repack_to_rpm $files || fatal files="$repacked_pkgs"
files="$repacked_rpms"
fi fi
epm_install_files $files epm_install_files $files
local RETVAL=$? local RETVAL=$?
# TODO: move it to exit handler __epm_remove_tmp_files
if [ -z "$DEBUG" ] ; then
# TODO: reinvent
[ -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
fi
return $RETVAL return $RETVAL
} }
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