Commit c58a5222 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm reposave: fix run under user

parent 8d7ee232
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
load_helper epm-sh-altlinux load_helper epm-sh-altlinux
# under root only
SAVELISTDIR=/tmp/eepm-etc-save SAVELISTDIR=/tmp/eepm-etc-save
__save_alt_repo_lists() __save_alt_repo_lists()
{ {
assure_root
info "Creating copy of all sources lists to $SAVELISTDIR ..." info "Creating copy of all sources lists to $SAVELISTDIR ..."
local i local i
rm -rf $verbose $SAVELISTDIR 2>/dev/null rm -rf $verbose $SAVELISTDIR 2>/dev/null
...@@ -34,8 +36,10 @@ __save_alt_repo_lists() ...@@ -34,8 +36,10 @@ __save_alt_repo_lists()
done done
} }
# under root only
__restore_alt_repo_lists() __restore_alt_repo_lists()
{ {
assure_root
info "Restoring copy of all sources lists from $SAVELISTDIR ..." info "Restoring copy of all sources lists from $SAVELISTDIR ..."
local i local i
[ -d "$SAVELISTDIR/apt" ] || return 0 [ -d "$SAVELISTDIR/apt" ] || return 0
...@@ -52,10 +56,17 @@ __restore_alt_repo_lists() ...@@ -52,10 +56,17 @@ __restore_alt_repo_lists()
done done
} }
# save and restore repo lists
__on_error_restore_alt_repo_lists()
{
warning "An error occurred..."
epm repo restore
}
try_change_alt_repo() try_change_alt_repo()
{ {
__save_alt_repo_lists epm repo save
trap __restore_alt_repo_lists EXIT trap __on_error_restore_alt_repo_lists EXIT
} }
end_change_alt_repo() end_change_alt_repo()
...@@ -64,11 +75,15 @@ end_change_alt_repo() ...@@ -64,11 +75,15 @@ end_change_alt_repo()
} }
epm_reposave() epm_reposave()
{ {
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
assure_root if ! is_root ; then
sudoepm repo save
return
fi
__save_alt_repo_lists __save_alt_repo_lists
;; ;;
*) *)
...@@ -82,7 +97,10 @@ epm_reporestore() ...@@ -82,7 +97,10 @@ epm_reporestore()
{ {
case $PMTYPE in case $PMTYPE in
apt-*) apt-*)
assure_root if ! is_root ; then
sudoepm repo restore
return
fi
__restore_alt_repo_lists __restore_alt_repo_lists
;; ;;
*) *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment