[equo] add "equo repo add/remove" tools
This commit is contained in:
@@ -69,6 +69,8 @@ help_opts = [
|
||||
(1, 'repo', 1, _('manage your repositories')),
|
||||
(2, 'enable', 2, _('enable given repository')),
|
||||
(2, 'disable', 1, _('disable given repository')),
|
||||
(2, 'add <string>', 1, _('add repository (pass repository string)')),
|
||||
(2, 'remove <id>', 1, _('remove repository')),
|
||||
(1, 'notice [repos]', 1, _('repository notice board reader')),
|
||||
(1, 'status', 2, _('show respositories status')),
|
||||
None,
|
||||
@@ -685,6 +687,10 @@ def _repo_enable_disable_bashcomp(cmdline):
|
||||
return sorted(sys_settings['repositories']['excluded'].keys())
|
||||
elif action == "disable":
|
||||
return sorted(sys_settings['repositories']['available'].keys())
|
||||
elif action == "remove":
|
||||
avail = list(sys_settings['repositories']['available'].keys())
|
||||
excl = list(sys_settings['repositories']['excluded'].keys())
|
||||
return sorted(set(avail+excl))
|
||||
return []
|
||||
|
||||
BASHCOMP_MAP = {
|
||||
|
||||
@@ -22,6 +22,7 @@ from entropy.output import red, darkred, blue, brown, bold, darkgreen, green, \
|
||||
print_info, print_warning, print_error, purple, teal
|
||||
from entropy.core.settings.base import SystemSettings as SysSet
|
||||
from entropy.i18n import _
|
||||
from text_tools import print_table
|
||||
import entropy.tools
|
||||
SystemSettings = SysSet()
|
||||
|
||||
@@ -78,6 +79,10 @@ def repositories(options):
|
||||
rc = _enable_repositories(entropy_client, myopts)
|
||||
elif repo_opt == "disable":
|
||||
rc = _disable_repositories(entropy_client, myopts)
|
||||
elif repo_opt == "add":
|
||||
rc = _add_repository(entropy_client, myopts)
|
||||
elif repo_opt == "remove":
|
||||
rc = _remove_repository(entropy_client, myopts)
|
||||
else:
|
||||
rc = -10
|
||||
|
||||
@@ -98,6 +103,64 @@ def repositories(options):
|
||||
|
||||
return rc
|
||||
|
||||
def _add_repository(entropy_client, repo_strings):
|
||||
|
||||
current_branch = SystemSettings['repositories']['branch']
|
||||
current_product = SystemSettings['repositories']['product']
|
||||
available_repos = SystemSettings['repositories']['available']
|
||||
|
||||
for repo_string in repo_strings:
|
||||
if not repo_string:
|
||||
print_warning("[%s] %s" % (
|
||||
purple(repo_string), blue(_("invalid data, skipping")),))
|
||||
continue
|
||||
if not ((repo_string.startswith("repository|")) and \
|
||||
(len(repo_string.split("|")) == 5)):
|
||||
print_warning("[%s] %s" % (
|
||||
purple(repo_string),
|
||||
blue(_("invalid repository string, skipping")),)
|
||||
)
|
||||
continue
|
||||
|
||||
print_info("%s: %s" % (
|
||||
teal(_("Adding repository string")), blue(repo_string),))
|
||||
|
||||
repoid, repodata = SystemSettings._analyze_client_repo_string(
|
||||
repo_string, current_branch, current_product)
|
||||
|
||||
# print some info
|
||||
toc = []
|
||||
toc.append((purple(_("Repository id:")), teal(repoid)))
|
||||
toc.append((darkgreen(_("Description:")), teal(repodata['description'])))
|
||||
toc.append((purple(_("Repository format:")), darkgreen(repodata['dbcformat'])))
|
||||
toc.append((brown(_("Service port:")), teal(str(repodata['service_port']))))
|
||||
toc.append((brown(_("Service port (SSL):")), teal(str(repodata['ssl_service_port']))))
|
||||
for pkg_url in repodata['plain_packages']:
|
||||
toc.append((purple(_("Packages URL:")), pkg_url))
|
||||
db_url = repodata['plain_database']
|
||||
if not db_url:
|
||||
db_url = _("None given")
|
||||
toc.append((purple(_("Repository URL:")), darkgreen(db_url)))
|
||||
toc.append(" ")
|
||||
print_table(toc)
|
||||
entropy_client.add_repository(repodata)
|
||||
print_info("[%s] %s" % (
|
||||
purple(repoid), blue(_("repository added succesfully")),))
|
||||
|
||||
def _remove_repository(entropy_client, repo_ids):
|
||||
|
||||
excluded_repos = SystemSettings['repositories']['excluded']
|
||||
available_repos = SystemSettings['repositories']['available']
|
||||
repos = set(list(excluded_repos.keys()) + list(available_repos.keys()))
|
||||
for repo_id in repo_ids:
|
||||
if repo_id not in repos:
|
||||
print_warning("[%s] %s" % (
|
||||
purple(repo_id), blue(_("repository id not available")),))
|
||||
continue
|
||||
|
||||
entropy_client.remove_repository(repo_id)
|
||||
print_info("[%s] %s" % (
|
||||
purple(repo_id), blue(_("repository removed succesfully")),))
|
||||
|
||||
def _enable_repositories(entropy_client, repos):
|
||||
excluded_repos = SystemSettings['repositories']['excluded']
|
||||
|
||||
@@ -78,6 +78,14 @@ enable given repository
|
||||
|
||||
disable given repository
|
||||
|
||||
=item B<add <string>>
|
||||
|
||||
add repository (pass repository string)
|
||||
|
||||
=item B<remove <id>>
|
||||
|
||||
remove repository
|
||||
|
||||
=back
|
||||
|
||||
=item B<notice [repos]>
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "ACTIVATOR 1"
|
||||
.TH ACTIVATOR 1 "2010-03-29" "perl v5.10.1" "Entropy"
|
||||
.TH ACTIVATOR 1 "2010-03-25" "perl v5.10.1" "Entropy"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "EQUO 1"
|
||||
.TH EQUO 1 "2010-05-02" "perl v5.10.1" "Entropy"
|
||||
.TH EQUO 1 "2010-05-05" "perl v5.10.1" "Entropy"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
@@ -190,6 +190,12 @@ enable given repository
|
||||
.IP "\fBdisable\fR" 4
|
||||
.IX Item "disable"
|
||||
disable given repository
|
||||
.IP "\fBadd <string\fR>" 4
|
||||
.IX Item "add <string>"
|
||||
add repository (pass repository string)
|
||||
.IP "\fBremove <id\fR>" 4
|
||||
.IX Item "remove <id>"
|
||||
remove repository
|
||||
.RE
|
||||
.RS 4
|
||||
.RE
|
||||
@@ -1170,6 +1176,6 @@ Fabio Erculiani <lxnay@sabayon.org>
|
||||
.SH "POD ERRORS"
|
||||
.IX Header "POD ERRORS"
|
||||
Hey! \fBThe above document had some coding errors, which are explained below:\fR
|
||||
.IP "Around line 1332:" 4
|
||||
.IX Item "Around line 1332:"
|
||||
.IP "Around line 1340:" 4
|
||||
.IX Item "Around line 1340:"
|
||||
You forgot a '=back' before '=head1'
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "REAGENT 1"
|
||||
.TH REAGENT 1 "2010-03-30" "perl v5.10.1" "Entropy"
|
||||
.TH REAGENT 1 "2010-04-01" "perl v5.10.1" "Entropy"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
||||
Reference in New Issue
Block a user