3
# Copyright (C) 2012, 2017, 2019 Etersoft
4
# Copyright (C) 2012, 2017, 2019 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
22
ETERSOFTPUBURL=http://download.etersoft.ru/pub
23
ALTLINUXPUBURL=http://ftp.altlinux.org/pub/distributions
28
if [ -z "$repo" ] ; then
30
echo "1. Use with repository URL, f.i. http://www.example.com/example.repo"
31
echo "2. Use with epel to add EPEL repository"
32
echo "3. Use with powertools to add PowerTools repository"
33
echo "4. Use with crb to add Rocky Linux CRB repository"
38
# dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
39
epm install epel-release
43
# https://serverfault.com/questions/997896/how-to-enable-powertools-repository-in-centos-8
44
epm install --skip-installed dnf-plugins-core
45
sudocmd dnf config-manager --set-enabled powertools
49
# https://wiki.rockylinux.org/rocky/repo/
50
epm install --skip-installed dnf-plugins-core
51
sudocmd dnf config-manager --set-enabled crb
58
__epm_addrepo_etersoft_addon()
60
epm install --skip-installed apt-conf-etersoft-common apt-conf-etersoft-hold || fatal
61
# TODO: ignore only error code 22 (skipped) || fatal
63
local pb="$DISTRVERSION/branch"
64
[ "$DISTRVERSION" = "Sisyphus" ] && pb="$DISTRVERSION"
67
[ -n "$DISTRVERSION" ] || fatal "Empty DISTRVERSION"
69
docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/noarch addon"
70
docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/$DISTRARCH addon"
71
if [ "$DISTRARCH" = "x86_64" ] ; then
72
docmd epm repo add "rpm [etersoft] $ETERSOFTPUBURL/Etersoft LINUX@Etersoft/$pb/x86_64-i586 addon"
94
fatal "Uknown CF comp $repo"
98
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/$DISTRARCH classic" || return
99
if [ "$DISTRARCH" = "x86_64" ] ; then
100
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/x86_64-i586 classic" || return
102
epm repo add "rpm [cert8] http://update.altsp.su/pub/distributions/ALTLinux $comp/branch/noarch classic" || return
116
# 'rpm protocol:/path/to/repo component'
117
__epm_addrepo_altlinux_short()
119
[ -n "$1" ] || fatal "only for rpm repo"
124
arch="$(basename "$url")"
125
url="$(dirname "$url")"
126
docmd epm repo add "rpm $url $arch $REPO_NAME"
130
__epm_addrepo_altlinux_url()
136
# URL to path/RPMS.addon
137
base="$(basename "$url")"
138
if echo "$base" | grep -q "^RPMS\." ; then
139
REPO_NAME="$(echo $base | sed -e 's|.*\.||')"
140
url="$(dirname $url)"
141
docmd epm repo add "rpm $url $REPO_NAME"
145
# TODO: add to eget file:/ support and use here
146
# URL to path (where RPMS.addon is exists)
147
local baseurl="$(eget --list "$url/RPMS.*")"
148
base="$(basename "$baseurl")"
149
if echo "$base" | grep -q "^RPMS\." ; then
150
REPO_NAME="$(echo $base | sed -e 's|.*\.||')"
151
docmd epm repo add "rpm $url $REPO_NAME"
155
# URL to {i586,x86_64,noarch}/RPMS.addon
157
for arch in $(get_archlist) ; do
158
local rd="$(eget --list $url/$arch/RPMS.*)"
159
[ -d "$rd" ] || continue
160
local REPO_NAME="$(echo "$rd" | sed -e 's|.*\.||')"
161
docmd epm repo add "rpm $url $arch $REPO_NAME"
164
[ -n "$res" ] || warning "There is no arch repos in $url"
168
__epm_addrepo_altlinux_help()
170
#sudocmd apt-repo $dryrun add branch
173
epm repo add - add branch repo. Use follow params:
174
basealt - for BaseALT repo"
175
altsp - add ALT SP repo"
176
yandex - for BaseALT repo mirror hosted by Yandex (recommended)"
177
autoimports - for BaseALT autoimports repo"
178
autoports - for Autoports repo (with packages from Sisyphus rebuilt to the branch)
179
altlinuxclub - for altlinuxclub repo (http://altlinuxclub.ru/)"
180
deferred - for Etersoft Sisyphus Deferred repo"
181
deferred.org - for Etersoft Sisyphus Deferred repo (at mirror.eterfund.org)"
182
etersoft - for LINUX@Etersoft repo"
183
korinf - for Korinf repo"
184
<task number> - add task repo"
185
archive 2018/02/09 - add archive of the repo from that date"
186
/dir/to/repo [component] - add repo dir generated with epm repo index --init"
187
URL [arch] [component] - add repo by URL"
190
# epm repo add yandex
191
# epm repo add "rpm http://somesite/pub/product x86_64 addon"
192
# epm repo add /var/ftp/pub/altlinux/p10
198
__epm_addrepo_altlinux()
202
if [ -z "$repo" ] || [ "$repo" = "-h" ] || [ "$repo" = "--list" ] || [ "$repo" = "--help" ] ; then
203
__epm_addrepo_altlinux_help
207
# 'rpm protocol:/path/to/repo component'
208
if [ "$1" = "rpm" ] && [ -n "$2" ] && [ -n "$3" ] && [ -z "$4" ] ; then
209
__epm_addrepo_altlinux_short "$@"
214
if [ -d "$1" ] ; then
215
__epm_addrepo_altlinux_url "file:$1"
219
# file:/path/to/repo or http://path/to/repo
220
if is_url "$1" ; then
221
__epm_addrepo_altlinux_url "$1"
225
local branch="$(echo "$DISTRVERSION" | tr "[:upper:]" "[:lower:]")"
226
[ -n "$branch" ] || fatal "Empty DISTRVERSION"
230
# TODO: return when Etersoft improved its repos
231
#info "add Etersoft's addon repo"
232
#__epm_addrepo_etersoft_addon
246
repo="autoimports.$branch"
250
epm installed apt-https && http="https"
255
fatal "Autoports is not supported for $DISTRNAME $branch. Check https://www.altlinux.org/Autoports ."
258
epm repo addkey cronbuild "DE73F3444C163CCD751AC483B584C633278EB305" "Cronbuild Service <cronbuild@altlinux.org>"
259
epm repo add "rpm [cronbuild] $http://autoports.altlinux.org/pub ALTLinux/autoports/$DISTRVERSION/$DISTRARCH autoports"
260
epm repo add "rpm [cronbuild] $http://autoports.altlinux.org/pub ALTLinux/autoports/$DISTRVERSION/noarch autoports"
264
repo="altlinuxclub.$branch"
266
autoimports.*|altlinuxclub.*)
271
epm installed apt-https && http="https"
272
epm repo add "rpm $http://download.etersoft.ru/pub Korinf/ALTLinux/$DISTRVERSION main"
276
[ "$DISTRVERSION" = "Sisyphus" ] || fatal "Etersot Sisyphus Deferred supported only for ALT Sisyphus."
277
epm repo add "http://download.etersoft.ru/pub Etersoft/Sisyphus/Deferred"
281
[ "$DISTRVERSION" = "Sisyphus" ] || fatal "Etersot Sisyphus Deferred supported only for ALT Sisyphus."
282
epm repo add "http://mirror.eterfund.org/download.etersoft.ru/pub Etersoft/Sisyphus/Deferred"
287
echo "$datestr" | grep -Eq "^20[0-2][0-9]/[01][0-9]/[0-3][0-9]$" || fatal "use follow date format: 2017/01/31"
289
local rpmsign='[alt]'
290
[ "$branch" != "sisyphus" ] && rpmsign="[$branch]"
292
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/$DISTRARCH classic"
293
if [ "$DISTRARCH" = "x86_64" ] ; then
294
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/x86_64-i586 classic"
296
epm repo add "rpm $rpmsign $ALTLINUXPUBURL archive/$branch/date/$datestr/noarch classic"
302
assure_exists apt-repo
304
if tasknumber "$repo" >/dev/null ; then
305
sudocmd_foreach "apt-repo $dryrun add" $(tasknumber "$repo")
311
__epm_addrepo_altsp "$repo"
316
if [ -z "$force" ] ; then
318
epm repo list --quiet | grep -q -F "$repo" && return 0
321
if echo "$repo" | grep -q "https://" ; then
322
local mh="$(echo /usr/lib*/apt/methods/https)"
323
assure_exists $mh apt-https
326
sudocmd apt-repo $dryrun add "$repo"
335
if [ -z "$repo" ] || [ "$repo" = "--help" ]; then
336
info "Add repo. You can use follow params:"
337
echo " distribution component name"
338
echo " full sources list line"
339
echo " URL version component"
343
local reponame="$(epm print info --repo-name)"
346
# https://wiki.astralinux.ru/pages/viewpage.action?pageId=3276859
347
case "$1-$reponame" in
349
# TODO epm repo change http / https
350
epm install --skip-installed apt-transport-https ca-certificates || fatal
351
if epm repo list | grep "dl.astralinux.ru/astra/stable/1.7_x86-64" ; then
352
fatal "Astra repo is already in the list"
354
# https://wiki.astralinux.ru/pages/viewpage.action?pageId=158598882
355
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-main/ 1.7_x86-64 main contrib non-free"
356
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-update/ 1.7_x86-64 main contrib non-free"
357
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-base/ 1.7_x86-64 main contrib non-free"
358
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended/ 1.7_x86-64 main contrib non-free"
359
epm repo add "deb [arch-=i386] https://dl.astralinux.ru/astra/stable/1.7_x86-64/repository-extended/ 1.7_x86-64 astra-ce"
363
# TODO epm repo change http / https
364
epm install --skip-installed apt-transport-https ca-certificates || fatal
365
# https://wiki.astralinux.ru/pages/viewpage.action?pageId=158605543
366
epm repo add "deb [arch=amd64] https://dl.astralinux.ru/astra/frozen/$(epm print info -v)_x86-64/$(epm print info --full-version)/repository stable main contrib non-free"
367
#epm repo add "deb https://download.astralinux.ru/astra/stable/orel/repository/ orel main contrib non-free"
371
fatal "Unsupported distro version $1-$reponame, see '# epm print info' output."
375
echo "Use workaround for AstraLinux ..."
376
# aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for AstraLinuxCE/orel
378
epm repo list --quiet | grep -q -F "$repo" && return 0
379
[ -z "$(tail -n1 /etc/apt/sources.list)" ] || echo "" | sudocmd tee -a /etc/apt/sources.list
380
echo "$repo" | sudocmd tee -a /etc/apt/sources.list
384
__epm_addrepo_alpine()
387
is_url "$repo" || fatal "Only URL is supported"
388
epm repo list --quiet | grep -q -F "$repo" && return 0
390
echo "$repo" | sudocmd tee -a /etc/apk/repositories
395
assure_exists apt-add-repository software-properties-common
396
local ad="$DISTRARCH"
397
# TODO: move to distro_info
398
local nd="$(lsb_release -cs)"
401
if [ -z "$repo" ] || [ "$repo" = "--help" ]; then
402
info "Add repo. You can use follow params:"
403
echo " docker - add official docker repo"
404
echo " ppa:<user>/<ppa-name> - add PPA repo"
405
echo " distribution component name"
406
echo " full sources list line"
407
echo " URL version component"
414
__epm_addkey_deb https://download.docker.com/linux/$PKGVENDOR/gpg "9DC858229FC7DD38854AE2D88D81803C0EBFCD88"
415
repo="https://download.docker.com/linux/$PKGVENDOR $nd stable"
419
# if started from url, use heroistic
420
if echo "$repo" | grep -E -q "^https?://" ; then
421
repo="deb [arch=$ad] $repo"
424
if echo "$repo" | grep -q "https://" ; then
425
assure_exists /usr/share/doc/apt-transport-https apt-transport-https
426
assure_exists /usr/sbin/update-ca-certificates ca-certificates
429
if [ -d "$repo" ] ; then
430
epm repo add "deb file:$repo ./"
434
# FIXME: quotes in showcmd/sudocmd
435
showcmd apt-add-repository "$repo"
436
sudorun apt-add-repository "$repo"
437
info "Check file /etc/apt/sources.list if needed"
444
case $BASEDISTRNAME in
446
__epm_addrepo_altlinux "$@"
450
__epm_addrepo_astra "$@"
454
__epm_addrepo_alpine "$repo" || return
460
__epm_addrepo_deb "$@"
463
info "You need manually add repo to /etc/apt/sources.list (TODO)"
466
assure_exists yum-utils
467
__epm_addrepo_rhel "$repo" || return
468
sudocmd yum-config-manager --add-repo "$repo"
471
__epm_addrepo_rhel "$repo" || return
472
sudocmd dnf config-manager --add-repo "$repo"
475
sudocmd urpmi.addmedia "$@"
478
sudocmd zypper ar "$repo"
481
sudocmd layman -a "$repo"
484
info "You need manually add repo to /etc/pacman.conf"
485
# Only for alone packages:
486
#sudocmd repo-add $pkg_filenames
489
sudocmd npackdcl add-repo --url="$repo"
492
sudocmd winget source add "$repo"
495
sudocmd nix-channel --add "$repo"
498
sudocmd pkg install "$repo"
501
info "You need manually add repo to /etc/slackpkg/mirrors"
504
fatal "Have no suitable command for $PMTYPE"