Exemplo n.º 1
0
 def __scanChroot(self):
     regexstr = "|".join(self.scan_opts['regexes'])
     regex = re.compile(regexstr)
     chroot = self.buildroot.make_chroot_path()
     file_util.mkdirIfAbsent(self.resultdir)
     count = 0
     logger = getLog()
     logger.debug("chroot_scan: Starting scan of %s", chroot)
     copied = []
     for root, _, files in os.walk(chroot):
         for f in files:
             m = regex.search(f)
             if m:
                 srcpath = os.path.join(root, f)
                 subprocess.call("cp --preserve=mode --parents %s %s" % (srcpath, self.resultdir), shell=True)
                 count += 1
                 copied.append(srcpath)
     logger.debug("chroot_scan: finished with %d files found", count)
     if count:
         logger.info("chroot_scan: %d files copied to %s", count, self.resultdir)
         logger.info("\n".join(copied))
         self.buildroot.uid_manager.changeOwner(self.resultdir, recursive=True)
         # some packages installs 555 perms on dirs,
         # so user can't delete/move chroot_scan's results
         subprocess.call(['chmod', '-R', 'u+w', self.resultdir])
Exemplo n.º 2
0
 def _bindMountCreateDirs(self):
     for srcdir, destdir in self.bind_opts['dirs']:
         if os.path.isdir(srcdir):
             file_util.mkdirIfAbsent(srcdir)
             file_util.mkdirIfAbsent(
                 self.buildroot.make_chroot_path(destdir))
         else:
             file_util.touch(self.buildroot.make_chroot_path(destdir))
Exemplo n.º 3
0
    def _ccachePreInitHook(self):
        getLog().info("enabled ccache")
        envupd = {"CCACHE_DIR": "/var/tmp/ccache", "CCACHE_UMASK": "002"}
        if self.ccache_opts.get('compress') is not None:
            envupd["CCACHE_COMPRESS"] = str(self.ccache_opts['compress'])
        self.buildroot.env.update(envupd)

        file_util.mkdirIfAbsent(
            self.buildroot.make_chroot_path('/var/tmp/ccache'))
        file_util.mkdirIfAbsent(self.ccachePath)
        self.buildroot.uid_manager.changeOwner(self.ccachePath, recursive=True)
Exemplo n.º 4
0
    def prepare_socket(self):
        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        try:
            sock.connect(self.socket_path)
        except (socket.error, OSError):
            try:
                os.unlink(self.socket_path)
            except OSError:
                pass
        else:
            # there's another process listening
            sys.exit(0)

        file_util.mkdirIfAbsent(self.rundir)
        # Don't allow regular users to access the socket as they may not be in
        # the mock group
        os.chown(self.rundir, self.buildroot.chrootuid,
                 self.buildroot.chrootgid)
        os.chmod(self.rundir, 0o770)
        sock.bind(self.socket_path)
        os.chown(self.socket_path, self.buildroot.chrootuid,
                 self.buildroot.chrootgid)
        return sock
Exemplo n.º 5
0
 def _mountCreateDirs(self):
     # pylint: disable=unused-variable
     for device, dest_dir, vfstype, mount_opts in self.opts['dirs']:
         file_util.mkdirIfAbsent(self.buildroot.make_chroot_path(dest_dir))