3
# Copyright (C) 2020, 2022, 2023 Etersoft
4
# Copyright (C) 2020, 2022, 2023 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/>.
20
# TODO: move to a common place and use
23
echo "$1" | grep -q "[*?]"
26
__alt_mark_hold_package()
29
showcmd "echo \"RPM::Hold {\"^$pkg\";};\" > /etc/apt/apt.conf.d/hold-$pkg.conf"
30
echo "RPM::Hold {\"^$pkg\";};" | sudorun tee "/etc/apt/apt.conf.d/hold-$pkg.conf" >/dev/null
35
echo "$*" | grep -q "\.[*?]" && warning "Only glob symbols * and ? are supported. Don't use regexp here!"
40
# TODO: do more long checking via apt
45
if __is_wildcard "$i" ; then
47
pkglist="$(epm qp --short "^$i")" || continue
48
for pkg in $pkglist ; do
49
__alt_mark_hold_package $pkg
53
pkg="$(epm query --short "$i")" || continue
55
__alt_mark_hold_package $pkg
61
# TODO: do more long checking via apt
66
pkg="$(epm query --short "$i")" || pkg="$i"
67
sudocmd rm -fv /etc/apt/apt.conf.d/hold-$pkg.conf
73
grep -h "RPM::Hold" /etc/apt/apt.conf.d/hold-*.conf 2>/dev/null | sed -e 's|RPM::Hold {"^\(.*\)";};|\1|'
76
__dnf_assure_versionlock()
78
epm assure /etc/dnf/plugins/versionlock.conf 'dnf-command(versionlock)'
81
__dnf_is_supported_versionlock()
83
[ -f /etc/dnf/plugins/versionlock.conf ]
98
sudocmd apt-mark hold "$@"
101
__dnf_assure_versionlock
102
sudocmd dnf versionlock add "$@"
105
sudocmd zypper al "$@"
108
info "Check /etc/portage/package.mask"
111
info "Manually: edit /etc/pacman.conf modifying IgnorePkg array"
114
fatal "Have no suitable command for $PMTYPE"
124
case $BASEDISTRNAME in
126
__alt_mark_unhold "$@"
133
sudocmd apt-mark unhold "$@"
136
__dnf_assure_versionlock
137
sudocmd dnf versionlock delete "$@"
140
sudocmd zypper rl "$@"
143
info "Check /etc/portage/package.mask (package.unmask)"
146
info "Manually: edit /etc/pacman.conf removing package from IgnorePkg line"
149
fatal "Have no suitable command for $PMTYPE"
159
case $BASEDISTRNAME in
161
__alt_mark_showhold "$@"
168
docmd apt-mark showhold "$@"
171
# there is no hold entries without versionlock
172
__dnf_is_supported_versionlock || return 0
173
__dnf_assure_versionlock
174
if [ -n "$short" ] ; then
175
load_helper epm-query
176
docmd dnf versionlock list "$@" | sed -e 's|\.\*$||' | grep -v " " | filter_pkgnames_to_short
178
docmd dnf versionlock list "$@"
185
cat /etc/portage/package.mask
191
fatal "Have no suitable command for $PMTYPE"
199
# workaround against epm assure questions
202
# there is no hold entries without versionlock
203
__dnf_is_supported_versionlock || return 1
204
__dnf_assure_versionlock
205
load_helper epm-query
206
docmd dnf versionlock list | grep "^$1" | sed -e 's|\.\*$||' | grep -v " " | filter_pkgnames_to_short | grep -q "^$1$"
211
epm_mark_showhold | grep -q "^$1$"
219
case $BASEDISTRNAME in
221
sudocmd apt-mark auto "$@"
228
sudocmd apt-mark auto "$@"
231
sudocmd dnf mark remove "$@"
234
sudocmd pacman -D --asdeps "$@"
237
sudocmd emerge --oneshot "$@"
240
fatal "Have no suitable command for $PMTYPE"
250
case $BASEDISTRNAME in
252
sudocmd apt-mark manual "$@"
259
sudocmd apt-mark manual "$@"
262
sudocmd dnf mark install "$@"
265
sudocmd pacman -D --asexplicit "$@"
268
sudocmd emerge --select "$@"
271
fatal "Have no suitable command for $PMTYPE"
281
case $BASEDISTRNAME in
283
sudocmd apt-mark showauto "$@"
290
sudocmd apt-mark showauto "$@"
293
sudocmd dnf repoquery --unneeded
296
fatal "Have no suitable command for $PMTYPE"
305
case $BASEDISTRNAME in
307
sudocmd apt-mark showmanual "$@"
314
sudocmd apt-mark showmanual "$@"
317
sudocmd dnf repoquery --userinstalled
320
fatal "Have no suitable command for $PMTYPE"
328
echo "mark is the interface for marking packages"
329
get_help HELPCMD $SHAREDIR/epm-mark
340
[ -n "$CMD" ] && shift
342
""|"-h"|"--help"|help) # HELPCMD: help
345
hold) # HELPCMD: mark the given package(s) as held back
348
unhold) # HELPCMD: unset the given package(s) as held back
351
showhold) # HELPCMD: print the list of packages on hold
352
epm_mark_showhold "$@"
354
checkhold) # HELPCMD: return true if the package is on hold
355
epm_mark_checkhold "$@"
357
auto) # HELPCMD: mark the given package(s) as automatically installed
360
manual) # HELPCMD: mark the given package(s) as manually installed
363
showauto) # HELPCMD: print the list of automatically installed packages
364
epm_mark_showauto "$@"
366
showmanual) # HELPCMD: print the list of manually installed packages
367
epm_mark_showmanual "$@"
370
fatal "Unknown command $ epm repo '$CMD'"