def _create_jhbuild_user(): """Create the jhbuild user""" if os.geteuid() == 0: common.run(['adduser', '--shell', '/bin/bash', '--disabled-password', '--system', '--quiet', '--home', os.sep + os.path.join('home', 'jhbuild'), 'jhbuild'])
def _create_jhbuild_user(): """Create the jhbuild user""" if os.geteuid() == 0: common.run([ 'adduser', '--shell', '/bin/bash', '--disabled-password', '--system', '--quiet', '--home', os.sep + os.path.join('home', 'jhbuild'), 'jhbuild' ])
def _fix_xml_tools(root): xml2_config_path = os.path.join(root, 'usr', 'bin', 'xml2-config') if os.path.isfile(xml2_config_path): common.run( ['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'. format(root), xml2_config_path]) xslt_config_path = os.path.join(root, 'usr', 'bin', 'xslt-config') if os.path.isfile(xslt_config_path): common.run( ['sed', '-i', '-e', 's|prefix=/usr|prefix={}/usr|'. format(root), xslt_config_path])
def _find_bin(binary, basedir): # If it doesn't exist it might be in the path logger.debug('Checking that {!r} is in the $PATH'.format(binary)) script = ('#!/bin/sh\n' + '{}\n'.format(common.assemble_env()) + 'which "{}"\n'.format(binary)) with tempfile.NamedTemporaryFile('w+') as tempf: tempf.write(script) tempf.flush() try: common.run(['/bin/sh', tempf.name], cwd=basedir, stdout=subprocess.DEVNULL) except subprocess.CalledProcessError: raise CommandError(binary)
def run(self, cmd, cwd=None, **kwargs): if cwd is None: cwd = self.builddir if True: print(' '.join(cmd)) os.makedirs(cwd, exist_ok=True) return common.run(cmd, cwd=cwd, **kwargs)
def run(self, cmd, cwd=None, **kwargs): if cwd is None: cwd = self.builddir if True: print(" ".join(cmd)) os.makedirs(cwd, exist_ok=True) return common.run(cmd, cwd=cwd, **kwargs)
def run(self, *, scriptlet): """Runs the specified scriptlet.""" if not scriptlet: return try: with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: f.write('#!/bin/sh\n') f.write(scriptlet) f.flush() scriptlet_path = f.name os.chmod(scriptlet_path, 0o755) run([scriptlet_path], cwd=self._builddir) finally: with suppress(FileNotFoundError): os.unlink(scriptlet_path)
def run(self, *, scriptlet): """Runs the specified scriptlet.""" if not scriptlet: return try: with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: f.write('#!/bin/sh -e\n') f.write(scriptlet) f.flush() scriptlet_path = f.name os.chmod(scriptlet_path, 0o755) run([scriptlet_path], cwd=self._builddir) finally: with suppress(FileNotFoundError): os.unlink(scriptlet_path)
def run(self, cmd, cwd=None, **kwargs): if not cwd: cwd = self.builddir print(" ".join(cmd)) os.makedirs(cwd, exist_ok=True) try: return common.run(cmd, cwd=cwd, **kwargs) except CalledProcessError as process_error: raise errors.SnapcraftPluginCommandError( command=cmd, part_name=self.name, exit_code=process_error.returncode ) from process_error
def run(self, cmd, cwd=None, **kwargs): if not cwd: cwd = self.builddir print(' '.join(cmd)) os.makedirs(cwd, exist_ok=True) return common.run(cmd, cwd=cwd, **kwargs)