From 7324c1d6908698ca6fddff47389ab49cae149480 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 21 Oct 2014 06:32:30 +0300 Subject: [PATCH] update source v2.0.2 --- CHANGELOG | 5 ++ PKG-INFO | 2 +- README.rst | 10 +-- install.sh | 2 +- setup.py | 2 +- slackbuild/slpkg.SlackBuild | 2 +- slackbuild/slpkg.info | 2 +- slpkg/__init__.py | 6 +- slpkg/__metadata__.py | 2 +- slpkg/blacklist.py | 18 +++--- slpkg/messages.py | 4 +- slpkg/pkg/manager.py | 4 +- slpkg/queue.py | 20 +++--- slpkg/sbo/tracking.py | 4 +- slpkg/sbo/views.py | 118 +++++++++++++++++++----------------- slpkg/slack/mirrors.py | 1 + 16 files changed, 104 insertions(+), 98 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 88dbba0a..0c14e149 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Version 2.0.2 +21-10-2014 + +[Updated] - Update source. + Version 2.0.1 20-10-2014 diff --git a/PKG-INFO b/PKG-INFO index 1525cfa9..02a24e0c 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: slpkg -Version: 2.0.1 +Version: 2.0.2 Author: dslackw Author-email: d zlatanidis at gmail com Maintainer: dslackw diff --git a/README.rst b/README.rst index 71bd0ed2..5fa339a6 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ .. image:: https://travis-ci.org/dslackw/slpkg.svg?branch=master :target: https://travis-ci.org/dslackw/slpkg .. image:: https://landscape.io/github/dslackw/slpkg/master/landscape.png - :target: https://landscape.io/github/dslackw/slpkg/master + :target: https://landscape.io/github/dslackw/slpkg/master .. image:: https://pypip.in/d/slpkg/badge.png :target: https://pypi.python.org/pypi/slpkg .. image:: https://pypip.in/license/slpkg/badge.png @@ -11,9 +11,9 @@ Latest Release: -- Version: 2.0.1 +- Version: 2.0.2 - `Package `_ -- `Source `_ +- `Source `_ - `CHANGELOG `_ .. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png @@ -100,8 +100,8 @@ Untar the archive and run install.sh script: .. code-block:: bash - $ tar xvf slpkg-2.0.1.tar.gz - $ cd slpkg-2.0.1 + $ tar xvf slpkg-2.0.2.tar.gz + $ cd slpkg-2.0.2 $ ./install.sh Using `pip `_ : diff --git a/install.sh b/install.sh index 30bec81f..8c14c9b5 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=slpkg -VERSION=${VERSION:-2.0.1} +VERSION=${VERSION:-2.0.2} TAG=${TAG:-_dsw} cd .. diff --git a/setup.py b/setup.py index 5c0c1b41..f399f455 100755 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ import sys import gzip import shutil -from slpkg import __version__, __email__, __author__ +from slpkg.__metadate__ import __version__, __email__, __author__ try: from setuptools import setup diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index c46b3d5a..09a5c51e 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -23,7 +23,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=slpkg -VERSION=${VERSION:-2.0.1} +VERSION=${VERSION:-2.0.2} BUILD=${BUILD:-1} TAG=${TAG:-_dsw} diff --git a/slackbuild/slpkg.info b/slackbuild/slpkg.info index 9a1afba6..3d2ea8c1 100644 --- a/slackbuild/slpkg.info +++ b/slackbuild/slpkg.info @@ -1,7 +1,7 @@ PRGNAM="slpkg" VERSION="2.0.1" HOMEPAGE="https://github.com/dslackw/slpkg" -DOWNLOAD="https://github.com/dslackw/slpkg/archive/v2.0.1.tar.gz" +DOWNLOAD="https://github.com/dslackw/slpkg/archive/v2.0.2.tar.gz" MD5SUM="" DOWNLOAD_x86_64="" MD5SUM_x86_64="" diff --git a/slpkg/__init__.py b/slpkg/__init__.py index ee0d668d..3f8f22d6 100644 --- a/slpkg/__init__.py +++ b/slpkg/__init__.py @@ -1,5 +1 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -from main import * -from __metadata__ import __author__, __version__, __license__, __email__ +# [ main ] directory diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index b785c67e..a0fb56a3 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -26,7 +26,7 @@ import subprocess __all__ = "slpkg" __author__ = "dslackw" -__version_info__ = (2, 0, 1) +__version_info__ = (2, 0, 2) __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 3445828d..622c90f8 100755 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -103,20 +103,20 @@ class BlackList(object): ''' Print blacklist packages ''' - exit = 0 + quit = 0 print("\nPackages in blacklist:\n") for black in self.packages(): if black: print("{0}{1}{2}".format(GREEN, black, ENDC)) - exit = 1 - if exit == 1: + quit = 1 + if quit == 1: print # new line at exit def add(self, pkgs): ''' Add blacklist packages if not exist ''' - exit = 0 + quit = 0 blacklist = self.packages() pkgs = set(pkgs) print("\nAdd packages in blacklist:\n") @@ -125,16 +125,16 @@ class BlackList(object): if pkg not in blacklist: print("{0}{1}{2}".format(GREEN, pkg, ENDC)) black_conf.write(pkg + "\n") - exit = 1 + quit = 1 black_conf.close() - if exit == 1: + if quit == 1: print # new line at exit def remove(self, pkgs): ''' Remove packages from blacklist ''' - exit = 0 + quit = 0 print("\nRemove packages from blacklist:\n") with open(self.blackfile, "w") as remove: for line in self.black_conf.splitlines(): @@ -142,7 +142,7 @@ class BlackList(object): remove.write(line + "\n") else: print("{0}{1}{2}".format(RED, line, ENDC)) - exit = 1 + quit = 1 remove.close() - if exit == 1: + if quit == 1: print # new line at exit diff --git a/slpkg/messages.py b/slpkg/messages.py index c7b5132f..1939e8c9 100755 --- a/slpkg/messages.py +++ b/slpkg/messages.py @@ -66,11 +66,11 @@ def build_FAILED(sbo_url, prgnam): print # new line at end -def template(max): +def template(max_len): ''' Print template ''' - print("+" + "=" * max) + print("+" + "=" * max_len) def view_sbo(pkg, sbo_url, sbo_desc, sbo_dwn, source_dwn, sbo_req): diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index 0ea0cdbb..1b185067 100755 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -101,8 +101,7 @@ class PackageManager(object): [removed, dependencies, rmv_list, - rmv_dependencies - ] = ([] for i in range(4)) + ] = ([] for i in range(3)) print("\nPackages with name matching [ {0}{1}{2} ]\n".format( CYAN, ", ".join(self.binary), ENDC)) for pkg in self.binary: @@ -162,7 +161,6 @@ class PackageManager(object): shell=True)) rmv_list.append(dep) os.remove(dep_path + rmv) - rmv_dependencies += dependencies[:-1] else: if find_package(rmv + sp, pkg_path): print(subprocess.check_output( diff --git a/slpkg/queue.py b/slpkg/queue.py index 6e719dd7..7fc58f4e 100755 --- a/slpkg/queue.py +++ b/slpkg/queue.py @@ -79,20 +79,20 @@ class QueuePkgs(object): ''' Print packages from queue ''' - exit = 0 + quit = 0 print("\nPackages in queue:\n") for pkg in self.packages(): if pkg: print("{0}{1}{2}".format(GREEN, pkg, ENDC)) - exit = 1 - if exit == 1: + quit = 1 + if quit == 1: print # new line at exit def add(self, pkgs): ''' Add packages in queue if not exist ''' - exit = 0 + quit = 0 queue_list = self.packages() pkgs = set(pkgs) print("\nAdd packages in queue:\n") @@ -102,19 +102,19 @@ class QueuePkgs(object): if pkg not in queue_list and find is not None: print("{0}{1}{2}".format(GREEN, pkg, ENDC)) queue.write(pkg + "\n") - exit = 1 + quit = 1 else: print("{0}{1}{2}".format(RED, pkg, ENDC)) - exit = 1 + quit = 1 queue.close() - if exit == 1: + if quit == 1: print # new line at exit def remove(self, pkgs): ''' Remove packages from queue ''' - exit = 0 + quit = 0 print("\nRemove packages from queue:\n") if pkgs == ["all"]: pkgs = self.packages() @@ -124,9 +124,9 @@ class QueuePkgs(object): queue.write(line + "\n") else: print("{0}{1}{2}".format(RED, line, ENDC)) - exit = 1 + quit = 1 queue.close() - if exit == 1: + if quit == 1: print # new line at exit def build(self): diff --git a/slpkg/sbo/tracking.py b/slpkg/sbo/tracking.py index 65469ee5..567f80ac 100755 --- a/slpkg/sbo/tracking.py +++ b/slpkg/sbo/tracking.py @@ -28,10 +28,10 @@ from init import initialization from __metadata__ import pkg_path, sp from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC -from dependency import sbo_dependencies_pkg - from pkg.find import find_package +from dependency import sbo_dependencies_pkg + def track_dep(name): ''' diff --git a/slpkg/sbo/views.py b/slpkg/sbo/views.py index 540b8fdb..3c08b888 100755 --- a/slpkg/sbo/views.py +++ b/slpkg/sbo/views.py @@ -53,13 +53,15 @@ def sbo_network(name): sys.stdout.flush() initialization() sbo_url = sbo_search_pkg(name) + sys.stdout.write(done) if sbo_url: grep = SBoGrep(name) sbo_desc = grep.description()[len(name) + 2:-1] sbo_req = grep.requires() source_dwn = grep.source().split() sbo_dwn = sbo_slackbuild_dwn(sbo_url) - sys.stdout.write(done) + sbo_version = grep.version() + prgnam = ("{0}-{1}".format(name, sbo_version)) view_sbo(name, sbo_url, sbo_desc, sbo_dwn.split("/")[-1], ", ".join([src.split("/")[-1] for src in source_dwn]), sbo_req) @@ -71,72 +73,30 @@ def sbo_network(name): FAULT = "".join(source_dwn) while True: try: - read = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC)) + choice = raw_input(" {0}Choose an option: {1}".format(GREY, + ENDC)) except KeyboardInterrupt: print # new line at exit break - if read == "D" or read == "d": - path = "" - Download(path, sbo_dwn).start() - for src in source_dwn: - Download(path, src).start() + if choice in ["D", "d"]: + download("", sbo_dwn, source_dwn) break - elif read == "R" or read == "r": + elif choice in ["R", "r"]: readme = "README" pydoc.pager(read_readme(sbo_url, readme)) - elif read == "F" or read == "f": + elif choice in ["F", "f"]: _info = ".info" pydoc.pager(read_info_slackbuild(sbo_url, name, _info)) - elif read == "S" or read == "s": + elif choice in ["S", "s"]: _SlackBuild = ".SlackBuild" pydoc.pager(read_info_slackbuild(sbo_url, name, _SlackBuild)) - elif read == "B" or read == "b": - if FAULT: - print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC)) - sys.exit() - if not os.path.exists(build_path): - os.mkdir(build_path) - sources = [] - os.chdir(build_path) - script = sbo_dwn.split("/")[-1] - Download(build_path, sbo_dwn).start() - for src in source_dwn: - Download(build_path, src).start() - sources.append(src.split("/")[-1]) - build_package(script, sources, build_path) + elif choice in ["B", "b"]: + build(sbo_dwn, source_dwn, FAULT) break - elif read == "I" or read == "i": - if FAULT: - print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC)) - sys.exit() - if not os.path.exists(build_path): - os.mkdir(build_path) - sbo_version = grep.version() - prgnam = ("{0}-{1}".format(name, sbo_version)) + elif choice in ["I", "i"]: if not find_package(prgnam + sp, pkg_path): - sources = [] - os.chdir(build_path) - Download(build_path, sbo_dwn).start() - script = sbo_dwn.split("/")[-1] - for src in source_dwn: - Download(build_path, src).start() - sources.append(src.split("/")[-1]) - build_package(script, sources, build_path) - # Searches the package name and version in /tmp to install. - # If find two or more packages e.g. to build tag - # 2 or 3 will fit most. - binary_list = [] - for search in find_package(prgnam, tmp): - if "_SBo" in search: - binary_list.append(search) - try: - binary = (tmp + max(binary_list)).split() - except ValueError: - build_FAILED(sbo_url, prgnam) - sys.exit() - print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC, - name)) - PackageManager(binary).upgrade() + build(sbo_dwn, source_dwn, FAULT) + install(name, prgnam, sbo_url) break else: template(78) @@ -146,6 +106,52 @@ def sbo_network(name): else: break else: - sys.stdout.write(done) message = "Can't view" pkg_not_found("\n", name, message, "\n") + + +def download(path, sbo_dwn, source_dwn): + ''' + Download sources + ''' + Download(path, sbo_dwn).start() + for src in source_dwn: + Download(path, src).start() + + +def build(sbo_dwn, source_dwn, FAULT): + ''' + Only build and create Slackware package + ''' + if FAULT: + print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC)) + sys.exit() + if not os.path.exists(build_path): + os.mkdir(build_path) + sources = [] + os.chdir(build_path) + Download(build_path, sbo_dwn).start() + script = sbo_dwn.split("/")[-1] + for src in source_dwn: + Download(build_path, src).start() + sources.append(src.split("/")[-1]) + build_package(script, sources, build_path) + + +def install(name, prgnam, sbo_url): + ''' + Install Slackware package found in /tmp + directory. + ''' + binary_list = [] + for search in find_package(prgnam, tmp): + if "_SBo" in search: + binary_list.append(search) + try: + binary = (tmp + max(binary_list)).split() + except ValueError: + build_FAILED(sbo_url, prgnam) + sys.exit() + print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC, + name)) + PackageManager(binary).upgrade() diff --git a/slpkg/slack/mirrors.py b/slpkg/slack/mirrors.py index e11b939d..1c6a9f12 100755 --- a/slpkg/slack/mirrors.py +++ b/slpkg/slack/mirrors.py @@ -22,6 +22,7 @@ # along with this program. If not, see . from __metadata__ import arch + from slack_version import slack_ver