NBash

Форк
0
709 строк · 23.4 Кб
1
#!/usr/bin/env bash
2
#
3
# Copyright (C) 2012-2023  Etersoft
4
# Copyright (C) 2012-2023  Vitaly Lipatov <lav@etersoft.ru>
5
#
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.
10
#
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.
15
#
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/>.
18
#
19

20
PROGDIR=$(dirname "$0")
21
PROGNAME=$(basename "$0")
22
[ -n "$EPMCURDIR" ] || export EPMCURDIR="$(pwd)"
23
CMDSHELL="/usr/bin/env bash"
24
# TODO: pwd for ./epm and which for epm
25
[ "$PROGDIR" = "." ] && PROGDIR="$EPMCURDIR"
26
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
27
    PROGDIR=""
28
    PROGNAME=""
29
fi
30

31
# will replaced with /usr/share/eepm during install
32
SHAREDIR=$PROGDIR
33
# will replaced with /etc/eepm during install
34
CONFIGDIR=$PROGDIR/../etc
35

36
EPMVERSION="@VERSION@"
37

38
# package, single (file), pipe, git
39
EPMMODE="package"
40
[ "$SHAREDIR" = "$PROGDIR" ] && EPMMODE="single"
41
[ "$EPMVERSION" = "@""VERSION""@" ] && EPMMODE="git"
42
[ "$PROGNAME" = "" ] && EPMMODE="pipe"
43

44
if [ "$EPMMODE" = "git" ] ; then
45
    EPMVERSION=$(head $PROGDIR/../eepm.spec | grep "^Version: " | sed -e 's|Version: ||' )
46
fi
47

48
load_helper()
49
{
50
    local shieldname="loaded$(echo "$1" | sed -e 's|-||g')"
51
    # already loaded
52
    eval "[ -n \"\$$shieldname\" ]" && debug "Already loaded $1" && return
53

54
    local CMD="$SHAREDIR/$1"
55
    # do not use fatal() here, it can be initial state
56
    [ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; }
57
    eval "$shieldname=1"
58
    # shellcheck disable=SC1090
59
    . $CMD
60
}
61

62

63
load_helper epm-sh-functions
64

65
# fast call for tool
66
if [ "$1" = "tool" ] ; then
67
        shift
68
        load_helper epm-tool
69
        epm_tool "$@"
70
        exit
71
fi
72

73
if [ "$1" = "--inscript" ] && [ "$2" = "tool" ] ; then
74
        shift 2
75
        load_helper epm-tool
76
        epm_tool "$@"
77
        exit
78
fi
79

80

81
set_pm_type
82

83
check_tty
84

85
#############################
86

87
phelp()
88
{
89
    echo "$Descr
90
$Usage
91

92
Options:
93
$(get_help HELPOPT)
94

95
Short commands:
96
$(get_help HELPSHORT)
97

98
$(get_help HELPCMD)
99

100
Examples:
101
    $ epmi etckeeper      install etckeeper package
102
    $ epmqp lib           print out all installed packages with 'lib' in a name
103
    $ epmqf ip            print out a package the command 'ip' from is
104
"
105
}
106

107
print_version()
108
{
109
        echo "EPM package manager version $EPMVERSION  Telegram: https://t.me/useepm  https://wiki.etersoft.ru/Epm"
110
        echo "Running on $DISTRNAME/$DISTRVERSION ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
111
        echo "Copyright (c) Etersoft 2012-2024"
112
        echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
113
}
114

115

116
Usage="Usage: epm [options] <command> [package name(s), package files]..."
117
Descr="epm - EPM package manager"
118

119
debug=
120
verbose=$EPM_VERBOSE
121
quiet=
122
nodeps=
123
noremove=
124
dryrun=
125
force=
126
repack=
127
norepack=
128
install=
129
inscript=
130
scripts=
131
noscripts=
132
short=
133
direct=
134
sort=
135
non_interactive=$EPM_AUTO
136
download=
137
download_only=
138
print_url=
139
interactive=
140
force_yes=
141
skip_installed=
142
skip_missed=
143
show_command_only=
144
epm_cmd=
145
warmup=
146
pkg_files=
147
pkg_dirs=
148
pkg_names=
149
pkg_urls=
150
pkg_options=
151
quoted_args=
152
direct_args=
153

154
eget_backend=$EGET_BACKEND
155
epm_vardir=/var/lib/eepm
156
epm_cachedir=/var/cache/eepm
157
eget_ipfs_db=$epm_vardir/eget-ipfs-db.txt
158

159
# load system wide config
160
[ -f $CONFIGDIR/eepm.conf ] && . $CONFIGDIR/eepm.conf
161

162

163
case $PROGNAME in
164
    epmi)                      # HELPSHORT: alias for epm install
165
        epm_cmd=install
166
        ;;
167
    epmI)                      # HELPSHORT: alias for epm Install
168
        epm_cmd=Install
169
        ;;
170
    epme)                      # HELPSHORT: alias for epm remove
171
        epm_cmd=remove
172
        ;;
173
    epmcl)                     # HELPSHORT: alias for epm changelog
174
        epm_cmd=changelog
175
        ;;
176
    epmp)                      # HELPSHORT: alias for epm play
177
        epm_cmd=play
178
        direct_args=1
179
        ;;
180
    epms)                      # HELPSHORT: alias for epm search
181
        epm_cmd=search
182
        direct_args=1
183
        ;;
184
    epmsf)                     # HELPSHORT: alias for epm search-file (epm sf)
185
        epm_cmd=search_file
186
        ;;
187
    epmwd)                     # HELPSHORT: alias for epm wd
188
        epm_cmd=whatdepends
189
        ;;
190
    epmq)                      # HELPSHORT: alias for epm query
191
        epm_cmd=query
192
        ;;
193
    epmqi)                     # HELPSHORT: alias for epm info
194
        epm_cmd=info
195
        ;;
196
    epmqf)                     # HELPSHORT: alias for epm belongs
197
        epm_cmd=query_file
198
        ;;
199
    epmqa)                     # HELPSHORT: alias for epm packages
200
        epm_cmd=packages
201
        ;;
202
    epmqp)                     # HELPSHORT: alias for epm qp (epm query package)
203
        epm_cmd=query_package
204
        ;;
205
    epmql)                     # HELPSHORT: alias for epm filelist
206
        epm_cmd=filelist
207
        ;;
208
    epmrl)                     # HELPSHORT: alias for epm repo list
209
        epm_cmd=repolist
210
        direct_args=1
211
        ;;
212
    epmu)                      # HELPSHORT: alias for epm update
213
        epm_cmd=update
214
        direct_args=1
215
        ;;
216
    epm|upm|eepm)              # HELPSHORT: other aliases for epm command
217
        ;;
218
    epm.sh)
219
        ;;
220
    *)
221
        # epm by default
222
        # fatal "Unknown command: $progname"
223
        ;;
224
esac
225

226
# was called with alias name
227
[ -n "$epm_cmd" ] && PROGNAME="epm"
228

229
check_command()
230
{
231
    # do not override command
232
    [ -z "$epm_cmd" ] || return
233

234
# HELPCMD: PART: Base commands:
235
    case $1 in
236
    -i|install|add|i|it)         # HELPCMD: install package(s) from remote repositories or from local file
237
        epm_cmd=install
238
        ;;
239
    -e|-P|rm|del|remove|delete|uninstall|erase|purge|e)  # HELPCMD: remove (delete) package(s) from the database and the system
240
        epm_cmd=remove
241
        ;;
242
    -s|search|s|find|sr)                # HELPCMD: search in remote package repositories
243
        epm_cmd=search
244
        direct_args=1
245
        ;;
246
    -qp|qp|grep|query_package)     # HELPCMD: search in the list of installed packages
247
        epm_cmd=query_package
248
        ;;
249
    -qf|qf|-S|wp|which|belongs)     # HELPCMD: query package(s) owning file
250
        epm_cmd=query_file
251
        ;;
252

253
# HELPCMD: PART: Useful commands:
254
    reinstall)                # HELPCMD: reinstall package(s) from remote repositories or from local file
255
        epm_cmd=reinstall
256
        ;;
257
    Install)                  # HELPCMD: perform update package repo info and install package(s) via install command
258
        epm_cmd=Install
259
        ;;
260
    -q|q|query)               # HELPCMD: check presence of package(s) and print this name (also --short is supported)
261
        epm_cmd=query
262
        ;;
263
    installed)                # HELPCMD: check presence of package(s) (like -q with --quiet)
264
        epm_cmd=installed
265
        ;;
266
    status)                   # HELPCMD: get status of package(s) (see epm status --help)
267
        epm_cmd=status
268
        direct_args=1
269
        ;;
270
    -sf|sf|filesearch|search-file)        # HELPCMD: search in which package a file is included
271
        epm_cmd=search_file
272
        ;;
273
    -ql|ql|filelist|get-files)          # HELPCMD: print package file list
274
        epm_cmd=filelist
275
        ;;
276
    -cl|cl|changelog)         # HELPCMD: show changelog for package
277
        epm_cmd=changelog
278
        ;;
279
    -qi|qi|info|show)         # HELPCMD: print package detail info
280
        epm_cmd=info
281
        ;;
282
    requires|deplist|depends|req|depends-on)     # HELPCMD: print package requires
283
        epm_cmd=requires
284
        ;;
285
    provides|prov)            # HELPCMD: print package provides
286
        epm_cmd=provides
287
        ;;
288
    whatdepends|rdepends|whatrequires|wd|required-by)   # HELPCMD: print packages dependences on that
289
        epm_cmd=whatdepends
290
        ;;
291
    whatprovides)             # HELPCMD: print packages provides that target
292
        epm_cmd=whatprovides
293
        ;;
294
    conflicts)                # HELPCMD: print package conflicts
295
        epm_cmd=conflicts
296
        ;;
297
    -qa|qa|ls|packages|list-installed|li)  # HELPCMD: print list of all installed packages
298
        epm_cmd=packages
299
        direct_args=1
300
        ;;
301
    list)                     # HELPCMD: print list of packages (see epm list --help)
302
        epm_cmd=list
303
        direct_args=1
304
        ;;
305
    # it is too hard operation, so just list name is very short for it
306
    list-available)           # HELPCMD: print list of all available packages
307
        epm_cmd=list_available
308
        direct_args=1
309
        ;;
310
    programs)                 # HELPCMD: print list of installed GUI program(s) (they have .desktop files)
311
        epm_cmd=programs
312
        direct_args=1
313
        ;;
314
    assure)                   # HELPCMD: <command> [package] [version]: install package if command does not exist
315
        epm_cmd=assure
316
        ;;
317
    policy|resolve)           # HELPCMD: print detailed information about the priority selection of package
318
        epm_cmd=policy
319
        ;;
320

321
# HELPCMD: PART: Repository control:
322
    update|update-repo|ur)                   # HELPCMD: update remote package repository databases
323
        epm_cmd=update
324
        direct_args=1
325
        ;;
326
    addrepo|ar|--add-repo)    # HELPCMD: add package repo (etersoft, autoimports, archive 2017/01/31); run with param to get list
327
        epm_cmd=addrepo
328
        direct_args=1
329
        ;;
330
    repolist|sl|rl|listrepo|repo-list|list-repo|lr)  # HELPCMD: print repo list
331
        epm_cmd=repolist
332
        direct_args=1
333
        ;;
334
    repofix)                  # HELPCMD: <mirror>: fix paths in sources lists (ALT Linux only). use repofix etersoft/yandex/basealt for rewrite URL to the specified server
335
        epm_cmd=repofix
336
        direct_args=1
337
        ;;
338
    removerepo|remove-repo|rr)            # HELPCMD: remove package repo (shortcut for epm repo remove)
339
        epm_cmd=removerepo
340
        direct_args=1
341
        ;;
342
    repo)                     # HELPCMD: manipulate with repository list (see epm repo --help)
343
        epm_cmd=repo
344
        direct_args=1
345
        ;;
346
    check|fix|verify)         # HELPCMD: check local package base integrity and fix it
347
        epm_cmd=check
348
        direct_args=1
349
        ;;
350
    dedup)                    # HELPCMD: remove unallowed duplicated pkgs (after upgrade crash)
351
        epm_cmd=dedup
352
        direct_args=1
353
        ;;
354
    full-upgrade)              # HELPCMD: update all system packages and kernel
355
        epm_cmd=full_upgrade
356
        direct_args=1
357
        ;;
358
    release-upgrade|upgrade-release|upgrade-system|release-switch)  # HELPCMD: upgrade/switch whole system to the release in arg (default: next (latest) release)
359
        epm_cmd=release_upgrade
360
        direct_args=1
361
        ;;
362
    release-downgrade|downgrade-release|downgrade-system)           # HELPCMD: downgrade whole system to the release in arg (default: previuos release)
363
        epm_cmd=release_downgrade
364
        direct_args=1
365
        ;;
366
    kernel-update|kernel-upgrade|update-kernel|upgrade-kernel)      # HELPCMD: update system kernel to the last repo version
367
        epm_cmd=kernel_update
368
        direct_args=1
369
        ;;
370
    remove-old-kernels|remove-old-kernel)      # HELPCMD: remove old system kernels (exclude current or last two kernels)
371
        epm_cmd=remove_old_kernels
372
        direct_args=1
373
        ;;
374
    stats)                                      # HELPCMD: show statistics about repositories and installations
375
        epm_cmd=stats
376
        direct_args=1
377
        ;;
378

379
# HELPCMD: PART: Other commands:
380
    clean|delete-cache|dc)                    # HELPCMD: clean local package cache
381
        epm_cmd=clean
382
        direct_args=1
383
        ;;
384
    restore)                  # HELPCMD: install (restore) packages need for the project (f.i. by requirements.txt)
385
        epm_cmd=restore
386
        direct_args=1
387
        ;;
388
    autoremove|package-cleanup)   # HELPCMD: auto remove unneeded package(s) Supports args for ALT: [--direct [libs|python|perl|libs-devel]]
389
        epm_cmd=autoremove
390
        direct_args=1
391
        ;;
392
    mark)                     # HELPCMD: mark package as manually or automatically installed or hold/unhold it (see epm mark --help)
393
        epm_cmd=mark
394
        direct_args=1
395
        ;;
396
    history)                  # HELPCMD: show a log of actions taken by the software management (see epm history --help)
397
        epm_cmd=history
398
        direct_args=1
399
        ;;
400
    autoorphans|--orphans|remove-orphans)    # HELPCMD: remove all packages not from the repository
401
        epm_cmd=autoorphans
402
        direct_args=1
403
        ;;
404
    upgrade|up|dist-upgrade)     # HELPCMD: performs upgrades of package software distributions
405
        epm_cmd=upgrade
406
        ;;
407
    Upgrade)                  # HELPCMD: force update package base, then run upgrade
408
        epm_cmd=Upgrade
409
        direct_args=1
410
        ;;
411
    downgrade)                # HELPCMD: downgrade [all] packages to the repo state
412
        epm_cmd=downgrade
413
        ;;
414
    download|fetch|fc)        # HELPCMD: download package(s) file to the current dir
415
        epm_cmd=download
416
        ;;
417
# TODO: replace with install --simulate
418
    simulate)                 # HELPCMD: simulate install with check requires
419
        epm_cmd=simulate
420
        ;;
421
    audit)                    # HELPCMD: audits installed packages against known vulnerabilities
422
        epm_cmd=audit
423
        direct_args=1
424
        ;;
425
    #checksystem)              # HELPCMD: check system for known errors (package management related)
426
    #    epm_cmd=checksystem
427
    #    direct_args=1
428
    #    ;;
429
    site|url)                 # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
430
        epm_cmd=site
431
        ;;
432
    ei|ik|epminstall|epm-install|selfinstall) # HELPCMD: install package(s) from Korinf (eepm by default)
433
        epm_cmd=epm_install
434
        ;;
435
    print)                    # HELPCMD: print various info, run epm print help for details
436
        epm_cmd=print
437
        direct_args=1
438
        ;;
439
    tool)                     # HELPCMD: run embedded tool (see epm tool --help)
440
        epm_cmd=tool
441
        direct_args=1
442
        ;;
443
    repack)                   # HELPCMD: repack rpm to local compatibility
444
        epm_cmd=repack
445
        ;;
446
    pack)                     # HELPCMD: pack tarball or dir to a rpm package
447
        epm_cmd=pack
448
        direct_args=1
449
        ;;
450
    moo)
451
        epm_cmd=moo
452
        direct_args=1
453
        ;;
454
    prescription|recipe)      # HELPCMD: run prescription (a script to achieving the goal), run without args to get list
455
        epm_cmd=prescription
456
        direct_args=1
457
        ;;
458
    play)                     # HELPCMD: install the application from the official site (run without args to get list)
459
        epm_cmd=play
460
        direct_args=1
461
        ;;
462
    -V|checkpkg|integrity)    # HELPCMD: check package file integrity (checksum)
463
        epm_cmd=checkpkg
464
        ;;
465
    -h|--help|help)           # HELPOPT: print this help
466
        help=1
467
        phelp
468
        exit 0
469
        ;;
470
    *)
471
        return 1
472
        ;;
473
    esac
474
    return 0
475
}
476

477
check_option()
478
{
479
    # optimization
480
    case $1 in
481
    -*)
482
        # pass
483
        ;;
484
    *)
485
        return 1
486
        ;;
487
    esac
488

489
    case $1 in
490
    -v|--version)         # HELPOPT: print version
491
        [ -n "$epm_cmd" ] && return 1
492
        [ -n "$short" ] && echo "$EPMVERSION" | sed -e 's|-.*||' && exit 0
493
        print_version
494
        exit 0
495
        ;;
496
    --verbose)            # HELPOPT: verbose mode
497
        verbose="--verbose"
498
        ;;
499
    --debug)              # HELPOPT: more debug output mode
500
        debug="--debug"
501
        ;;
502
    --skip-installed)     # HELPOPT: skip already installed packages during install
503
        skip_installed=1
504
        ;;
505
    --skip-missed)        # HELPOPT: skip not installed packages during remove
506
        skip_missed=1
507
        ;;
508
    --show-command-only)  # HELPOPT: show command only, do not any action (supports install and remove ONLY)
509
        show_command_only=1
510
        ;;
511
    --quiet|--silent)     # HELPOPT: quiet mode (do not print commands before exec)
512
        quiet="--quiet"
513
        ;;
514
    --nodeps)             # HELPOPT: skip dependency check (during install/simulate and so on)
515
        nodeps="--nodeps"
516
        ;;
517
    --force)              # HELPOPT: force install/remove package (f.i., override)
518
        force="--force"
519
        ;;
520
    --noremove|--no-remove)  # HELPOPT: exit if any packages are to be removed during upgrade
521
        noremove="--no-remove"
522
        ;;
523
    --no-stdin|--inscript)  # HELPOPT: don't read from stdin for epm args
524
        inscript=1
525
        ;;
526
    --dry-run|--simulate|--just-print|--no-act) # HELPOPT: print only (autoremove/autoorphans/remove only)
527
        dryrun="--dry-run"
528
        ;;
529
    --short)              # HELPOPT: short output (just 'package' instead 'package-version-release')
530
        short="--short"
531
        ;;
532
    --direct)              # HELPOPT: direct install package file from ftp (not via hilevel repository manager)
533
        direct="--direct"
534
        ;;
535
    --repack)              # HELPOPT: repack rpm package(s) before install
536
        repack="--repack"
537
        ;;
538
    --norepack)              # HELPOPT: don't repack rpm package(s) if it is by default before install
539
        norepack="--norepack"
540
        ;;
541
    --install)             # HELPOPT: install packed rpm package(s)
542
        install="--install"
543
        ;;
544
    --scripts)             # HELPOPT: include scripts in repacked rpm package(s) (see --repack or repacking when foreign package is installed)
545
        scripts="--scripts"
546
        ;;
547
    --noscripts)           # HELPOPT: disable scripts in install packages
548
        noscripts="--noscripts"
549
        ;;
550
    --save-only)            # HELPOPT: save the package/tarball after all transformations (instead of install it)
551
        save_only="--save-only"
552
        ;;
553
    --put-to-repo=*)          # HELPOPT: put the package after all transformations to the repo (--put-to-repo=/path/to/repo)
554
        put_to_repo="$(echo "$1" | sed -e 's|--put-to-repo=||')"
555
        ;;
556
    --download-only)       # HELPOPT: download only the package/tarball (before any transformation)
557
        download_only="--download-only"
558
        ;;
559
    --url)                 # HELPOPT: print only URL instead of download package
560
        print_url="--url"
561
        ;;
562
    --sort)               # HELPOPT: sort output, f.i. --sort=size (supported only for packages command)
563
        # TODO: how to read arg?
564
        sort="$1"
565
        ;;
566
    -y|--auto|--assumeyes|--non-interactive|--disable-interactivity)  # HELPOPT: non interactive mode
567
        non_interactive="--auto"
568
        interactive=""
569
        ;;
570
    --interactive)  # HELPOPT: interactive mode (ask before any operation)
571
        interactive="--interactive"
572
        non_interactive=""
573
        ;;
574
    --force-yes)           # HELPOPT: force yes in a danger cases (f.i., during release upgrade)
575
        force_yes="--force-yes"
576
        ;;
577
    --no-check-certificate)
578
        fatal "--no-check-certificate is a wget option. It is recommended never use it at all. Check the date or upgrade your system."
579
        ;;
580
    -*)
581
        [ -n "$direct_args" ] && return 1
582
        [ -n "$pkg_options" ] && pkg_options="$pkg_options $1" || pkg_options="$1"
583
        ;;
584
    *)
585
        return 1
586
        ;;
587
    esac
588
    return 0
589
}
590

591
check_filenames()
592
{
593
    local opt
594
    for opt in "$@" ; do
595
        # files can be with full path or have extension via .
596
        if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then
597
            has_space "$opt" && warning "There are space(s) in filename '$opt', it is not supported. Skipped" && continue
598
            [ -n "$pkg_files" ] && pkg_files="$pkg_files $opt" || pkg_files="$opt"
599
        elif [ -d "$opt" ] ; then
600
            has_space "$opt" && warning "There are space(s) in directory path '$opt', it is not supported. Skipped" && continue
601
            [ -n "$pkg_dirs" ] && pkg_dirs="$pkg_dirs $opt" || pkg_dirs="$opt"
602
        elif is_url "$opt" ; then
603
            has_space "$opt" && warning "There are space(s) in URL '$opt', it is not supported. Skipped" && continue
604
            [ -n "$pkg_urls" ] && pkg_urls="$pkg_urls $opt" || pkg_urls="$opt"
605
        else
606
            has_space "$opt" && warning "There are space(s) in package name '$opt', it is not supported. Skipped." && continue
607
            echo "$opt" | grep -q "[*]" && warning "There are forbidden symbols in package name '$opt'. Skipped." && continue
608
            [ -n "$pkg_names" ] && pkg_names="$pkg_names $opt" || pkg_names="$opt"
609
        fi
610
        [ -n "$quoted_args" ] && quoted_args="$quoted_args \"$opt\"" || quoted_args="\"$opt\""
611
    done
612
}
613

614
# handle external EPM_OPTIONS
615
for opt in $EPM_OPTIONS ; do
616
        check_option "$opt"
617
done
618

619
FLAGENDOPTS=
620
# NOTE: can't use while read here: set vars inside
621
for opt in "$@" ; do
622

623
    [ "$opt" = "--" ] && FLAGENDOPTS=1 && continue
624

625
    if [ -z "$FLAGENDOPTS" ] ; then
626
        check_command "$opt" && continue
627
        check_option "$opt" && continue
628
    fi
629

630
    if [ -n "$direct_args" ] ; then
631
        [ -n "$quoted_args" ] && quoted_args="$quoted_args \"$opt\"" || quoted_args="\"$opt\""
632
    else
633
        # Note: will parse all params separately (no package names with spaces!)
634
        check_filenames "$opt"
635
    fi
636
done
637

638
if [ -n "$quiet" ] ; then
639
    verbose=''
640
    EPM_VERBOSE=''
641
fi
642

643
# fill
644
export EPM_OPTIONS="$nodeps $force $verbose $debug $quiet $interactive $non_interactive $save_only $download_only"
645

646
# if input is not console and run script from file, get pkgs from stdin too
647
if [ ! -n "$inscript" ] && [ -p /dev/stdin ] && [ "$EPMMODE" != "pipe" ] ; then
648
    for opt in $(withtimeout 10 cat) ; do
649
        # FIXME: do not work
650
        # workaround against # yes | epme
651
        [ "$opt" = "y" ] && break;
652
        [ "$opt" = "yes" ] && break;
653
        check_filenames $opt
654
    done
655
fi
656

657
# in common case dirs equals to names only suddenly
658
pkg_names=$(strip_spaces "$pkg_names $pkg_dirs")
659

660
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
661

662
# Just debug
663
#echover "command: $epm_cmd"
664
#echover "pkg_files=$pkg_files"
665
#echover "pkg_names=$pkg_names"
666

667
print_short_help()
668
{
669
cat <<EOF
670

671
Popular commands:
672
 epm search <name>          - search package by name
673
 epm install <package>      - install package
674
 epm full-upgrade           - do full upgrade (packages, kernel) of the system
675
 epm Upgrade                - upgrade all installed packages (Upgrade = update + upgrade)
676
 epm play [application]     - install the application (run without params to get list of available apps)
677
 epm qf (<command>|<path>)  - print what package contains this command (file)
678
 epm sf <name>              - search for the name in all files of all packages
679
 epm cl <package name>      - print changelog for the package
680
EOF
681
}
682

683
# Just printout help if run without args
684
if [ -z "$epm_cmd" ] ; then
685
    print_version >&2
686
    echo >&2
687
    fatstr="Unrecognized command in '$*' arg(s)"
688
    if [ -z "$*" ] ; then
689
        fatstr="That program needs be running with some command"
690
        print_short_help >&2
691
    fi
692
    echo "Run $(echocmd "$PROGNAME --help") to get help." >&2
693
    echo "Run $(echocmd "epm print info") to get some system and distro info." >&2
694
    fatal "$fatstr."
695
fi
696

697
# Use eatmydata for write specific operations
698
case $epm_cmd in
699
    update|upgrade|Upgrade|install|reinstall|Install|remove|autoremove|kernel_update|release_upgrade|release_downgrade|check)
700
        set_eatmydata
701
        ;;
702
esac
703

704
[ -n "$verbose$EPM_VERBOSE" ] && showcmd "$0 $*"
705

706
# Run helper for command with natural args
707
load_helper epm-$epm_cmd
708
eval epm_$epm_cmd $quoted_args
709
# return last error code (from subroutine)
710

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.