def it_self_update(): """Check from GitHub slpkg repository if new version is available download and update itself """ __new_version__ = "" repository = "github" branch = "master" ver_link = ("https://raw.{0}usercontent.com/{1}/{2}/" "{3}/{4}/__metadata__.py".format(repository, _meta_.__author__, _meta_.__all__, branch, _meta_.__all__)) version_data = URL(ver_link).reading() for line in version_data.splitlines(): line = line.strip() if line.startswith("__version_info__"): __new_version__ = ".".join(re.findall(r"\d+", line)) if __new_version__ > _meta_.__version__: if _meta_.default_answer in ["y", "Y"]: answer = _meta_.default_answer else: print("\nNew version '{0}-{1}' is available !\n".format( _meta_.__all__, __new_version__)) try: answer = raw_input("Would you like to upgrade [y/N]? ") except EOFError: print("") raise SystemExit() if answer in ["y", "Y"]: print("") # new line after answer else: raise SystemExit() dwn_link = [ "https://{0}.com/{1}/{2}/archive/" "v{3}.tar.gz".format(repository, _meta_.__author__, _meta_.__all__, __new_version__) ] if not os.path.exists(_meta_.build_path): os.makedirs(_meta_.build_path) Download(_meta_.build_path, dwn_link, repo="").start() os.chdir(_meta_.build_path) slpkg_tar_file = "v" + __new_version__ + ".tar.gz" tar = tarfile.open(slpkg_tar_file) tar.extractall() tar.close() file_name = "{0}-{1}".format(_meta_.__all__, __new_version__) os.chdir(file_name) check_md5( pkg_checksum(_meta_.__all__ + "-" + slpkg_tar_file[1:], _meta_.__all__), _meta_.build_path + slpkg_tar_file) subprocess.call("chmod +x {0}".format("install.sh"), shell=True) subprocess.call("sh install.sh", shell=True) else: print("\n{0}: There is no new version, already used the last !" "\n".format(_meta_.__all__)) raise SystemExit()
def it_self_update(): """ Check from GitHub slpkg repository if new version is available download and update itself """ __new_version__ = "" repository = "github" branch = "master" ver_link = ("https://raw.{0}usercontent.com/{1}/{2}/" "{3}/{4}/__metadata__.py".format(repository, _meta_.__author__, _meta_.__all__, branch, _meta_.__all__)) version_data = URL(ver_link).reading() for line in version_data.splitlines(): line = line.strip() if line.startswith("__version_info__"): __new_version__ = ".".join(re.findall(r"\d+", line)) if __new_version__ > _meta_.__version__: if _meta_.default_answer in ["y", "Y"]: answer = _meta_.default_answer else: print("\nNew version '{0}-{1}' is available !\n".format( _meta_.__all__, __new_version__)) try: answer = raw_input("Would you like to upgrade [y/N]? ") except EOFError: print("") raise SystemExit() if answer in ["y", "Y"]: print("") # new line after answer else: raise SystemExit() dwn_link = ["https://{0}.com/{1}/{2}/archive/" "v{3}.tar.gz".format(repository, _meta_.__author__, _meta_.__all__, __new_version__)] if not os.path.exists(_meta_.build_path): os.makedirs(_meta_.build_path) Download(_meta_.build_path, dwn_link, repo="").start() os.chdir(_meta_.build_path) slpkg_tar_file = "v" + __new_version__ + ".tar.gz" tar = tarfile.open(slpkg_tar_file) tar.extractall() tar.close() file_name = "{0}-{1}".format(_meta_.__all__, __new_version__) os.chdir(file_name) check_md5(pkg_checksum(_meta_.__all__ + "-" + slpkg_tar_file[1:], _meta_.__all__), _meta_.build_path + slpkg_tar_file) subprocess.call("chmod +x {0}".format("install.sh"), shell=True) subprocess.call("sh install.sh", shell=True) else: print("\n{0}: There is no new version, already used the last !" "\n".format(_meta_.__all__)) raise SystemExit()
def get(self): num = "NO_BUILD" if self.sbo_url: SlackBuild = URL("{0}{1}.SlackBuild".format( self.sbo_url, self.pkg)).reading() else: SlackBuild = Utils().read_file("{0}{1}/{2}.SlackBuild".format( self.meta.build_path, self.pkg, self.pkg)) for line in SlackBuild.splitlines(): line = line.lstrip() if line.startswith("BUILD="): num = re.findall(r"\d+", line) break return "".join(num)
def pkg_checksum(binary, repo): """Return checksum from CHECKSUMS.md5 file by repository """ md5 = "None" if repo == "slack_patches" and _meta_.slack_rel == "stable": CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading() elif repo == "slack_patches" and _meta_.slack_rel == "current": CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).reading() elif repo == "slpkg": CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).reading() else: lib = "{0}{1}_repo/CHECKSUMS.md5".format(_meta_.lib_path, repo) f = open(lib, "r") CHECKSUMS_md5 = f.read() f.close() for line in CHECKSUMS_md5.splitlines(): if line.endswith("/{0}".format(binary)): md5 = line.split()[0] return md5