예제 #1
0
 def getDeps(self):
     pkgbuild = open(os.path.join(self.path, "PKGBUILD"),
                     errors="surrogateescape").read()
     depends = []
     m = re.findall("^makedepends.*?=\((.*?)\)\s*$", pkgbuild,
                    re.MULTILINE | re.DOTALL)
     if m:
         m = " ".join(m)
         depends.extend(m.replace("'", "").replace('"', '').split())
     for dep in depends:
         tmp = Package(dep, self.buildPath, self.repoPath, self.repoName)
         if not tmp.aur and not tmp.repo:
             print("Could not find make dependency %s" % (dep))
         if tmp.aur:
             self.aurdeps.append(tmp)
         else:
             try:
                 pacman("-Qi", dep)
             except sh.ErrorReturnCode_1:
                 try:
                     print("Installing make dependency %s" % (dep))
                     results = sudo.pacman("--noconfirm", "-S", dep)
                 except sh.ErrorReturnCode_1:
                     print("Could not install make dependency %s" % (dep))
                     raise BuildError
     depends = []
     m = re.findall("^depends.*?=\((.*?)\)\s*$", pkgbuild,
                    re.MULTILINE | re.DOTALL)
     if m:
         m = " ".join(m)
         depends.extend(m.replace("'", "").replace('"', '').split())
     for dep in depends:
         tmp = Package(dep, self.buildPath, self.repoPath, self.repoName)
         if not tmp.aur and not tmp.repo:
             print("Could not find dependency %s" % (dep))
         elif tmp.aur:
             self.aurdeps.append(tmp)
         else:
             try:
                 pacman("-Qi", dep)
             except sh.ErrorReturnCode_1:
                 try:
                     print("Installing dependency %s" % (dep))
                     results = sudo.pacman("--noconfirm", "-S", dep)
                 except sh.ErrorReturnCode_1:
                     print("Could not install dependency %s" % (dep))
                     raise BuildError
예제 #2
0
 def write_info_file(self):
     from sh import pacman
     info = pacman("-Si", self.package)
     info_string = str(info)  # # .decode("utf-8")
     with open(
             os.path.join(self.volume, self.package,
                          self.package + "_info.txt"), "w") as fp:
         fp.write(info_string)
예제 #3
0
 def inrepo(self):
     try:
         results = pacman("-Ssq", self.name)
     except sh.ErrorReturnCode_1:
         return
     for result in results.split("\n"):
         if self.name == result:
             self.repo = True
예제 #4
0
def pacman_get_upgradable():
    text_helper.print_header('[PACMAN] Obteniendo paquetes actualizables')
    try:
        pkg_list = sh.pacman('-Qu')
    except:
        text_helper.print_error(
            '[PACMAN] Hubo un error al obtener la lista de paquetes actualizables')
        return False
    text_helper.new_line()
    return pkg_list
예제 #5
0
def pacman_get_installed():
    text_helper.print_header('[PACMAN] Obteniendo paquetes instalados')
    try:
        pkg_list = sh.pacman('-Q')
    except:
        text_helper.print_error(
            '[PACMAN] Hubo un error al obtener la lista de paquetes instalados')
        return False
    text_helper.new_line()
    return pkg_list
예제 #6
0
파일: builder.py 프로젝트: fgsect/fexm
 def install_with_pacman(self) -> bool:
     print("Trying to install {0} via pacman".format(self.package))
     try:
         install_command = pacman(
             "-Sy",
             "--noconfirm",
             self.package,
             _env=configfinder.config_settings.newenv)  # _out=sys.stdout)
         self.qemu = True
     except sh.ErrorReturnCode as e:
         print("Could not install package {0}".format(self.package))
         return False
     if self.package_manager == PackageManager.PACMAN:
         self.install_opt_depends_for_pacman()
     self.installed = True
     return True
예제 #7
0
파일: builder.py 프로젝트: fgsect/fexm
 def install_opt_depends_for_pacman(self):
     from repo_crawlers.archcrawler import ArchCrawler
     ac = ArchCrawler(query="name={0}".format(self.package))
     packagedict = list(ac)[0]
     opt_dependencies = packagedict.get("optdepends")
     opt_dependencies = [
         dep.split(":")[0] for dep in opt_dependencies
         if len(dep.split(":")) >= 1
     ]  # Dependencies often have format package: description
     for dep in opt_dependencies:
         print("Trying to install dependency {0} via pacman".format(dep))
         try:
             install_command = pacman("pacman")("-Sy", "--needed",
                                                "--noconfirm",
                                                dep)  # _out=sys.stdout)
             self.qemu = True
         except sh.ErrorReturnCode as e:
             print("Could not install dependency {0}".format(dep))
         print("Successfully installed package {0}".format(dep))
예제 #8
0
파일: builder.py 프로젝트: fgsect/fexm
 def is_package_installed(self) -> bool:
     if self.package_manager == PackageManager.PACMAN:
         installed_query_command = pacman("-Qi",
                                          self.package,
                                          _ok_code=[0, 1],
                                          _env=configfinder.config_settings.
                                          newenv)  # type:sh.RunningCommand
     elif self.package_manager == PackageManager.APT:
         installed_query_command = dpkg(
             "-s",
             self.package,
             _ok_code=[0, 1],
             _env=configfinder.config_settings.newenv)
     else:
         raise ValueError("No supported package manager found!")
     if installed_query_command.exit_code == 0:
         print("Package {0} is already installed!".format(self.package))
         return True
     elif installed_query_command.exit_code == 1:
         return False
예제 #9
0
파일: builder.py 프로젝트: fgsect/fexm
    def get_file_list(self):
        """
        If the package is already installed/build, returns the paths to the files
        that are shipped with the packages
        :return:
        """
        if self.installed:
            if self.package_manager == PackageManager.APT:

                query_command = dpkg_query(
                    "-L", self.package)  # type: sh.RunningCommand
                query_commmand_output = str(query_command).strip()[
                    1:]  # starts with "./" apparently
                files = query_commmand_output.split("\n")
                return files
            else:
                query_command = pacman("-Ql", "--quiet",
                                       self.package)  # type: sh.RunningCommand
                query_command_output = str(query_command).strip()[
                    1:]  # starts with "./" (not in pacman)
                files = query_command_output.split("\n")
                return files
        elif self.package_dir:
            return list(helpers.utils.absoluteFilePaths(self.package_dir))
예제 #10
0
 def install_logcheck():
     pacman("logcheck", "logcheck_database", -S)
예제 #11
0
 def install_ufw():
     pacman("ufw", "-S")
예제 #12
0
 def install_fail2ban():
     pacman("fail2ban", "-S")
예제 #13
0
def install_essentials():
    logging.info("Installing Essentials")
    pacman("unzip", "wget", "vim", "less", "imagemagick", "sudo", "whois", "dnsutils", "-S")
예제 #14
0
def upgrade_system():
    logging.info("Upgrading System...")
    pacman("-Syy")
    pacman("-Su")