upgrade all SBo packages

This commit is contained in:
Dimitris Zlatanidis 2014-08-25 02:15:51 +03:00
parent 1249a58d0f
commit e7c63851b6

View file

@ -32,69 +32,88 @@ from pkg.manager import pkg_upgrade
from colors import colors from colors import colors
from functions import get_file from functions import get_file
from messages import pkg_not_found, template from messages import pkg_not_found, template
from __metadata__ import tmp, pkg_path, arch, sp from __metadata__ import tmp, pkg_path, sp
from __metadata__ import sbo_arch, sbo_tag, sbo_filetype, build_path from __metadata__ import sbo_arch, sbo_tag, sbo_filetype, build_path
from search import sbo_search_pkg from search import sbo_search_pkg
from download import sbo_slackbuild_dwn from download import sbo_slackbuild_dwn
from greps import sbo_source_dwn, sbo_version_pkg from greps import sbo_source_dwn, sbo_version_pkg
def sbo_check(name): def sbo_check():
''' '''
Check for new package updates Upgrade all slackbuilds packages from slackbuilds.org
repository
''' '''
sys.stdout.write("Reading package lists ...") sys.stdout.write("Reading package lists ...")
sbo_file = "".join(find_package(name + sp, pkg_path)) sys.stdout.flush()
if sbo_file == "": index, toolbar_width = 0, 3
sys.stdout.write("Done\n") sbo_list, pkg_name, sbo_ver, pkg_for_upg = [], [], [], []
message = "Not installed" for pkg in os.listdir(pkg_path):
bol, eol = "\n", "\n" if "_SBo" in pkg:
pkg_not_found(bol, name, message, eol) sbo_list.append(pkg)
else: for pkg in sbo_list:
sys.stdout.flush() index += 1
sbo_url = sbo_search_pkg(name) if index == toolbar_width:
if sbo_url is None: sys.stdout.write(".")
sys.stdout.write("Done\n") sys.stdout.flush()
message = "From slackbuilds.org" toolbar_width += 3
bol, eol = "\n", "\n" if "-x86_64-" in pkg:
pkg_not_found(bol, name, message, eol) arch = "x86_64"
elif "-i486-" in pkg:
arch = "i486"
elif "-arm-" in pkg:
arch = "i686"
elif "-noarch-" in pkg:
arch = "noarch"
else: else:
sys.stdout.write("Done\n") arch = os.uname()[4]
sbo_version = sbo_version_pkg(name) name = pkg[:-(len(arch) + len("_SBo") + 3)]
sbo_dwn = sbo_slackbuild_dwn(sbo_url, name) pkg_version = get_file(name, "-")
source_dwn = sbo_source_dwn(sbo_url, name) pkg_version = pkg_version[1:]
extra_dwn = sbo_extra_dwn(sbo_url, name) name = name[:-(len(pkg_version) + 1)]
sbo_file_version = sbo_file[len(name) + 1:-len(arch) - 7] sbo_url = sbo_search_pkg(name)
if sbo_version > sbo_file_version: sbo_version = sbo_version_pkg(name)
print("\n{0}New version is available:{1}".format( if sbo_version > pkg_version:
colors.YELLOW, colors.ENDC)) pkg_name.append(name)
template(78) pkg_for_upg.append(name + "-" + pkg_version)
print("| Package {0} {1} --> {2} {3}".format( sbo_ver.append(sbo_version)
name, sbo_file_version, name, sbo_version)) sys.stdout.write("Done\n")
template(78) if pkg_for_upg:
print # new line at start print("\nThese packages need upgrading:\n")
try: template(78)
read = raw_input("Would you like to install [Y/n]? ") print "| Package", " "*15, "New version", " "*5, "Arch", " "*7, "Repository"
except KeyboardInterrupt: template(78)
print # new line at exit print("Upgrading:")
sys.exit() for upg, ver in zip(pkg_for_upg, sbo_ver):
if read == "Y" or read == "y": print " ", upg, " "*(22-len(upg)), ver, " "*(
if not os.path.exists(build_path): 16-len(ver)), arch, " "*(11-len(arch)), "SBo"
os.mkdir(build_path) msg_pkg = "package"
os.chdir(build_path) if len(pkg_for_upg) > 1:
pkg_for_install = ("{0}-{1}".format(name, sbo_version)) msg_pkg = msg_pkg + "s"
script = get_file(sbo_dwn, "/") print("\nInstalling summary")
source = get_file(source_dwn, "/") print("=" * 79)
print("\n{0}Start -->{1}\n".format(colors.GREEN, colors.ENDC)) print("Total {0} {1} will be upgrading.\n".format(len(pkg_for_upg), msg_pkg))
subprocess.call("wget -N {0} {1}".format(sbo_dwn, source_dwn), shell=True) read = raw_input("Would you like to upgrade [Y/n]? ")
extra = [] if read == "Y" or read == "y":
if extra_dwn: if not os.path.exists(build_path):
for src in extra_dwn.split(): os.mkdir(build_path)
subprocess.call("wget -N {0}".format(src), shell=True) os.chdir(build_path)
extra.append(get_file(src, "/")) for name, version in zip(pkg_name, sbo_ver):
build_package(script, source, extra, build_path) pkg_for_install = ("{0}-{1}".format(name, version))
binary = ("{0}{1}{2}{3}{4}".format( sbo_url = sbo_search_pkg(name)
tmp, pkg_for_install, sbo_arch, sbo_tag, sbo_filetype).split()) sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
pkg_upgrade(binary) src_dwn = sbo_source_dwn(name).split()
else: script = get_file(sbo_dwn, "/")
print("\nPackage {0}-{1} is up to date\n".format(name, sbo_file_version)) print("\n{0}Start -->{1} {2}\n".format(colors.GREEN, colors.ENDC, name))
subprocess.call("wget -N {0}".format(sbo_dwn), shell=True)
sources = []
for src in src_dwn:
subprocess.call("wget -N {0}".format(src), shell=True)
sources.append(get_file(src, "/"))
build_package(script, sources, build_path)
binary = ("{0}{1}{2}{3}{4}".format(
tmp, pkg_for_install, sbo_arch, sbo_tag, sbo_filetype).split())
pkg_upgrade(binary)
print("Completed!\n")
else:
print("\nAll packages are up to date\n")