Esempio n. 1
0
 def pkg_blacklist(self):
     """Manage blacklist packages
     """
     blacklist = BlackList()
     options = [
         "-b",
         "--blacklist"
     ]
     flag = [
         "--add",
         "--remove"
     ]
     command = ["list"]
     if (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == command[0]):
         blacklist.listed()
     elif (len(self.args) > 2 and self.args[0] in options and
             self.args[-1] == flag[0]):
         blacklist.add(self.args[1:-1])
     elif (len(self.args) == 3 and self.args[0] in options and
             self.args[1] == "ALL" and self.args[-1] == flag[1]):
         blacklist.remove(blacklist.get_black())
     elif (len(self.args) > 2 and self.args[0] in options and
             self.args[-1] == flag[1]):
         blacklist.remove(self.args[1:-1])
     else:
         usage("")
Esempio n. 2
0
def store(*args):
    '''
    Store and return packages for upgrading
    '''
    (dwn, upgrade, comp_sum, uncomp_sum) = ([] for i in range(4))
    if args[4] == "stable":  # stables versions upgrade
        for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
            if (not os.path.isfile(pkg_path + name[:-4])
                    and split_package(name)[0] not in BlackList().packages()):
                dwn.append("{0}{1}/{2}".format(mirrors("", "", args[4]), loc,
                                               name))
                comp_sum.append(comp)
                uncomp_sum.append(uncomp)
                upgrade.append(name)
    else:  # current version upgrade
        installed = []
        # get all installed packages and store the package name.
        for pkg in os.listdir(pkg_path):
            installed.append(split_package(pkg)[0])
        for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
            # If the package from the current repository is installed
            # (check with the name) but not is in the path (check with
            # all package like 'apr-1.5.0-x86_64-1') then add to list for
            # upgrade.
            # etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1'
            # exist in /var/log/packages ?? if no add to upgrade.
            if split_package(name)[0] in installed:
                if (not os.path.isfile(pkg_path + name[:-4]) and
                        split_package(name)[0] not in BlackList().packages()):
                    dwn.append("{0}{1}/{2}".format(mirrors("", "", args[4]),
                                                   loc, name))
                    comp_sum.append(comp)
                    uncomp_sum.append(uncomp)
                    upgrade.append(name)
    return [dwn, upgrade, comp_sum, uncomp_sum]
Esempio n. 3
0
 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 = []
Esempio n. 4
0
 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")
Esempio n. 5
0
 def __init__(self, packages, repo, flag):
     self.packages = packages
     pkg_security(packages)
     self.repo = repo
     self.flag = flag
     self.meta = _meta_
     self.msg = Msg()
     self.version = self.meta.slack_rel
     self.tmp_path = self.meta.slpkg_tmp_packages
     for fl in self.flag:
         if fl.startswith("--directory-prefix="):
             self.tmp_path = fl.split("=")[1]
             if not self.tmp_path.endswith("/"):
                 self.tmp_path += "/"
     self.dwn, self.dep_dwn = [], []
     self.install, self.dep_install = [], []
     self.comp_sum, self.dep_comp_sum = [], []
     self.uncomp_sum, self.dep_uncomp_sum = [], []
     self.dependencies = []
     self.deps_dict = {}
     self.answer = ""
     self.msg.reading()
     self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
     self.data = repo_data(self.PACKAGES_TXT, self.repo, self.flag)
     self.repo_pkg_names = []
     for name in self.data[0]:
         self.repo_pkg_names.append(split_package(name)[0])
     self.blacklist = BlackList().packages(self.data[0], self.repo)
     self.matching = False
Esempio n. 6
0
 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()
Esempio n. 7
0
def store(*args):
    '''
    Store and return packages for install
    '''
    dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
    for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
        if args[4] in name and args[4] not in BlackList().packages():
            dwn.append("{0}{1}/{2}".format(mirrors("", "", args[5]), loc,
                                           name))
            install.append(name)
            comp_sum.append(comp)
            uncomp_sum.append(uncomp)
    return [dwn, install, comp_sum, uncomp_sum]
Esempio n. 8
0
def find_package(find_pkg, directory):
    """Find packages
    """
    pkgs = []
    if os.path.isdir(directory):
        installed = sorted(os.listdir(directory))
        blacklist = BlackList().packages(pkgs=installed, repo="local")
        if os.path.exists(directory):
            for pkg in installed:
                if (not pkg.startswith(".") and pkg.startswith(find_pkg)
                        and split_package(pkg)[0] not in blacklist):
                    pkgs.append(pkg)
    return pkgs
Esempio n. 9
0
def search_pkg(name, repo):
    """Search if package exists in PACKAGES.TXT file
    and return the name.
    """
    PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
                                     "PACKAGES.TXT".format(repo))
    names = Utils().package_name(PACKAGES_TXT)
    blacklist = BlackList().packages(pkgs=names, repo=repo)
    for line in PACKAGES_TXT.splitlines():
        status(0)
        if line.startswith("PACKAGE NAME:  ") and len(line) > 16:
            pkg_name = split_package(line[15:])[0].strip()
            if name == pkg_name and name not in blacklist:
                return pkg_name
Esempio n. 10
0
 def repositories(self):
     """Get dependencies by repositories
     """
     if self.repo == "sbo":
         self.sbo_case_insensitive()
         self.find_pkg = sbo_search_pkg(self.name)
         if self.find_pkg:
             self.dependencies_list = Requires(self.flag).sbo(self.name)
     else:
         PACKAGES_TXT = Utils().read_file(
             self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo))
         self.names = Utils().package_name(PACKAGES_TXT)
         self.bin_case_insensitive()
         self.find_pkg = search_pkg(self.name, self.repo)
         if self.find_pkg:
             self.black = BlackList().packages(self.names, self.repo)
             self.dependencies_list = Dependencies(
                 self.repo, self.black).binary(self.name, self.flag)
Esempio n. 11
0
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
Esempio n. 12
0
def sbo_search_pkg(name):
    '''
    Search for package path from SLACKBUILDS.TXT file
    '''
    try:
        blacklist = BlackList().packages()
        sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(
            slack_ver()))
        with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
                  "r") as SLACKBUILDS_TXT:
            for line in SLACKBUILDS_TXT:
                if line.startswith("SLACKBUILD LOCATION"):
                    sbo_name = (line[23:].split("/")[-1].replace("\n",
                                                                 "")).strip()
                    if name == sbo_name and name not in blacklist:
                        SLACKBUILDS_TXT.close()
                        return (sbo_url + line[23:].strip() + "/")
    except KeyboardInterrupt:
        print  # new line at exit
        sys.exit()
Esempio n. 13
0
 def store(self):
     """
     Store and return packages for upgrading
     """
     data = repo_data(self.PACKAGES_TXT, "slack", self.flag)
     black = BlackList().packages(pkgs=data[0], repo="slack")
     for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
         status(0.0003)
         repo_pkg_name = split_package(name)[0]
         if (not os.path.isfile(self.meta.pkg_path + name[:-4])
                 and repo_pkg_name not in black
                 and repo_pkg_name not in self.skip):
             self.dwn_links.append("{0}{1}/{2}".format(
                 mirrors("", ""), loc, name))
             self.comp_sum.append(comp)
             self.uncomp_sum.append(uncomp)
             self.upgrade_all.append(name)
             self.count_upg += 1
             if not find_package(repo_pkg_name + self.meta.sp,
                                 self.meta.pkg_path):
                 self.count_added += 1
                 self.count_upg -= 1
     return self.count_upg
Esempio n. 14
0
def sbo_dependencies_pkg(name):
    '''
    Build all dependencies of a package
    '''
    try:
        dependencies = []
        blacklist = BlackList().packages()
        requires = SBoGrep(name).requires()
        if requires:
            for req in requires:
                # avoid to add %README% as dependency and
                # if require in blacklist
                if "%README%" not in req and req not in blacklist:
                    dependencies.append(req)
            if dependencies:
                dep_results.append(dependencies)
                for dep in dependencies:
                    sys.stdout.write("{0}.{1}".format(GREY, ENDC))
                    sys.stdout.flush()
                    sbo_dependencies_pkg(dep)
        return dep_results
    except KeyboardInterrupt:
        print  # new line at exit
        sys.exit()
Esempio n. 15
0
 def pkg_blacklist(self):
     """Manage blacklist packages
     """
     blacklist = BlackList()
     options = ["-b", "--blacklist"]
     flag = ["--add", "--remove"]
     command = ["list"]
     if (len(self.args) == 2 and self.args[0] in options
             and self.args[1] == command[0]):
         blacklist.listed()
     elif (len(self.args) > 2 and self.args[0] in options
           and flag[0] in self.args):
         self.args.remove(flag[0])
         blacklist.add(self.args[1:])
     elif (len(self.args) == 3 and self.args[0] in options
           and "ALL" in self.args and flag[1] in self.args):
         self.args.remove(flag[1])
         blacklist.remove(blacklist.get_black())
     elif (len(self.args) > 2 and self.args[0] in options
           and flag[1] in self.args):
         self.args.remove(flag[1])
         blacklist.remove(self.args[1:])
     else:
         usage("")