fix support multi-packages

This commit is contained in:
Dimitris Zlatanidis 2015-01-14 16:31:10 +02:00
parent f15fc05a3c
commit f797bbc9a3
7 changed files with 664 additions and 364 deletions

View file

@ -50,7 +50,7 @@ from __metadata__ import (
from pkg.build import BuildPackage
from pkg.manager import PackageManager
from sbo.check import SBoCheck
from sbo.check import exists
from sbo.views import SBoNetwork
from sbo.slackbuild import SBoInstall
@ -73,10 +73,10 @@ class Case(object):
Slack(self.package).start()
def others_install(self, repo):
OthersInstall(self.package, repo, slack_rel).start()
OthersInstall(self.package, repo, self.release).start()
def sbo_upgrade(self):
SBoCheck().start()
SBoInstall(exists()).start()
def slack_upgrade(self):
Patches(self.release).start()
@ -107,126 +107,126 @@ def main():
'-o', '-r', '-d'
]
if len(args) == 1 and args[0] == "update":
if len(args) == 1 and args[0] == 'update':
Update().repository()
if len(args) == 2 and args[0] == "update" and args[1] == "slpkg":
if len(args) == 2 and args[0] == 'update' and args[1] == 'slpkg':
it_self_update()
if len(args) == 1 and args[0] == "repo-list":
if len(args) == 1 and args[0] == 'repo-list':
RepoList().repos()
if len(args) == 0:
usage('')
elif (len(args) == 1 and args[0] == "-h" or
args[0] == "--help" and args[1:] == []):
elif (len(args) == 1 and args[0] == '-h' or
args[0] == '--help' and args[1:] == []):
options()
if (len(args) == 1 and args[0] == "-v" or
args[0] == "--version" and args[1:] == []):
if (len(args) == 1 and args[0] == '-v' or
args[0] == '--version' and args[1:] == []):
prog_version()
if len(args) == 3 and args[0] == "repo-add":
if len(args) == 3 and args[0] == 'repo-add':
Repo().add(args[1], args[2])
if len(args) == 2 and args[0] == "repo-remove":
if len(args) == 2 and args[0] == 'repo-remove':
Repo().remove(args[1])
# checking if repositories exists
check_exists_repositories()
if len(args) == 1 and args[0] == "re-create":
if len(args) == 1 and args[0] == 're-create':
Initialization().re_create()
if (len(args) == 2 and args[0] == "repo-info" and
if (len(args) == 2 and args[0] == 'repo-info' and
args[1] in RepoList().all_repos):
del RepoList().all_repos
RepoInfo().view(args[1])
elif (len(args) == 2 and args[0] == "repo-info" and
elif (len(args) == 2 and args[0] == 'repo-info' and
args[1] not in RepoList().all_repos):
usage(args[1])
if len(args) == 3 and args[0] == "-a":
if len(args) == 3 and args[0] == '-a':
BuildPackage(args[1], args[2:], path).build()
elif len(args) == 2 and args[0] == "-l":
elif len(args) == 2 and args[0] == '-l':
if args[1] in ['all', 'official', 'non-official']:
PackageManager(None).list(args[1], False)
else:
usage('')
elif len(args) == 3 and args[0] == "-l" and args[2] == '--index':
elif len(args) == 3 and args[0] == '-l' and args[2] == '--index':
if args[1] in ['all', 'official', 'non-official']:
PackageManager(None).list(args[1], True)
else:
usage('')
elif len(args) == 3 and args[0] == "-c" and args[2] == "--upgrade":
elif len(args) == 3 and args[0] == '-c' and args[2] == '--upgrade':
if args[1] in repositories and args[1] not in ['slack', 'sbo']:
Case('').others_upgrade(args[1])
elif args[1] in ['slack', 'sbo']:
upgrade = {
'sbo': Case(args[2]).sbo_upgrade,
'slack': Case(args[2]).slack_upgrade
'sbo': Case('').sbo_upgrade,
'slack': Case('').slack_upgrade
}
upgrade[args[1]]()
else:
usage(args[1])
elif len(args) == 3 and args[0] == "-s":
elif len(args) >= 3 and args[0] == '-s':
if args[1] in repositories and args[1] not in ['slack', 'sbo']:
Case(args[2]).others_install(args[1])
Case(args[2:]).others_install(args[1])
elif args[1] in ['slack', 'sbo']:
install = {
'sbo': Case(args[2]).sbo_install,
'sbo': Case(args[2:]).sbo_install,
'slack': Case(args[2]).slack_install
}
install[args[1]]()
else:
usage(args[1])
elif (len(args) == 3 and args[0] == "-t" and args[1] in repositories):
elif (len(args) == 3 and args[0] == '-t' and args[1] in repositories):
track_dep(args[2], args[1])
elif len(args) == 2 and args[0] == "-n" and "sbo" in repositories:
elif len(args) == 2 and args[0] == '-n' and 'sbo' in repositories:
SBoNetwork(args[1]).view()
elif len(args) == 2 and args[0] == "-b" and args[1] == "--list":
elif len(args) == 2 and args[0] == '-b' and args[1] == '--list':
blacklist.listed()
elif len(args) > 2 and args[0] == "-b" and args[-1] == "--add":
elif len(args) > 2 and args[0] == '-b' and args[-1] == '--add':
blacklist.add(args[1:-1])
elif len(args) > 2 and args[0] == "-b" and args[-1] == "--remove":
elif len(args) > 2 and args[0] == '-b' and args[-1] == '--remove':
blacklist.remove(args[1:-1])
elif len(args) == 2 and args[0] == "-q" and args[1] == "--list":
elif len(args) == 2 and args[0] == '-q' and args[1] == '--list':
queue.listed()
elif len(args) > 2 and args[0] == "-q" and args[-1] == "--add":
elif len(args) > 2 and args[0] == '-q' and args[-1] == '--add':
queue.add(args[1:-1])
elif len(args) > 2 and args[0] == "-q" and args[-1] == "--remove":
elif len(args) > 2 and args[0] == '-q' and args[-1] == '--remove':
queue.remove(args[1:-1])
elif len(args) == 2 and args[0] == "-q" and args[1] == "--build":
elif len(args) == 2 and args[0] == '-q' and args[1] == '--build':
queue.build()
elif len(args) == 2 and args[0] == "-q" and args[1] == "--install":
elif len(args) == 2 and args[0] == '-q' and args[1] == '--install':
queue.install()
elif len(args) == 2 and args[0] == "-q" and args[1] == "--build-install":
elif len(args) == 2 and args[0] == '-q' and args[1] == '--build-install':
queue.build()
queue.install()
elif len(args) > 1 and args[0] == "-i":
elif len(args) > 1 and args[0] == '-i':
PackageManager(args[1:]).install()
elif len(args) > 1 and args[0] == "-u":
elif len(args) > 1 and args[0] == '-u':
PackageManager(args[1:]).upgrade()
elif len(args) > 1 and args[0] == "-o":
elif len(args) > 1 and args[0] == '-o':
PackageManager(args[1:]).reinstall()
elif len(args) > 1 and args[0] == "-r":
elif len(args) > 1 and args[0] == '-r':
PackageManager(args[1:]).remove()
elif len(args) > 1 and args[0] == "-f":
elif len(args) > 1 and args[0] == '-f':
PackageManager(args[1:]).find()
elif len(args) == 3 and args[0] == "-p" and args[1] in repositories:
PkgDesc(args[2], args[1], "").view()
elif len(args) == 4 and args[0] == "-p" and args[3].startswith("--color="):
elif len(args) == 3 and args[0] == '-p' and args[1] in repositories:
PkgDesc(args[2], args[1], '').view()
elif len(args) == 4 and args[0] == '-p' and args[3].startswith('--color='):
colors = ['red', 'green', 'yellow', 'cyan', 'grey']
tag = args[3][len("--color="):]
tag = args[3][len('--color='):]
if args[1] in repositories and tag in colors:
PkgDesc(args[2], args[1], tag).view()
else:
usage(args[1])
elif len(args) > 1 and args[0] == "-d":
elif len(args) > 1 and args[0] == '-d':
PackageManager(args[1:]).display()
elif len(args) == 2 and args[0] == "-g" and args[1].startswith("--config"):
editor = args[1][len("--config="):]
if args[1] == "--config":
elif len(args) == 2 and args[0] == '-g' and args[1].startswith('--config'):
editor = args[1][len('--config='):]
if args[1] == '--config':
Config().view()
elif editor:
Config().edit(editor)
@ -238,5 +238,5 @@ def main():
else:
usage('')
if __name__ == "__main__":
if __name__ == '__main__':
main()

View file

@ -27,28 +27,32 @@ from slpkg.toolbar import status
from greps import Requires
dep_results = []
class Dependencies(object):
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)
def __init__(self):
self.dep_results = []
def others(self, name, repo):
'''
Build all dependencies of a package
'''
try:
sys.setrecursionlimit(10000)
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:
self.dep_results.append(dependencies)
for dep in dependencies:
self.others(dep, repo)
return self.dep_results
except KeyboardInterrupt:
print("") # new line at exit
sys.exit(0)

View file

@ -53,18 +53,22 @@ from slpkg.pkg.manager import PackageManager
from slpkg.slack.slack_version import slack_ver
from greps import repo_data
from dependency import dependencies_pkg
from dependency import Dependencies
class OthersInstall(object):
def __init__(self, package, repo, version):
self.package = package
def __init__(self, packages, repo, version):
self.packages = packages
self.repo = repo
self.version = version
self.tmp_path = slpkg_tmp_packages
self.dwn, self.dep_dwn = [], []
self.install, self.dep_install = [], []
self.comp_sum, self.dep_comp_sum = [], []
self.uncomp_sum, self.dep_uncomp_sum = [], []
self.deps_pass = False
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
color['CYAN'], self.package, color['ENDC']))
color['CYAN'], ', '.join(self.packages), color['ENDC']))
sys.stdout.write("{0}Reading package lists ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
@ -78,7 +82,6 @@ class OthersInstall(object):
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)
@ -170,222 +173,113 @@ class OthersInstall(object):
'''
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)
(self.dwn, self.install, self.comp_sum,
self.uncomp_sum) = self.store(self.packages)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
dependencies = self.resolving_deps()
self.deps_pass = True
(self.dep_dwn, self.dep_install, self.dep_comp_sum,
self.dep_uncomp_sum) = self.store(dependencies)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
print("") # new line at start
if self.install:
self.top_view()
print("Installing:")
self.views(self.install, self.comp_sum)
if dependencies:
print("Installing for dependencies:")
self.views(self.dep_install, self.dep_comp_sum)
def store(self, deps):
def resolving_deps(self):
'''
Store and return packages for install
Return package dependencies
'''
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:
requires, dependencies = [], []
sys.stdout.write("{0}Resolving dependencies ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
for dep in self.packages:
deps = Dependencies().others(dep, self.repo)
# 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 views(self, install, comp_sum):
'''
Views packages
'''
pkg_sum = uni_sum = upg_sum = 0
# fix repositories align
self.repo = self.repo + (' ' * (6 - (len(self.repo))))
for pkg, comp in zip(install, 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])), self.repo,
comp, " K"))
return [pkg_sum, upg_sum, uni_sum]
def top_view(self):
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)
def store(self, packages):
'''
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)
for pkg in packages:
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()
if not install:
for pkg in packages:
for name, loc, comp, uncomp in zip(data[0], data[1],
data[2], data[3]):
if pkg in split_package(name)[0] and not self.deps_pass:
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]

391
slpkg/others/install2.py Normal file
View file

@ -0,0 +1,391 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# install.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
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()

View file

@ -42,21 +42,25 @@ def exists():
and it gets to avoidable modified packages
from the user with the tag _SBo
'''
sys.stdout.write("{0}Checking ...{1}".format(color['GREY'],
color['ENDC']))
upgrade_names = []
index, toolbar_width = 0, 3
for pkg in sbo_list():
index += 1
toolbar_width = status(index, toolbar_width, 4)
name = split_package(pkg)[0]
if sbo_search_pkg(name):
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
package = ("{0}-{1}".format(name, split_package(pkg)[1]))
if sbo_package > package:
upgrade_names.append(name)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
return upgrade_names
try:
sys.stdout.write("{0}Checking ...{1}".format(color['GREY'],
color['ENDC']))
upgrade_names = []
index, toolbar_width = 0, 3
for pkg in sbo_list():
index += 1
toolbar_width = status(index, toolbar_width, 4)
name = split_package(pkg)[0]
if sbo_search_pkg(name):
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
package = ("{0}-{1}".format(name, split_package(pkg)[1]))
if sbo_package > package:
upgrade_names.append(name)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
return upgrade_names
except KeyboardInterrupt:
print("") # new line at exit
sys.exit(0)
def sbo_list():

View file

@ -71,68 +71,75 @@ class SBoInstall(object):
sys.stdout.flush()
def start(self):
dependencies, tagc, match = [], '', False
count_ins = count_upg = count_uni = 0
for sbo in self.slackbuilds:
sbo_deps = []
self.index += 1
self.toolbar_width = status(self.index, self.toolbar_width, 4)
if sbo_search_pkg(sbo):
sbo_deps = Requires().sbo(sbo)
self.deps += sbo_deps
self.deps_dict[sbo] = self.one_for_all(sbo_deps)
self.package_found.append(sbo)
else:
self.package_not_found.append(sbo)
if not self.package_found:
match = True
self.package_found = self.matching(self.package_not_found)
self.dependencies, dep_src = self.sbo_version_source(
self.one_for_all(self.deps))
self.master_packages, mas_src = self.sbo_version_source(
self.package_found)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
print("\nThe following packages will be automatically "
"installed or upgraded \nwith new version:\n")
self.top_view()
for sbo, ar in zip(self.master_packages, mas_src):
if sbo not in dependencies:
tagc, count_ins, count_upg, count_uni = self.tag(sbo,
count_ins,
count_upg,
count_uni)
self.view_packages(tagc, '-'.join(sbo.split('-')[:-1]),
sbo.split('-')[-1], self.select_arch(ar))
if not match:
print("Installing for dependencies:")
for dep, ar in zip(self.dependencies, dep_src):
tagc, count_ins, count_upg, count_uni = self.tag(dep, count_ins,
count_upg,
count_uni)
self.view_packages(tagc, '-'.join(dep.split('-')[:-1]),
dep.split('-')[-1], self.select_arch(ar))
try:
dependencies, tagc, match = [], '', False
count_ins = count_upg = count_uni = 0
for sbo in self.slackbuilds:
sbo_deps = []
self.index += 1
self.toolbar_width = status(self.index, self.toolbar_width, 4)
if sbo_search_pkg(sbo):
sbo_deps = Requires().sbo(sbo)
self.deps += sbo_deps
self.deps_dict[sbo] = self.one_for_all(sbo_deps)
self.package_found.append(sbo)
else:
self.package_not_found.append(sbo)
if not self.package_found:
match = True
self.package_found = self.matching(self.package_not_found)
self.dependencies, dep_src = self.sbo_version_source(
self.one_for_all(self.deps))
self.master_packages, mas_src = self.sbo_version_source(
self.package_found)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'],
color['ENDC']))
if self.package_found:
print("\nThe following packages will be automatically "
"installed or upgraded \nwith new version:\n")
self.top_view()
for sbo, ar in zip(self.master_packages, mas_src):
if sbo not in dependencies:
tagc, count_ins, count_upg, count_uni = self.tag(
sbo, count_ins, count_upg, count_uni)
self.view_packages(tagc, '-'.join(sbo.split('-')[:-1]),
sbo.split('-')[-1],
self.select_arch(ar))
if not match:
print("Installing for dependencies:")
for dep, ar in zip(self.dependencies, dep_src):
tagc, count_ins, count_upg, count_uni = self.tag(
dep, count_ins, count_upg, count_uni)
self.view_packages(tagc, '-'.join(dep.split('-')[:-1]),
dep.split('-')[-1], self.select_arch(ar))
count_total = (count_ins + count_upg + count_uni)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(
color['GREY'], count_total, self.msg(count_total)))
print("{0} {1} will be installed, {2} allready installed and "
"{3} {4}".format(count_uni, self.msg(count_uni), count_ins,
count_upg, self.msg(count_upg)))
print("will be upgraded.{0}\n".format(color['ENDC']))
if self.master_packages:
answer = self.continue_install()
if answer in['y', 'Y']:
# installs = b_ins[0]
# upgraded = b_ins[1]
# versions = b_ins[2]
b_ins = self.build_install()
self.reference(len(b_ins[0]), self.msg(len(b_ins[0])),
len(b_ins[1]), self.msg(len(b_ins[1])),
b_ins[0], b_ins[2], b_ins[1])
self.write_deps()
delete(build_path)
count_total = (count_ins + count_upg + count_uni)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(
color['GREY'], count_total, self.msg(count_total)))
print("{0} {1} will be installed, {2} allready installed and "
"{3} {4}".format(count_uni, self.msg(count_uni),
count_ins, count_upg,
self.msg(count_upg)))
print("will be upgraded.{0}\n".format(color['ENDC']))
if self.master_packages:
answer = self.continue_install()
if answer in['y', 'Y']:
# installs = b_ins[0]
# upgraded = b_ins[1]
# versions = b_ins[2]
b_ins = self.build_install()
self.reference(len(b_ins[0]), self.msg(len(b_ins[0])),
len(b_ins[1]), self.msg(len(b_ins[1])),
b_ins[0], b_ins[2], b_ins[1])
self.write_deps()
delete(build_path)
else:
print('\nNot found packages for installation\n')
except KeyboardInterrupt:
print("") # new line at exit
sys.exit(0)
def matching(self, sbo_not_found):
'''

View file

@ -38,7 +38,7 @@ from sbo.search import sbo_search_pkg
from sbo.dependency import Requires
from others.search import search_pkg
from others.dependency import dependencies_pkg
from others.dependency import Dependencies
def track_dep(name, repo):
@ -55,7 +55,7 @@ def track_dep(name, repo):
dependencies_list = Requires().sbo(name)
find_pkg = sbo_search_pkg(name)
else:
dependencies_list = dependencies_pkg(name, repo)
dependencies_list = Dependencies().others(name, repo)
find_pkg = search_pkg(name, repo)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
if find_pkg: