diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index faff840e..78089e37 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -23,7 +23,6 @@ import os - __all__ = "slpkg" __author__ = "dslackw" __version_info__ = (2, 1, 'x-dev') @@ -44,7 +43,7 @@ repositories = [ 'slacky', 'studio', 'slackr', - 'only' + 'slonly' ] build_path = "/tmp/slpkg/build/" slpkg_tmp_packages = tmp + "slpkg/packages/" diff --git a/slpkg/arguments.py b/slpkg/arguments.py index 96073534..be86890e 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -21,6 +21,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys from __metadata__ import ( __version__, @@ -36,6 +37,7 @@ def options(): " update update all package " + "lists", " re-create recreate package lists", + " repolist list all repositories", " update slpkg check and update slpkg\n", "Optional arguments:", " -h, --help show this help message " + @@ -68,6 +70,7 @@ def options(): ] for opt in arguments: print(opt) + sys.exit(0) def usage(): @@ -89,3 +92,4 @@ def usage(): ] for usg in view: print(usg) + sys.exit(0) diff --git a/slpkg/main.py b/slpkg/main.py index 2f48fec3..87ec44cd 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -24,6 +24,8 @@ import sys import getpass +from repolist import RepoList + from desc import PkgDesc from config import Config from queue import QueuePkgs @@ -126,21 +128,26 @@ def main(): if len(args) == 2 and args[0] == "update" and args[1] == "slpkg": it_self_update() - # checking if repositories exists - check_exists_repositories() - - if len(args) == 1 and args[0] == "re-create": - Initialization().re_create() + if len(args) == 1 and args[0] == "repolist": + RepoList().repos() if len(args) == 0: usage() elif (len(args) == 1 and args[0] == "-h" or args[0] == "--help" and args[1:] == []): options() - elif (len(args) == 1 and args[0] == "-v" or + + if (len(args) == 1 and args[0] == "-v" or args[0] == "--version" and args[1:] == []): prog_version() - elif len(args) == 3 and args[0] == "-a": + + # checking if repositories exists + check_exists_repositories() + + if len(args) == 1 and args[0] == "re-create": + Initialization().re_create() + + if len(args) == 3 and args[0] == "-a": BuildPackage(args[1], args[2:], path).build() elif len(args) == 2 and args[0] == "-l": pkg_list = ["all", "noarch"] + repositories diff --git a/slpkg/repolist.py b/slpkg/repolist.py new file mode 100644 index 00000000..248266c3 --- /dev/null +++ b/slpkg/repolist.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# repolist.py file is part of slpkg. + +# Copyright 2014 Dimitris Zlatanidis +# All rights reserved. + +# Slpkg is a user-friendly package manager for Slackware installations + +# https://github.com/dslackw/slpkg + +# Slpkg is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import sys + +from repositories import Repo +from messages import template +from __metadata__ import repositories, color + + +class RepoList(object): + + def __init__(self): + self.all_repos = { + 'slack': Repo().slack(), + 'sbo': Repo().sbo(), + 'rlw': Repo().rlw(), + 'alien': Repo().alien(), + 'slacky': Repo().slacky(), + 'studio': Repo().studioware(), + 'slackr': Repo().slackers(), + 'slonly': Repo().slackonly() + } + + def repos(self): + ''' + View or enabled or disabled repositories + ''' + print('') + template(78) + print('{0}{1}{2}{3}{4}'.format( + '| Repo id', ' ' * 10, + 'Repo name', ' ' * 45, + 'Status')) + template(78) + for repo_id, repo_name in sorted(self.all_repos.iteritems()): + status = '{0}disabled{1}'.format(color['RED'], color['ENDC']) + if repo_id in repositories: + status = '{0}enabled{1}'.format(color['GREEN'], color['ENDC']) + print(' {0}{1}{2}{3}{4:>17}'.format( + repo_id, ' ' * (17 - len(repo_id)), + repo_name, ' ' * (52 - len(repo_name)), + status)) + print("\nFor enable or disable repositories edit " + "'/etc/slpkg/slpkg.conf' file\n") + sys.exit(0) diff --git a/slpkg/version.py b/slpkg/version.py index b67ebc54..c92acf60 100644 --- a/slpkg/version.py +++ b/slpkg/version.py @@ -21,6 +21,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import sys + from __metadata__ import ( __version__, __license__, @@ -35,3 +37,4 @@ def prog_version(): print("Version : {0}".format(__version__)) print("Licence : {0}".format(__license__)) print("Email : {0}".format(__email__)) + sys.exit(0)