def __init__(
        self,
        root,
        repositories: {str: [str]} = None,
        architecture: str = "auto",
        user_options: {} = None,
    ):
        self._root = Path(root)
        self._config_path = self._root / "pacman.conf"
        self._db_path = self._root / "db"
        self._cache_dir = self._root / "pkg"
        self._gpg_dir = self._root / "gnupg"
        self._repositories = repositories
        self._keyrings = []
        self._architecture = architecture
        self._options = user_options if user_options else {}
        self._deps = dict()

        self._db_path.mkdir(parents=True, exist_ok=True)
        self._cache_dir.mkdir(parents=True, exist_ok=True)
        self._gpg_dir.mkdir(parents=True, exist_ok=True)

        self._logger = logging.getLogger("pacman")
        self._deps = shell.resolve_commands_paths(DEPENDS_ON)
        self._generate_config()
        self._start_gpg_agent()
        self._configure_keyring()
Exemple #2
0
def has_soname(path):
    """
    Determine if an elf is a library

    Elf must have a SONAME tag in the dynamic section
    """
    command_args = shell.resolve_commands_paths(["readelf"])
    command_args["path"] = path
    _proc = subprocess.run(
        "{readelf} -d {path}".format(**command_args),
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True,
    )

    has_soname_tag = False
    if _proc.returncode == 0:
        output = _proc.stdout.decode("utf-8")
        has_soname_tag = "SONAME" in output
    return has_soname_tag
Exemple #3
0
    def __init__(
        self,
        base_path: str,
        sources: [str],
        keys: [str],
        architectures: [],
        user_options: {} = None,
    ):
        self.logger = logging.getLogger("apt")
        self._deps = shell.resolve_commands_paths(DEPENDS_ON)

        self.sources = sources
        self.keys = keys
        self.architectures = architectures
        self.user_options = user_options

        self._generate_paths(base_path)
        self._write_apt_conf(user_options, architectures)
        self._write_sources_list(sources)
        self._write_keys(keys)
        self._write_dpkg_arch(architectures)
Exemple #4
0
def has_start_symbol(path):
    """
    Determine if an elf is executable

    The `_start` symbol must be present in every runnable elf file.
    http://www.dbp-consulting.com/tutorials/debugging/linuxProgramStartup.html
    """
    command_args = shell.resolve_commands_paths(["readelf"])
    command_args["path"] = path
    _proc = subprocess.run(
        "{readelf} -s {path}".format(**command_args),
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        shell=True,
    )

    has_main_method = False
    if _proc.returncode == 0:
        output = _proc.stdout.decode("utf-8")
        has_main_method = "_start" in output
    return has_main_method
 def __init__(self):
     self.logger = logging.getLogger(str(self.__class__.__name__))
     self._cli_tools = shell.resolve_commands_paths(self.REQUIRED_COMMANDS)
 def __init__(self):
     self.logger = logging.getLogger("AppRuntimeAnalyser")
     self._deps = shell.resolve_commands_paths(DEPENDS_ON)