def view(self): PACKAGES_TXT = Utils().read_file(self.lib) print("") # new line at start count = 0 if self.repo != "sbo": for line in PACKAGES_TXT.splitlines(): if line.startswith(self.name + ":"): print(self.COLOR + line[len(self.name) + 1:] + self.meta.color["ENDC"]) count += 1 if count == 11: break else: for line in PACKAGES_TXT.splitlines(): if (line.startswith( "SLACKBUILD SHORT DESCRIPTION: " + self.name + " (")): count += 1 print(self.COLOR + line[31:] + self.meta.color["ENDC"]) if count == 0: Msg().pkg_not_found("", self.name, "No matching", "\n") else: print("") # new line at end
def slack(self): """ Official slackware repository """ default = "http://mirrors.slackware.com/slackware/" if os.path.isfile("/etc/slpkg/slackware-mirrors"): mirrors = Utils().read_file( self.meta.conf_path + "slackware-mirrors") for line in mirrors.splitlines(): line = line.rstrip() if not line.startswith("#") and line: default = line.split()[-1] return default
def view(self): """ View slpkg config file """ print("") # new line at start conf_args = [ "RELEASE", "REPOSITORIES", "BUILD_PATH", "PACKAGES", "PATCHES", "CHECKMD5", "DEL_ALL", "DEL_BUILD", "SBO_BUILD_LOG", "MAKEFLAGS", "DEFAULT_ANSWER", "REMOVE_DEPS_ANSWER", "SKIP_UNST", "RSL_DEPS", "DEL_DEPS", "USE_COLORS", "DOWNDER", "DOWNDER_OPTIONS", "SLACKPKG_LOG", "ONLY_INSTALLED" ] read_conf = Utils().read_file(self.config_file) try: for line in read_conf.splitlines(): if not line.startswith("#") and line.split("=")[0] in conf_args: print(line) else: print("{0}{1}{2}".format(self.meta.color["CYAN"], line, self.meta.color["ENDC"])) except KeyboardInterrupt: print("") sys.exit(0) print("") # new line at end
def library(repo): """Load packages from slpkg library and from local """ pkg_list, packages = [], "" if repo == "sbo": if (os.path.isfile( _meta_.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))): packages = Utils().read_file(_meta_.lib_path + "{0}_repo/" "SLACKBUILDS.TXT".format(repo)) else: if (os.path.isfile( _meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(repo))): packages = Utils().read_file(_meta_.lib_path + "{0}_repo/" "PACKAGES.TXT".format(repo)) for line in packages.splitlines(): if repo == "sbo": if line.startswith("SLACKBUILD NAME: "): pkg_list.append(line[17:].strip()) elif "local" not in repo: if line.startswith("PACKAGE NAME: "): pkg_list.append(line[15:].strip()) if repo == "local": pkg_list = find_package("", _meta_.pkg_path) return pkg_list
class Repo(object): def __init__(self): self.meta = _meta_ self.repo_file = "/etc/slpkg/custom-repositories" self.repositories_list = Utils().read_file(self.repo_file) def add(self, repo, url): """ Write custom repository name and url in a file """ repo_name = [] if not url.endswith("/"): url = url + "/" for line in self.repositories_list.splitlines(): line = line.lstrip() if line and not line.startswith("#"): repo_name.append(line.split()[0]) if (repo in self.meta.repositories or repo in repo_name or repo in self.meta.default_repositories): print("\nRepository name '{0}' exist, select different name.\n" "View all repositories with command 'repo-list'.\n".format( repo)) sys.exit(0) elif len(repo) > 6: print("\nMaximum repository name length must be six (6) " "characters\n") sys.exit(0) with open(self.repo_file, "a") as repos: new_line = " {0}{1}{2}\n".format(repo, " " * (10 - len(repo)), url) repos.write(new_line) repos.close() print("\nRepository '{0}' successfully added\n".format(repo)) sys.exit(0) def remove(self, repo): """ Remove custom repository """ rem_repo = False with open(self.repo_file, "w") as repos: for line in self.repositories_list.splitlines(): repo_name = line.split()[0] if repo_name != repo: repos.write(line + "\n") else: print("\nRepository '{0}' successfully " "removed\n".format(repo)) rem_repo = True repos.close() if not rem_repo: print("\nRepository '{0}' doesn't exist\n".format(repo)) sys.exit(0) def custom_repository(self): """ Return dictionary with repo name and url """ dict_repo = {} for line in self.repositories_list.splitlines(): line = line.lstrip() if not line.startswith("#"): dict_repo[line.split()[0]] = line.split()[1] return dict_repo def slack(self): """ Official slackware repository """ default = "http://mirrors.slackware.com/slackware/" if os.path.isfile("/etc/slpkg/slackware-mirrors"): mirrors = Utils().read_file( self.meta.conf_path + "slackware-mirrors") for line in mirrors.splitlines(): line = line.rstrip() if not line.startswith("#") and line: default = line.split()[-1] return default def sbo(self): """ SlackBuilds.org repository """ return "http://slackbuilds.org/slackbuilds/" def rlw(self): """ Robby"s repoisitory """ return "http://rlworkman.net/pkgs/" def alien(self): """ Alien"s slackbuilds repository """ return "http://taper.alienbase.nl/mirrors/people/alien/sbrepos/" def slacky(self): """ Slacky.eu repository """ return "http://repository.slacky.eu/" def studioware(self): """ Studioware repository """ return "http://studioware.org/files/packages/" def slackers(self): """ Slackers.it repository """ return "http://ponce.cc/slackers/repository/" def slackonly(self): """ Slackonly.com repository """ return "https://slackonly.com/pub/packages/" def ktown(self): """ Alien"s ktown repository """ return "http://alien.slackbook.org/ktown/" def multi(self): """ Alien"s multilib repository """ return "http://www.slackware.com/~alien/multilib/" def slacke(self): """ Slacke slacke{17|18} repository """ return "http://ngc891.blogdns.net/pub/" def salix(self): """ SalixOS salix repository """ return "http://download.salixos.org/" def slackel(self): """ Slackel.gr slackel repository """ return "http://www.slackel.gr/repo/" def restricted(self): """ Slackel.gr slackel repository """ return ("http://taper.alienbase.nl/mirrors/people/alien/" "restricted_slackbuilds/") def msb(self): """ MSB mate repository """ return "http://slackware.org.uk/msb/"
class BlackList(object): """Blacklist class to add, remove or listed packages in blacklist file.""" def __init__(self): self.meta = _meta_ self.quit = False self.blackfile = "/etc/slpkg/blacklist" self.black_conf = Utils().read_file(self.blackfile) def get_black(self): """Return blacklist packages from /etc/slpkg/blacklist configuration file.""" blacklist = [] for read in self.black_conf.splitlines(): read = read.lstrip() if not read.startswith("#"): blacklist.append(read.replace("\n", "")) return blacklist def listed(self): """Print blacklist packages """ print("\nPackages in blacklist:\n") for black in self.get_black(): if black: print("{0}{1}{2}".format(self.meta.color["GREEN"], black, self.meta.color["ENDC"])) self.quit = True if self.quit: print("") # new line at exit def add(self, pkgs): """Add blacklist packages if not exist """ blacklist = self.get_black() pkgs = set(pkgs) print("\nAdd packages in blacklist:\n") with open(self.blackfile, "a") as black_conf: for pkg in pkgs: if pkg not in blacklist: print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg, self.meta.color["ENDC"])) black_conf.write(pkg + "\n") self.quit = True black_conf.close() if self.quit: print("") # new line at exit def remove(self, pkgs): """Remove packages from blacklist """ print("\nRemove packages from blacklist:\n") with open(self.blackfile, "w") as remove: for line in self.black_conf.splitlines(): if line not in pkgs: remove.write(line + "\n") else: print("{0}{1}{2}".format(self.meta.color["RED"], line, self.meta.color["ENDC"])) self.quit = True remove.close() if self.quit: print("") # new line at exit def packages(self, pkgs, repo): """Return packages in blacklist or by repository """ self.black = [] for bl in self.get_black(): pr = bl.split(":") for pkg in pkgs: self.__priority(pr, repo, pkg) self.__blackpkg(bl, repo, pkg) return self.black def __add(self, repo, pkg): """Split packages by repository """ if repo == "sbo": return pkg else: return split_package(pkg)[0] def __priority(self, pr, repo, pkg): """Add packages in blacklist by priority """ if (pr[0] == repo and pr[1].startswith("*") and pr[1].endswith("*")): if pr[1][1:-1] in pkg: self.black.append(self.__add(repo, pkg)) elif pr[0] == repo and pr[1].endswith("*"): if pkg.startswith(pr[1][:-1]): self.black.append(self.__add(repo, pkg)) elif pr[0] == repo and pr[1].startswith("*"): if pkg.endswith(pr[1][1:]): self.black.append(self.__add(repo, pkg)) elif pr[0] == repo and "*" not in pr[1]: self.black.append(self.__add(repo, pkg)) def __blackpkg(self, bl, repo, pkg): """Add packages in blacklist """ if bl.startswith("*") and bl.endswith("*"): if bl[1:-1] in pkg: self.black.append(self.__add(repo, pkg)) elif bl.endswith("*"): if pkg.startswith(bl[:-1]): self.black.append(self.__add(repo, pkg)) elif bl.startswith("*"): if pkg.endswith(bl[1:]): self.black.append(self.__add(repo, pkg)) if bl not in self.black and "*" not in bl: self.black.append(bl)