Fix pg_buildext running.

This commit is contained in:
Jelmer Vernooij 2021-03-23 13:50:53 +00:00
parent 96e3e52059
commit 4230c7a6b8
No known key found for this signature in database
GPG key ID: 579C160D4C9E23E8
4 changed files with 15 additions and 4 deletions

View file

@ -22,6 +22,7 @@ __all__ = [
from datetime import datetime
import logging
import os
import shutil
import sys
from typing import List, Set, Optional, Type, Tuple
@ -543,7 +544,9 @@ class PgBuildExtOutOfDateControlFixer(BuildFixer):
def _fix(self, error, context):
logging.info("Running 'pg_buildext updatecontrol'")
self.session.check_call(["pg_buildext", "updatecontrol"])
# TODO(jelmer): Copy control file back
shutil.copy(
self.session.external_path('debian/control'),
context.tree.abspath(os.path.join(context.subpath, 'debian/control')))
return commit_debian_changes(
context.tree,
context.subpath,
@ -744,6 +747,8 @@ def main(argv=None):
args = parser.parse_args()
from breezy.workingtree import WorkingTree
import breezy.git
import breezy.bzr
from .apt import AptManager
from ..session.plain import PlainSession
from ..session.schroot import SchrootSession

View file

@ -97,6 +97,9 @@ class Session(object):
def setup_from_directory(self, path, subdir="package") -> Tuple[str, str]:
raise NotImplementedError(self.setup_from_directory)
def external_path(self, path: str) -> str:
raise NotImplementedError
class SessionSetupFailure(Exception):
"""Session failed to be set up."""

View file

@ -92,6 +92,9 @@ class PlainSession(Session):
def chdir(self, path):
os.chdir(path)
def external_path(self, path):
return os.path.abspath(path)
def setup_from_vcs(
self, tree, include_controldir=None, subdir="package"):
from ..vcs import dupe_vcs_tree, export_vcs_tree

View file

@ -177,17 +177,17 @@ class SchrootSession(Session):
self.check_call(["mkdir", "-p", home], cwd="/", user="root")
self.check_call(["chown", user, home], cwd="/", user="root")
def _fullpath(self, path: str) -> str:
def external_path(self, path: str) -> str:
if self._cwd is None:
raise ValueError("no cwd set")
return os.path.join(self.location, os.path.join(self._cwd, path).lstrip("/"))
def exists(self, path: str) -> bool:
fullpath = self._fullpath(path)
fullpath = self.external_path(path)
return os.path.exists(fullpath)
def scandir(self, path: str):
fullpath = self._fullpath(path)
fullpath = self.external_path(path)
return os.scandir(fullpath)
def setup_from_vcs(