3
# Copyright (C) 2020, 2021 Etersoft
4
# Copyright (C) 2020, 2021 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
load_helper epm-sh-altlinux
24
SAVELISTDIR=$epm_vardir/eepm-etc-save
25
__save_alt_repo_lists()
28
info "Creating copy of all sources lists to $SAVELISTDIR ..."
30
rm -rf $verbose $SAVELISTDIR 2>/dev/null
31
mkdir -p $SAVELISTDIR/apt/ $SAVELISTDIR/apt/sources.list.d/
32
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
33
[ -s "$i" ] || continue
34
local DD="$(echo "$i" | sed -e "s|/etc|$SAVELISTDIR|")"
35
cp -af $verbose "$i" "$DD" || fatal "Can't save apt source list files to $SAVELISTDIR"
40
__restore_alt_repo_lists()
43
info "Restoring copy of all sources lists from $SAVELISTDIR ..."
45
[ -d "$SAVELISTDIR/apt" ] || return 0
46
mkdir -p $SAVELISTDIR/apt/ $SAVELISTDIR/apt/sources.list.d/
47
for i in /etc/apt/sources.list /etc/apt/sources.list.d/*.list ; do
48
[ -s "$i" ] || continue
49
local DD="$(echo "$i" | sed -e "s|/etc|$SAVELISTDIR|")"
50
# restore only if there are differences
51
if diff -q "$DD" "$i" >/dev/null ; then
54
mv $verbose "$DD" "$i" || warning "Can't restore $i file"
59
# save and restore repo lists
60
__on_error_restore_alt_repo_lists()
62
warning "An error occurred..."
69
trap __on_error_restore_alt_repo_lists EXIT
90
fatal "Have no suitable command for $PMTYPE"
104
__restore_alt_repo_lists
107
fatal "Have no suitable command for $PMTYPE"
115
case $BASEDISTRNAME in
117
sudoepm repo set $DISTRVERSION
124
sudocmd winget source reset
127
fatal "Have no suitable command for $PMTYPE"
138
load_helper epm-check_updated_repo
139
if [ -n "$short" ] ; then
141
days="$(__epm_check_apt_db_days)" && return 0
146
days="$(__epm_check_apt_db_days)" && info "APT database is actual." && return 0
147
info "APT database is $days."
152
fatal "Have no suitable command for $PMTYPE"