Beispiel #1
0
 def build_install(self):
     """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.
     """
     slackbuilds = self.dependencies + self.master_packages
     installs, upgraded, = [], []
     if not os.path.exists(self.build_folder):
         os.makedirs(self.build_folder)
     os.chdir(self.build_folder)
     for sbo in slackbuilds:
         pkg = "-".join(sbo.split("-")[:-1])
         ver = sbo.split("-")[-1]
         prgnam = ("{0}-{1}".format(pkg, ver))
         sbo_file = "".join(find_package(prgnam, self.meta.pkg_path))
         src_link = SBoGrep(pkg).source().split()
         if sbo_file:
             Msg().template(78)
             Msg().pkg_found(pkg, split_package(sbo_file)[1])
             Msg().template(78)
         elif self.unst[0] in src_link or self.unst[1] in src_link:
             Msg().template(78)
             print("| Package {0} {1}{2}{3}".format(
                 sbo, self.meta.color["RED"], "".join(src_link),
                 self.meta.color["ENDC"]))
             Msg().template(78)
         else:
             sbo_url = sbo_search_pkg(pkg)
             sbo_link = SBoLink(sbo_url).tar_gz()
             script = sbo_link.split("/")[-1]
             dwn_srcs = sbo_link.split() + src_link
             Download(self.build_folder, dwn_srcs, repo="sbo").start()
             sources = self.filenames(src_link)
             BuildPackage(script, sources, self.build_folder).build()
             binary_list = self.search_in_tmp(prgnam)
             try:
                 binary = (self.meta.output + max(binary_list)).split()
             except ValueError:
                 Msg().build_FAILED(sbo_url, prgnam)
                 sys.exit(0)
             if find_package(pkg + "-", self.meta.pkg_path):
                 print("{0}[ Upgrading ] --> {1}{2}".format(
                     self.meta.color["YELLOW"],
                     self.meta.color["ENDC"], pkg))
                 upgraded.append(prgnam)
             else:
                 print("{0}[ Installing ] --> {1}{2}".format(
                     self.meta.color["GREEN"], self.meta.color["ENDC"], pkg))
                 installs.append(prgnam)
             PackageManager(binary).upgrade(flag="--install-new")
     return installs, upgraded
Beispiel #2
0
 def __init__(self, name):
     self.name = name
     sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
     sys.stdout.flush()
     initialization()
     grep = SBoGrep(self.name)
     self.sbo_url = sbo_search_pkg(self.name)
     self.sbo_desc = grep.description()[len(self.name) + 2:-1]
     self.sbo_req = grep.requires()
     self.source_dwn = grep.source().split()
     self.sbo_dwn = SBoLink(self.sbo_url).tar_gz()
     self.sbo_version = grep.version()
     self.space = ("\n" * 50)
     sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
Beispiel #3
0
 def __init__(self, name):
     self.name = name
     sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
     sys.stdout.flush()
     initialization()
     grep = SBoGrep(self.name)
     self.sbo_url = sbo_search_pkg(self.name)
     self.sbo_desc = grep.description()[len(self.name) + 2:-1]
     self.sbo_req = grep.requires()
     self.source_dwn = grep.source().split()
     self.sbo_dwn = SBoLink(self.sbo_url).tar_gz()
     self.sbo_version = grep.version()
     self.space = ("\n" * 50)
     sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
Beispiel #4
0
def exists(index, toolbar_width):
    '''
    search packages if exists in the repository
    and it gets to avoidable modified packages
    from the user with the tag _SBo
    '''
    upgrade_names = []
    for pkg in sbo_list():
        index += 1
        toolbar_width = status(index, toolbar_width, 4)
        name = split_package(pkg)[0]
        if sbo_search_pkg(name):
            sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
            package = ("{0}-{1}".format(name, split_package(pkg)[1]))
            if sbo_package > package:
                upgrade_names.append(name)
    return upgrade_names
Beispiel #5
0
 def __init__(self, name):
     self.name = name
     self.meta = _meta_
     self.build_folder = self.meta.build_path
     Msg().reading()
     grep = SBoGrep(self.name)
     self.data = SBoGrep(name="").names()
     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
     self.space = ("\n" * 50)
     Msg().done()
Beispiel #6
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 #7
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 #8
0
 def start(self):
     '''
     Download, build and install or upgrade packages
     with all dependencies if version is greater than
     that established.
     '''
     try:
         if self.dependencies_list or sbo_search_pkg(self.name) is not None:
             requires = one_for_all(self.name, self.dependencies_list)
             dependencies = remove_dbs(requires)
             # sbo versions = idata[0]
             # package arch = idata[1]
             # package sum = idata[2]
             # sources = idata[3]
             idata = installing_data(dependencies, self.UNST)
             sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
             # count upgraded = cnt[0]
             # count installed = cnt[1]
             (PKG_COLOR, count) = pkg_colors_tag(self.name, idata[0], 0, 0)
             print("\nThe following packages will be automatically "
                   "installed or upgraded")
             print("with new version:\n")
             top_view()
             print("Installing:")
             ARCH_COLOR = arch_colors_tag(self.UNST, idata[1])
             view_packages(PKG_COLOR, self.name, idata[0][-1], ARCH_COLOR,
                           idata[1][-1])
             print("Installing for dependencies:")
             for dep, ver, dep_arch in zip(dependencies[:-1], idata[0][:-1],
                                           idata[1][:-1]):
                 (DEP_COLOR, count) = pkg_colors_tag(dep, ver, count[0],
                                                     count[1])
                 ARCH_COLOR = arch_colors_tag(self.UNST, dep)
                 view_packages(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
             # insstall message = msg[0]
             # upgraded message = msg[1]
             # total message = msg[2]
             msg = msgs(dependencies, count[1], count[0])
             print("\nInstalling summary")
             print("=" * 79)
             print("{0}Total {1} {2}.".format(GREY, len(dependencies),
                                              msg[2]))
             print("{0} {1} will be installed, {2} allready installed and "
                   "{3} {4}".format(count[1], msg[0], idata[2], count[0],
                                    msg[1]))
             print("will be upgraded.{0}\n".format(ENDC))
             read = arch_support(idata[3], self.UNST, idata[2], dependencies)
             if read == "Y" or read == "y":
                 # installs = b_ins[0]
                 # upgraded = b_ins[1]
                 # versions = b_ins[2]
                 b_ins = build_install(dependencies, idata[0], idata[1])
                 reference(count[1], msg[0], count[0], msg[1],
                           b_ins[0], b_ins[2], b_ins[1])
                 write_deps(self.name, dependencies)
         else:
             count_installed = count_uninstalled = 0
             # sbo matching = mdata[0]
             # sbo version = mdata1]
             # package arch = mdata[2]
             mdata = matching_data(self.name, self.UNST)
             sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
             if mdata[0]:
                 print("\nPackages with name matching [ {0}{1}{2} ]"
                       "\n".format(CYAN, self.name, ENDC))
                 top_view()
                 print("Matching:")
                 for match, ver, march in zip(mdata[0], mdata[1], mdata[2]):
                     if find_package(match + sp + ver, pkg_path):
                         view_packages(GREEN, match, ver, "", march)
                         count_installed += 1
                     else:
                         view_packages(RED, match, ver, "", march)
                         count_uninstalled += 1
                 # insstall message = msg[0]
                 # uninstall message = msg[1]
                 # total message = msg[2]
                 msg = msgs(mdata[0], count_installed, count_uninstalled)
                 print("\nInstalling summary")
                 print("=" * 79)
                 print("{0}Total found {1} matching {2}.".format(
                     GREY, len(mdata[0]), msg[2]))
                 print("{0} installed {1} and {2} uninstalled {3}.{4}"
                       "\n".format(count_installed, msg[0],
                                   count_uninstalled, msg[1], ENDC))
             else:
                 pkg_not_found("\n", self.name, "No matching", "\n")
     except KeyboardInterrupt:
         print   # new line at exit
         sys.exit()
Beispiel #9
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 #10
0
 def start(self):
     '''
     Download, build and install or upgrade packages
     with all dependencies if version is greater than
     that established.
     '''
     try:
         if self.dependencies_list or sbo_search_pkg(self.name) is not None:
             requires = one_for_all(self.name, self.dependencies_list)
             dependencies = remove_dbs(requires)
             # sbo versions = idata[0]
             # package arch = idata[1]
             # package sum = idata[2]
             # sources = idata[3]
             idata = installing_data(dependencies, self.UNST)
             sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
             # count upgraded = cnt[0]
             # count installed = cnt[1]
             (PKG_COLOR, count) = pkg_colors_tag(self.name, idata[0], 0, 0)
             print("\nThe following packages will be automatically "
                   "installed or upgraded")
             print("with new version:\n")
             top_view()
             print("Installing:")
             ARCH_COLOR = arch_colors_tag(self.UNST, idata[1])
             view_packages(PKG_COLOR, self.name, idata[0][-1], ARCH_COLOR,
                           idata[1][-1])
             print("Installing for dependencies:")
             for dep, ver, dep_arch in zip(dependencies[:-1], idata[0][:-1],
                                           idata[1][:-1]):
                 (DEP_COLOR,
                  count) = pkg_colors_tag(dep, ver, count[0], count[1])
                 ARCH_COLOR = arch_colors_tag(self.UNST, dep)
                 view_packages(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
             # insstall message = msg[0]
             # upgraded message = msg[1]
             # total message = msg[2]
             msg = msgs(dependencies, count[1], count[0])
             print("\nInstalling summary")
             print("=" * 79)
             print("{0}Total {1} {2}.".format(GREY, len(dependencies),
                                              msg[2]))
             print("{0} {1} will be installed, {2} allready installed and "
                   "{3} {4}".format(count[1], msg[0], idata[2], count[0],
                                    msg[1]))
             print("will be upgraded.{0}\n".format(ENDC))
             read = arch_support(idata[3], self.UNST, idata[2],
                                 dependencies)
             if read == "Y" or read == "y":
                 # installs = b_ins[0]
                 # upgraded = b_ins[1]
                 # versions = b_ins[2]
                 b_ins = build_install(dependencies, idata[0], idata[1])
                 reference(count[1], msg[0], count[0], msg[1], b_ins[0],
                           b_ins[2], b_ins[1])
                 write_deps(self.name, dependencies)
         else:
             count_installed = count_uninstalled = 0
             # sbo matching = mdata[0]
             # sbo version = mdata1]
             # package arch = mdata[2]
             mdata = matching_data(self.name, self.UNST)
             sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
             if mdata[0]:
                 print("\nPackages with name matching [ {0}{1}{2} ]"
                       "\n".format(CYAN, self.name, ENDC))
                 top_view()
                 print("Matching:")
                 for match, ver, march in zip(mdata[0], mdata[1], mdata[2]):
                     if find_package(match + sp + ver, pkg_path):
                         view_packages(GREEN, match, ver, "", march)
                         count_installed += 1
                     else:
                         view_packages(RED, match, ver, "", march)
                         count_uninstalled += 1
                 # insstall message = msg[0]
                 # uninstall message = msg[1]
                 # total message = msg[2]
                 msg = msgs(mdata[0], count_installed, count_uninstalled)
                 print("\nInstalling summary")
                 print("=" * 79)
                 print("{0}Total found {1} matching {2}.".format(
                     GREY, len(mdata[0]), msg[2]))
                 print("{0} installed {1} and {2} uninstalled {3}.{4}"
                       "\n".format(count_installed, msg[0],
                                   count_uninstalled, msg[1], ENDC))
             else:
                 pkg_not_found("\n", self.name, "No matching", "\n")
     except KeyboardInterrupt:
         print  # new line at exit
         sys.exit()