diff --git a/slpkg/others/__init__.py b/slpkg/others/__init__.py deleted file mode 100644 index 3727bd56..00000000 --- a/slpkg/others/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# [ others ] directory diff --git a/slpkg/others/check.py b/slpkg/others/check.py deleted file mode 100644 index 284dd580..00000000 --- a/slpkg/others/check.py +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# check.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 os -import sys - -from slpkg.sizes import units -from slpkg.remove import delete -from slpkg.toolbar import status -from slpkg.repositories import Repo -from slpkg.messages import template -from slpkg.checksum import check_md5 -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.grep_md5 import pkg_checksum -from slpkg.splitting import split_package -from slpkg.__metadata__ import ( - pkg_path, - lib_path, - slpkg_tmp_packages, - default_answer, - color, - slacke_sub_repo, - default_repositories -) - -from slpkg.pkg.find import find_package -from slpkg.pkg.manager import PackageManager - -from slpkg.slack.slack_version import slack_ver - -from greps import repo_data - - -class OthersUpgrade(object): - - def __init__(self, repo, version): - self.repo = repo - self.version = version - self.tmp_path = slpkg_tmp_packages - sys.stdout.write("{0}Reading package lists ...{1}".format( - color['GREY'], color['ENDC'])) - sys.stdout.flush() - self.step = 700 - - if repo in default_repositories: - exec('self._init_{0}()'.format(self.repo)) - else: - exec('self._init_custom()') - - f = open(self.lib, "r") - self.PACKAGES_TXT = f.read() - f.close() - - def _init_custom(self): - self.lib = lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo) - self.mirror = "{0}".format(Repo().custom_repository()[self.repo]) - - def _init_rlw(self): - self.lib = lib_path + "rlw_repo/PACKAGES.TXT" - self.mirror = "{0}{1}/".format(Repo().rlw(), slack_ver()) - - def _init_alien(self): - self.lib = lib_path + "alien_repo/PACKAGES.TXT" - self.mirror = Repo().alien() - self.step = self.step * 2 - - def _init_slacky(self): - self.lib = lib_path + "slacky_repo/PACKAGES.TXT" - arch = "" - if os.uname()[4] == "x86_64": - arch = "64" - self.mirror = "{0}slackware{1}-{2}/".format(Repo().slacky(), arch, - slack_ver()) - self.step = self.step * 2 - - def _init_studio(self): - self.lib = lib_path + "studio_repo/PACKAGES.TXT" - arch = "" - if os.uname()[4] == "x86_64": - arch = "64" - self.mirror = "{0}slackware{1}-{2}/".format(Repo().studioware(), - arch, slack_ver()) - self.step = self.step * 2 - - def _init_slackr(self): - self.lib = lib_path + "slackr_repo/PACKAGES.TXT" - self.mirror = Repo().slackers() - self.step = self.step * 2 - - def _init_slonly(self): - self.lib = lib_path + "slonly_repo/PACKAGES.TXT" - arch = "{0}-x86".format(slack_ver()) - if os.uname()[4] == "x86_64": - arch = "{0}-x86_64".format(slack_ver()) - self.mirror = "{0}{1}/".format(Repo().slackonly(), arch) - self.step = self.step * 3 - - def _init_ktown(self): - self.lib = lib_path + "ktown_repo/PACKAGES.TXT" - self.mirror = Repo().ktown() - self.step = self.step * 2 - - def _init_multi(self): - self.lib = lib_path + "multi_repo/PACKAGES.TXT" - self.mirror = Repo().multi() - self.step = self.step * 2 - - def _init_slacke(self): - arch = "" - if os.uname()[4] == "x86_64": - arch = "64" - elif os.uname()[4] == "arm": - arch = "arm" - self.lib = lib_path + "slacke_repo/PACKAGES.TXT" - self.mirror = "{0}slacke{1}/slackware{2}-{3}/".format( - Repo().slacke(), slacke_sub_repo[1:-1], arch, slack_ver()) - self.step = self.step * 2 - - def _init_salix(self): - arch = "i486" - if os.uname()[4] == "x86_64": - arch = "x86_64" - self.lib = lib_path + "salix_repo/PACKAGES.TXT" - self.mirror = "{0}{1}/{2}/".format(Repo().salix(), arch, slack_ver()) - self.step = self.step * 2 - - def _init_slackl(self): - arch = "i486" - if os.uname()[4] == "x86_64": - arch = "x86_64" - self.lib = lib_path + "slackl_repo/PACKAGES.TXT" - self.mirror = "{0}{1}/current/".format(Repo().slackel(), arch) - self.step = self.step * 2 - - def _init_rested(self): - self.lib = lib_path + "rested_repo/PACKAGES.TXT" - self.mirror = Repo().restricted() - self.step = self.step * 2 - - def start(self): - ''' - Install packages from official Slackware distribution - ''' - try: - (pkg_for_upgrade, dwn_links, upgrade_all, comp_sum, - uncomp_sum) = self.store() - sys.stdout.write("{0}Done{1}\n".format(color['GREY'], - color['ENDC'])) - print("") # new line at start - if upgrade_all: - template(78) - print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( - "| Package", " " * 17, - "New version", " " * 9, - "Arch", " " * 4, - "Build", " " * 2, - "Repos", " " * 9, - "Size")) - template(78) - print("Upgrading:") - views(pkg_for_upgrade, upgrade_all, comp_sum, self.repo) - unit, size = units(comp_sum, uncomp_sum) - msg = msgs(upgrade_all) - print("\nInstalling summary") - print("=" * 79) - print("{0}Total {1} {2} will be upgraded.".format( - color['GREY'], len(upgrade_all), msg)) - print("Need to get {0} {1} of archives.".format(size[0], - unit[0])) - print("After this process, {0} {1} of additional disk " - "space will be used.{2}".format(size[1], unit[1], - color['ENDC'])) - if default_answer == "y": - answer = default_answer - else: - answer = raw_input("\nWould you like to continue [Y/n]? ") - if answer in ['y', 'Y']: - upgrade_all.reverse() - Download(self.tmp_path, dwn_links).start() - upgrade(self.tmp_path, upgrade_all, self.repo, self.version) - delete(self.tmp_path, upgrade_all) - else: - print("No new updates from repository '{0}'\n".format( - self.repo)) - except KeyboardInterrupt: - print("") # new line at exit - sys.exit(0) - - def store(self): - ''' - Store and return packages for install - ''' - pkg_for_upgrade, dwn, install, comp_sum, uncomp_sum = ( - [] for i in range(5)) - # name = data[0] - # location = data[1] - # size = data[2] - # unsize = data[3] - data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version) - index, toolbar_width = 0, 700 - for pkg in self.installed(): - index += 1 - toolbar_width = status(index, toolbar_width, 10) - for name, loc, comp, uncomp in zip(data[0], data[1], data[2], - data[3]): - inst_pkg = split_package(pkg) - if name: # this tips because some pkg_name is empty - repo_pkg = split_package(name[:-4]) - if (repo_pkg[0] == inst_pkg[0] and - repo_pkg[1] > inst_pkg[1] and - inst_pkg[0] not in BlackList().packages()): - # store downloads packages by repo - dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) - install.append(name) - comp_sum.append(comp) - uncomp_sum.append(uncomp) - pkg_for_upgrade.append('{0}-{1}'.format( - inst_pkg[0], inst_pkg[1])) - return [pkg_for_upgrade, dwn, install, comp_sum, uncomp_sum] - - def installed(self): - ''' - Return all installed packages - ''' - return find_package('', pkg_path) - - -def views(pkg_for_upgrade, upgrade_all, comp_sum, repository): - ''' - Views packages - ''' - upg_sum = 0 - # fix repositories align - repository = repository + (' ' * (6 - (len(repository)))) - for upg, pkg, comp in zip(pkg_for_upgrade, upgrade_all, comp_sum): - pkg_split = split_package(pkg[:-4]) - upg_sum += 1 - print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>10}{12}".format( - color['YELLOW'], upg, color['ENDC'], - " " * (24-len(upg)), pkg_split[1], - " " * (19-len(pkg_split[1])), pkg_split[2], - " " * (8-len(pkg_split[2])), pkg_split[3], - " " * (7-len(pkg_split[3])), repository, - comp, " K")) - return upg_sum - - -def msgs(upgrade_all): - ''' - Print singular plural - ''' - msg_pkg = "package" - if len(upgrade_all) > 1: - msg_pkg = msg_pkg + "s" - return msg_pkg - - -def upgrade(tmp_path, upgrade_all, repo, version): - ''' - Install or upgrade packages - ''' - for pkg in upgrade_all: - package = (tmp_path + pkg).split() - if repo == "alien" and version == "stable": - check_md5(pkg_checksum("/" + slack_ver() + "/" + pkg, repo), - tmp_path + pkg) - elif repo == "alien" and version == "current": - check_md5(pkg_checksum("/" + version + "/" + pkg, repo), - tmp_path + pkg) - else: - check_md5(pkg_checksum(pkg, repo), tmp_path + pkg) - print("[ {0}upgrading{1} ] --> {2}".format(color['YELLOW'], - color['ENDC'], pkg[:-4])) - PackageManager(package).upgrade() diff --git a/slpkg/others/dependency.py b/slpkg/others/dependency.py deleted file mode 100644 index 8996fc5a..00000000 --- a/slpkg/others/dependency.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# dependency.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 slpkg.toolbar import status - -from greps import Requires - -dep_results = [] - - -def dependencies_pkg(name, repo): - ''' - Build all dependencies of a package - ''' - try: - dependencies = [] - requires = Requires(name, repo).get_deps() - toolbar_width, index = 2, 0 - if requires: - for req in requires: - index += 1 - toolbar_width = status(index, toolbar_width, 1) - if req: - dependencies.append(req) - if dependencies: - dep_results.append(dependencies) - for dep in dependencies: - dependencies_pkg(dep, repo) - return dep_results - except KeyboardInterrupt: - print("") # new line at exit - sys.exit(0) diff --git a/slpkg/others/greps.py b/slpkg/others/greps.py deleted file mode 100644 index b32045db..00000000 --- a/slpkg/others/greps.py +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# greps.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 os - -from slpkg.toolbar import status -from slpkg.slack.slack_version import slack_ver -from slpkg.__metadata__ import ( - lib_path, - ktown_kde_repo -) - - -def repo_data(PACKAGES_TXT, step, repo, version): - ''' - Grap data packages - ''' - (name, location, size, unsize, - rname, rlocation, rsize, runsize) = ([] for i in range(8)) - index, toolbar_width = 0, 700 - for line in PACKAGES_TXT.splitlines(): - index += 1 - toolbar_width = status(index, toolbar_width, step) - if line.startswith("PACKAGE NAME"): - if repo == "slackr": - name.append(fix_slackers_pkg(line[15:])) - else: - name.append(line[15:].strip()) - if line.startswith("PACKAGE LOCATION"): - location.append(line[21:].strip()) - if line.startswith("PACKAGE SIZE (compressed): "): - size.append(line[28:-2].strip()) - if line.startswith("PACKAGE SIZE (uncompressed): "): - unsize.append(line[30:-2].strip()) - if repo == "rlw": - (rname, - rlocation, - rsize, - runsize - ) = rlw_filter(name, location, size, unsize) - elif repo == "alien" or repo == "rested": - (rname, - rlocation, - rsize, - runsize - ) = alien_filter(name, location, size, unsize, version) - elif repo == "ktown": - (rname, - rlocation, - rsize, - runsize - ) = ktown_filter(name, location, size, unsize, version) - elif repo == "multi": - (rname, - rlocation, - rsize, - runsize - ) = multi_filter(name, location, size, unsize, version) - else: - rname, rlocation, rsize, runsize = name, location, size, unsize - return [rname, rlocation, rsize, runsize] - - -def rlw_filter(name, location, size, unsize): - ''' - Filter rlw repository data - ''' - arch = os.uname()[4] - if arch.startswith("i") and arch.endswith("86"): - arch = "i486" - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - for n, l, s, u in zip(name, location, size, unsize): - loc = l.split("/") - if arch == loc[-1]: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - return [fname, flocation, fsize, funsize] - - -def alien_filter(name, location, size, unsize, version): - ''' - Filter Alien's repository data - ''' - ver = slack_ver() - if version == "current": - ver = "current" - path_pkg = "pkg" - if os.uname()[4] == "x86_64": - path_pkg = "pkg64" - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - for n, l, s, u in zip(name, location, size, unsize): - if path_pkg == l.split("/")[-2] and ver == l.split("/")[-1]: - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - return [fname, flocation, fsize, funsize] - - -def ktown_filter(name, location, size, unsize, version): - ''' - Filter Alien's ktown repository data - ''' - ver = slack_ver() - if version == "current": - ver = "current" - path_pkg = "x86" - if os.uname()[4] == "x86_64": - path_pkg = os.uname()[4] - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - for n, l, s, u in zip(name, location, size, unsize): - if path_pkg in l and ktown_kde_repo[1:-1] in l and l.startswith(ver): - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - return [fname, flocation, fsize, funsize] - - -def multi_filter(name, location, size, unsize, version): - ''' - Filter Alien's multilib repository data - ''' - ver = slack_ver() - if version == "current": - ver = "current" - (fname, flocation, fsize, funsize) = ([] for i in range(4)) - for n, l, s, u in zip(name, location, size, unsize): - if l.startswith(ver): - fname.append(n) - flocation.append(l) - fsize.append(s) - funsize.append(u) - return [fname, flocation, fsize, funsize] - - -def fix_slackers_pkg(name): - ''' - Fix 'PACKAGE NAME:' from PACKAGES.TXT file - Beacause repository slackers.it not report the full - name in PACKAGES.TXT file use FILELIST.TXT to - get. - ''' - f = open(lib_path + "slackr_repo/FILELIST.TXT", "r") - FILELIST_TXT = f.read() - f.close() - for line in FILELIST_TXT.splitlines(): - if name in line and line.endswith(".txz"): - return line.split("/")[-1].strip() - # This trick fix spliting 'NoneType' packages - # reference wrong name between PACKAGE.TXT and - # FILELIST.TXT - return "" - - -class Requires(object): - - def __init__(self, name, repo): - self.name = name - self.repo = repo - - def get_deps(self): - ''' - Grap package requirements from repositories - ''' - if self.repo == "rlw": - # Robby's repository dependencies as shown in the central page - # http://rlworkman.net/pkgs/ - dependencies = { - "abiword": "wv", - "claws-mail": "libetpan bogofilter html2ps", - "inkscape": "gtkmm atkmm pangomm cairomm mm-common libsigc++ " - "libwpg lxml gsl numpy BeautifulSoup", - "texlive": "libsigsegv texi2html", - "xfburn": "libburn libisofs" - } - if self.name in dependencies.keys(): - return dependencies[self.name].split() - else: - return "" - else: - lib = '{0}{1}_repo/PACKAGES.TXT'.format(lib_path, self.repo) - f = open(lib, "r") - PACKAGES_TXT = f.read() - f.close() - for line in PACKAGES_TXT.splitlines(): - if line.startswith("PACKAGE NAME: "): - pkg_name = line[14:].strip().split('-')[0] - if line.startswith("PACKAGE REQUIRED: "): - if pkg_name == self.name: - if line[17:].strip(): - return self._req_fix(line) - - def _req_fix(self, line): - ''' - Fix slacky and salix requirements because many dependencies splitting - with ',' and others with '|' - ''' - deps = [] - for dep in line[18:].strip().split(','): - dep = dep.split("|") - if self.repo == 'slacky': - if len(dep) > 1: - for d in dep: - deps.append(d.split()[0]) - dep = "".join(dep) - deps.append(dep.split()[0]) - else: - if len(dep) > 1: - for d in dep: - deps.append(d) - deps.append(dep[0]) - return deps diff --git a/slpkg/others/install.py b/slpkg/others/install.py deleted file mode 100644 index e0c96a78..00000000 --- a/slpkg/others/install.py +++ /dev/null @@ -1,391 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# install.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 os -import sys - -from slpkg.sizes import units -from slpkg.remove import delete -from slpkg.repositories import Repo -from slpkg.checksum import check_md5 -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.grep_md5 import pkg_checksum -from slpkg.splitting import split_package -from slpkg.messages import ( - pkg_not_found, - template -) -from slpkg.__metadata__ import ( - pkg_path, - lib_path, - log_path, - slpkg_tmp_packages, - default_answer, - color, - slacke_sub_repo, - default_repositories -) - -from slpkg.pkg.find import find_package -from slpkg.pkg.manager import PackageManager - -from slpkg.slack.slack_version import slack_ver - -from greps import repo_data -from dependency import dependencies_pkg - - -class OthersInstall(object): - - def __init__(self, package, repo, version): - self.package = package - self.repo = repo - self.version = version - self.tmp_path = slpkg_tmp_packages - print("\nPackages with name matching [ {0}{1}{2} ]\n".format( - color['CYAN'], self.package, color['ENDC'])) - sys.stdout.write("{0}Reading package lists ...{1}".format( - color['GREY'], color['ENDC'])) - sys.stdout.flush() - self.step = 700 - - if repo in default_repositories: - exec('self._init_{0}()'.format(self.repo)) - else: - exec('self._init_custom()') - - f = open(self.lib, "r") - self.PACKAGES_TXT = f.read() - f.close() - sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC'])) - - def _init_custom(self): - self.lib = lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo) - self.mirror = "{0}".format(Repo().custom_repository()[self.repo]) - - def _init_rlw(self): - self.lib = lib_path + "rlw_repo/PACKAGES.TXT" - self.mirror = "{0}{1}/".format(Repo().rlw(), slack_ver()) - - def _init_alien(self): - self.lib = lib_path + "alien_repo/PACKAGES.TXT" - self.mirror = Repo().alien() - self.step = self.step * 2 - - def _init_slacky(self): - self.lib = lib_path + "slacky_repo/PACKAGES.TXT" - arch = "" - if os.uname()[4] == "x86_64": - arch = "64" - self.mirror = "{0}slackware{1}-{2}/".format(Repo().slacky(), arch, - slack_ver()) - self.step = self.step * 2 - - def _init_studio(self): - self.lib = lib_path + "studio_repo/PACKAGES.TXT" - arch = "" - if os.uname()[4] == "x86_64": - arch = "64" - self.mirror = "{0}slackware{1}-{2}/".format(Repo().studioware(), - arch, slack_ver()) - self.step = self.step * 2 - - def _init_slackr(self): - self.lib = lib_path + "slackr_repo/PACKAGES.TXT" - self.mirror = Repo().slackers() - self.step = self.step * 2 - - def _init_slonly(self): - self.lib = lib_path + "slonly_repo/PACKAGES.TXT" - arch = "{0}-x86".format(slack_ver()) - if os.uname()[4] == "x86_64": - arch = "{0}-x86_64".format(slack_ver()) - self.mirror = "{0}{1}/".format(Repo().slackonly(), arch) - self.step = self.step * 3 - - def _init_ktown(self): - self.lib = lib_path + "ktown_repo/PACKAGES.TXT" - self.mirror = Repo().ktown() - self.step = self.step * 2 - - def _init_multi(self): - self.lib = lib_path + "multi_repo/PACKAGES.TXT" - self.mirror = Repo().multi() - self.step = self.step * 2 - - def _init_slacke(self): - arch = "" - if os.uname()[4] == "x86_64": - arch = "64" - elif os.uname()[4] == "arm": - arch = "arm" - self.lib = lib_path + "slacke_repo/PACKAGES.TXT" - self.mirror = "{0}slacke{1}/slackware{2}-{3}/".format( - Repo().slacke(), slacke_sub_repo[1:-1], arch, slack_ver()) - self.step = self.step * 2 - - def _init_salix(self): - arch = "i486" - if os.uname()[4] == "x86_64": - arch = "x86_64" - self.lib = lib_path + "salix_repo/PACKAGES.TXT" - self.mirror = "{0}{1}/{2}/".format(Repo().salix(), arch, slack_ver()) - self.step = self.step * 2 - - def _init_slackl(self): - arch = "i486" - if os.uname()[4] == "x86_64": - arch = "x86_64" - self.lib = lib_path + "slackl_repo/PACKAGES.TXT" - self.mirror = "{0}{1}/current/".format(Repo().slackel(), arch) - self.step = self.step * 2 - - def _init_rested(self): - self.lib = lib_path + "rested_repo/PACKAGES.TXT" - self.mirror = Repo().restricted() - self.step = self.step * 2 - - def start(self): - ''' - Install packages from official Slackware distribution - ''' - try: - dependencies = resolving_deps(self.package, self.repo) - (dwn_links, install_all, comp_sum, uncomp_sum - ) = self.store(dependencies) - dependencies = equal_deps_and_install(dependencies, install_all) - sys.stdout.write("{0}Done{1}\n".format(color['GREY'], - color['ENDC'])) - print("") # new line at start - if install_all: - template(78) - print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( - "| Package", " " * 17, - "Version", " " * 12, - "Arch", " " * 4, - "Build", " " * 2, - "Repos", " " * 10, - "Size")) - template(78) - print("Installing:") - sums = views(install_all, comp_sum, self.repo, dependencies) - unit, size = units(comp_sum, uncomp_sum) - msg = msgs(install_all, sums[2]) - print("\nInstalling summary") - print("=" * 79) - print("{0}Total {1} {2}.".format(color['GREY'], - len(install_all), msg[0])) - print("{0} {1} will be installed, {2} will be upgraded and " - "{3} will be resettled.".format(sums[2], msg[1], - sums[1], sums[0])) - print("Need to get {0} {1} of archives.".format(size[0], - unit[0])) - print("After this process, {0} {1} of additional disk " - "space will be used.{2}".format(size[1], unit[1], - color['ENDC'])) - if default_answer == "y": - answer = default_answer - else: - answer = raw_input("\nWould you like to continue " + - "[Y/n]? ") - if answer in ['y', 'Y']: - install_all.reverse() - Download(self.tmp_path, dwn_links).start() - install(self.tmp_path, install_all, self.repo, - self.version) - write_deps(dependencies) - delete(self.tmp_path, install_all) - else: - pkg_not_found("", self.package, "No matching", "\n") - except KeyboardInterrupt: - print("") # new line at exit - sys.exit(0) - - def store(self, deps): - ''' - Store and return packages for install - ''' - dwn, install, comp_sum, uncomp_sum = ([] for i in range(4)) - black = BlackList().packages() - # name = data[0] - # location = data[1] - # size = data[2] - # unsize = data[3] - data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version) - if len(deps) > 1: - for pkg in deps: - for name, loc, comp, uncomp in zip(data[0], data[1], data[2], - data[3]): - if name.startswith(pkg + "-") and pkg not in black: - # store downloads packages by repo - dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) - install.append(name) - comp_sum.append(comp) - uncomp_sum.append(uncomp) - else: - for name, loc, comp, uncomp in zip(data[0], data[1], data[2], - data[3]): - package = "".join(deps) - if package in name and package not in black: - # store downloads packages by repo - dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) - install.append(name) - comp_sum.append(comp) - uncomp_sum.append(uncomp) - dwn.reverse() - install.reverse() - comp_sum.reverse() - uncomp_sum.reverse() - return [dwn, install, comp_sum, uncomp_sum] - - -def equal_deps_and_install(dependencies, install_all): - ''' - This fixes be written dependencies equal to those that - will be installed because some repositories like 'salix' - said dependencies that exist in the distribution but not - in the repository itself. - ''' - deps = [] - for dep in dependencies: - for inst in install_all: - if inst.startswith(dep + '-'): - deps.append(dep) - return deps - - -def views(install_all, comp_sum, repository, dependencies): - ''' - Views packages - ''' - count = pkg_sum = uni_sum = upg_sum = 0 - # fix repositories align - repository = repository + (' ' * (6 - (len(repository)))) - for pkg, comp in zip(install_all, comp_sum): - pkg_split = split_package(pkg[:-4]) - if find_package(pkg_split[0] + "-" + pkg_split[1], pkg_path): - pkg_sum += 1 - COLOR = color['GREEN'] - elif find_package(pkg_split[0] + "-", pkg_path): - COLOR = color['YELLOW'] - upg_sum += 1 - else: - COLOR = color['RED'] - uni_sum += 1 - print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format( - COLOR, pkg_split[0], color['ENDC'], - " " * (24-len(pkg_split[0])), pkg_split[1], - " " * (18-len(pkg_split[1])), pkg_split[2], - " " * (8-len(pkg_split[2])), pkg_split[3], - " " * (7-len(pkg_split[3])), repository, - comp, " K")) - if len(dependencies) > 1 and len(install_all) > 1 and count == 0: - print("Installing for dependencies:") - count += 1 - return [pkg_sum, upg_sum, uni_sum] - - -def msgs(install_all, uni_sum): - ''' - Print singular plural - ''' - msg_pkg = "package" - msg_2_pkg = msg_pkg - if len(install_all) > 1: - msg_pkg = msg_pkg + "s" - if uni_sum > 1: - msg_2_pkg = msg_2_pkg + "s" - return [msg_pkg, msg_2_pkg] - - -def install(tmp_path, install_all, repo, version): - ''' - Install or upgrade packages - ''' - for install in install_all: - package = (tmp_path + install).split() - if repo == "alien" and version == "stable": - check_md5(pkg_checksum("/" + slack_ver() + "/" + install, repo), - tmp_path + install) - elif repo == "alien" and version == "current": - check_md5(pkg_checksum("/" + version + "/" + install, repo), - tmp_path + install) - else: - check_md5(pkg_checksum(install, repo), tmp_path + install) - if os.path.isfile(pkg_path + install[:-4]): - print("[ {0}reinstalling{1} ] --> {2}".format(color['GREEN'], - color['ENDC'], - install)) - PackageManager(package).reinstall() - elif find_package(split_package(install)[0] + "-", pkg_path): - print("[ {0}upgrading{1} ] --> {2}".format(color['YELLOW'], - color['ENDC'], - install)) - PackageManager(package).upgrade() - else: - print("[ {0}installing{1} ] --> {2}".format(color['GREEN'], - color['ENDC'], - install)) - PackageManager(package).upgrade() - - -def resolving_deps(name, repo): - ''' - Return package dependencies - ''' - requires, dependencies = [], [] - sys.stdout.write("{0}Resolving dependencies ...{1}".format(color['GREY'], - color['ENDC'])) - sys.stdout.flush() - deps = dependencies_pkg(name, repo) - requires.append(name) - # Create one list for all packages - for pkg in deps: - requires += pkg - requires.reverse() - # Remove double dependencies - for duplicate in requires: - if duplicate not in dependencies: - dependencies.append(duplicate) - return dependencies - - -def write_deps(dependencies): - ''' - Write dependencies in a log file - into directory `/var/log/slpkg/dep/` - ''' - if len(dependencies) > 1: - name = dependencies[-1] - if find_package(name + "-", pkg_path): - dep_path = log_path + "dep/" - if not os.path.exists(dep_path): - os.mkdir(dep_path) - if os.path.isfile(dep_path + name): - os.remove(dep_path + name) - if len(dependencies[:-1]) > 0: - with open(dep_path + name, "w") as f: - for dep in dependencies[:-1]: - f.write(dep + "\n") - f.close() diff --git a/slpkg/others/search.py b/slpkg/others/search.py deleted file mode 100644 index 8e22c997..00000000 --- a/slpkg/others/search.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# search.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 slpkg.blacklist import BlackList -from slpkg.splitting import split_package -from slpkg.__metadata__ import ( - lib_path -) - - -def search_pkg(name, repo): - ''' - Search if package exists in PACKAGES.TXT file - and return the name. - ''' - try: - blacklist = BlackList().packages() - with open(lib_path + '{0}_repo/PACKAGES.TXT'.format( - repo), "r") as PACKAGES_TXT: - for line in PACKAGES_TXT: - if line.startswith("PACKAGE NAME: ") and len(line) > 16: - if repo == 'slackr': - pkg_name = line[15:].strip() - else: - pkg_name = split_package(line[15:])[0].strip() - if name == pkg_name and name not in blacklist: - PACKAGES_TXT.close() - return pkg_name - except KeyboardInterrupt: - print("") # new line at exit - sys.exit(0) diff --git a/slpkg/slack/greps.py b/slpkg/slack/greps.py deleted file mode 100644 index 81cf2fff..00000000 --- a/slpkg/slack/greps.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# greps.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 . - -from slpkg.toolbar import status - - -def slack_data(PACKAGES_TXT, step): - ''' - Grap data packages - ''' - (name, location, size, unsize) = ([] for i in range(4)) - index, toolbar_width = 0, 700 - for line in PACKAGES_TXT.splitlines(): - index += 1 - toolbar_width = status(index, toolbar_width, step) - if line.startswith("PACKAGE NAME:"): - name.append(line[15:].strip()) - if line.startswith("PACKAGE LOCATION:"): - location.append(line[21:].strip()) - if line.startswith("PACKAGE SIZE (compressed): "): - size.append(line[28:-2].strip()) - if line.startswith("PACKAGE SIZE (uncompressed): "): - unsize.append(line[30:-2].strip()) - return [name, location, size, unsize] diff --git a/slpkg/slack/install.py b/slpkg/slack/install.py deleted file mode 100644 index 254784be..00000000 --- a/slpkg/slack/install.py +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# install.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 os -import sys - -from slpkg.sizes import units -from slpkg.remove import delete -from slpkg.checksum import check_md5 -from slpkg.blacklist import BlackList -from slpkg.downloader import Download -from slpkg.grep_md5 import pkg_checksum -from slpkg.splitting import split_package -from slpkg.messages import ( - pkg_not_found, - template -) -from slpkg.__metadata__ import ( - pkg_path, - lib_path, - slpkg_tmp_packages, - default_answer, - color -) - -from slpkg.pkg.find import find_package -from slpkg.pkg.manager import PackageManager - -from mirrors import mirrors -from greps import slack_data - - -class Slack(object): - - def __init__(self, slack_pkg): - self.slack_pkg = slack_pkg - self.tmp_path = slpkg_tmp_packages - print("\nPackages with name matching [ {0}{1}{2} ]\n".format( - color['CYAN'], self.slack_pkg, color['ENDC'])) - sys.stdout.write("{0}Reading package lists ...{1}".format( - color['GREY'], color['ENDC'])) - sys.stdout.flush() - lib = lib_path + "slack_repo/PACKAGES.TXT" - f = open(lib, "r") - self.PACKAGES_TXT = f.read() - f.close() - - def start(self): - ''' - Install packages from official Slackware distribution - ''' - try: - dwn_links, install_all, comp_sum, uncomp_sum = self.store() - sys.stdout.write("{0}Done{1}\n\n".format(color['GREY'], - color['ENDC'])) - if install_all: - template(78) - print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( - "| Package", " " * 17, - "Version", " " * 12, - "Arch", " " * 4, - "Build", " " * 2, - "Repos", " " * 10, - "Size")) - template(78) - print("Installing:") - sums = views(install_all, comp_sum) - unit, size = units(comp_sum, uncomp_sum) - msg = msgs(install_all, sums[2]) - print("\nInstalling summary") - print("=" * 79) - print("{0}Total {1} {2}.".format(color['GREY'], - len(install_all), msg[0])) - print("{0} {1} will be installed, {2} will be upgraded and " - "{3} will be resettled.".format(sums[2], msg[1], - sums[1], sums[0])) - print("Need to get {0} {1} of archives.".format(size[0], - unit[0])) - print("After this process, {0} {1} of additional disk space " - "will be used.{2}".format(size[1], unit[1], - color['ENDC'])) - if default_answer == "y": - answer = default_answer - else: - answer = raw_input("\nWould you like to continue [Y/n]? ") - if answer in ['y', 'Y']: - Download(self.tmp_path, dwn_links).start() - install(self.tmp_path, install_all) - delete(self.tmp_path, install_all) - else: - pkg_not_found("", self.slack_pkg, "No matching", "\n") - except KeyboardInterrupt: - print("") # new line at exit - sys.exit(0) - - def store(self): - ''' - Store and return packages for install - ''' - dwn, install, comp_sum, uncomp_sum = ([] for i in range(4)) - data = slack_data(self.PACKAGES_TXT, 700) - black = BlackList().packages() - for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]): - if self.slack_pkg in name and self.slack_pkg not in black: - dwn.append("{0}{1}/{2}".format(mirrors("", ""), loc, name)) - install.append(name) - comp_sum.append(comp) - uncomp_sum.append(uncomp) - return [dwn, install, comp_sum, uncomp_sum] - - -def views(install_all, comp_sum): - ''' - Views packages - ''' - pkg_sum = uni_sum = upg_sum = 0 - for pkg, comp in sorted(zip(install_all, comp_sum)): - pkg_split = split_package(pkg[:-4]) - if os.path.isfile(pkg_path + pkg[:-4]): - pkg_sum += 1 - COLOR = color['GREEN'] - elif find_package(pkg_split[0] + "-", pkg_path): - COLOR = color['YELLOW'] - upg_sum += 1 - else: - COLOR = color['RED'] - uni_sum += 1 - print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format( - COLOR, pkg_split[0], color['ENDC'], - " " * (24-len(pkg_split[0])), pkg_split[1], - " " * (18-len(pkg_split[1])), pkg_split[2], - " " * (8-len(pkg_split[2])), pkg_split[3], - " " * (7-len(pkg_split[3])), "Slack", - comp, " K")) - return [pkg_sum, upg_sum, uni_sum] - - -def msgs(install_all, uni_sum): - ''' - Print singular plural - ''' - msg_pkg = "package" - msg_2_pkg = msg_pkg - if len(install_all) > 1: - msg_pkg = msg_pkg + "s" - if uni_sum > 1: - msg_2_pkg = msg_2_pkg + "s" - return [msg_pkg, msg_2_pkg] - - -def install(tmp_path, install_all): - ''' - Install or upgrade packages - ''' - for install in install_all: - package = (tmp_path + install).split() - check_md5(pkg_checksum(install, "slack"), tmp_path + install) - if os.path.isfile(pkg_path + install[:-4]): - print("[ {0}reinstalling{1} ] --> {2}".format(color['GREEN'], - color['ENDC'], - install)) - PackageManager(package).reinstall() - elif find_package(split_package(install)[0] + "-", pkg_path): - print("[ {0}upgrading{1} ] --> {2}".format(color['YELLOW'], - color['ENDC'], - install)) - PackageManager(package).upgrade() - else: - print("[ {0}installing{1} ] --> {2}".format(color['GREEN'], - color['ENDC'], - install)) - PackageManager(package).upgrade()