3
# Copyright (C) 2015, 2017, 2019, 2020, 2022 Etersoft
4
# Copyright (C) 2015, 2017, 2019, 2020, 2022 Vitaly Lipatov <lav@etersoft.ru>
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Affero General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Affero General Public License for more details.
16
# You should have received a copy of the GNU Affero General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
__check_installed_app()
23
[ -s $epm_vardir/installed-app ] || return 1
24
grep -q -- "^$1\$" $epm_vardir/installed-app
29
[ -d "$epm_vardir" ] || return 0
30
__check_installed_app "$1" && return 0
31
echo "$1" | sudorun tee -a $epm_vardir/installed-app >/dev/null
34
__remove_installed_app()
36
[ -s $epm_vardir/installed-app ] || return 0
39
sudorun sed -i "/^$i$/d" $epm_vardir/installed-app
47
__run_script "$1" --installed "$2"
53
local script="$psdir/$1.sh"
54
[ -x "$script" ] || return
55
[ -f "$script.rpmnew" ] && warning "There is .rpmnew file(s) in $psdir dir. The play script can be outdated."
58
[ "$PROGDIR" = "/usr/bin" ] && SCPATH="$PATH" || SCPATH="$PROGDIR:$PATH"
59
( unset EPMCURDIR ; export PATH=$SCPATH ; $script "$@" )
65
__run_script "$1" --package-name "$2" "$3" 2>/dev/null
75
[ -n "$IGNOREi586" ] && startwith "$name" "i586-" && continue
76
startwith "$name" "common" && continue
85
for name in $(__list_all_app) ; do
86
__get_app_package $name
91
__list_app_packages_table()
94
for name in $(__list_all_app) ; do
95
local pkg="$(__get_app_package $name)"
96
[ -n "$pkg" ] || continue
101
__filter_by_installed_packages()
107
pkglist="$(mktemp)" || fatal
108
remove_on_exit $pkglist
110
# get intersect between full package list and available packages table
111
epm --short packages | LC_ALL=C sort -u >$pkglist
112
LC_ALL=C join -11 -21 $tapt $pkglist | uniq
115
# rpm on Fedora/CentOS no more print missed packages to stderr
116
# get supported packages list and print lines with it
117
#for i in $(epm query --short $(cat $tapt | cut -f1 -d" ") 2>/dev/null) ; do
122
__get_installed_table()
126
tapt="$(mktemp)" || fatal
128
__list_app_packages_table | LC_ALL=C sort -u >$tapt
129
__filter_by_installed_packages $tapt
133
__list_installed_app()
135
# get all installed packages and convert it to a apps list
136
__get_installed_table | cut -f2 -d" "
139
__list_installed_packages()
141
# get all installed packages
142
__get_installed_table | cut -f1 -d" "
146
# args: script, host arch
147
__get_app_description()
149
__run_script "$1" --description "$2" 2>/dev/null
154
local script="$psdir/$1.sh"
163
local script="$psdir/$1.sh"
167
addopt="$dryrun $non_interactive"
170
[ -n "$debug" ] && bashopt='-x'
171
#info "Running $($script --description 2>/dev/null) ..."
172
[ "$PROGDIR" = "/usr/bin" ] && SCPATH="$PATH" || SCPATH="$PROGDIR:$PATH"
173
( export EPM_OPTIONS="$EPM_OPTIONS $addopt" export PATH=$SCPATH ; docmd $CMDSHELL $bashopt $script "$@" )
176
__epm_play_list_installed()
179
if [ -n "$short" ] ; then
180
for i in $(__list_installed_app) ; do
182
local desc="$(__get_app_description $i)"
183
[ -n "$desc" ] || continue
188
[ -n "$quiet" ] || echo "Installed applications:"
189
for i in $(__list_installed_app) ; do
191
local desc="$(__get_app_description $i)"
192
[ -n "$desc" ] || continue
193
[ -n "$quiet" ] || echo -n " "
194
printf "%-20s - %s\n" "$i" "$desc"
205
local arch="$SYSTEMARCH"
206
[ "$arch" = "x86_64" ] && IGNOREi586='' || IGNOREi586=1
208
if [ -n "$short" ] ; then
209
for i in $(__list_all_app) ; do
210
local desc="$(__get_app_description $i $arch)"
211
[ -n "$desc" ] || continue
213
if [ -n "$extra" ] ; then
214
for j in $(__run_script "$i" "--product-alternatives") ; do
222
for i in $(__list_all_app) ; do
223
local desc="$(__get_app_description $i $arch)"
224
[ -n "$desc" ] || continue
225
[ -n "$quiet" ] || echo -n " "
226
printf "%-20s - %s\n" "$i" "$desc"
227
if [ -n "$extra" ] ; then
228
for j in $(__run_script "$i" "--product-alternatives") ; do
229
printf " %-20s - %s\n" "$i=$j" "$desc"
239
Usage: epm play [options] [<app>]
241
<app> - install <app>
242
--remove <app> - uninstall <app>
243
--update [<app>|all] - update <app> (or all installed apps) if there is new version
244
--list - list all installed apps
245
--list-all - list all available apps
246
--list-scripts - list all available scripts
247
--short (with --list) - list names only
248
--installed <app> - check if the app is installed
249
--product-alternatives- list alternatives (use like epm play app=beta)
252
epm play --remove opera
253
epm play yandex-browser = beta
254
epm play telegram = beta
255
epm play telegram = 4.7.1
256
epm play --update all
264
for prescription in $* ; do
265
if __check_play_script "$prescription" ; then
266
__epm_play_run $prescription --remove
267
__remove_installed_app "$prescription"
270
__check_play_script "$prescription" || fatal "We have no idea how to remove $prescription (checked in $psdir and $prsdir)"
271
__epm_play_run "$prescription" --remove || fatal "There was some error during run the script."
286
if ! __is_app_installed "$i" ; then
287
warning "$i is not installed"
291
if ! __check_play_script $prescription ; then
292
warning "Can't find executable play script for $prescription. Try epm play --remove $prescription if you don't need it anymore."
296
__epm_play_run $prescription $CMDUPDATE || RES=$?
303
__epm_play_install_one()
305
local prescription="$1"
308
if __check_play_script "$prescription" ; then
309
#__is_app_installed "$prescription" && info "$$prescription is already installed (use --remove to remove)" && exit 1
310
__epm_play_run "$prescription" --run "$@" && __save_installed_app "$prescription" || fatal "There was some error during install the application."
314
__check_play_script "$prescription" || fatal "We have no idea how to play $prescription (checked in $opsdir and $prsdir)"
315
__epm_play_run "$prescription" --run "$@" || fatal "There was some error during run $prescription script."
325
load_helper epm-check_updated_repo
327
update_repo_if_needed
334
options="$options $i"
339
while [ -n "$1" ] ; do
350
if [ "$n" = "=" ] ; then
356
__epm_play_install_one "$p" "$v" $options || RES=1
362
__epm_play_download_epm_file()
366
# use short version (3.4.5)
367
local epmver="$(epm --short --version)"
369
for URL in "https://eepm.ru/releases/$epmver/app-versions" "https://eepm.ru/app-versions" ; do
370
info "Updating local IPFS DB in $eget_ipfs_db file from $URL/eget-ipfs-db.txt"
371
docmd eget -q -O "$target" "$URL/$file" && return
376
__epm_play_initialize_ipfs()
378
if [ ! -d "$(dirname "$eget_ipfs_db")" ] ; then
379
warning "ipfs db dir $eget_ipfs_db does not exist, skipping IPFS mode"
383
if [ ! -r "$eget_ipfs_db" ] ; then
384
sudorun touch "$eget_ipfs_db" >&2
385
sudorun chmod -v a+rw "$eget_ipfs_db" >&2
388
# download and merge with local db
392
__epm_play_download_epm_file "$t" "eget-ipfs-db.txt" || warning "Can't update IPFS DB"
393
if [ -s "$t" ] && [ -z "$EPM_IPFS_DB_UPDATE_SKIPPING" ] ; then
395
cat $eget_ipfs_db >>$t
396
sort -u < $t | grep -v "^$" > $eget_ipfs_db
399
# the only one thing is needed to enable IPFS in eget
400
export EGET_IPFS_DB="$eget_ipfs_db"
405
[ "$EPMMODE" = "package" -o "$EPMMODE" = "git" ] || fatal "epm play is not supported in single file mode"
406
local psdir="$(realpath $CONFIGDIR/play.d)"
407
local prsdir="$(realpath $CONFIGDIR/prescription.d)"
410
[ -n "$short" ] || [ -n "$quiet" ] || echo "Available applications (for current arch $DISTRARCH):"
411
__epm_play_list $psdir
416
while [ -n "$1" ] ; do
425
__epm_play_initialize_ipfs
430
if [ -z "$1" ] ; then
431
fatal "run --remove with 'all' or a project name"
435
if [ "$1" = "all" ] ; then
437
info "Retrieving list of installed apps ..."
438
list="$(__list_installed_app)"
443
__epm_play_remove $list
449
local CMDUPDATE="--update"
450
# check --force on common.sh side
451
#[ -n "$force" ] && CMDUPDATE="--run"
453
if [ -z "$1" ] ; then
454
fatal "run --update with 'all' or a project name"
458
if [ "$1" = "all" ] ; then
460
info "Retrieving list of installed apps ..."
461
list="$(__list_installed_app)"
466
__epm_play_update $CMDUPDATE $list
472
__is_app_installed "$1" "$2"
473
#[ -n "$quiet" ] && exit
478
--installed-version|--package-name|--product-alternatives|--info)
479
__run_script "$2" "$1" "$3"
482
--list-installed-packages)
483
__list_installed_packages
486
--list|--list-installed)
487
__epm_play_list_installed
492
[ -n "$short" ] || [ -n "$quiet" ] || echo "Available applications (for current arch $DISTRARCH):"
493
__epm_play_list $psdir extra
498
[ -n "$short" ] || [ -n "$quiet" ] || echo "Available applications (for current arch $DISTRARCH):"
499
__epm_play_list $psdir
500
[ -n "$quiet" ] || [ -n "$*" ] && exit
502
#echo "Run epm play --help for help"
508
[ -n "$short" ] || [ -n "$quiet" ] || echo "Run with a name of a play script to run:"
509
__epm_play_list $prsdir
513
fatal "Unknown option $1"
522
__epm_play_install $(echo "$*" | sed -e 's|=| = |g')