How to use the mock.py.mockbuild.trace_decorator.traceLog function in mock

To help you get started, we’ve selected a few mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rpm-software-management / mock / mock / py / mockbuild / buildroot.py View on Github external
    @traceLog()
    def _init(self, prebuild, do_log):

        self.state.start("chroot init")
        util.mkdirIfAbsent(self.basedir)
        mockgid = grp.getgrnam('mock').gr_gid
        os.chown(self.basedir, os.getuid(), mockgid)
        os.chmod(self.basedir, 0o2775)
        util.mkdirIfAbsent(self.make_chroot_path())
        self.plugins.call_hooks('mount_root')
        # intentionally we do not call bootstrap hook here - it does not have sense
        self._setup_nosync()
        self.chroot_was_initialized = self.chroot_is_initialized()
        self._setup_result_dir()
        getLog().info("calling preinit hooks")
        self.plugins.call_hooks('preinit')
        # intentionally we do not call bootstrap hook here - it does not have sense
github rpm-software-management / mock / mock / py / mockbuild / util.py View on Github external
@traceLog()
def createrepo(config_opts, path):
    """ Create repository in given path. """
    cmd = shlex.split(config_opts["createrepo_command"])
    if os.path.exists(os.path.join(path, 'repodata/repomd.xml')):
        cmd.append('--update')
    cmd.append(path)
    return do(cmd)
github rpm-software-management / mock / mock / py / mockbuild / backend.py View on Github external
    @traceLog()
    def init(self, **kwargs):
        try:
            if self.bootstrap_buildroot is not None:
                # add the extra bind mount to the outer chroot
                inner_mount = self.bootstrap_buildroot.make_chroot_path(self.buildroot.make_chroot_path())
                util.mkdirIfAbsent(self.buildroot.make_chroot_path())
                self.bootstrap_buildroot.initialize(**kwargs)
                # Hide re-mounted chroot from host by rprivate tmpfs.
                self.buildroot.mounts.managed_mounts.append(
                    FileSystemMountPoint(filetype='tmpfs',
                                         device='hide_root_in_bootstrap',
                                         path=inner_mount,
                                         options="rprivate"))
                self.buildroot.mounts.managed_mounts.append(
                    BindMountPoint(self.buildroot.make_chroot_path(), inner_mount,
                                   recursive=True))
github rpm-software-management / mock / mock / py / mockbuild / buildroot.py View on Github external
    @traceLog()
    def _setup_nosync(self):
        multilib = ('x86_64', 's390x')
        # ld_preload need to be same as in bootstrap because we call DNF in bootstrap, but
        # but it will load nosync from the final chroot
        if self.bootstrap_buildroot is not None:
            self.tmpdir = self.bootstrap_buildroot.tmpdir
            if not os.path.isdir(self.tmpdir):
                os.mkdir(self.tmpdir, 0o700)
        else:
            self.tmpdir = tempfile.mkdtemp(prefix="tmp.mock.", dir='/var/tmp')
        os.chmod(self.tmpdir, 0o777)
        tmp_libdir = os.path.join(self.tmpdir, '$LIB')
        mock_libdir = self.make_chroot_path(tmp_libdir)
        nosync_unresolved = '/usr/$LIB/nosync/nosync.so'

        def copy_nosync(lib64=False):
github rpm-software-management / mock / mock / py / mockbuild / package_manager.py View on Github external
    @traceLog()
    def execute(self, *args, **kwargs):
        args_copy = list(copy.copy(args))
        cmd = args_copy[0]
        if cmd not in ['update', 'remove', 'install']:
            self.command = self.config['dnf_command']
            self.support_installroot = True
            self.config['releasever'] = self.saved_releasever
        # else it is builddep or resolvedep and we keep command == config['microdnf_command']
        if cmd == "dnf-install":
            cmd = args_copy[0] = "install"
        result = super(MicroDnf, self).execute(*args_copy, **kwargs)
        # restore original value
        self.command = self.config['microdnf_command']
        self.support_installroot = False
        self.config['releasever'] = None
        return result
github rpm-software-management / mock / mock / py / mockbuild / package_manager.py View on Github external
    @traceLog()
    # pylint: disable=unused-argument
    def install(self, *args, **kwargs):
        return self.execute('install', *args)
github rpm-software-management / mock / mock / py / mockbuild / uid.py View on Github external
    @traceLog()
    # pylint: disable=no-self-use
    def _elevatePrivs(self):
        setresuid(0, 0, 0)
        os.setregid(0, 0)
github rpm-software-management / mock / mock / py / mockbuild / util.py View on Github external
@traceLog()
def add_local_repo(config_opts, baseurl, repoid=None, bootstrap=None):
    if not repoid:
        repoid = generate_repo_id(baseurl)
    else:
        REPOS_ID.append(repoid)
    localyumrepo = """

[{repoid}]
name={baseurl}
baseurl={baseurl}
enabled=1
skip_if_unavailable=0
metadata_expire=0
cost=1
best=1
""".format(repoid=repoid, baseurl=baseurl)
github rpm-software-management / mock / mock / py / mockbuild / uid.py View on Github external
    @traceLog()
    def restorePrivs(self):
        # back to root first
        self._elevatePrivs()

        # then set saved
        privs = self.privStack.pop()
        os.environ.clear()
        os.environ.update(self.privEnviron.pop())
        os.setregid(privs['rgid'], privs['egid'])
        setresuid(privs['ruid'], privs['euid'])
github rpm-software-management / mock / mock / py / mockbuild / plugin.py View on Github external
    @traceLog()
    def call_hooks(self, stage, *args, **kwargs):
        required = kwargs.get('required', False)
        if 'required' in kwargs:
            del kwargs['required']
        hooks = self._hooks.get(stage, [])
        if required and not hooks:
            raise Error(
                "Feature {0} is not provided by any of enabled plugins".format(stage))
        for hook in hooks:
            hook(*args, **kwargs)