Beispiel #1
0
def slack_dwn(path, links):
    '''
    Download patches
    '''
    for dwn in links:
        Download(path, dwn).start()
        Download(path, dwn + ".asc").start()
Beispiel #2
0
 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
Beispiel #3
0
def download(path, sbo_dwn, source_dwn):
    '''
    Download sources
    '''
    Download(path, sbo_dwn).start()
    for src in source_dwn:
        Download(path, src).start()
Beispiel #4
0
 def build(self):
     """Only build and create Slackware package
     """
     pkg_security([self.name])
     self.error_uns()
     if self.FAULT:
         print("")
         self.msg.template(78)
         print("| Package {0} {1} {2} {3}".format(self.prgnam, self.red,
                                                  self.FAULT, self.endc))
         self.msg.template(78)
     else:
         sources = []
         if not os.path.exists(self.meta.build_path):
             os.makedirs(self.meta.build_path)
         if not os.path.exists(self._SOURCES):
             os.makedirs(self._SOURCES)
         os.chdir(self.meta.build_path)
         Download(self.meta.build_path, self.sbo_dwn.split(),
                  repo="sbo").start()
         Download(self._SOURCES, self.source_dwn, repo="sbo").start()
         script = self.sbo_dwn.split("/")[-1]
         for src in self.source_dwn:
             sources.append(src.split("/")[-1])
         BuildPackage(script, sources, self.meta.build_path,
                      auto=False).build()
         slack_package(self.prgnam)  # check if build
Beispiel #5
0
 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)
Beispiel #6
0
def build(sbo_dwn, source_dwn, FAULT):
    '''
    Only build and create Slackware package
    '''
    if FAULT:
        print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC))
        sys.exit()
    if not os.path.exists(build_path):
        os.mkdir(build_path)
    sources = []
    os.chdir(build_path)
    Download(build_path, sbo_dwn).start()
    script = sbo_dwn.split("/")[-1]
    for src in source_dwn:
        Download(build_path, src).start()
        sources.append(src.split("/")[-1])
    BuildPackage(script, sources, build_path).build()
Beispiel #7
0
def dwn_sources(sources):
    '''
    Download sources and return filenames
    '''
    filename = []
    for src in sources:
        Download(build_path, src).start()
        filename.append(src.split("/")[-1])
    return filename
Beispiel #8
0
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()
Beispiel #9
0
 def start(self):
     """
     Install new patches from official Slackware mirrors
     """
     self.store()
     self.msg.done()
     if self.upgrade_all:
         if "--checklist" in self.flag:
             self.dialog_checklist()
         print("\nThese packages need upgrading:\n")
         self.msg.template(78)
         print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
             "| Package", " " * 17, "New Version", " " * 8, "Arch", " " * 4,
             "Build", " " * 2, "Repos", " " * 10, "Size"))
         self.msg.template(78)
         print("Upgrading:")
         self.views()
         unit, size = units(self.comp_sum, self.uncomp_sum)
         print("\nInstalling summary")
         print("=" * 79)
         print("{0}Total {1} {2} will be upgraded and {3} will be "
               "installed.".format(self.meta.color["GREY"], self.count_upg,
                                   self.msg.pkg(self.upgrade_all),
                                   self.count_added))
         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],
                                         self.meta.color["ENDC"]))
         print("")
         if self.msg.answer() in ["y", "Y"]:
             Download(self.patch_path, self.dwn_links, repo="slack").start()
             self.upgrade_all = self.utils.check_downloaded(
                 self.patch_path, self.upgrade_all)
             self.upgrade()
             self.kernel()
             if self.meta.slackpkg_log in ["on", "ON"]:
                 self.slackpkg_update()
             self.msg.reference(self.installed, self.upgraded)
             delete_package(self.patch_path, self.upgrade_all)
             self.update_lists()
     else:
         slack_arch = ""
         if self.meta.arch == "x86_64":
             slack_arch = "64"
         print("\nSlackware{0} '{1}' v{2} distribution is up to "
               "date\n".format(slack_arch, self.version, slack_ver()))
Beispiel #10
0
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]
Beispiel #11
0
 def down(self, path, link, repo):
     """Download files
     """
     filename = link.split("/")[-1]
     if not os.path.isfile(path + filename):
         Download(path, link.split(), repo).start()
Beispiel #12
0
 def start(self):
     '''
     Upgrade all slackbuilds packages from slackbuilds.org
     repository.
     NOTE: This functions check packages by version not by build
     tag because build tag not reported the SLACKBUILDS.TXT file,
     but install the package with maximum build tag if find the
     some version in /tmp directory.
     '''
     try:
         if sbo_list():
             upg_name = exists(self.index, self.toolbar_width)
             sys.stdout.write(self.done)
             data = []
             if upg_name:
                 sys.stdout.write("{0}Resolving dependencies ...{1}".format(
                                  GREY, ENDC))
                 sys.stdout.flush()
                 dependencies = deps(upg_name)
                 requires = one_for_all(dependencies)
                 dependencies_list = order_list(upg_name,
                                                remove_dbs(requires))
                 # upgrade name = data[0]
                 # package for upgrade = data[1]
                 # upgrade version = data[2]
                 # upgrade arch = data[3]
                 data = store(dependencies_list)
                 sys.stdout.write(self.done)
             if data:
                 # count installed = count[0]
                 # count upgraded = count[1]
                 # message install = msg[0]
                 # message upgrade = msg[1]
                 count, msg = view_packages(data[1], data[2], data[3])
                 read = raw_input("Would you like to upgrade [Y/n]? ")
                 if read == "Y" or read == "y":
                     create_build_path()
                     os.chdir(build_path)
                     for name, version in zip(data[0], data[2]):
                         prgnam = ("{0}-{1}".format(name, version))
                         sbo_url = sbo_search_pkg(name)
                         sbo_dwn = SBoLink(sbo_url).tar_gz()
                         src_dwn = SBoGrep(name).source().split()
                         script = sbo_dwn.split("/")[-1]
                         Download(build_path, sbo_dwn).start()
                         sources = dwn_sources(src_dwn)
                         BuildPackage(script, sources, build_path).build()
                         # 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.
                         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(name + sp, pkg_path):
                             print("[ {0}Upgrading{1} ] --> {2}".format(
                                 YELLOW, ENDC, name))
                         else:
                             print("[ {0}Installing{1} ] --> {2}".format(
                                 GREEN, ENDC, name))
                             # Use this list to pick out what
                             # packages will be installed
                             self.installed.append(name)
                         PackageManager(binary).upgrade()
                     reference(data[0], data[1], data[2], count[0], count[1],
                               msg[0], msg[1], self.installed)
             else:
                 print("\nTotal {0} SBo packages are up to date\n".format(
                     len(sbo_list())))
         else:
             sys.stdout.write(self.done)
             print("\nNo SBo packages found\n")
     except KeyboardInterrupt:
         print   # new line at exit
         sys.exit()
Beispiel #13
0
 def start(self, is_upgrade):
     """
     Install packages from official Slackware distribution
     """
     self.case_insensitive()
     # fix if packages is for upgrade
     self.is_upgrade = is_upgrade
     mas_sum = dep_sum = sums = [0, 0, 0]
     self.msg.done()
     self.dependencies = self.resolving_deps()
     self.update_deps()
     (self.dep_dwn, self.dep_install, self.dep_comp_sum,
         self.dep_uncomp_sum) = self.store(self.dependencies)
     self.clear_masters()
     (self.dwn, self.install, self.comp_sum,
         self.uncomp_sum) = self.store(self.packages)
     if (self.meta.rsl_deps in ["on", "ON"] and
             "--resolve-off" not in self.flag):
         self.msg.done()
     if self.install:
         print("\nThe following packages will be automatically "
               "installed or upgraded \nwith new version:\n")
         if self.matching:
             self.msg.matching(self.packages)
         self.top_view()
         self.msg.upg_inst(self.is_upgrade)
         mas_sum = self.views(self.install, self.comp_sum)
         if self.dependencies:
             print("Installing for dependencies:")
             dep_sum = self.views(self.dep_install, self.dep_comp_sum)
         # sums[0] --> installed
         # sums[1] --> upgraded
         # sums[2] --> uninstall
         sums = [sum(i) for i in zip(mas_sum, dep_sum)]
         unit, size = units(self.comp_sum + self.dep_comp_sum,
                            self.uncomp_sum + self.dep_uncomp_sum)
         print("\nInstalling summary")
         print("=" * 79)
         print("{0}Total {1} {2}.".format(self.meta.color["GREY"],
                                          sum(sums),
                                          self.msg.pkg(sum(sums))))
         print("{0} {1} will be installed, {2} will be upgraded and "
               "{3} will be reinstalled.".format(sums[2],
                                                 self.msg.pkg(sums[2]),
                                                 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],
                                               self.meta.color["ENDC"]))
         print("")
         self.if_all_installed()
         if self.msg.answer() in ["y", "Y"]:
             for inst, dwn in zip(self.dep_install + self.install,
                                  self.dep_dwn + self.dwn):
                 if (self.meta.not_downgrade == "on" and
                         self.not_downgrade(inst) is True):
                     continue
                 if (not os.path.isfile(self.meta.pkg_path + inst[:-4]) or
                         "--download-only" in self.flag or
                         "--reinstall" in self.flag):
                     Download(self.tmp_path, dwn.split(), self.repo).start()
                 else:
                     self.msg.template(78)
                     self.msg.pkg_found(inst)
                     self.msg.template(78)
             if "--download-only" in self.flag:
                 raise SystemExit()
             self.dep_install = Utils().check_downloaded(
                 self.tmp_path, self.dep_install)
             self.install = Utils().check_downloaded(
                 self.tmp_path, self.install)
             ins, upg = self.install_packages()
             self.msg.reference(ins, upg)
             write_deps(self.deps_dict)
             delete_package(self.tmp_path, self.dep_install + self.install)
     else:
         self.msg.not_found(self.is_upgrade)
         raise SystemExit(1)
Beispiel #14
0
 def choice_download(self):
     """Download script.tar.gz and sources
     """
     Download(path="", url=self.dwn_srcs, repo="sbo").start()
     raise SystemExit()