epm-repo 5.34 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
#
# 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

22
epm_repo_help()
23
{
24
    get_help HELPCMD $SHAREDIR/epm-repo
25
    message '
26

27
Examples:
28 29 30 31 32 33
  epm repo set p9          - clean all sources and add default repo for p9 branch
  epm repo set c10f1       - clean all sources and add default repo for c10f1 branch
  epm repo switch p10      - change only branch name to p10
  epm repo add autoimports - add autoimports (from Fedora) repo
  epm repo change yandex   - change only base url part to mirror.yandex.ru server
  epm repo list            - list current repos
34
'
35 36 37 38 39
}


epm_repo()
{
40 41 42 43 44 45
    local CMD="$1"
    [ -n "$CMD" ] && shift
    case $CMD in
    "-h"|"--help"|help)               # HELPCMD: help
        epm_repo_help
        ;;
46
    ""|list)                          # HELPCMD: list enabled repositories (-a|--all for list disabled repositorires too)
47 48 49
        load_helper epm-repolist
        epm_repolist "$@"
        ;;
50
    change)                           # HELPCMD: <mirror>: switch sources to the mirror (supports etersoft/yandex/basealt/altlinux.org/eterfund.org): rewrite URLs to the specified server
51
        load_helper epm-repofix
52
        epm_repochange "$@"
53 54
        ;;
    set)                              # HELPCMD: <mirror>: remove all existing sources and add mirror for the branch
55 56 57
        if [ -z "$1" ]; then
            fatal "No repository specified."
        fi
58 59 60
        epm repo rm all
        epm addrepo "$@"
        ;;
61
    switch)                           # HELPCMD: switch repo to <repo>: rewrite URLs to the repo (but use epm release-upgrade [Sisyphus|p10] for upgrade to a next branch)
62 63 64 65 66 67 68 69 70 71 72
        load_helper epm-repofix
        epm_reposwitch "$@"
        ;;
    enable)                           # HELPCMD: enable <repo>
        load_helper epm-repoenable
        epm_repoenable "$@"
        ;;
    disable)                          # HELPCMD: disable <repo>
        load_helper epm-repodisable
        epm_repodisable "$@"
        ;;
73
    addkey)                           # HELPCMD: add repository gpg key (by URL or file) (run with --help to detail)
74
        load_helper epm-repo-addkey
75 76 77
        epm_addkey "$@"
        ;;
    clean)                            # HELPCMD: remove temp. repos (tasks and CD-ROMs)
78
        [ "$BASEDISTRNAME" = "alt" ] || fatal "TODO: only ALT now is supported"
79 80 81
        # TODO: check for ALT
        sudocmd apt-repo $dryrun clean
        ;;
82
    save)                             # HELPCMD: save sources lists to a temp place
83 84 85
        load_helper epm-reposave
        epm_reposave "$@"
        ;;
86
    restore)                          # HELPCMD: restore sources lists from a temp place
87 88 89
        load_helper epm-reposave
        epm_reporestore "$@"
        ;;
90
    reset)                            # HELPCMD: reset repo lists to the distro default
91 92 93
        load_helper epm-reposave
        epm_reporeset "$@"
        ;;
94
    status)                           # HELPCMD: print repo status
95 96 97
        load_helper epm-reposave
        epm_repostatus "$@"
        ;;
98
    add)                              # HELPCMD: add package repo (etersoft, autoimports, archive 2017/01/31); run with param to get list
99 100 101 102 103 104 105 106
        load_helper epm-addrepo
        epm_addrepo "$@"
        ;;
    Add)                              # HELPCMD: like add, but do update after add
        load_helper epm-addrepo
        epm_addrepo "$@"
        epm update
        ;;
107
    rm|del|remove)                     # HELPCMD: remove repository from the sources lists (epm repo remove all for all)
108 109 110
        load_helper epm-removerepo
        epm_removerepo "$@"
        ;;
111 112 113 114
    fix)                              # HELPCMD: fix paths in sources lists (ALT Linux only)
        load_helper epm-repofix
        epm_repofix "$@"
        ;;
115

116
# HELPCMD: PART: Local repo commands:
117 118 119 120
    create)                            # HELPCMD: create (initialize) repo: [path] [name]
        load_helper epm-repoindex
        epm_repocreate "$@"
        ;;
121
    index)                            # HELPCMD: index repo (update indexes): [--init] [path] [name]
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
        load_helper epm-repoindex
        epm_repoindex "$@"
        ;;
    pkgadd)                           # HELPCMD: add to <dir> applied <package-filename1> [<package-filename2>...]
        load_helper epm-repopkg
        epm_repo_pkgadd "$@"
        ;;
    pkgupdate)                        # HELPCMD: replace in <dir> with new <package-filename1> [<package-filename2>...]
        load_helper epm-repopkg
        epm_repo_pkgupdate "$@"
        ;;
    pkgdel)                           # HELPCMD: del from <dir> <package1> [<package2>...]
        load_helper epm-repopkg
        epm_repo_pkgdel "$@"
        ;;
    *)
138
        fatal 'Unknown command $ epm repo $CMD'
139
        ;;
140 141 142
esac

}