def __init__(self, name, flag): self.name = name self.flag = flag self.meta = _meta_ self.msg = Msg() self.arch = SBoArch().get() self.comp_tar = ".tar.gz" self.choice = "" self.FAULT = "" self.green = self.meta.color["GREEN"] self.red = self.meta.color["RED"] self.yellow = self.meta.color["YELLOW"] self.cyan = self.meta.color["CYAN"] self.grey = self.meta.color["GREY"] self.endc = self.meta.color["ENDC"] self.build_folder = self.meta.build_path self.msg.reading() self.data = SBoGrep(name="").names() self.case_insensitive() if "--checklist" in self.flag: self.with_checklist() grep = SBoGrep(self.name) self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo") self.sbo_url = sbo_search_pkg(self.name) if self.sbo_url: self.sbo_desc = grep.description()[len(self.name) + 2:-1] self.source_dwn = grep.source().split() self.sbo_req = grep.requires() self.sbo_dwn = SBoLink(self.sbo_url).tar_gz() self.sbo_version = grep.version() self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn if "--checklist" not in self.flag or not self.sbo_url and self.name: self.msg.done()
def sbo_version_source(self, slackbuilds): """Create sbo name with version """ sbo_versions, sources = [], [] for sbo in slackbuilds: status(0.02) sbo_ver = "{0}-{1}".format(sbo, SBoGrep(sbo).version()) sbo_versions.append(sbo_ver) sources.append(SBoGrep(sbo).source()) return [sbo_versions, sources]
def __init__(self, name, flag): self.name = name self.flag = flag self.meta = _meta_ self.msg = Msg() self.arch = SBoArch().get() self.comp_tar = ".tar.gz" self.choice = "" self.FAULT = "" self.green = self.meta.color["GREEN"] self.red = self.meta.color["RED"] self.yellow = self.meta.color["YELLOW"] self.cyan = self.meta.color["CYAN"] self.grey = self.meta.color["GREY"] self.endc = self.meta.color["ENDC"] self.build_folder = self.meta.build_path self._SOURCES = self.meta.SBo_SOURCES self.msg.reading() self.data = SBoGrep(name="").names() self.case_insensitive() if "--checklist" in self.flag: self.with_checklist() grep = SBoGrep(self.name) self.sbo_files = grep.files() self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo") self.sbo_url = sbo_search_pkg(self.name) if self.sbo_url: self.sbo_desc = grep.description()[len(self.name) + 2:-1] self.source_dwn = grep.source().split() self.sbo_req = grep.requires() self.sbo_dwn = SBoLink(self.sbo_url).tar_gz() self.sbo_version = grep.version() self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn if "--checklist" not in self.flag or not self.sbo_url and self.name: self.msg.done()
def _create_md5_dict(self): """Create md5 dictionary per source """ self.sbo_md5 = {} md5_lists = SBoGrep(self.prgnam).checksum() for src, md5 in zip(self.sources, md5_lists): self.sbo_md5[src] = md5
def __init__(self, flag): self.flag = flag self.meta = _meta_ self.SLACKBUILDS_TXT = SBoGrep(name="").names() self.blacklist = BlackList().packages(pkgs=self.SLACKBUILDS_TXT, repo="sbo") self.dep_results = []
def __init__(self, slackbuilds, flag): self.slackbuilds = slackbuilds pkg_security(self.slackbuilds) self.flag = flag self.meta = _meta_ self.msg = Msg() self.arch = SBoArch().get() self.build_folder = self.meta.build_path self._SOURCES = self.meta.SBo_SOURCES for fl in self.flag: if fl.startswith("--directory-prefix="): self.build_folder = fl.split("=")[1] if not self.build_folder.endswith("/"): self.build_folder += "/" self.unst = ["UNSUPPORTED", "UNTESTED"] self.master_packages = [] self.deps = [] self.dependencies = [] self.package_not_found = [] self.package_found = [] self.deps_dict = {} self.answer = "" self.match = False self.count_ins = 0 self.count_upg = 0 self.count_uni = 0 self.msg.reading() self.data = SBoGrep(name="").names() self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo")
def build_install(self): """Build and install packages if not already installed """ slackbuilds = self.dependencies + self.master_packages installs, upgraded, = [], [] if not os.path.exists(self.build_folder): os.makedirs(self.build_folder) if not os.path.exists(self._SOURCES): os.makedirs(self._SOURCES) os.chdir(self.build_folder) for prgnam in slackbuilds: if (self.meta.not_downgrade == "on" and self.not_downgrade(prgnam) is True): continue pkg = "-".join(prgnam.split("-")[:-1]) installed = "".join(find_package(prgnam, self.meta.pkg_path)) src_link = SBoGrep(pkg).source().split() if (installed and "--download-only" not in self.flag and "--rebuild" not in self.flag): self.msg.template(78) self.msg.pkg_found(prgnam) self.msg.template(78) elif self.unst[0] in src_link or self.unst[1] in src_link: self.msg.template(78) print("| Package {0} {1}{2}{3}".format( prgnam, self.meta.color["RED"], "".join(src_link), self.meta.color["ENDC"])) self.msg.template(78) else: sbo_url = sbo_search_pkg(pkg) sbo_link = SBoLink(sbo_url).tar_gz() script = sbo_link.split("/")[-1] if self.meta.sbosrcarch in ["on", "ON"]: src_link = self.sbosrcarsh(prgnam, sbo_link, src_link) Download(self.build_folder, sbo_link.split(), repo="sbo").start() Download(self._SOURCES, src_link, repo="sbo").start() if "--download-only" in self.flag: continue sources = self.filenames(src_link) BuildPackage(script, sources, self.build_folder, auto=False).build() binary = slack_package(prgnam) if os.path.isfile("".join(binary)): if GetFromInstalled(pkg).name() == pkg: print("[ {0}Upgrading{1} ] --> {2}".format( self.meta.color["YELLOW"], self.meta.color["ENDC"], prgnam)) upgraded.append(prgnam) else: print("[ {0}Installing{1} ] --> {2}".format( self.meta.color["GREEN"], self.meta.color["ENDC"], prgnam)) installs.append(prgnam) if ("--rebuild" in self.flag and GetFromInstalled(pkg).name() == pkg): PackageManager(binary).upgrade(flag="--reinstall") else: PackageManager(binary).upgrade(flag="--install-new") return installs, upgraded
def build(self): """Build packages from queue """ packages = self.packages() if packages: for pkg in packages: if not os.path.exists(self.meta.build_path): os.mkdir(self.meta.build_path) if not os.path.exists(self._SOURCES): os.mkdir(self._SOURCES) sbo_url = sbo_search_pkg(pkg) sbo_dwn = SBoLink(sbo_url).tar_gz() source_dwn = SBoGrep(pkg).source().split() sources = [] os.chdir(self.meta.build_path) script = sbo_dwn.split("/")[-1] Download(self.meta.build_path, sbo_dwn.split(), repo="sbo").start() for src in source_dwn: Download(self._SOURCES, src.split(), repo="sbo").start() sources.append(src.split("/")[-1]) BuildPackage(script, sources, self.meta.build_path, auto=False).build() else: print("\nPackages not found in the queue for building\n") raise SystemExit(1)
def sbo_version(self, repo, find): """ Add version to SBo packages """ ver = "" if repo == "sbo": ver = "-" + SBoGrep(find).version() return ver
def sbo_case_insensitive(self): """Matching packages distinguish between uppercase and lowercase for sbo repository """ if "--case-ins" in self.flag: data = SBoGrep(name="").names() data_dict = Utils().case_sensitive(data) for key, value in data_dict.iteritems(): if key == self.name.lower(): self.name = value
def sbo_upgrade(skip, flag): """Return packages for upgrade """ Msg().checking() upgrade_names = [] data = SBoGrep(name="").names() blacklist = BlackList().packages(pkgs=data, repo="sbo") for pkg in sbo_list(): status(0.02) name = split_package(pkg)[0] ver = split_package(pkg)[1] if (name in data and name not in skip and name not in blacklist): sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version())) package = ("{0}-{1}".format(name, ver)) if LooseVersion(sbo_package) > LooseVersion(package): upgrade_names.append(name) Msg().done() if "--checklist" in flag: upgrade_names = choose_upg(upgrade_names) return upgrade_names
def install(self): """Install packages from queue """ packages = self.packages() if packages: print("") # new line at start for pkg in packages: ver = SBoGrep(pkg).version() prgnam = "{0}-{1}".format(pkg, ver) if find_package(prgnam, self.meta.output): binary = slack_package(prgnam) PackageManager(binary).upgrade(flag="--install-new") else: print("\nPackage {0} not found in the {1} for " "installation\n".format(prgnam, self.meta.output)) else: print("\nPackages not found in the queue for installation\n") raise SystemExit(1)
def sbo(self, name): """Build all dependencies of a package """ if (self.meta.rsl_deps in ["on", "ON"] and "--resolve-off" not in self.flag): sys.setrecursionlimit(10000) dependencies = [] requires = SBoGrep(name).requires() if requires: for req in requires: status(0.03) # toolbar_width = status(index, toolbar_width, 1) # avoid to add %README% as dependency and # if require in blacklist if "%README%" not in req and req not in self.blacklist: dependencies.append(req) if dependencies: self.dep_results.append(dependencies) for dep in dependencies: self.sbo(dep) return self.dep_results else: return []
def view(self): """Print package description by repository """ print("") # new line at start description, count = "", 0 if self.repo == "sbo": description = SBoGrep(self.name).description() else: PACKAGES_TXT = Utils().read_file(self.lib) for line in PACKAGES_TXT.splitlines(): if line.startswith(self.name + ":"): description += line[len(self.name) + 2:] + "\n" count += 1 if count == 11: break if description: print("{0}{1}{2}".format(self.COLOR, description, self.meta.color["ENDC"])) else: self.msg.pkg_not_found("", self.name, "No matching", "\n") raise SystemExit(1) if description and self.repo == "sbo": print("")
def build(self): ''' Build package from source and create log file in path /var/log/slpkg/sbo/build_logs/. Also check md5sum calculates. ''' try: tar = tarfile.open(self.script) tar.extractall() tar.close() sbo_md5_list = SBoGrep(self.prgnam).checksum() for src, sbo_md5 in zip(self.sources, sbo_md5_list): # fix build sources with spaces src = src.replace("%20", " ") check_md5(sbo_md5, src) shutil.copy2(src, self.prgnam) os.chdir(self.path + self.prgnam) # change permissions subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam), shell=True) # start log write log_head(self.build_logs, self.log_file, self.start_log_time) subprocess.Popen("./{0}.SlackBuild 2>&1 | tee -a {1}{2}".format( self.prgnam, self.build_logs, self.log_file), shell=True, stdout=sys.stdout).communicate() sum_time = build_time(self.start_time) # write end in log file log_end(self.build_logs, self.log_file, sum_time) os.chdir(self.path) print("Total build time for package {0} : {1}\n".format( self.prgnam, sum_time)) except (OSError, IOError): pkg_not_found("\n", self.prgnam, "Wrong file", "\n") except KeyboardInterrupt: print # new line at exit sys.exit()
def info_file(self): """Grab sources from .info file and store filename """ sources = SBoGrep(self.prgnam).source().split() for source in sources: self.sbo_sources.append(source.split("/")[-1])