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) | ||||
|         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): | ||||
|         self._setup(session, 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: | ||||
|         run_apt(self.session, ["satisfy"] + deps) | ||||
| 
 | ||||
|     def satisfy_command(self, deps: List[str]) -> str: | ||||
|         return ["apt", "satisfy"] + deps | ||||
| 
 | ||||
| 
 | ||||
| class ContentsFileNotFound(Exception): | ||||
|     """The contents file was not found.""" | ||||
|  |  | |||
|  | @ -595,7 +595,7 @@ class AptResolver(Resolver): | |||
|             if apt_req is not None: | ||||
|                 apt_requirements.append((r, apt_req)) | ||||
|         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): | ||||
|         return resolve_requirement_apt(self.apt, req) | ||||
|  |  | |||
|  | @ -27,6 +27,13 @@ class PlainSession(Session): | |||
| 
 | ||||
|     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): | ||||
|         return "%s()" % (type(self).__name__, ) | ||||
| 
 | ||||
|  | @ -40,6 +47,7 @@ class PlainSession(Session): | |||
|         return subprocess.check_output(args) | ||||
| 
 | ||||
|     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) | ||||
| 
 | ||||
|     def exists(self, path): | ||||
|  |  | |||
							
								
								
									
										2
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								setup.py
									
										
									
									
									
								
							|  | @ -6,7 +6,7 @@ from setuptools import setup | |||
| 
 | ||||
| setup(name="ognibuild", | ||||
|       description="Detect and run any build system", | ||||
|       version="0.0.2", | ||||
|       version="0.0.1", | ||||
|       maintainer="Jelmer Vernooij", | ||||
|       maintainer_email="jelmer@jelmer.uk", | ||||
|       license="GNU GPLv2 or later", | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jelmer Vernooij
						Jelmer Vernooij