epm-install 15.8 KB
Newer Older
Vitaly Lipatov's avatar
Vitaly Lipatov committed
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012-2017  Etersoft
# Copyright (C) 2012-2017  Vitaly Lipatov <lav@etersoft.ru>
Vitaly Lipatov's avatar
Vitaly Lipatov committed
5
#
6 7 8
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
Vitaly Lipatov's avatar
Vitaly Lipatov committed
9 10 11 12 13
# (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
14
# GNU Affero General Public License for more details.
Vitaly Lipatov's avatar
Vitaly Lipatov committed
15
#
16 17
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
Vitaly Lipatov's avatar
Vitaly Lipatov committed
18 19
#

20
load_helper epm-sh-altlinux
21
load_helper epm-query
22
load_helper epm-assure
23
load_helper epm-check_updated_repo
24
load_helper epm-sh-warmup
25

26 27 28 29 30 31 32 33 34 35
# TODO: use when run install with epm --skip-installed install
filter_out_installed_packages()
{
	[ -z "$skip_installed" ] && cat && return

	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'
			;;
36 37 38 39 40
		# dpkg -l lists some non ii status (un, etc)
		#"deb")
		#	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'
		#	;;
41
		*)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
42
			# shellcheck disable=SC2013
43 44 45
			for i in $(cat) ; do
				is_installed $i || echo $i
			done
46
			;;
47
	esac | sed -e "s|rpm-build-altlinux-compat[^ ]*||g" | filter_strip_spaces
48 49
}

50 51 52
# for zypper before SUSE/11.0
__use_zypper_no_gpg_checks()
{
Vitaly Lipatov's avatar
Vitaly Lipatov committed
53
    a='' zypper install --help 2>&1 | grep -q -- "--no-gpg-checks" && echo "--no-gpg-checks"
54
}
55

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
# args: cmd_reinstall, cmd_install, packages
__separate_sudocmd_foreach()
{
    local cmd_re=$1
    local cmd_in=$2
    shift 2
    separate_installed $@
    if [ -n "$pkg_noninstalled" ] ; then
        sudocmd_foreach "$cmd_re" $pkg_noninstalled || return
    fi
    if [ -n "$pkg_installed" ] ; then
        sudocmd_foreach "$cmd_in" $pkg_installed || return
    fi
    return 0
}

# args: cmd_reinstall, cmd_install, packages
__separate_sudocmd()
{
    local cmd_re=$1
    local cmd_in=$2
    shift 2
    separate_installed $@
    if [ -n "$pkg_noninstalled" ] ; then
        sudocmd "$cmd_re" $pkg_noninstalled || return
    fi
    if [ -n "$pkg_installed" ] ; then
        sudocmd "$cmd_in" $pkg_installed || return
    fi
    return 0
}

Vitaly Lipatov's avatar
Vitaly Lipatov committed
88
# copied from etersoft-build-utils/share/eterbuild/functions/rpmpkg
89
epm_install_names()
Vitaly Lipatov's avatar
Vitaly Lipatov committed
90
{
91 92 93 94
	[ -z "$1" ] && return

	warmup_hibase

95 96 97 98 99
	if [ -n "$non_interactive" ] ; then
		epm_ni_install_names "$@"
		return
	fi

100
	case $PMTYPE in
101
		apt-rpm|apt-dpkg)
102
			APTOPTIONS="$APTOPTIONS $(subst_option verbose "-o Debug::pkgMarkInstall=1 -o Debug::pkgProblemResolver=1")"
103
			sudocmd apt-get $APTOPTIONS $noremove install $@
104
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
105 106 107
		aptitude-dpkg)
			sudocmd aptitude install $@
			return ;;
108 109 110
		deepsolver-rpm)
			sudocmd ds-install $@
			return ;;
111
		urpm-rpm)
112
			sudocmd urpmi $URPMOPTIONS $@
113
			return ;;
114
		pkgsrc)
115
			sudocmd pkg_add -r $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
116
			return ;;
117 118 119
		pkgng)
			sudocmd pkg install $@
			return ;;
120
		emerge)
121
			sudocmd emerge -uD $@
122
			return ;;
123
		pacman)
124
			sudocmd pacman -S $force $nodeps $@
125
			return ;;
126 127 128
		aura)
			sudocmd aura -A $force $nodeps $@
			return ;;
129
		yum-rpm)
130
			sudocmd yum $YUMOPTIONS install $@
131
			return ;;
132 133 134
		dnf-rpm)
			sudocmd dnf install $@
			return ;;
135 136 137
		snappy)
			sudocmd snappy install $@
			return ;;
138
		zypper-rpm)
139
			sudocmd zypper install $ZYPPEROPTIONS $@
140 141
			return ;;
		mpkg)
142
			sudocmd mpkg install $@
143
			return ;;
144 145 146
		conary)
			sudocmd conary update $@
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
147
		npackd)
148 149
			# FIXME: correct arg
			__separate_sudocmd_foreach "npackdcl add --package=" "npackdcl update --package=" $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
150
			return ;;
151
		slackpkg)
152
			__separate_sudocmd_foreach "/usr/sbin/slackpkg install" "/usr/sbin/slackpkg upgrade" $@
153 154
			return ;;
		homebrew)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
155
			# FIXME: sudo and quote
Vitaly Lipatov's avatar
Vitaly Lipatov committed
156
			SUDO='' __separate_sudocmd "brew install" "brew upgrade" "$@"
157 158 159 160
			return ;;
		ipkg)
			[ -n "$force" ] && force=-force-depends
			sudocmd ipkg $force install $@
161
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
162
		nix)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
163
			__separate_sudocmd "nix-env --install" "nix-env --upgrade" "$@"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
164
			return ;;
165 166 167
		apk)
			sudocmd apk add $@
			return ;;
168 169 170
		tce)
			sudocmd tce-load -wi $@
			return ;;
171 172 173
		guix)
			__separate_sudocmd "guix package -i" "guix package -i" $@
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
174
		android)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
175
			fatal "We still have no idea how to use package repository, ever if it is F-Droid."
176
			return ;;
177 178 179
		aptcyg)
			sudocmd apt-cyg install $@
			return ;;
180 181 182
		xbps)
			sudocmd xbps-install $@
			return ;;
183
		*)
184
			fatal "Have no suitable install command for $PMTYPE"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
185
			;;
186 187 188
	esac
}

189
# Non interactive install
190 191
epm_ni_install_names()
{
Danil Mikhailov's avatar
Danil Mikhailov committed
192
	[ -z "$1" ] && return
193

194
	case $PMTYPE in
195
		apt-rpm|apt-dpkg)
196
			export DEBIAN_FRONTEND=noninteractive
197
			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 $@
198
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
199
		aptitude-dpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
200
			sudocmd aptitude -y install $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
201
			return ;;
202
		yum-rpm)
203
			sudocmd yum -y $YUMOPTIONS install $@
204
			return ;;
205 206 207
		dnf-rpm)
			sudocmd dnf -y $YUMOPTIONS install $@
			return ;;
208
		urpm-rpm)
209
			sudocmd urpmi --auto $URPMOPTIONS $@
210 211
			return ;;
		zypper-rpm)
212
			# FIXME: returns true ever no package found, need check for "no found", "Nothing to do."
213
			yes | sudocmd zypper --non-interactive $ZYPPEROPTIONS install $@
214
			return ;;
215
		pkgsrc)
216
			sudocmd pkg_add -r $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
217
			return ;;
218 219 220
		pkgng)
			sudocmd pkg install -y $@
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
221 222 223
		emerge)
			sudocmd emerge -uD $@
			return ;;
224
		pacman)
225
			sudocmd pacman -S --noconfirm $force $nodeps $@
226
			return ;;
227 228 229
		aura)
			sudocmd aura -A $force $nodeps $@
			return ;;
230 231
		npackd)
			#  npackdcl update --package=<package> (remove old and install new)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
232
			sudocmd npackdcl add --package="$*"
233
			return ;;
234 235 236
		chocolatey)
			docmd chocolatey install $@
			return ;;
237 238 239
		ipkg)
			sudocmd ipkg -force-defaults install $@
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
240 241 242
		nix)
			sudocmd nix-env --install $@
			return ;;
243 244 245
		apk)
			sudocmd apk add $@
			return ;;
246 247 248
		tce)
			sudocmd tce-load -wi $@
			return ;;
249 250 251
		xbps)
			sudocmd xbps-install -y $@
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
252 253
		homebrew)
			# FIXME: sudo and quote
Vitaly Lipatov's avatar
Vitaly Lipatov committed
254
			SUDO='' __separate_sudocmd "brew install" "brew upgrade" $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
255
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
256 257 258
		#android)
		#	sudocmd pm install $@
		#	return ;;
259
		slackpkg)
260
			# FIXME: broken status when use batch and default answer
261
			__separate_sudocmd_foreach "/usr/sbin/slackpkg -batch=on -default_answer=yes install" "/usr/sbin/slackpkg -batch=on -default_answer=yes upgrade" $@
262
			return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
263
		*)
264
			fatal "Have no suitable appropriate install command for $PMTYPE"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
265 266 267 268
			;;
	esac
}

269 270 271 272 273 274
__epm_check_if_rpm_already_installed()
{
	# Not: we can make optimize if just check version?
	LANG=C $SUDO rpm -Uvh $force $nodeps $@ 2>&1 | grep -q "is already installed"
}

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_deb()
{
	local pkg
	local debpkgs=""
	for pkg in $@ ; do
		[ "$(get_package_type "$pkg")" = "deb" ] || return 1
		[ -e "$pkg" ] || fatal "Can't read $pkg"
		debpkgs="$debpkgs $(realpath $pkg)"
	done
	[ -n "$debpkgs" ] || return 1

	assure_exists alien

	local TDIR=$(mktemp -d)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
290
	cd $TDIR || fatal
291
	for pkg in $debpkgs ; do
292 293 294 295 296
		# TODO: fakeroot for non ALT?
		showcmd_store_output alien -r -k --scripts "$pkg" || fatal
		local RPMCONVERTED=$(grep "rpm generated" $RC_STDOUT | sed -e "s| generated||g")
		clean_store_output
		epm install $RPMCONVERTED
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
	done
	rm -f $TDIR/*
	rmdir $TDIR/

	return 0
}

# TODO: rewrite to convert (get some code from Korinf?)
__epm_check_if_try_install_rpm()
{
	local pkg
	local rpmpkgs=""
	for pkg in $@ ; do
		[ "$(get_package_type "$pkg")" = "rpm" ] || return 1
		[ -e "$pkg" ] || fatal "Can't read $pkg"
		rpmpkgs="$rpmpkgs $(realpath $pkg)"
	done
	[ -n "$rpmpkgs" ] || return 1

	assure_exists alien
317
	assure_exists fakeroot
318 319

	local TDIR=$(mktemp -d)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
320
	cd $TDIR || fatal
321
	for pkg in $rpmpkgs ; do
322 323 324 325
		showcmd_store_output fakeroot alien -d -k --scripts "$pkg"
		local DEBCONVERTED=$(grep "deb generated" $RC_STDOUT | sed -e "s| generated||g")
		clean_store_output
		epm install $DEBCONVERTED
326 327 328 329 330 331 332
	done
	rm -f $TDIR/*
	rmdir $TDIR/

	return 0
}

333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
__handle_direct_install()
{
    case "$DISTRNAME" in
        "ALTLinux")
            load_helper epm-download
            local pkg url
            for pkg in $pkg_names ; do
                url=$(__epm_get_altpkg_url $pkg)
                [ -n "$url" ] || continue
                # TODO: use estrlist
                pkg_urls="$pkg_urls $url"
            done
            # FIXME: need remove
            pkg_names=""
            ;;
    esac
}
350

351
epm_install_files()
Vitaly Lipatov's avatar
Vitaly Lipatov committed
352
{
Danil Mikhailov's avatar
Danil Mikhailov committed
353
    [ -z "$1" ] && return
354

Vitaly Lipatov's avatar
Vitaly Lipatov committed
355 356 357 358
    # TODO: check read permissions
    # sudo test -r FILE
    # do not fallback to install_names if we have no permissions

359
    case $PMTYPE in
360
        apt-rpm)
361 362
            __epm_check_if_try_install_deb $@ && return

363 364 365 366
            # do not use low-level for install by file path
            if ! is_dirpath "$@" || [ "$(get_package_type "$@")" = "rpm" ] ; then
                sudocmd rpm -Uvh $force $nodeps $@ && return
                local RES=$?
367
                # TODO: check rpm result code and convert it to compatible format if possible
368
                __epm_check_if_rpm_already_installed $@ && return
369

370
            # if run with --nodeps, do not fallback on hi level
371
            [ -n "$nodeps" ] && return $RES
372
            fi
373

374 375
            # use install_names
            ;;
376

Vitaly Lipatov's avatar
Vitaly Lipatov committed
377
        apt-dpkg|aptitude-dpkg)
378 379 380 381
            # the new version of the conf. file is installed with a .dpkg-dist suffix
            if [ -n "$non_interactive" ] ; then
                DPKGOPTIONS="--force-confdef --force-confold"
            fi
382 383 384

            __epm_check_if_try_install_rpm $@ && return

385
            # FIXME: return false in case no install and in case install with broken deps
386
            sudocmd dpkg $DPKGOPTIONS -i $@
387
            local RES=$?
388 389
            # if run with --nodeps, do not fallback on hi level

390
            [ -n "$nodeps" ] && return $RES
391
            # fall to apt-get -f install for fix deps
Vitaly Lipatov's avatar
Vitaly Lipatov committed
392 393
            # can't use APTOPTIONS with empty install args
            epm_install_names -f
394 395 396

            # repeat install for get correct status
            sudocmd dpkg $DPKGOPTIONS -i $@
Vitaly Lipatov's avatar
Vitaly Lipatov committed
397
            return
398
            ;;
399

400
        yum-rpm|dnf-rpm)
401 402
            __epm_check_if_try_install_deb $@ && return

403 404 405
            sudocmd rpm -Uvh $force $nodeps $@ && return
            # if run with --nodeps, do not fallback on hi level

406 407
            __epm_check_if_rpm_already_installed $@ && return

408 409 410 411
            [ -n "$nodeps" ] && return
            YUMOPTIONS=--nogpgcheck
            # use install_names
            ;;
412

413
        zypper-rpm)
414
            __epm_check_if_try_install_deb $@ && return
415
            sudocmd rpm -Uvh $force $nodeps $@ && return
416 417
            local RES=$?

418 419
            __epm_check_if_rpm_already_installed $@ && return

420 421
            # if run with --nodeps, do not fallback on hi level

422
            [ -n "$nodeps" ] && return $RES
423
            ZYPPEROPTIONS=$(__use_zypper_no_gpg_checks)
424 425
            # use install_names
            ;;
426

427
        urpm-rpm)
428
            __epm_check_if_try_install_deb $@ && return
429
            sudocmd rpm -Uvh $force $nodeps $@ && return
430 431
            local RES=$?

432 433
            __epm_check_if_rpm_already_installed $@ && return

434
            # if run with --nodeps, do not fallback on hi level
435
            [ -n "$nodeps" ] && return $RES
436 437

            URPMOPTIONS=--no-verify-rpm
438 439
            # use install_names
            ;;
440
        pkgsrc)
441
            sudocmd pkg_add $@
442
            return ;;
443 444 445 446 447 448 449 450 451 452 453
        pkgng)
            local PKGTYPE="$(get_package_type $@)"
            case "$PKGTYPE" in
                tbz)
                    sudocmd pkg_add $@
                    ;;
                *)
                    sudocmd pkg add $@
                    ;;
            esac
            return ;;
454 455 456
        android)
            sudocmd pm install $@
            return ;;
457
        emerge)
458 459
            load_helper epm-install-emerge
            sudocmd epm_install_emerge $@
460
            return ;;
461
        pacman)
462
            sudocmd pacman -U --noconfirm $force $nodeps $@ && return
463 464 465
            local RES=$?

            [ -n "$nodeps" ] && return $RES
466
            sudocmd pacman -U $force $@
467
            return ;;
468
        slackpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
469
            # FIXME: check for full package name
Vitaly Lipatov's avatar
Vitaly Lipatov committed
470
            # FIXME: broken status when use batch and default answer
471
            __separate_sudocmd_foreach "/sbin/installpkg" "/sbin/upgradepkg" $@
472
            return ;;
473 474
    esac

475
    # other systems can install file package via ordinary command
476
    epm_install_names "$@"
477 478
}

479 480
epm_print_install_command()
{
481
    [ -z "$1" ] && return
482
    case $PMTYPE in
483
        apt-rpm|yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
484
            echo "rpm -Uvh --force $nodeps $*"
485
            ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
486
        apt-dpkg|aptitude-dpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
487
            echo "dpkg -i $*"
488
            ;;
489
        pkgsrc)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
490
            echo "pkg_add $*"
491
            ;;
492
        pkgng)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
493
            echo "pkg add $*"
494
            ;;
495 496
        emerge)
            # need be placed in /usr/portage/packages/somewhere
Vitaly Lipatov's avatar
Vitaly Lipatov committed
497
            echo "emerge --usepkg $*"
498
            ;;
499
        pacman)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
500
            echo "pacman -U --noconfirm --force $nodeps $*"
501 502
            ;;
        slackpkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
503
            echo "/sbin/installpkg $*"
504
            ;;
505
        npackd)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
506
            echo "npackdcl add --package=$*"
507
            ;;
508
        ipkg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
509
            echo "ipkg install $*"
510
            ;;
511
        android)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
512
            echo "pm install $*"
513
            ;;
514
        aptcyg)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
515
            echo "apt-cyg install $*"
516
            ;;
517
        tce)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
518
            echo "tce-load -wi $*"
519
            ;;
520
        xbps)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
521
            echo "xbps-install -y $*"
522
            ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
523 524
        homebrew)
            # FIXME: sudo and quote
Vitaly Lipatov's avatar
Vitaly Lipatov committed
525
            echo "brew install $*"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
526
            ;;
527

528
        *)
529
            fatal "Have no suitable appropriate install command for $PMTYPE"
530 531 532 533
            ;;
    esac
}

534 535 536 537 538
epm_print_install_names_command()
{
	[ -z "$1" ] && return
	case $PMTYPE in
		apt-rpm|apt-dpkg)
539
			echo "apt-get -y --force-yes -o APT::Install::VirtualVersion=true -o APT::Install::Virtual=true $APTOPTIONS install $*"
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
			return ;;
		aptitude-dpkg)
			echo "aptitude -y install $*"
			return ;;
		yum-rpm)
			echo "yum -y $YUMOPTIONS install $*"
			return ;;
		dnf-rpm)
			echo "dnf -y $YUMOPTIONS install $*"
			return ;;
		urpm-rpm)
			echo "urpmi --auto $URPMOPTIONS $*"
			return ;;
		zypper-rpm)
			echo "zypper --non-interactive $ZYPPEROPTIONS install $*"
			return ;;
		pacman)
			echo "pacman -S --noconfirm $force $*"
			return ;;
		chocolatey)
			echo "chocolatey install $*"
			return ;;
		nix)
			echo "nix-env --install $*"
			return ;;
		*)
			fatal "Have no suitable appropriate install command for $PMTYPE"
			;;
	esac
}

571 572 573

epm_install()
{
574 575 576 577 578 579
    if tasknumber "$pkg_names" >/dev/null ; then
        assure_exists apt-repo
        sudocmd apt-repo test $(tasknumber "$pkg_names")
        return
    fi

580
    if [ -n "$show_command_only" ] ; then
581 582
        epm_print_install_command $pkg_files
        epm_print_install_names_command $pkg_names
583 584 585
        return
    fi

586 587 588 589
    if [ -n "$direct" ] ; then
        __handle_direct_install
    fi

590 591 592 593 594
    # if possible, it will put pkg_urls into pkg_files or pkg_names
    if [ -n "$pkg_urls" ] ; then
        load_helper epm-download
        __handle_pkg_urls_to_install
    fi
595

596
    [ -z "$pkg_files$pkg_names" ] && info "Skip empty install list" && return 22
597

598 599 600
    # to be filter happy
    warmup_lowbase

601 602
    local names="$(echo $pkg_names | filter_out_installed_packages)"
    local files="$(echo $pkg_files | filter_out_installed_packages)"
603

604
    [ -z "$files$names" ] && info "Skip empty install list" && return 22
605

606
    if [ -z "$files" ] && [ -z "$direct" ] ; then
607 608 609
        # it is useful for first time running
        update_repo_if_needed
    fi
610

611
    epm_install_names $names || return
612
    epm_install_files $files
613
    local RETVAL=$?
614 615 616

    # TODO: reinvent
    [ -n "$to_remove_pkg_files" ] && rm -fv $to_remove_pkg_files
617

618
    return $RETVAL
Vitaly Lipatov's avatar
Vitaly Lipatov committed
619
}