def top_view(): ''' View top template ''' template(78) print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "Version", " " * 10, "Arch", " " * 9, "Repository")) template(78)
def top_view(): ''' View top template ''' template(78) print("{0}{1}{2}{3}{4}{5}{6}".format( "| Package", " " * 30, "Version", " " * 10, "Arch", " " * 9, "Repository")) template(78)
def view(self): ''' View SlackBuild package, read or install them from slackbuilds.org ''' if self.sbo_url: prgnam = ("{0}-{1}".format(self.name, self.sbo_version)) view_sbo( self.name, self.sbo_url, self.sbo_desc, self.sbo_dwn.split("/")[-1], ", ".join([src.split("/")[-1] for src in self.source_dwn]), self.sbo_req) FAULT = error_uns(self.source_dwn) while True: choice = read_choice() if choice in ["D", "d"]: download("", self.sbo_dwn, self.source_dwn) break elif choice in ["R", "r"]: README = Read(self.sbo_url).readme("README") fill = fill_pager(README) pydoc.pager(README + fill) elif choice in ["F", "f"]: info = Read(self.sbo_url).info(self.name, ".info") fill = fill_pager(info) pydoc.pager(info + fill) elif choice in ["S", "s"]: SlackBuild = Read(self.sbo_url).slackbuild( self.name, ".SlackBuild") fill = fill_pager(SlackBuild) pydoc.pager(SlackBuild + fill) elif choice in ["B", "b"]: build(self.sbo_dwn, self.source_dwn, FAULT) break elif choice in ["I", "i"]: if not find_package(prgnam + sp, pkg_path): build(self.sbo_dwn, self.source_dwn, FAULT) install(self.name, prgnam, self.sbo_url) break else: template(78) pkg_found(self.name, self.sbo_version) template(78) break else: break else: pkg_not_found("\n", self.name, "Can't view", "\n")
def view(self): ''' View SlackBuild package, read or install them from slackbuilds.org ''' if self.sbo_url: prgnam = ("{0}-{1}".format(self.name, self.sbo_version)) view_sbo(self.name, self.sbo_url, self.sbo_desc, self.sbo_dwn.split("/")[-1], ", ".join([src.split("/")[-1] for src in self.source_dwn]), self.sbo_req) FAULT = error_uns(self.source_dwn) while True: choice = read_choice() if choice in ["D", "d"]: download("", self.sbo_dwn, self.source_dwn) break elif choice in ["R", "r"]: README = Read(self.sbo_url).readme("README") fill = fill_pager(README) pydoc.pager(README + fill) elif choice in ["F", "f"]: info = Read(self.sbo_url).info(self.name, ".info") fill = fill_pager(info) pydoc.pager(info + fill) elif choice in ["S", "s"]: SlackBuild = Read(self.sbo_url).slackbuild(self.name, ".SlackBuild") fill = fill_pager(SlackBuild) pydoc.pager(SlackBuild + fill) elif choice in ["B", "b"]: build(self.sbo_dwn, self.source_dwn, FAULT) break elif choice in ["I", "i"]: if not find_package(prgnam + sp, pkg_path): build(self.sbo_dwn, self.source_dwn, FAULT) install(self.name, prgnam, self.sbo_url) break else: template(78) pkg_found(self.name, self.sbo_version) template(78) break else: break else: pkg_not_found("\n", self.name, "Can't view", "\n")
def start(self): ''' Install new patches from official Slackware mirrors ''' try: data = slack_data(self.PACKAGES_TXT, self.step) (dwn_links, upgrade_all, comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3], self.version) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) if upgrade_all: print("\nThese packages need upgrading:\n") 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("Upgrading:") views(upgrade_all, comp_sum) unit, size = units(comp_sum, uncomp_sum) print("\nInstalling summary") print("=" * 79) print("{0}Total {1} {2} will be upgraded.".format( GREY, len(upgrade_all), msgs(upgrade_all))) 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], ENDC)) read = raw_input("\nWould you like to upgrade [Y/n]? ") if read == "Y" or read == "y": slack_dwn(self.patch_path, dwn_links) upgrade(self.patch_path, upgrade_all) kernel(upgrade_all) delete(self.patch_path, upgrade_all) else: slack_arch = "" if os.uname()[4] == "x86_64": slack_arch = 64 print("\nSlackware{0} '{1}' v{2} distribution is up to " "date\n".format(slack_arch, self.version, slack_ver())) except KeyboardInterrupt: print # new line at exit sys.exit()
def start(self): ''' Install packages from official Slackware distribution ''' try: data = slack_data(self.PACKAGES_TXT, 700) (dwn_links, install_all, comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3], self.slack_pkg, self.version) sys.stdout.write("{0}Done{1}\n\n".format(GREY, 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(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], ENDC)) read = raw_input("\nWould you like to install [Y/n]? ") if read == "Y" or read == "y": slack_dwn(self.tmp_path, dwn_links) 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()
def track_dep(name): ''' View tree of dependencies and also highlight packages with color green if allready installed and color red if not installed. ''' sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.flush() initialization() dependencies_list = sbo_dependencies_pkg(name) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) if dependencies_list: requires, dependencies = [], [] # Create one list for all packages for pkg in dependencies_list: requires += pkg requires.reverse() # Remove double dependencies for duplicate in requires: if duplicate not in dependencies: dependencies.append(duplicate) if dependencies == []: dependencies = ["No dependencies"] pkg_len = len(name) + 24 print # new line at start template(pkg_len) print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC)) template(pkg_len) print("\\") print(" +---{0}[ Tree of dependencies ]{1}".format(YELLOW, ENDC)) index = 0 for pkg in dependencies: index += 1 if find_package(pkg + sp, pkg_path): print(" |") print(" {0}{1}: {2}{3}{4}".format("+--", index, GREEN, pkg, ENDC)) else: print(" |") print(" {0}{1}: {2}{3}{4}".format("+--", index, RED, pkg, ENDC)) print # new line at end else: print("\nNo package was found to match\n")
def start(self): ''' Install new patches from official Slackware mirrors ''' try: data = slack_data(self.PACKAGES_TXT, self.step) (dwn_links, upgrade_all, comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3], self.version) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) if upgrade_all: print("\nThese packages need upgrading:\n") 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("Upgrading:") views(upgrade_all, comp_sum) unit, size = units(comp_sum, uncomp_sum) print("\nInstalling summary") print("=" * 79) print("{0}Total {1} {2} will be upgraded.".format( GREY, len(upgrade_all), msgs(upgrade_all))) 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], ENDC)) read = raw_input("\nWould you like to upgrade [Y/n]? ") if read == "Y" or read == "y": slack_dwn(self.patch_path, dwn_links) upgrade(self.patch_path, upgrade_all) kernel(upgrade_all) delete(self.patch_path, upgrade_all) else: slack_arch = "" if os.uname()[4] == "x86_64": slack_arch = 64 print("\nSlackware{0} '{1}' v{2} distribution is up to " "date\n".format(slack_arch, self.version, slack_ver())) except KeyboardInterrupt: print # new line at exit sys.exit()
def start(self): ''' Install packages from official Slackware distribution ''' try: data = slack_data(self.PACKAGES_TXT, 700) (dwn_links, install_all, comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3], self.slack_pkg, self.version) sys.stdout.write("{0}Done{1}\n\n".format(GREY, 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(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], ENDC)) read = raw_input("\nWould you like to install [Y/n]? ") if read == "Y" or read == "y": slack_dwn(self.tmp_path, dwn_links) 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()
def build_install(dependencies, sbo_versions, packages_arch): ''' Searches the package name and version in /tmp to install. If find two or more packages e.g. to build tag 2 or 3 will fit most ''' installs, upgraded, versions = [], [], [] create_build_path() os.chdir(build_path) for pkg, ver, ar in zip(dependencies, sbo_versions, packages_arch): prgnam = ("{0}-{1}".format(pkg, ver)) sbo_file = "".join(find_package(prgnam, pkg_path)) if sbo_file: sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7] template(78) pkg_found(pkg, sbo_file_version) template(78) else: sbo_url = sbo_search_pkg(pkg) sbo_link = SBoLink(sbo_url).tar_gz() src_link = SBoGrep(pkg).source().split() script = sbo_link.split("/")[-1] Download(build_path, sbo_link).start() sources = dwn_sources(src_link) BuildPackage(script, sources, build_path).build() binary_list = search_in_tmp(prgnam) try: binary = (tmp + max(binary_list)).split() except ValueError: build_FAILED(sbo_url, prgnam) sys.exit() if find_package(pkg + sp, pkg_path): print("{0}[ Upgrading ] --> {1}{2}".format(GREEN, ENDC, pkg)) upgraded.append(pkg) else: print("{0}[ Installing ] --> {1}{2}".format(GREEN, ENDC, pkg)) PackageManager(binary).upgrade() installs.append(pkg) versions.append(ver) return [installs, upgraded, versions]
def view_sbo(*args): ''' View slackbuild.org ''' print # new line at start template(78) print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0], GREEN, ENDC + args[1])) template(78) print("| {0}Description : {1}{2}".format(GREEN, ENDC, args[2])) print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, args[3])) print("| {0}Sources : {1}{2}".format(GREEN, ENDC, args[4])) print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC, ", ".join(args[5]))) template(78) print(" {0}R{1}EADME View the README file".format(RED, ENDC)) print(" {0}S{1}lackBuild View the SlackBuild file".format( RED, ENDC)) print(" In{0}f{1}o View the Info file".format(RED, ENDC)) print(" {0}D{1}ownload Download this package".format( RED, ENDC)) print(" {0}B{1}uild Download and build".format(RED, ENDC)) print(" {0}I{1}nstall Download/Build/Install".format( RED, ENDC)) print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
def check_md5(sbo_md5, src): ''' MD5 Checksum ''' md5 = md5sum(src) if sbo_md5 != md5: template(78) print("| MD5SUM check for {0} [ {1}FAILED{2} ]".format(src, RED, ENDC)) template(78) print("| Expected: {0}".format(md5)) print("| Found: {0}".format(sbo_md5)) template(78) read = raw_input("\nDo you want to continue [Y/n]? ") if read == "Y" or read == "y": pass else: sys.exit() else: template(78) print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format( src, GREEN, ENDC)) template(78) print # new line after pass checksum
def check_md5(sbo_md5, src): ''' MD5 Checksum ''' md5 = md5sum(src) if sbo_md5 != md5: template(78) print("| MD5SUM check for {0} [ {1}FAILED{2} ]".format(src, RED, ENDC)) template(78) print("| Expected: {0}".format(md5)) print("| Found: {0}".format(sbo_md5)) template(78) read = raw_input("\nDo you want to continue [Y/n]? ") if read == "Y" or read == "y": pass else: sys.exit() else: template(78) print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(src, GREEN, ENDC)) template(78) print # new line after pass checksum
def view_packages(package_for_upgrade, upgrade_version, upgrade_arch): ''' View packages for upgrade ''' print("\nThese packages need upgrading:\n") template(78) print("{0}{1}{2}{3}{4}{5}{6}".format( "| Package", " " * 30, "New version", " " * 6, "Arch", " " * 9, "Repository")) template(78) print("Upgrading:") count_upgraded = count_installed = 0 for upg, ver, arch in zip(package_for_upgrade, upgrade_version, upgrade_arch): if find_package(upg[:-len(ver)], pkg_path): COLOR = YELLOW count_upgraded += 1 else: COLOR = RED count_installed += 1 print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( COLOR, upg, ENDC, " " * (38-len(upg)), GREEN, ver, ENDC, " " * (17-len(ver)), arch, " " * (13-len(arch)), "SBo")) msg_upg = "package" msg_ins = msg_upg if count_upgraded > 1: msg_upg = msg_upg + "s" if count_installed > 1: msg_ins = msg_ins + "s" print("\nInstalling summary") print("=" * 79) print("{0}Total {1} {2} will be upgraded and {3} {4} will be " "installed.{5}\n".format(GREY, count_upgraded, msg_upg, count_installed, msg_ins, ENDC)) return [count_installed, count_upgraded], [msg_ins, msg_upg]
def view_deps(path, package): ''' View dependencies for before remove ''' with open(path + package, "r") as f: dependencies = f.read().split() f.close() print # new line at start template(78) print("| Found dependencies for package {0}:".format(package)) template(78) for dep in dependencies: print("| {0}{1}{2}".format(RED, dep, ENDC)) template(78) return dependencies
def reference_rmvs(removes): ''' Prints all removed packages ''' if len(removes) > 1: template(78) print("| Total {0} packages removed".format(len(removes))) template(78) for pkg in removes: if not find_package(pkg + sp, pkg_path): print("| Package {0} removed".format(pkg)) else: print("| Package {0} not found".format(pkg)) template(78) print # new line at end
def reference(*args): ''' Reference list with packages installed and upgraded ''' template(78) print("| Total {0} {1} installed and {2} {3} upgraded".format( args[0], args[1], args[2], args[3])) template(78) for pkg, ver in zip(args[4], args[5]): installed = ("{0}-{1}".format(pkg, ver)) if find_package(installed, pkg_path): if pkg in args[5]: print("| Package {0} upgraded successfully".format(installed)) else: print("| Package {0} installed successfully".format(installed)) else: print("| Package {0} NOT installed".format(installed)) template(78)
def reference(*args): # reference(data[0], data[1], data[2], count[0], count[1], # msg[0], msg[1], installed) ''' Print results ''' if len(args[1]) > 1: template(78) print("| Total {0} {1} upgraded and {2} {3} " "installed".format(args[4], args[6], args[3], args[5])) template(78) for pkg, upg, ver in zip(args[1], args[0], args[2]): upgraded = ("{0}-{1}".format(upg, ver)) if find_package(upgraded, pkg_path): if upg in args[7]: print("| Package {0} installed".format(pkg)) else: print("| Package {0} upgraded with new " "package {1}-{2}".format(pkg, upg, ver)) template(78)
def view_sbo(*args): ''' View slackbuild.org ''' print # new line at start template(78) print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0], GREEN, ENDC + args[1])) template(78) print("| {0}Description : {1}{2}".format(GREEN, ENDC, args[2])) print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, args[3])) print("| {0}Sources : {1}{2}".format(GREEN, ENDC, args[4])) print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC, ", ".join(args[5]))) template(78) print(" {0}R{1}EADME View the README file".format(RED, ENDC)) print(" {0}S{1}lackBuild View the SlackBuild file".format( RED, ENDC)) print(" In{0}f{1}o View the Info file".format(RED, ENDC)) print(" {0}D{1}ownload Download this package".format(RED, ENDC)) print(" {0}B{1}uild Download and build".format(RED, ENDC)) print(" {0}I{1}nstall Download/Build/Install".format( RED, ENDC)) print(" {0}Q{1}uit Quit\n".format(RED, ENDC))