示例#1
0
文件: manager.py 项目: dslackw/slpkg
 def _get_removed(self):
     """Manage removed packages by extra options
     """
     removed, packages = [], []
     if "--tag" in self.extra:
         for pkg in find_package("", self.meta.pkg_path):
             for tag in self.binary:
                 if pkg.endswith(tag):
                     removed.append(split_package(pkg)[0])
                     packages.append(pkg)
         if not removed:
             self.msg.pkg_not_found("", "'tag'", "Can't remove", "\n")
             raise SystemExit(1)
     else:
         for pkg in self.binary:
             name = GetFromInstalled(pkg).name()
             ver = GetFromInstalled(pkg).version()
             package = find_package("{0}{1}{2}".format(
                 name, ver, self.meta.sp), self.meta.pkg_path)
             if pkg and name == pkg:
                 removed.append(pkg)
                 packages.append(package[0])
             else:
                 self.msg.pkg_not_found("", pkg, "Can't remove", "\n")
                 raise SystemExit(1)
     return removed, packages
示例#2
0
 def views(self, install, comp_sum):
     """
     Views packages
     """
     pkg_sum = uni_sum = upg_sum = 0
     # fix repositories align
     repo = self.repo + (" " * (6 - (len(self.repo))))
     for pkg, comp in zip(install, comp_sum):
         pkg_split = split_package(pkg[:-4])
         if find_package(pkg[:-4], self.meta.pkg_path):
             pkg_sum += 1
             COLOR = self.meta.color["GREEN"]
         elif find_package(pkg_split[0] + self.meta.sp, self.meta.pkg_path):
             COLOR = self.meta.color["YELLOW"]
             upg_sum += 1
         else:
             COLOR = self.meta.color["RED"]
             uni_sum += 1
         ver = get_installed_version(pkg_split[0])
         print("  {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
             COLOR, pkg_split[0] + ver, self.meta.color["ENDC"],
             " " * (23-len(pkg_split[0] + ver)), pkg_split[1],
             " " * (18-len(pkg_split[1])), pkg_split[2],
             " " * (8-len(pkg_split[2])), pkg_split[3],
             " " * (7-len(pkg_split[3])), repo,
             comp, " K")).rstrip()
     return [pkg_sum, upg_sum, uni_sum]
示例#3
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
示例#4
0
 def __init__(self, image):
     self.image = image
     self.meta = _meta_
     self.msg = Msg()
     self.grey = self.meta.color["GREY"]
     self.green = self.meta.color["GREEN"]
     self.endc = self.meta.color["ENDC"]
     self.dmap = {}
     self.count_pkg = 0
     self.count_dep = 0
     self.dep_path = self.meta.log_path + "dep/"
     self.logs = find_package("", self.dep_path)
     if not self.logs:
         self.no_logs()
     self.installed = find_package("", self.meta.pkg_path)
示例#5
0
 def _check_if_used(self, removes):
     """Check package if dependencies for another package
     before removed"""
     if self.extra == "--check-deps":
         print("")
         view = False
         package, dependency = [], []
         for pkg in find_package("", self.dep_path):
             deps = Utils().read_file(self.dep_path + pkg)
             for rmv in removes:
                 if rmv in deps.split():
                     view = True
                     package.append(pkg)
                     dependency.append(rmv)
         if view:
             Msg().template(78)
             print("| {0}{1}{2}".format(
                 self.meta.color["RED"], " " * 30 + "!!! WARNING !!!",
                 self.meta.color["ENDC"]))
             Msg().template(78)
             for p, d in zip(package, dependency):
                 print("| {0}{1}{2} is dependency of the package --> "
                       "{3}{4}{5}".format(self.meta.color["YELLOW"], d,
                                          self.meta.color["ENDC"],
                                          self.meta.color["GREEN"], p,
                                          self.meta.color["ENDC"]))
             Msg().template(78)
             self._skip_remove()
示例#6
0
文件: manager.py 项目: websafe/slpkg
 def find(self, flag):
     """Find installed Slackware packages
     """
     matching, pkg_cache, match_cache = 0, "", ""
     print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
         self.meta.color["CYAN"], ", ".join(self.binary),
         self.meta.color["ENDC"]))
     for pkg in self.binary:
         for match in find_package("", self.meta.pkg_path):
             if "--case-ins" in flag:
                 pkg_cache = pkg.lower()
                 match_cache = match.lower()
             else:
                 pkg_cache = pkg
                 match_cache = match
             if pkg_cache in match_cache:
                 matching += 1
                 print("[ {0}installed{1} ] - {2}".format(
                     self.meta.color["GREEN"], self.meta.color["ENDC"],
                     match))
                 self._sizes(match)
     if matching == 0:
         message = "Can't find"
         self.msg.pkg_not_found("", ", ".join(self.binary), message, "\n")
     else:
         self._calc_sizes()
         print("\nFound summary")
         print("=" * 79)
         print("{0}Total found {1} matching packages.{2}".format(
             self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
         print("{0}Size of installed packages {1} {2}.{3}\n".format(
             self.meta.color["GREY"], round(self.size, 2), self.unit,
             self.meta.color["ENDC"]))
示例#7
0
 def find(self):
     """Find installed Slackware packages
     """
     matching = size = 0
     print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
         self.meta.color["CYAN"], ", ".join(self.binary),
         self.meta.color["ENDC"]))
     for pkg in self.binary:
         for match in find_package("", self.meta.pkg_path):
             if pkg in match:
                 matching += 1
                 print("[ {0}installed{1} ] - {2}".format(
                     self.meta.color["GREEN"], self.meta.color["ENDC"],
                     match))
                 data = Utils().read_file(self.meta.pkg_path + match)
                 for line in data.splitlines():
                     if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
                         if "M" in line[26:]:
                             size += float(line[26:-1]) * 1024
                         else:
                             size += float(line[26:-1])
                         break
     if matching == 0:
         message = "Can't find"
         Msg().pkg_not_found("", ", ".join(self.binary), message, "\n")
     else:
         print("\n{0}Total found {1} matching packages.{2}".format(
             self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
         unit = "Kb"
         if size > 1024:
             unit = "Mb"
             size = (size / 1024)
         print("{0}Size of installed packages {1} {2}.{3}\n".format(
             self.meta.color["GREY"], round(size, 2), unit,
             self.meta.color["ENDC"]))
示例#8
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
示例#9
0
def choose_upg(packages):
    """Create checklist to choose packages for upgrade
    """
    selected_packages, data = [], []
    if packages:
        for pkg in packages:
            name = GetFromInstalled(pkg).name()
            ver = GetFromInstalled(pkg).version()
            binary = "{0}{1}".format(name, ver)
            installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
            data.append(installed)
        text = "Press 'spacebar' to unchoose packages from upgrade"
        title = " Upgrade "
        backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__)
        status = True
        pkgs = DialogUtil(data, text, title, backtitle,
                          status).checklist()
        pkgs = [] if pkgs is None else pkgs
        for pkg in pkgs:
            name = split_package(pkg)[0]
            if name in packages:
                selected_packages.append(name)
        if not selected_packages:
            raise SystemExit()
        print("")
    return selected_packages
示例#10
0
 def tag(self, sbo, count_ins, count_upg, count_uni):
     """Tag with color green if package already installed,
     color yellow for packages to upgrade and color red
     if not installed.
     """
     if find_package(sbo, self.meta.pkg_path):
         paint = self.meta.color["GREEN"]
         count_ins += 1
     elif find_package("-".join(sbo.split("-")[:-1]) + "-",
                       self.meta.pkg_path):
         paint = self.meta.color["YELLOW"]
         count_upg += 1
     else:
         paint = self.meta.color["RED"]
         count_uni += 1
     return paint, count_ins, count_upg, count_uni
示例#11
0
def store(dependencies_list):
    '''
    In the end lest a check of the packages that are on the list
    are already installed.
    '''
    (upgrade_name,
     package_for_upgrade,
     upgrade_version,
     upgrade_arch
     ) = ([] for i in range(4))
    for pkg in dependencies_list:
        ver = SBoGrep(pkg).version()
        prgnam = ("{0}-{1}".format(pkg, ver))
        # if package not installed
        # take version from repository
        pkg_version = ver
        arch = os.uname()[4]
        if arch.startswith("i") and arch.endswith("86"):
            arch = "i486"
        if find_package(prgnam, pkg_path) == []:
            for sbo in os.listdir(pkg_path):
                if (sbo.startswith(pkg + sp) and
                        sbo.endswith("_SBo")):
                    # search if packages installed
                    # if yes grab package name and version
                    pkg_version = split_package(sbo)[1]
            upgrade_name.append(pkg)
            package_for_upgrade.append("{0}-{1}".format(pkg, pkg_version))
            upgrade_version.append(ver)
            upgrade_arch.append(arch)
    return [upgrade_name, package_for_upgrade, upgrade_version, upgrade_arch]
示例#12
0
 def install_packages(self):
     """
     Install or upgrade packages
     """
     installs, upgraded = [], []
     for inst in (self.dep_install + self.install):
         package = (self.tmp_path + inst).split()
         pkg_ver = "{0}-{1}".format(split_package(inst)[0],
                                    split_package(inst)[1])
         self.checksums(inst)
         if os.path.isfile(self.meta.pkg_path + inst[:-4]):
             print("[ {0}reinstalling{1} ] --> {2}".format(
                 self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
             installs.append(pkg_ver)
             PackageManager(package).upgrade("--reinstall")
         elif find_package(split_package(inst)[0] + self.meta.sp,
                           self.meta.pkg_path):
             print("[ {0}upgrading{1} ] --> {2}".format(
                 self.meta.color["YELLOW"], self.meta.color["ENDC"], inst))
             upgraded.append(pkg_ver)
             PackageManager(package).upgrade("--install-new")
         else:
             print("[ {0}installing{1} ] --> {2}".format(
                 self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
             installs.append(pkg_ver)
             PackageManager(package).upgrade("--install-new")
     return [installs, upgraded]
示例#13
0
 def _rmv_pkg(self, package):
     """Remove one signle package
     """
     if (find_package(package + self.meta.sp, self.meta.pkg_path) and
             package not in self.skip):
         self._removepkg(package)
     return package.split()
示例#14
0
 def search_in_tmp(self, prgnam):
     """Search for binary packages in /tmp directory
     """
     binary = []
     for search in find_package(prgnam, self.meta.output):
         if "_SBo" in search:
             binary.append(search)
     return binary
示例#15
0
 def list_of_installed(self, pkg):
     """Return installed packages
     """
     find = pkg + self.meta.sp
     if pkg.endswith(".txz") or pkg.endswith(".tgz"):
         find = pkg[:-4]
     if find_package(find, self.meta.pkg_path):
         return pkg
示例#16
0
 def deps_used(self, pkg, used):
     """Create dependencies dictionary
     """
     if find_package(pkg + self.meta.sp, self.meta.pkg_path):
         if pkg not in self.deps_dict.values():
             self.deps_dict[pkg] = used
         else:
             self.deps_dict[pkg] += used
示例#17
0
文件: tracking.py 项目: dslackw/slpkg
 def run(self):
     """Run tracking dependencies
     """
     self.msg.resolving()
     self.repositories()
     if self.find_pkg:
         self.dependencies_list.reverse()
         self.requires = Utils().dimensional_list(self.dependencies_list)
         self.dependencies = Utils().remove_dbs(self.requires)
         if self.dependencies == []:
             self.dependencies = ["No dependencies"]
         if "--graph=" in self.flag:
             self.deps_tree()
         self.msg.done()
         pkg_len = len(self.name) + 24
         print("")    # new line at start
         self.msg.template(pkg_len)
         print("| Package {0}{1}{2} dependencies :".format(
             self.cyan, self.name, self.endc))
         self.msg.template(pkg_len)
         print("\\")
         print(" +---{0}[ Tree of dependencies ]{1}".format(self.yellow,
                                                            self.endc))
         index = 0
         for pkg in self.dependencies:
             if "--check-deps" in self.flag:
                 used = self.check_used(pkg)
                 self.deps_used(pkg, used)
                 used = "{0} {1}{2}{3}".format(
                     "is dependency -->", self.cyan,
                     ", ".join(used), self.endc)
             else:
                 used = ""
             index += 1
             installed = ""
             if find_package(pkg + self.meta.sp, self.meta.pkg_path):
                 if self.meta.use_colors in ["off", "OFF"]:
                     installed = "* "
                 print(" |")
                 print(" {0}{1}: {2}{3}{4} {5}{6}".format(
                     "+--", index, self.green, pkg,
                     self.endc, installed, used))
             else:
                 print(" |")
                 print(" {0}{1}: {2}{3}{4} {5}".format(
                     "+--", index, self.red, pkg,
                     self.endc, installed))
         if self.meta.use_colors in ["off", "OFF"]:
             print("\n * = Installed\n")
         else:
             print("")    # new line at end
         if "--graph=" in self.flag:
             self.graph()
     else:
         self.msg.done()
         print("\nNo package was found to match\n")
         raise SystemExit(1)
示例#18
0
def search_in_tmp(prgnam):
    '''
    Search for binarys packages in /tmp directory
    '''
    binary = []
    for search in find_package(prgnam, tmp):
        if "_SBo" in search:
            binary.append(search)
    return binary
示例#19
0
 def __init__(self, package):
     self.package = package
     self.meta = _meta_
     self.files = find_package(self.package + self.meta.sp,
                               self.meta.pkg_path)
     self.find = ""
     for f in self.files:
         if split_package(f)[0] == self.package:
             self.find = f
示例#20
0
 def list_color_tag(self, pkg):
     """Tag with color installed packages
     """
     find = pkg + self.meta.sp
     if pkg.endswith(".txz") or pkg.endswith(".tgz"):
         find = pkg[:-4]
     if find_package(find, self.meta.pkg_path):
         pkg = "{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
                                  self.meta.color["ENDC"])
     return pkg
示例#21
0
文件: manager.py 项目: websafe/slpkg
 def list_of_installed(self, repo):
     """Return installed packages
     """
     all_installed_names = []
     all_installed_packages = find_package("", self.meta.pkg_path)
     for inst in all_installed_packages:
         if repo == "sbo" and inst.endswith("_SBo"):
             name = split_package(inst)[0]
             all_installed_names.append(name)
         else:
             all_installed_names.append(inst)
     return all_installed_names
示例#22
0
 def check_used(self, pkg):
     """Check if dependencies used
     """
     used = []
     dep_path = self.meta.log_path + "dep/"
     logs = find_package("", dep_path)
     for log in logs:
         deps = Utils().read_file(dep_path + log)
         for dep in deps.splitlines():
             if pkg == dep:
                 used.append(log)
     return used
示例#23
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]
示例#24
0
 def choice_install(self):
     """Download, build and install package
     """
     if not find_package(self.prgnam, self.meta.pkg_path):
         self.build()
         self.install()
         delete(self.build_folder)
         raise SystemExit()
     else:
         self.msg.template(78)
         self.msg.pkg_found(self.prgnam)
         self.msg.template(78)
         raise SystemExit()
示例#25
0
def pkg_colors_tag(name, sbo_versions, count_upg, count_ins):
    '''
    Tag with color green if package already installed,
    color yellow for packages to upgrade and color red
    if not installed. Also if package arch is UNSUPPORTED
    tag with color red and if UNTESTED with color yellow.
    '''
    # check if 'sbo_versions' is list if true
    # then get last package from list is master package
    # if false 'sbo_version' is a string
    if isinstance(sbo_versions, list):
        sbo_versions = sbo_versions[-1]
    master_pkg = ("{0}-{1}".format(name, sbo_versions))
    if find_package(master_pkg, pkg_path):
        color = GREEN
    elif find_package(name + sp, pkg_path):
        color = YELLOW
        count_upg += 1
    else:
        color = RED
        count_ins += 1
    return color, [count_upg, count_ins]
示例#26
0
文件: views.py 项目: fatman2021/slpkg
 def view(self):
     """
     View SlackBuild package, read or install them
     from slackbuilds.org
     """
     if self.sbo_url and self.name not in self.blacklist:
         prgnam = ("{0}-{1}".format(self.name, self.sbo_version))
         self.view_sbo(
             self.name, self.sbo_url, self.sbo_desc,
             self.sbo_dwn.split("/")[-1],
             ", ".join([src.split("/")[-1] for src in self.source_dwn]),
             self.sbo_req)
         FAULT = self.error_uns()
         while True:
             choice = self.read_choice()
             if choice in ["D", "d"]:
                 Download(path="", url=self.dwn_srcs, repo="sbo").start()
                 break
             elif choice in ["R", "r"]:
                 README = Read(self.sbo_url).readme("README")
                 fill = self.fill_pager(README)
                 pydoc.pager(README + fill)
             elif choice in ["F", "f"]:
                 info = Read(self.sbo_url).info(self.name, ".info")
                 fill = self.fill_pager(info)
                 pydoc.pager(info + fill)
             elif choice in ["S", "s"]:
                 SlackBuild = Read(self.sbo_url).slackbuild(self.name,
                                                            ".SlackBuild")
                 fill = self.fill_pager(SlackBuild)
                 pydoc.pager(SlackBuild + fill)
             elif choice in ["B", "b"]:
                 self.build(FAULT)
                 delete(self.build_folder)
                 break
             elif choice in ["I", "i"]:
                 if not find_package(prgnam + self.meta.sp,
                                     self.meta.pkg_path):
                     self.build(FAULT)
                     self.install(prgnam)
                     delete(self.build_folder)
                     break
                 else:
                     Msg().template(78)
                     Msg().pkg_found(self.name, self.sbo_version)
                     Msg().template(78)
                     break
             else:
                 break
     else:
         Msg().pkg_not_found("\n", self.name, "Can't view", "\n")
示例#27
0
 def _rmv_deps(self, dependencies, package):
     """Remove dependencies
     """
     removes = []
     deps = dependencies.split()
     deps.append(package)
     self._check_if_used(deps)
     for dep in deps:
         if (dep not in self.skip and
                 find_package(dep + self.meta.sp, self.meta.pkg_path)):
             self._removepkg(dep)
             removes.append(dep)
     os.remove(self.dep_path + package)
     return removes
示例#28
0
 def _reference_rmvs(self, removes):
     """Prints all removed packages
     """
     print("")
     Msg().template(78)
     print("| Total {0} packages removed".format(len(removes)))
     Msg().template(78)
     for pkg in removes:
         if not find_package(pkg + self.meta.sp, self.meta.pkg_path):
             print("| Package {0} removed".format(pkg))
         else:
             print("| Package {0} not found".format(pkg))
     Msg().template(78)
     print("")   # new line at end
示例#29
0
def slack_package(prgnam):
    """Return maximum binary Slackware package from output directory
    """
    binaries, cache, binary = [], " ", ""
    for pkg in find_package(prgnam, _meta_.output):
        if pkg.startswith(prgnam) and pkg[:-4].endswith("_SBo"):
            binaries.append(pkg)
    for bins in binaries:
        if LooseVersion(bins) > LooseVersion(cache):
            binary = bins
            cache = binary
    if not binary:
        Msg().build_FAILED(prgnam)
        raise SystemExit()
    return ["".join(_meta_.output + binary)]
示例#30
0
def write_deps(deps_dict):
    """Write dependencies in a log file
    into directory `/var/log/slpkg/dep/`
    """
    for name, dependencies in deps_dict.iteritems():
        if find_package(name + _meta_.sp, _meta_.pkg_path):
            dep_path = _meta_.log_path + "dep/"
            if not os.path.exists(dep_path):
                os.mkdir(dep_path)
            if os.path.isfile(dep_path + name):
                os.remove(dep_path + name)
            if len(dependencies) >= 1:
                with open(dep_path + name, "w") as f:
                    for dep in dependencies:
                        f.write(dep + "\n")
                    f.close()