Stop returning SbuildFailure.
This commit is contained in:
parent
43937c8326
commit
52b8694b5c
2 changed files with 54 additions and 11 deletions
|
@ -19,7 +19,8 @@ __all__ = [
|
||||||
"get_build_architecture",
|
"get_build_architecture",
|
||||||
"add_dummy_changelog_entry",
|
"add_dummy_changelog_entry",
|
||||||
"build",
|
"build",
|
||||||
"SbuildFailure",
|
"DetailedDebianBuildFailure",
|
||||||
|
"UnidentifiedDebianBuildError",
|
||||||
]
|
]
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -27,6 +28,7 @@ from debmutate.changelog import ChangelogEditor
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -39,13 +41,33 @@ from breezy.tree import Tree
|
||||||
|
|
||||||
from buildlog_consultant.sbuild import (
|
from buildlog_consultant.sbuild import (
|
||||||
worker_failure_from_sbuild_log,
|
worker_failure_from_sbuild_log,
|
||||||
SbuildFailure,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .. import DetailedFailure as DetailedFailure, UnidentifiedError
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_BUILDER = "sbuild --no-clean-source"
|
DEFAULT_BUILDER = "sbuild --no-clean-source"
|
||||||
|
|
||||||
|
|
||||||
|
class DetailedDebianBuildFailure(DetailedFailure):
|
||||||
|
|
||||||
|
def __init__(self, stage, phase, retcode, argv, error, description):
|
||||||
|
super(DetailedDebianBuildFailure, self).__init__(retcode, argv, error)
|
||||||
|
self.stage = stage
|
||||||
|
self.phase = phase
|
||||||
|
self.description = description
|
||||||
|
|
||||||
|
|
||||||
|
class UnidentifiedDebianBuildError(UnidentifiedError):
|
||||||
|
|
||||||
|
def __init__(self, stage, phase, retcode, argv, lines, description, secondary=None):
|
||||||
|
super(UnidentifiedDebianBuildError, self).__init__(
|
||||||
|
retcode, argv, lines, secondary)
|
||||||
|
self.stage = stage
|
||||||
|
self.phase = phase
|
||||||
|
self.description = description
|
||||||
|
|
||||||
|
|
||||||
class MissingChangesFile(Exception):
|
class MissingChangesFile(Exception):
|
||||||
"""Expected changes file was not written."""
|
"""Expected changes file was not written."""
|
||||||
|
|
||||||
|
@ -200,9 +222,23 @@ def build_once(
|
||||||
subpath=subpath,
|
subpath=subpath,
|
||||||
source_date_epoch=source_date_epoch,
|
source_date_epoch=source_date_epoch,
|
||||||
)
|
)
|
||||||
except BuildFailedError:
|
except BuildFailedError as e:
|
||||||
with open(build_log_path, "rb") as f:
|
with open(build_log_path, "rb") as f:
|
||||||
raise worker_failure_from_sbuild_log(f)
|
sbuild_failure = worker_failure_from_sbuild_log(f)
|
||||||
|
retcode = getattr(e, 'returncode', None)
|
||||||
|
if sbuild_failure.error:
|
||||||
|
raise DetailedDebianBuildFailure(
|
||||||
|
sbuild_failure.stage,
|
||||||
|
sbuild_failure.phase, retcode,
|
||||||
|
shlex.split(build_command),
|
||||||
|
sbuild_failure.error,
|
||||||
|
sbuild_failure.description)
|
||||||
|
else:
|
||||||
|
raise UnidentifiedDebianBuildError(
|
||||||
|
sbuild_failure.stage,
|
||||||
|
sbuild_failure.phase,
|
||||||
|
retcode, shlex.split(build_command),
|
||||||
|
[], sbuild_failure.description)
|
||||||
|
|
||||||
(cl_package, cl_version) = get_latest_changelog_version(local_tree, subpath)
|
(cl_package, cl_version) = get_latest_changelog_version(local_tree, subpath)
|
||||||
changes_names = []
|
changes_names = []
|
||||||
|
|
|
@ -111,10 +111,11 @@ from buildlog_consultant.common import (
|
||||||
NeedPgBuildExtUpdateControl,
|
NeedPgBuildExtUpdateControl,
|
||||||
MissingPerlFile,
|
MissingPerlFile,
|
||||||
)
|
)
|
||||||
from buildlog_consultant.sbuild import (
|
|
||||||
SbuildFailure,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
from . import (
|
||||||
|
DetailedDebianBuildFailure,
|
||||||
|
UnidentifiedDebianBuildError,
|
||||||
|
)
|
||||||
from ..buildlog import problem_to_upstream_requirement
|
from ..buildlog import problem_to_upstream_requirement
|
||||||
from ..fix_build import BuildFixer, resolve_error
|
from ..fix_build import BuildFixer, resolve_error
|
||||||
from ..resolver.apt import (
|
from ..resolver.apt import (
|
||||||
|
@ -675,17 +676,23 @@ def main(argv=None):
|
||||||
update_changelog=args.update_changelog,
|
update_changelog=args.update_changelog,
|
||||||
max_iterations=args.max_iterations,
|
max_iterations=args.max_iterations,
|
||||||
)
|
)
|
||||||
except SbuildFailure as e:
|
except DetailedDebianBuildFailure as e:
|
||||||
if e.phase is None:
|
if e.phase is None:
|
||||||
phase = "unknown phase"
|
phase = "unknown phase"
|
||||||
elif len(e.phase) == 1:
|
elif len(e.phase) == 1:
|
||||||
phase = e.phase[0]
|
phase = e.phase[0]
|
||||||
else:
|
else:
|
||||||
phase = "%s (%s)" % (e.phase[0], e.phase[1])
|
phase = "%s (%s)" % (e.phase[0], e.phase[1])
|
||||||
if e.error:
|
logging.fatal("Error during %s: %s", phase, e.error)
|
||||||
logging.fatal("Error during %s: %s", phase, e.error)
|
return 1
|
||||||
|
except UnidentifiedDebianBuildError as e:
|
||||||
|
if e.phase is None:
|
||||||
|
phase = "unknown phase"
|
||||||
|
elif len(e.phase) == 1:
|
||||||
|
phase = e.phase[0]
|
||||||
else:
|
else:
|
||||||
logging.fatal("Error during %s: %s", phase, e.description)
|
phase = "%s (%s)" % (e.phase[0], e.phase[1])
|
||||||
|
logging.fatal("Error during %s: %s", phase, e.description)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
logging.info(
|
logging.info(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue