update messages, fix create build_path

This commit is contained in:
Dimitris Zlatanidis 2015-01-24 04:55:51 +02:00
parent 776be404d0
commit 47278d792d
8 changed files with 88 additions and 44 deletions

View file

@ -27,12 +27,17 @@ import sys
from slpkg.sizes import units
from slpkg.remove import delete
from slpkg.log_deps import write_deps
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.messages import (
template,
msg_done,
msg_reading,
msg_resolving
)
from slpkg.utils import (
remove_dbs,
dimensional_list
@ -69,9 +74,7 @@ class BinaryInstall(object):
self.dependencies = []
self.deps_dict = {}
self.answer = ''
sys.stdout.write("{0}Reading package lists ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
msg_reading()
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
num_lines = sum(1 for line in self.PACKAGES_TXT)
self.step = (num_lines / 700)
@ -87,16 +90,14 @@ class BinaryInstall(object):
self.packages, self.pkg_ver = self.packages[0], self.packages[1]
mas_sum = dep_sum = sums = [0, 0, 0]
self.pkg_exist()
sys.stdout.write("{0}Done{1}\n".format(color['GREY'],
color['ENDC']))
msg_done()
self.dependencies = self.resolving_deps()
(self.dep_dwn, self.dep_install, self.dep_comp_sum,
self.dep_uncomp_sum) = self.store(self.dependencies)
self.packages = self.clear_masters()
(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']))
msg_done()
print("") # new line at start
if self.install:
self.top_view()
@ -221,9 +222,7 @@ class BinaryInstall(object):
Return package dependencies
'''
requires = []
sys.stdout.write("{0}Resolving dependencies ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
msg_resolving()
for dep in self.packages:
dependencies = []
dependencies = dimensional_list(Dependencies(self.PACKAGES_TXT,

View file

@ -66,13 +66,13 @@ class Case(object):
self.release = slack_rel
def sbo_install(self):
SBoInstall(self.package).start()
SBoInstall(self.package).start(False)
def binary_install(self, repo):
BinaryInstall(self.package, repo, self.release).start(False)
def sbo_upgrade(self):
SBoInstall(sbo_upgrade()).start()
SBoInstall(sbo_upgrade()).start(True)
def slack_upgrade(self):
Patches(self.release).start()

View file

@ -76,3 +76,19 @@ def template(max_len):
Print template
'''
print("+" + "=" * max_len)
def msg_reading():
sys.stdout.write("{0}Reading package lists ...{1}".format(color['GREY'],
color['ENDC']))
sys.stdout.flush()
def msg_resolving():
sys.stdout.write("{0}Resolving dependencies ...{1}".format(color['GREY'],
color['ENDC']))
sys.stdout.flush()
def msg_done():
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))

View file

@ -43,19 +43,21 @@ def sbo_upgrade():
try:
sys.stdout.write("{0}Checking ...{1}".format(color['GREY'],
color['ENDC']))
upgrade_names = []
upgrade_names, pkg_ver = [], []
index, toolbar_width = 0, 3
for pkg in sbo_list():
index += 1
toolbar_width = status(index, toolbar_width, 4)
name = split_package(pkg)[0]
ver = split_package(pkg)[1]
if sbo_search_pkg(name):
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
package = ("{0}-{1}".format(name, split_package(pkg)[1]))
package = ("{0}-{1}".format(name, ver))
if sbo_package > package:
upgrade_names.append(name)
pkg_ver.append(ver)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
return upgrade_names
return upgrade_names, pkg_ver
except KeyboardInterrupt:
print("") # new line at exit
sys.exit(0)

View file

@ -34,8 +34,11 @@ from slpkg.utils import (
)
from slpkg.messages import (
template,
msg_done,
pkg_found,
build_FAILED
msg_reading,
build_FAILED,
msg_resolving
)
from slpkg.__metadata__ import (
tmp,
@ -71,12 +74,15 @@ class SBoInstall(object):
self.deps_dict = {}
self.toolbar_width, self.index = 2, 0
self.answer = ''
sys.stdout.write("{0}Reading package lists ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
msg_reading()
def start(self):
def start(self, if_upgrade):
try:
self.if_upgrade, self.pkg_ver = if_upgrade, []
self.view_version()
if self.if_upgrade:
self.slackbuilds, self.pkg_ver = (self.slackbuilds[0],
self.slackbuilds[1])
tagc, match = '', False
count_ins = count_upg = count_uni = 0
for sbo in self.slackbuilds:
@ -93,30 +99,38 @@ class SBoInstall(object):
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']))
msg_done()
msg_resolving()
self.dependencies, dep_src = self.sbo_version_source(
self.one_for_all(self.deps))
msg_done()
self.master_packages = self.clear_masters()
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):
# view master packages
for sbo, ver, ar in zip(self.master_packages, self.pkg_ver,
mas_src):
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))
name = '-'.join(sbo.split('-')[:-1]) + '-' + ver
if not if_upgrade:
name = '-'.join(sbo.split('-')[:-1])
self.view_packages(tagc, name, sbo.split('-')[-1],
self.select_arch(ar))
if not match and self.dependencies:
print("Installing for dependencies:")
# view 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))
name = '-'.join(dep.split('-')[:-1])
self.view_packages(tagc, name, dep.split('-')[-1],
self.select_arch(ar))
count_total = (count_ins + count_upg + count_uni)
print("\nInstalling summary")
print("=" * 79)
@ -211,6 +225,15 @@ class SBoInstall(object):
"Size"))
template(78)
def view_version(self):
'''
Create empty seats if not upgrade
'''
if not self.if_upgrade:
i = 0
for i in range(len(self.slackbuilds)):
self.pkg_ver.append('')
def view_packages(self, *args):
'''
View slackbuild packages with version and arch
@ -303,6 +326,8 @@ class SBoInstall(object):
'''
slackbuilds = self.dependencies + self.master_packages
installs, upgraded, versions = [], [], []
if not os.path.exists(build_path):
os.makedirs(build_path)
os.chdir(build_path)
for sbo in slackbuilds:
pkg = '-'.join(sbo.split('-')[:-1])

View file

@ -203,6 +203,8 @@ class SBoNetwork(object):
color['ENDC']))
sys.exit(0)
sources = []
if not os.path.exists(build_path):
os.makedirs(build_path)
os.chdir(build_path)
Download(build_path, self.dwn_srcs).start()
script = self.sbo_dwn.split("/")[-1]

View file

@ -28,12 +28,16 @@ import subprocess
from slpkg.sizes import units
from slpkg.url_read import URL
from slpkg.remove import delete
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.messages import (
template,
msg_done,
msg_reading
)
from slpkg.__metadata__ import (
pkg_path,
slpkg_tmp_patches,
@ -55,13 +59,11 @@ class Patches(object):
def __init__(self, version):
self.version = version
self.patch_path = slpkg_tmp_patches
sys.stdout.write("{0}Reading package lists ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
msg_reading()
if self.version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
"patches/")).reading()
self.step = 10
self.step = 20
else:
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading()
self.step = 700
@ -73,8 +75,7 @@ class Patches(object):
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']))
msg_done()
if upgrade_all:
print("\nThese packages need upgrading:\n")
template(78)

View file

@ -21,7 +21,6 @@
# 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 sys
from utils import (
read_file,
@ -29,7 +28,9 @@ from utils import (
dimensional_list
)
from messages import (
template
template,
msg_done,
msg_resolving
)
from __metadata__ import (
lib_path,
@ -54,9 +55,7 @@ def track_dep(name, repo):
if allready installed and color red
if not installed.
'''
sys.stdout.write("{0}Reading package lists ...{1}".format(color['GREY'],
color['ENDC']))
sys.stdout.flush()
msg_resolving()
if repo == "sbo":
dependencies_list = Requires().sbo(name)
find_pkg = sbo_search_pkg(name)
@ -65,7 +64,7 @@ def track_dep(name, repo):
repo))
dependencies_list = Dependencies(PACKAGES_TXT, repo).binary(name)
find_pkg = search_pkg(name, repo)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
msg_done()
if find_pkg:
requires, dependencies = [], []
requires = dimensional_list(dependencies_list)