#!/bin/sh # # Copyright (C) 2012 Etersoft # Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru> # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # # TODO: use when run install with epm --skip-installed install filter_out_installed_packages() { [ -z "$skip_installed" ] && cat && return # TODO: rewrite with use epm_query # TODO: use this more effectively way #for i in $(cat) ; do # rpm -q $i >/dev/null && continue # echo $i #done | case $PKGFORMAT in "rpm") LANG=C LC_ALL=C xargs -n1 rpm -q 2>&1 | grep 'is not installed' | sed -e 's|^.*package \(.*\) is not installed.*|\1|g' ;; "deb") LANG=C LC_ALL=C xargs -n1 dpkg -L 2>&1 | grep 'is not installed.' | sed -e 's|^Package .\(.*\). is not installed.*|\1|g' ;; *) cat ;; esac | sed -e "s|rpm-build-altlinux-compat[^ ]*||g" | filter_strip_spaces } # copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg epm_install_names() { if [ -n "$non_interactive" ] ; then epm_ni_install_names "$@" return fi [ -z "$1" ] && return case $PMTYPE in apt-rpm|apt-dpkg) sudocmd apt-get install $@ return ;; urpm-rpm) sudocmd urpmi $@ return ;; pkg_add) sudocmd pkg_add -r $@ return ;; emerge) sudocmd emerge -uD $@ return ;; pacman) sudocmd pacman -S $@ return ;; yum-rpm) sudocmd yum install $@ return ;; zypper-rpm) sudocmd zypper install $@ return ;; mpkg) sudocmd mpkg install $@ return ;; slackpkg) # TODO: use upgrade if package is already installed sudocmd /usr/sbin/slackpkg install $@ return ;; *) fatal "Do not known install command for $PMTYPE" ;; esac } # Non interactive install epm_ni_install_names() { [ -z "$1" ] && return case $PMTYPE in apt-rpm|apt-dpkg) sudocmd apt-get -y --force-yes install $@ return ;; yum-rpm) sudocmd yum -y install $@ return ;; urpm-rpm) sudocmd urpmi --auto --no-verify-rpm $@ return ;; zypper-rpm) yes | sudocmd zypper --non-interactive install $@ return ;; pkg_add) sudocmd pkg_add -r $@ return ;; pacman) sudocmd pacman -S --noconfirm $@ return ;; npackd) # npackdcl update --package=<package> (remove old and install new) docmd npackdcl add --package=$@ return ;; chocolatey) docmd chocolatey install $@ return ;; slackpkg) # TODO: use upgrade if package is already installed sudocmd /usr/sbin/slackpkg -batch=on -default_answer=yes install $@ return ;; *) fatal "Do not known appropriate install command for $PMTYPE" ;; esac } epm_install_files() { [ -z "$1" ] && return case $PMTYPE in apt-rpm|urpm-rpm) sudocmd rpm -Uvh $force $nodeps $@ && return # use install_names ;; apt-dpkg) sudocmd dpkg -i $@ sudocmd apt-get -f install return ;; yum-rpm) sudocmd rpm -Uvh $force $@ && return sudocmd yum --nogpgcheck install $@ return ;; pkg_add) sudocmd pkg_add $@ return ;; pacman) sudocmd pacman -U --noconfirm $@ return ;; slackpkg) sudocmd /sbin/installpkg $@ return ;; esac # other systems can install file package via ordinary command epm_install_names "$@" } epm_print_install_command() { case $PMTYPE in apt-rpm|yum-rpm|urpm-rpm|zypper-rpm) echo "rpm -Uvh --force $nodeps $@" ;; apt-dpkg) echo "dpkg -i $@" ;; pkg_add) echo "pkg_add $@" ;; pacman) echo "pacman -U --noconfirm $@" ;; slackpkg) echo "/sbin/installpkg $@" ;; npackd) echo "npackdcl add --package=$@" ;; *) fatal "Do not known appropriate install command for $PMTYPE" ;; esac } epm_install() { if [ -n "$show_command_only" ] ; then epm_print_install_command $pkg_filenames return fi [ -n "$pkg_files$pkg_names" ] || fatal "Run install without packages" local names="$(echo $pkg_names | filter_out_installed_packages)" local files="$(echo $pkg_files | filter_out_installed_packages)" [ -z "$files$names" ] && echo "Skip empty install list" && return 2 epm_install_names $names || return epm_install_files $files }