This commit is contained in:
Dimitris Zlatanidis 2014-08-25 09:01:11 +03:00
parent 2e8fa423af
commit afd81b666b

View file

@ -44,76 +44,78 @@ def sbo_check():
Upgrade all slackbuilds packages from slackbuilds.org
repository
'''
sys.stdout.write("Reading package lists ...")
sys.stdout.flush()
index, toolbar_width = 0, 3
sbo_list, pkg_name, sbo_ver, pkg_for_upg = [], [], [], []
for pkg in os.listdir(pkg_path):
if "_SBo" in pkg:
sbo_list.append(pkg)
for pkg in sbo_list:
index += 1
if index == toolbar_width:
sys.stdout.write(".")
sys.stdout.flush()
toolbar_width += 3
if "-x86_64-" in pkg:
arch = "x86_64"
elif "-i486-" in pkg:
arch = "i486"
elif "-arm-" in pkg:
arch = "i686"
elif "-noarch-" in pkg:
arch = "noarch"
try:
sys.stdout.write("Reading package lists ...")
sys.stdout.flush()
index, toolbar_width = 0, 3
pkg_name, sbo_ver, pkg_for_upg = [], [], []
for pkg in os.listdir(pkg_path):
if "_SBo" in pkg:
index += 1
if index == toolbar_width:
sys.stdout.write(".")
sys.stdout.flush()
toolbar_width += 3
if "-x86_64-" in pkg:
arch = "x86_64"
elif "-i486-" in pkg:
arch = "i486"
elif "-arm-" in pkg:
arch = "i686"
elif "-noarch-" in pkg:
arch = "noarch"
else:
arch = os.uname()[4]
name = pkg[:-(len(arch) + len("_SBo") + 3)]
pkg_version = get_file(name, "-")[1:]
name = name[:-(len(pkg_version) + 1)]
sbo_version = sbo_version_pkg(name)
if sbo_version > pkg_version:
pkg_name.append(name)
pkg_for_upg.append(name + "-" + pkg_version)
sbo_ver.append(sbo_version)
sys.stdout.write("Done\n")
if pkg_for_upg:
print("\nThese packages need upgrading:\n")
template(78)
print "| Package", " "*27, "New version", " "*5, "Arch", " "*7, "Repository"
template(78)
print("Upgrading:")
for upg, ver in zip(pkg_for_upg, sbo_ver):
print " ", upg, " "*(34-len(upg)), ver, " "*(
16-len(ver)), arch, " "*(11-len(arch)), "SBo"
msg_pkg = "package"
if len(pkg_for_upg) > 1:
msg_pkg = msg_pkg + "s"
print("\nInstalling summary")
print("=" * 79)
print("Total {0} {1} will be upgraded.\n".format(len(pkg_for_upg), msg_pkg))
read = raw_input("Would you like to upgrade [Y/n]? ")
if read == "Y" or read == "y":
if not os.path.exists(build_path):
os.mkdir(build_path)
os.chdir(build_path)
for name, version in zip(pkg_name, sbo_ver):
pkg_for_install = ("{0}-{1}".format(name, version))
sbo_url = sbo_search_pkg(name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
src_dwn = sbo_source_dwn(name).split()
script = get_file(sbo_dwn, "/")
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())
print("{0}[ Upgrading ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, name))
pkg_upgrade(binary)
print("Completed!\n")
else:
arch = os.uname()[4]
name = pkg[:-(len(arch) + len("_SBo") + 3)]
pkg_version = get_file(name, "-")
pkg_version = pkg_version[1:]
name = name[:-(len(pkg_version) + 1)]
sbo_url = sbo_search_pkg(name)
sbo_version = sbo_version_pkg(name)
if sbo_version > pkg_version:
pkg_name.append(name)
pkg_for_upg.append(name + "-" + pkg_version)
sbo_ver.append(sbo_version)
sys.stdout.write("Done\n")
if pkg_for_upg:
print("\nThese packages need upgrading:\n")
template(78)
print "| Package", " "*15, "New version", " "*5, "Arch", " "*7, "Repository"
template(78)
print("Upgrading:")
for upg, ver in zip(pkg_for_upg, sbo_ver):
print " ", upg, " "*(22-len(upg)), ver, " "*(
16-len(ver)), arch, " "*(11-len(arch)), "SBo"
msg_pkg = "package"
if len(pkg_for_upg) > 1:
msg_pkg = msg_pkg + "s"
print("\nInstalling summary")
print("=" * 79)
print("Total {0} {1} will be upgrading.\n".format(len(pkg_for_upg), msg_pkg))
read = raw_input("Would you like to upgrade [Y/n]? ")
if read == "Y" or read == "y":
if not os.path.exists(build_path):
os.mkdir(build_path)
os.chdir(build_path)
for name, version in zip(pkg_name, sbo_ver):
pkg_for_install = ("{0}-{1}".format(name, version))
sbo_url = sbo_search_pkg(name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
src_dwn = sbo_source_dwn(name).split()
script = get_file(sbo_dwn, "/")
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")
print("\nAll packages are up to date\n")
except KeyboardInterrupt:
print # new line at exit
sys.exit()