epm-repo 2.65 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2021  Etersoft
# Copyright (C) 2021  Vitaly Lipatov <lav@etersoft.ru>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#
# 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
# (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
# GNU Affero General Public License for more details.
#
# 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/>.
#

load_helper epm-sh-altlinux

epm_repo()
{
	local CMD="$1"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
25
	[ -n "$CMD" ] && shift
26 27
	case $CMD in
	"-h"|"--help"|help)               # HELPCMD: help
Vitaly Lipatov's avatar
Vitaly Lipatov committed
28
		get_help HELPCMD $SHAREDIR/epm-repo
29 30 31 32 33 34 35
cat <<EOF
Examples:
  epm repo set p9
  epm repo add autoimports
  epm repo list
  epm repo change yandex
EOF
36 37 38 39 40 41 42 43 44
		;;
	""|list)                          # HELPCMD: list packages
		load_helper epm-repolist
		epm_repolist "$@"
		;;
	fix)                              # HELPCMD: fix paths in sources lists (ALT Linux only)
		load_helper epm-repofix
		epm_repofix "$@"
		;;
45
	change)                           # HELPCMD: <mirror>: switch sources to the mirror (supports etersoft/yandex/basealt): rewrite URLs to the specified server
46 47 48
		load_helper epm-repofix
		epm_repofix "$@"
		;;
49
	set)                              # HELPCMD: <mirror>: remove all existing sources and add mirror for the branch
Vitaly Lipatov's avatar
Vitaly Lipatov committed
50
		epm repo rm all
51 52
		epm addrepo "$@"
		;;
53 54 55 56
	switch)                           # HELPCMD: switch repo to <repo>: rewrite URLs to the repo
		load_helper epm-repofix
		epm_reposwitch "$@"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
57
	clean)                            # HELPCMD: remove temp. repos (tasks and CD-ROMs)
58 59 60 61 62 63 64 65 66 67 68
		# TODO: check for ALT
		sudocmd apt-repo $dryrun clean
		;;
	save)
		load_helper epm-reposave
		epm_reposave "$@"
		;;
	restore)
		load_helper epm-reposave
		epm_reporestore "$@"
		;;
69 70 71 72
	reset)
		load_helper epm-reposave
		epm_reporeset "$@"
		;;
73 74 75 76
	add)                              # HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list
		load_helper epm-addrepo
		epm_addrepo "$@"
		;;
77 78 79 80 81
	Add)                              # HELPCMD: like add, but do update after add
		load_helper epm-addrepo
		epm_addrepo "$@"
		epm update
		;;
82
	rm|remove)                           # HELPCMD: remove repository from sources list (epm repo remove all for all)
83 84 85 86 87 88 89 90 91
		load_helper epm-removerepo
		epm_removerepo "$@"
		;;
	*)
		fatal "Unknown command $ epm repo '$CMD'"
		;;
esac

}