epm 16.7 KB
Newer Older
1
#!/bin/sh
Vitaly Lipatov's avatar
Vitaly Lipatov committed
2
#
Vitaly Lipatov's avatar
Vitaly Lipatov committed
3 4
# Copyright (C) 2012-2020  Etersoft
# Copyright (C) 2012-2020  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 21
PROGDIR=$(dirname "$0")
PROGNAME=$(basename "$0")
22
[ "$PROGDIR" = "." ] && PROGDIR=$(pwd)
23 24
if [ "$0" = "/dev/stdin" ] || [ "$0" = "sh" ] ; then
    PROGDIR=""
25
    PROGNAME=""
26
fi
27

28
# will replaced to /usr/share/eepm during install
29
SHAREDIR=$PROGDIR
Vitaly Lipatov's avatar
Vitaly Lipatov committed
30
CONFIGDIR=$PROGDIR/..
31 32 33

load_helper()
{
34
    local CMD="$SHAREDIR/$1"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
35 36
    # do not use fatal() here, it can be initial state
    [ -r "$CMD" ] || { echo "FATAL: Have no $CMD helper file" ; exit 1; }
Vitaly Lipatov's avatar
Vitaly Lipatov committed
37
    # shellcheck disable=SC1090
38
    . $CMD
39 40
}

41

42 43
load_helper epm-sh-functions

Vitaly Lipatov's avatar
Vitaly Lipatov committed
44 45
#PATH=$PATH:/sbin:/usr/sbin

46 47
set_pm_type

48
set_sudo
49

50
check_tty
Vitaly Lipatov's avatar
Vitaly Lipatov committed
51 52 53 54 55 56 57 58

#############################

phelp()
{
	echo "$Descr
$Usage

Vitaly Lipatov's avatar
Vitaly Lipatov committed
59
Options:
60
$(get_help HELPOPT)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
61 62 63 64 65 66 67 68 69 70

Short commands:
$(get_help HELPSHORT)

$(get_help HELPCMD)

Examples:
    $ epmi etckeeper      install etckeeper package
    $ epmqp lib           print out all installed packages with 'lib' in a name
    $ epmqf ip            print out a package the command 'ip' from is
Vitaly Lipatov's avatar
Vitaly Lipatov committed
71 72 73
"
}

Vitaly Lipatov's avatar
Vitaly Lipatov committed
74 75
print_version()
{
Vitaly Lipatov's avatar
Vitaly Lipatov committed
76
        echo "EPM package manager version @VERSION@  https://wiki.etersoft.ru/Epm"
77
        echo "Running on $($DISTRVENDOR -e) ('$PMTYPE' package manager uses '$PKGFORMAT' package format)"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
78
        echo "Copyright (c) Etersoft 2012-2020"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
79
        echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
Vitaly Lipatov's avatar
Vitaly Lipatov committed
80 81
}

82

Danil Mikhailov's avatar
Danil Mikhailov committed
83 84
Usage="Usage: epm [options] <command> [package name(s), package files]..."
Descr="epm - EPM package manager"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
85

86
EPMVERSION=@VERSION@
87
verbose=
88
quiet=
89
nodeps=
90
noremove=
91
dryrun=
92
force=
93
repack=
94
inscript=
95
scripts=
96
noscripts=
97
short=
98
direct=
Vitaly Lipatov's avatar
Vitaly Lipatov committed
99
sort=
100
non_interactive=
101
skip_installed=
102
skip_missed=
103
show_command_only=
Vitaly Lipatov's avatar
Vitaly Lipatov committed
104 105
epm_cmd=
pkg_files=
106
pkg_dirs=
Vitaly Lipatov's avatar
Vitaly Lipatov committed
107
pkg_names=
108
pkg_urls=
109
quoted_args=
110

111 112 113 114
# load system wide config
[ -f /etc/eepm/eepm.conf ] && . /etc/eepm/eepm.conf


115
case $PROGNAME in
Vitaly Lipatov's avatar
Vitaly Lipatov committed
116
    epmi)                      # HELPSHORT: alias for epm install
117 118
        epm_cmd=install
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
119
    epmI)                      # HELPSHORT: alias for epm Install
Vitaly Lipatov's avatar
Vitaly Lipatov committed
120 121
        epm_cmd=Install
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
122
    epme)                      # HELPSHORT: alias for epm remove
Danil Mikhailov's avatar
Danil Mikhailov committed
123 124
        epm_cmd=remove
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
125
    epmcl)                     # HELPSHORT: alias for epm changelog
126 127
        epm_cmd=changelog
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
128
    epms)                      # HELPSHORT: alias for epm search
Danil Mikhailov's avatar
Danil Mikhailov committed
129 130
        epm_cmd=search
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
131
    epmsf)                     # HELPSHORT: alias for epm search file
132 133
        epm_cmd=search_file
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
134
    epmq)                      # HELPSHORT: alias for epm query
135 136
        epm_cmd=query
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
137
    epmqi)                     # HELPSHORT: alias for epm info
138 139
        epm_cmd=info
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
140
    epmqf)                     # HELPSHORT: alias for epm belongs
Danil Mikhailov's avatar
Danil Mikhailov committed
141 142
        epm_cmd=query_file
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
143
    epmqa)                     # HELPSHORT: alias for epm packages
144 145
        epm_cmd=packages
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
146
    epmqp)                     # HELPSHORT: alias for epm qp (epm query package)
147 148
        epm_cmd=query_package
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
149
    epmql)                     # HELPSHORT: alias for epm filelist
150 151
        epm_cmd=filelist
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
152
    epmrl)                     # HELPSHORT: alias for epm repo list
153 154
        epm_cmd=repolist
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
155
    epmu)                      # HELPSHORT: alias for epm update
156 157
        epm_cmd=update
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
158
    epm|upm|eepm)              # HELPSHORT: other aliases for epm command
Danil Mikhailov's avatar
Danil Mikhailov committed
159
        ;;
160 161
    epm.sh)
        ;;
162
    *)
163 164
        # epm by default
        # fatal "Unknown command: $progname"
165 166 167
        ;;
esac

168 169 170
# was called with alias name
[ -n "$epm_cmd" ] && PROGNAME="epm"

171 172 173 174 175
check_command()
{
    # do not override command
    [ -z "$epm_cmd" ] || return

Vitaly Lipatov's avatar
Vitaly Lipatov committed
176
# HELPCMD: PART: Base commands:
177
    case $1 in
Vitaly Lipatov's avatar
Vitaly Lipatov committed
178
    -i|install|add|i)         # HELPCMD: install package(s) from remote repositories or from local file
Vitaly Lipatov's avatar
Vitaly Lipatov committed
179 180
        epm_cmd=install
        ;;
181
    -e|-P|rm|del|remove|delete|uninstall|erase|e)  # HELPCMD: remove (delete) package(s) from the database and the system
Danil Mikhailov's avatar
Danil Mikhailov committed
182 183
        epm_cmd=remove
        ;;
184
    -s|search|s)                # HELPCMD: search in remote package repositories
185
        epm_cmd=search
186
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
187
    -qp|qp|query_package)     # HELPCMD: search in the list of installed packages
188 189
        epm_cmd=query_package
        ;;
190
    -qf|qf|-S|wp|which|belongs)     # HELPCMD: query package(s) owning file
191
        epm_cmd=query_file
192
        ;;
193

Vitaly Lipatov's avatar
Vitaly Lipatov committed
194
# HELPCMD: PART: Useful commands:
Vitaly Lipatov's avatar
Vitaly Lipatov committed
195
    reinstall)                # HELPCMD: reinstall package(s) from remote repositories or from local file
196
        epm_cmd=reinstall
Danil Mikhailov's avatar
Danil Mikhailov committed
197
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
198
    Install)                  # HELPCMD: perform update package repo info and install package(s) via install command
199 200
        epm_cmd=Install
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
201
    -q|q|installed|query)     # HELPCMD: check presence of package(s) and print this name (also --short is supported)
Danil Mikhailov's avatar
Danil Mikhailov committed
202
        epm_cmd=query
Danil Mikhailov's avatar
Danil Mikhailov committed
203
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
204
    -sf|sf|filesearch)        # HELPCMD: search in which package a file is included
205 206
        epm_cmd=search_file
        ;;
207
    -ql|ql|filelist|get-files)          # HELPCMD: print package file list
208
        epm_cmd=filelist
Danil Mikhailov's avatar
Danil Mikhailov committed
209
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
210
    check|fix|verify)         # HELPCMD: check local package base integrity and fix it
211 212
        epm_cmd=check
        ;;
213 214 215
    dedup)                    # HELPCMD: remove unallowed duplicated pkgs (after upgrade crash)
        epm_cmd=dedup
        ;;
216
    -cl|cl|changelog)         # HELPCMD: show changelog for package
217 218
        epm_cmd=changelog
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
219
    -qi|qi|info|show)         # HELPCMD: print package detail info
220 221
        epm_cmd=info
        ;;
222
    requires|deplist|depends|req|depends-on)     # HELPCMD: print package requires
223 224
        epm_cmd=requires
        ;;
225
    provides|prov)            # HELPCMD: print package provides
226 227
        epm_cmd=provides
        ;;
228
    whatdepends|rdepends|whatrequires|wd|required-by)   # HELPCMD: print packages dependences on that
229 230
        epm_cmd=whatdepends
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
231
    whatprovides)             # HELPCMD: print packages provides that target
232 233
        epm_cmd=whatprovides
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
234
    conflicts)                # HELPCMD: print package conflicts
235 236
        epm_cmd=conflicts
        ;;
237
    -qa|qa|-l|list|packages)  # HELPCMD: print list of installed package(s)
238 239
        epm_cmd=packages
        ;;
240
    programs)                 # HELPCMD: print list of installed GUI program(s) (they have .desktop files)
241 242
        epm_cmd=programs
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
243
    assure)                   # HELPCMD: <command> [package] [version]: install package if command does not exist
244 245
        epm_cmd=assure
        ;;
246
    policy|resolve)           # HELPCMD: print detailed information about the priority selection of package
247 248
        epm_cmd=policy
        ;;
249

Vitaly Lipatov's avatar
Vitaly Lipatov committed
250
# HELPCMD: PART: Repository control:
Vitaly Lipatov's avatar
Vitaly Lipatov committed
251
    update)                   # HELPCMD: update remote package repository databases
252
        epm_cmd=update
253
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
254
    addrepo|ar)               # HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list
255 256
        epm_cmd=addrepo
        ;;
257
    repolist|sl|rl|listrepo|repo-list)  # HELPCMD: print repo list
Vitaly Lipatov's avatar
Vitaly Lipatov committed
258 259
        epm_cmd=repolist
        ;;
260
    repofix)                  # HELPCMD: <mirror>: fix paths in sources lists (ALT Linux only). use repofix etersoft/yandex/basealt for rewrite URL to the specified server
261 262
        epm_cmd=repofix
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
263
    removerepo|rr)            # HELPCMD: remove package repo (shortcut for epm repo remove)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
264 265
        epm_cmd=removerepo
        ;;
266 267 268
    repo)                     # HELPCMD: manipulate with repository list (run epm repo --help to help)
        epm_cmd=repo
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
269 270 271
    full-upgrade)              # HELPCMD: update all system packages and kernel
        epm_cmd=full_upgrade
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
272
    release-upgrade|upgrade-release|upgrade-system|release-switch|release-downgrade)  # HELPCMD: upgrade/switch whole system to the release in arg (default: next (latest) release)
273 274
        epm_cmd=release_upgrade
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
275
    kernel-update|kernel-upgrade|update-kernel|upgrade-kernel)      # HELPCMD: update system kernel to the last repo version
276
        epm_cmd=kernel_update
Vitaly Lipatov's avatar
Vitaly Lipatov committed
277
        ;;
278 279
    remove-old-kernels|remove-old-kernel)      # HELPCMD: remove old system kernels (exclude current or last two kernels)
        epm_cmd=remove_old_kernels
280
        ;;
281

Vitaly Lipatov's avatar
Vitaly Lipatov committed
282
# HELPCMD: PART: Other commands:
Vitaly Lipatov's avatar
Vitaly Lipatov committed
283
    clean)                    # HELPCMD: clean local package cache
284 285
        epm_cmd=clean
        ;;
286 287 288
    restore)                  # HELPCMD: install (restore) packages need for the project (f.i. by requirements.txt)
        epm_cmd=restore
        ;;
289
    autoremove|package-cleanup)   # HELPCMD: auto remove unneeded package(s) Supports args for ALT: [--direct [libs|python|perl|libs-devel]]
290 291
        epm_cmd=autoremove
        ;;
292 293 294
    mark)                     # HELPCMD: mark package as manually or automatically installed (see epm mark --help)
        epm_cmd=mark
        ;;
295 296 297
    autoorphans|--orphans)    # HELPCMD: remove all packages not from the repository
        epm_cmd=autoorphans
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
298
    upgrade|dist-upgrade)     # HELPCMD: performs upgrades of package software distributions
299 300
        epm_cmd=upgrade
        ;;
301
    Upgrade)                  # HELPCMD: force update package base, then run upgrade
302 303
        epm_cmd=Upgrade
        ;;
304 305 306
    downgrade)                # HELPCMD: downgrade [all] packages to the repo state
        epm_cmd=downgrade
        ;;
307
    download)                 # HELPCMD: download package(s) file to the current dir
308 309
        epm_cmd=download
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
310
# TODO: replace with install --simulate
311
    simulate)                 # HELPCMD: simulate install with check requires
312 313
        epm_cmd=simulate
        ;;
314 315 316
    audit)                    # HELPCMD: audits installed packages against known vulnerabilities
        epm_cmd=audit
        ;;
317 318 319
    #checksystem)              # HELPCMD: check system for known errors (package management related)
    #    epm_cmd=checksystem
    #    ;;
320 321 322
    site|url)                 # HELPCMD: open package's site in a browser (use -p for open packages.altlinux.org site)
        epm_cmd=site
        ;;
323
    ei|ik|epminstall|epm-install|selfinstall) # HELPCMD: install package(s) from Korinf (eepm by default)
324 325
        epm_cmd=epm_install
        ;;
326 327 328
    print)                    # HELPCMD: print various info, run epm print help for details
        epm_cmd=print
        ;;
329 330 331
    repack)                   # HELPCMD: repack rpm to local compatibility
        epm_cmd=repack
        ;;
332 333 334
    prescription|recipe)      # HELPCMD: run prescription (a script to achieving the goal), run without args to get list
        epm_cmd=prescription
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
335
    play)                     # HELPCMD: install the application from the official site (run without args to get list)
336
        epm_cmd=play
Vitaly Lipatov's avatar
Vitaly Lipatov committed
337
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
338
    -V|checkpkg|integrity)    # HELPCMD: check package file integrity (checksum)
339 340
        epm_cmd=checkpkg
        ;;
341 342 343 344 345
    -h|--help|help)           # HELPOPT: print this help
        help=1
        phelp
        exit 0
        ;;
346 347
    *)
        return 1
348
        ;;
349 350 351 352
    esac
    return 0
}

353 354 355
check_option()
{
    case $1 in
356
    -v|--version)         # HELPOPT: print version
Vitaly Lipatov's avatar
Vitaly Lipatov committed
357 358
        print_version
        exit 0
359 360
        ;;
    --verbose)            # HELPOPT: verbose mode
361
        verbose="--verbose"
362
        ;;
363
    --skip-installed)     # HELPOPT: skip already installed packages during install
364 365
        skip_installed=1
        ;;
366 367 368
    --skip-missed)        # HELPOPT: skip not installed packages during remove
        skip_missed=1
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
369
    --show-command-only)  # HELPOPT: show command only, do not any action (supports install and remove ONLY)
370 371
        show_command_only=1
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
372
    --quiet|--silent)     # HELPOPT: quiet mode (do not print commands before exec)
373 374
        quiet=1
        ;;
375 376 377
    --nodeps)             # HELPOPT: skip dependency check (during install/simulate and so on)
        nodeps="--nodeps"
        ;;
378 379 380
    --force)              # HELPOPT: force install/remove package (f.i., override)
        force="--force"
        ;;
381 382 383
    --noremove|--no-remove)  # HELPOPT: exit if any packages are to be removed during upgrade
        noremove="--no-remove"
        ;;
384
    --no-stdin|--inscript)  # HELPOPT: don't read from stdin for epm args
385 386
        inscript=1
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
387
    --dry-run|--simulate|--just-print|--no-act) # HELPOPT: print only (autoremove/autoorphans/remove only)
388 389
        dryrun="--dry-run"
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
390
    --short)              # HELPOPT: short output (just 'package' instead 'package-version-release')
391 392
        short="--short"
        ;;
393 394 395
    --direct)              # HELPOPT: direct install package file from ftp (not via hilevel repository manager)
        direct="--direct"
        ;;
396 397 398
    --repack)              # HELPOPT: repack rpm package(s) before install
        repack="--repack"
        ;;
399
    --scripts)             # HELPOPT: include scripts in repacked rpm package(s) (see --repack or repacking when foreign package is installed)
400
        scripts="--scripts"
401 402 403
        ;;
    --noscripts)           # HELPOPT: disable scripts in install packages
        noscripts="--noscripts"
404
        ;;
405
    --sort)               # HELPOPT: sort output, f.i. --sort=size (supported only for packages command)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
406
        # TODO: how to read arg?
407 408
        sort="$1"
        ;;
409
    --auto|--assumeyes|--non-interactive)  # HELPOPT: non interactive mode
Vitaly Lipatov's avatar
Vitaly Lipatov committed
410
        non_interactive="--auto"
411
        ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
412
    *)
413
        return 1
Vitaly Lipatov's avatar
Vitaly Lipatov committed
414 415
        ;;
    esac
416 417 418
    return 0
}

Vitaly Lipatov's avatar
Vitaly Lipatov committed
419 420
# TODO: skip for commands where we don't need parse args

421 422
check_filenames()
{
423
    local opt
424
    for opt in "$@" ; do
425 426
        # files can be with full path or have extension via .
        if [ -f "$opt" ] && echo "$opt" | grep -q "[/\.]" ; then
427
            has_space "$opt" && warning "There are space(s) in filename '$opt', it is not supported. Skipped" && continue
428
            pkg_files="$pkg_files $opt"
429
        elif [ -d "$opt" ] ; then
430
            has_space "$opt" && warning "There are space(s) in directory path '$opt', it is not supported. Skipped" && continue
431
            pkg_dirs="$pkg_dirs $opt"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
432
        elif echo "$opt" | grep -q "^[fhtps]*://" ; then
433
            has_space "$opt" && warning "There are space(s) in URL '$opt', it is not supported. Skipped" && continue
434
            pkg_urls="$pkg_urls $opt"
435
        else
Vitaly Lipatov's avatar
Vitaly Lipatov committed
436
            has_space "$opt" && warning "There are space(s) in package name '$opt', it is not supported. Skipped." && continue
437 438 439 440
            pkg_names="$pkg_names $opt"
        fi
        quoted_args="$quoted_args \"$opt\""
    done
441 442
}

443 444 445 446 447
# handle external EPM_OPTIONS
for opt in $EPM_OPTIONS ; do
        check_option "$opt"
done

448
FLAGENDOPTS=
449
for opt in "$@" ; do
450 451
    [ "$opt" = "--" ] && FLAGENDOPTS=1 && continue
    if [ -z "$FLAGENDOPTS" ] ; then
452 453
        check_command "$opt" && continue
        check_option "$opt" && continue
454
    fi
455
    # Note: will parse all params separately (no package names with spaces!)
456
    check_filenames "$opt"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
457 458
done

459 460 461
# fill
export EPM_OPTIONS="$nodeps $force $non_interactive"

462
# if input is not console and run script from file, get pkgs from stdin too
463
if [ ! -n "$inscript" ] && ! inputisatty && [ -n "$PROGDIR" ] ; then
464
    for opt in $(withtimeout 10 cat) ; do
465 466 467 468
        # FIXME: do not work
        # workaround against # yes | epme
        [ "$opt" = "y" ] && break;
        [ "$opt" = "yes" ] && break;
469 470 471 472
        check_filenames $opt
    done
fi

Vitaly Lipatov's avatar
Vitaly Lipatov committed
473
pkg_files=$(strip_spaces "$pkg_files")
474
pkg_dirs=$(strip_spaces "$pkg_dirs")
475 476
# in common case dirs equals to names only suddenly
pkg_names=$(strip_spaces "$pkg_names $pkg_dirs")
477
pkg_urls=$(strip_spaces "$pkg_urls")
Vitaly Lipatov's avatar
Vitaly Lipatov committed
478

479
pkg_filenames=$(strip_spaces "$pkg_files $pkg_names")
480

481 482 483 484
# Just debug
#echover "command: $epm_cmd"
#echover "pkg_files=$pkg_files"
#echover "pkg_names=$pkg_names"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
485

Vitaly Lipatov's avatar
Vitaly Lipatov committed
486
# Just printout help if run without args
Vitaly Lipatov's avatar
Vitaly Lipatov committed
487 488 489
if [ -z "$epm_cmd" ] ; then
    print_version
    echo
490
    fatstr="Unknown command in $* arg(s)"
491
    [ -n "$*" ] || fatstr="That program needs be running with some command"
492 493 494
    echo "Run $ $PROGNAME --help  to get help." >&2
    echo "Run $ epm print info  to get some system and distro info." >&2
    fatal "$fatstr."
Vitaly Lipatov's avatar
Vitaly Lipatov committed
495 496
fi

497 498
# Use eatmydata for write specific operations
case $epm_cmd in
499
    update|upgrade|Upgrade|install|reinstall|Install|remove|autoremove|kernel_update|release_upgrade|check)
500
        set_eatmydata
501
        ;;
502 503
esac

504 505
[ -n "$verbose$EPM_VERBOSE" ] && showcmd "$0 $*"

506
# Run helper for command with natural args
507
load_helper epm-$epm_cmd
508
eval epm_$epm_cmd $quoted_args
Vitaly Lipatov's avatar
Vitaly Lipatov committed
509
# return last error code (from subroutine)