Support for running apt as root.
This commit is contained in:
parent
9c74e770a6
commit
0b9077f964
5 changed files with 17 additions and 2 deletions
|
@ -302,6 +302,10 @@ class Meson(BuildSystem):
|
||||||
self._setup(session, fixers)
|
self._setup(session, fixers)
|
||||||
run_with_build_fixers(session, ["ninja", "-C", "build"], fixers)
|
run_with_build_fixers(session, ["ninja", "-C", "build"], fixers)
|
||||||
|
|
||||||
|
def dist(self, session, resolver, fixers, quiet=False):
|
||||||
|
self._setup(session, fixers)
|
||||||
|
run_with_build_fixers(session, ["ninja", "-C", "build", "dist"], fixers)
|
||||||
|
|
||||||
def test(self, session, resolver, fixers):
|
def test(self, session, resolver, fixers):
|
||||||
self._setup(session, fixers)
|
self._setup(session, fixers)
|
||||||
run_with_build_fixers(session, ["ninja", "-C", "build", "test"], fixers)
|
run_with_build_fixers(session, ["ninja", "-C", "build", "test"], fixers)
|
||||||
|
|
|
@ -103,6 +103,9 @@ class AptManager(object):
|
||||||
def satisfy(self, deps: List[str]) -> None:
|
def satisfy(self, deps: List[str]) -> None:
|
||||||
run_apt(self.session, ["satisfy"] + deps)
|
run_apt(self.session, ["satisfy"] + deps)
|
||||||
|
|
||||||
|
def satisfy_command(self, deps: List[str]) -> str:
|
||||||
|
return ["apt", "satisfy"] + deps
|
||||||
|
|
||||||
|
|
||||||
class ContentsFileNotFound(Exception):
|
class ContentsFileNotFound(Exception):
|
||||||
"""The contents file was not found."""
|
"""The contents file was not found."""
|
||||||
|
|
|
@ -595,7 +595,7 @@ class AptResolver(Resolver):
|
||||||
if apt_req is not None:
|
if apt_req is not None:
|
||||||
apt_requirements.append((r, apt_req))
|
apt_requirements.append((r, apt_req))
|
||||||
if apt_requirements:
|
if apt_requirements:
|
||||||
yield (["apt", "satisfy"] + [PkgRelation.str(chain(*[r.relations for o, r in apt_requirements]))], [o for o, r in apt_requirements])
|
yield (self.apt.satisfy_command([PkgRelation.str(chain(*[r.relations for o, r in apt_requirements]))]), [o for o, r in apt_requirements])
|
||||||
|
|
||||||
def resolve(self, req: Requirement):
|
def resolve(self, req: Requirement):
|
||||||
return resolve_requirement_apt(self.apt, req)
|
return resolve_requirement_apt(self.apt, req)
|
||||||
|
|
|
@ -27,6 +27,13 @@ class PlainSession(Session):
|
||||||
|
|
||||||
location = "/"
|
location = "/"
|
||||||
|
|
||||||
|
def _prepend_user(self, user, args):
|
||||||
|
if user is not None:
|
||||||
|
import getpass
|
||||||
|
if user != getpass.getuser():
|
||||||
|
args = ["sudo", "-u", user] + args
|
||||||
|
return args
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "%s()" % (type(self).__name__, )
|
return "%s()" % (type(self).__name__, )
|
||||||
|
|
||||||
|
@ -40,6 +47,7 @@ class PlainSession(Session):
|
||||||
return subprocess.check_output(args)
|
return subprocess.check_output(args)
|
||||||
|
|
||||||
def Popen(self, args, stdout=None, stderr=None, user=None, cwd=None):
|
def Popen(self, args, stdout=None, stderr=None, user=None, cwd=None):
|
||||||
|
args = self._prepend_user(user, args)
|
||||||
return subprocess.Popen(args, stdout=stdout, stderr=stderr, cwd=cwd)
|
return subprocess.Popen(args, stdout=stdout, stderr=stderr, cwd=cwd)
|
||||||
|
|
||||||
def exists(self, path):
|
def exists(self, path):
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ from setuptools import setup
|
||||||
|
|
||||||
setup(name="ognibuild",
|
setup(name="ognibuild",
|
||||||
description="Detect and run any build system",
|
description="Detect and run any build system",
|
||||||
version="0.0.2",
|
version="0.0.1",
|
||||||
maintainer="Jelmer Vernooij",
|
maintainer="Jelmer Vernooij",
|
||||||
maintainer_email="jelmer@jelmer.uk",
|
maintainer_email="jelmer@jelmer.uk",
|
||||||
license="GNU GPLv2 or later",
|
license="GNU GPLv2 or later",
|
||||||
|
|
Loading…
Add table
Reference in a new issue