def __init__(self, check): self.check = check self.meta = _meta_ self.def_repos_dict = Repo().default_repository() self.conf_path = self.meta.conf_path self.log_path = self.meta.log_path self.lib_path = self.meta.lib_path self.tmp_path = self.meta.tmp_path self.build_path = self.meta.build_path self._SOURCES = self.meta.SBo_SOURCES self.slpkg_tmp_packages = self.meta.slpkg_tmp_packages self.slpkg_tmp_patches = self.meta.slpkg_tmp_patches if not os.path.exists(self.conf_path): os.mkdir(self.conf_path) if not os.path.exists(self.log_path): os.mkdir(self.log_path) if not os.path.exists(self.lib_path): os.mkdir(self.lib_path) if not os.path.exists(self.tmp_path): os.mkdir(self.tmp_path) if not os.path.exists(self.build_path): os.makedirs(self.build_path) if not os.path.exists(self._SOURCES): os.makedirs(self._SOURCES) if not os.path.exists(self.slpkg_tmp_packages): os.makedirs(self.slpkg_tmp_packages) if not os.path.exists(self.slpkg_tmp_patches): os.makedirs(self.slpkg_tmp_patches)
def command_repo_add(self): """Add custom repositories """ if len(self.args) == 3 and self.args[0] == "repo-add": Repo().add(self.args[1], self.args[2]) else: usage("")
def custom(self, name): """Creating user select repository local library """ repo = Repo().custom_repository()[name] log = self.log_path + name + "/" lib = self.lib_path + "{0}_repo/".format(name) repo_name = log[:-1].split("/")[-1] lib_file = "PACKAGES.TXT" # lst_file = "" md5_file = "CHECKSUMS.md5" log_file = "ChangeLog.txt" if not os.path.exists(log): os.mkdir(log) if not os.path.exists(lib): os.mkdir(lib) PACKAGES_TXT = "{0}{1}".format(repo, lib_file) FILELIST_TXT = "" CHECKSUMS_MD5 = "{0}{1}".format(repo, md5_file) ChangeLog_txt = "{0}{1}".format(repo, log_file) if self.check: return self.checks_logs(log, ChangeLog_txt) self.down(lib, PACKAGES_TXT, repo_name) self.down(lib, CHECKSUMS_MD5, repo_name) self.down(log, ChangeLog_txt, repo_name) self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, FILELIST_TXT, repo_name)
def command_repo_remove(self): """Remove custom repositories """ if len(self.args) == 2 and self.args[0] == "repo-remove": Repo().remove(self.args[1]) else: usage("")
def __init__(self): self.form = { "Last updated:": "", "Number of packages:": "", "Repo id:": "", "Default:": "", "Repo url:": "", "Status:": "", "Total compressed packages:": "", "Total uncompressed packages:": "" } self.meta = _meta_ self.all_repos = Repo().default_repository() self.all_repos["slack"] = Repo().slack() self.all_repos.update(Repo().custom_repository()) del RepoList().all_repos
class RepoList(object): """List of repositories """ def __init__(self): self.meta = _meta_ self.msg = Msg() self.all_repos = Repo().default_repository() self.all_repos["slack"] = Repo().slack() self.all_repos.update(Repo().custom_repository()) def repos(self): """View or enabled or disabled repositories """ def_cnt, cus_cnt = 0, 0 print("") self.msg.template(78) print("{0}{1}{2}{3}{4}{5}{6}".format( "| Repo id", " " * 2, "Repo URL", " " * 44, "Default", " " * 3, "Status")) self.msg.template(78) for repo_id, repo_URL in sorted(self.all_repos.iteritems()): status, COLOR = "disabled", self.meta.color["RED"] default = "yes" if len(repo_URL) > 49: repo_URL = repo_URL[:48] + "~" if repo_id in self.meta.repositories: def_cnt += 1 status, COLOR = "enabled", self.meta.color["GREEN"] if repo_id not in self.meta.default_repositories: cus_cnt += 1 default = "no" print(" {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}".format( repo_id, " " * (9 - len(repo_id)), repo_URL, " " * (52 - len(repo_URL)), default, " " * (8 - len(default)), COLOR, status, self.meta.color["ENDC"])) print("\nRepositories summary") print("=" * 79) print("{0}{1}/{2} enabled default repositories and {3} custom.".format( self.meta.color["GREY"], def_cnt, len(self.all_repos), cus_cnt)) print("For enable or disable default repositories edit " "'/etc/slpkg/repositories.conf'\nfile.\n{0}".format( self.meta.color["ENDC"])) raise SystemExit()
def check_for_local_repos(repo): """Check if repository is local """ repos_dict = Repo().default_repository() if repo in repos_dict: repo_url = repos_dict[repo] if repo_url.startswith("file:///"): return True
class RepoList(object): """List of repositories """ def __init__(self): self.meta = _meta_ self.msg = Msg() self.all_repos = Repo().default_repository() self.all_repos["slack"] = Repo().slack() self.all_repos.update(Repo().custom_repository()) def repos(self): """View or enabled or disabled repositories """ def_cnt, cus_cnt = 0, 0 print("") self.msg.template(78) print("{0}{1}{2}{3}{4}{5}{6}".format("| Repo id", " " * 2, "Repo URL", " " * 44, "Default", " " * 3, "Status")) self.msg.template(78) for repo_id, repo_URL in sorted(self.all_repos.iteritems()): status, COLOR = "disabled", self.meta.color["RED"] default = "yes" if len(repo_URL) > 49: repo_URL = repo_URL[:48] + "~" if repo_id in self.meta.repositories: def_cnt += 1 status, COLOR = "enabled", self.meta.color["GREEN"] if repo_id not in self.meta.default_repositories: cus_cnt += 1 default = "no" print(" {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}".format( repo_id, " " * (9 - len(repo_id)), repo_URL, " " * (52 - len(repo_URL)), default, " " * (8 - len(default)), COLOR, status, self.meta.color["ENDC"])) print("\nRepositories summary") print("=" * 79) print("{0}{1}/{2} enabled default repositories and {3} custom.".format( self.meta.color["GREY"], def_cnt, len(self.all_repos), cus_cnt)) print("For enable or disable default repositories edit " "'/etc/slpkg/repositories.conf'\nfile or run 'slpkg " "repo-enable' command.\n{0}".format(self.meta.color["ENDC"])) raise SystemExit()
def sbo_search_pkg(name): """Search for package path from SLACKBUILDS.TXT file and return url """ repo = Repo().default_repository()["sbo"] sbo_url = "{0}{1}/".format(repo, slack_ver()) SLACKBUILDS_TXT = Utils().read_file(_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT") for line in SLACKBUILDS_TXT.splitlines(): if line.startswith("SLACKBUILD LOCATION"): sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip() if name == sbo_name: return (sbo_url + line[23:].strip() + "/") return ""
def mirrors(name, location): """ Select Slackware official mirror packages based architecture and version. """ rel = _meta_.slack_rel ver = slack_ver() repo = Repo().slack() if _meta_.arch == "x86_64": if rel == "stable": http = repo + "slackware64-{0}/{1}{2}".format(ver, location, name) else: http = repo + "slackware64-{0}/{1}{2}".format(rel, location, name) elif _meta_.arch.startswith("arm"): if rel == "stable": http = repo + "slackwarearm-{0}/{1}{2}".format(ver, location, name) else: http = repo + "slackwarearm-{0}/{1}{2}".format(rel, location, name) else: if rel == "stable": http = repo + "slackware-{0}/{1}{2}".format(ver, location, name) else: http = repo + "slackware-{0}/{1}{2}".format(rel, location, name) return http
def _init_custom(self): self.mirror = "{0}".format(Repo().custom_repository()[self.repo])
def __init__(self, repo): self.repo = repo self.meta = _meta_ self.def_repo_dict = Repo().default_repository() self.mirror = ""
class RepoInfo(object): """Repository information """ def __init__(self): self.form = { "Last updated:": "", "Number of packages:": "", "Repo id:": "", "Default:": "", "Repo url:": "", "Status:": "", "Total compressed packages:": "", "Total uncompressed packages:": "" } self.meta = _meta_ self.all_repos = Repo().default_repository() self.all_repos["slack"] = Repo().slack() self.all_repos.update(Repo().custom_repository()) del RepoList().all_repos def view(self, repo): """ View repository information """ status = "{0}disabled{1}".format(self.meta.color["RED"], self.meta.color["ENDC"]) self.form["Status:"] = status self.form["Default:"] = "no" if repo in self.meta.default_repositories: self.form["Default:"] = "yes" if (repo in self.meta.repositories and os.path.isfile(self.meta.lib_path + "{0}_repo/PACKAGES." "TXT".format(repo))): status = "{0}enabled{1}".format(self.meta.color["GREEN"], self.meta.color["ENDC"]) if repo != "sbo": data = self.repository_data(repo) size = units(data[1], data[2]) self.form["Repo id:"] = repo self.form["Repo url:"] = self.all_repos[repo] self.form["Total compressed packages:"] = "{0} {1}".format( str(size[1][0]), str(size[0][0])) self.form["Total uncompressed packages:"] = "{0} {1}".format( str(size[1][1]), str(size[0][1])) self.form["Number of packages:"] = data[0] self.form["Status:"] = status self.form["Last updated:"] = data[3] elif (repo == "sbo" and os.path.isfile(self.meta.lib_path + "{0}_repo/" "SLACKBUILDS.TXT".format(repo))): status = "{0}enabled{1}".format(self.meta.color["GREEN"], self.meta.color["ENDC"]) sum_sbo_pkgs = 0 for line in (Utils().read_file( self.meta.lib_path + "sbo_repo/SLACKBUILDS." "TXT").splitlines()): if line.startswith("SLACKBUILD NAME: "): sum_sbo_pkgs += 1 changelog_txt = Utils().read_file( self.meta.log_path + "sbo/ChangeLog.txt") last_upd = changelog_txt.split("\n", 1)[0] self.form["Repo id:"] = repo self.form["Repo url:"] = self.all_repos[repo] self.form["Total compressed packages:"] = "" self.form["Total uncompressed packages:"] = "" self.form["Number of packages:"] = sum_sbo_pkgs self.form["Status:"] = status self.form["Last updated:"] = last_upd print("") for key, value in sorted(self.form.iteritems()): print self.meta.color["GREY"] + key + self.meta.color["ENDC"], value print("") raise SystemExit() def repository_data(self, repo): """ Grap data packages """ sum_pkgs, size, unsize, last_upd = 0, [], [], "" for line in (Utils().read_file( self.meta.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()): if line.startswith("PACKAGES.TXT;"): last_upd = line[14:].strip() if line.startswith("PACKAGE NAME:"): sum_pkgs += 1 if line.startswith("PACKAGE SIZE (compressed): "): size.append(line[28:-2].strip()) if line.startswith("PACKAGE SIZE (uncompressed): "): unsize.append(line[30:-2].strip()) if repo in ["salix", "slackl"]: log = Utils().read_file( self.meta.log_path + "{0}/ChangeLog.txt".format(repo)) last_upd = log.split("\n", 1)[0] return [sum_pkgs, size, unsize, last_upd]
def __init__(self): self.meta = _meta_ self.msg = Msg() self.all_repos = Repo().default_repository() self.all_repos["slack"] = Repo().slack() self.all_repos.update(Repo().custom_repository())