Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If pkgman install fails, let the user see what the problems were. #275

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions HaikuPorter/DependencyResolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import os
import re
from subprocess import CalledProcessError, check_output
import subprocess

from .Options import getOption
from .PackageInfo import PackageInfo, ResolvableExpression
Expand Down Expand Up @@ -238,15 +238,26 @@ def _addImmediate(self, parent, requires, typeString, forBuildhost):
if getOption('getDependencies'):
try:
print('Fetching package for ' + str(requires) + ' ...')
output = check_output(['pkgman', 'install', '-y', str(requires).replace(' ', '')]).decode('utf-8')
output = subprocess.check_output(['pkgman', 'install', '-y',
str(requires).replace(' ', '')], stderr=subprocess.PIPE).decode('utf-8')
for pkg in re.findall(r'://.*/([^/\n]+\.hpkg)', output):
pkginfo = PackageInfo('/boot/system/packages/' + pkg)
self._providesManager.addProvidesFromPackageInfo(pkginfo)
provides = self._providesManager.getMatchingProvides(requires,
isPrerequiresType, self._ignoreBase)
except CalledProcessError:
except subprocess.CalledProcessError as e:
# `pkgman install -y` failed, propagate the why.
error = e.stderr.decode('utf-8')
output = e.output.decode('utf-8').splitlines()
for index, line in enumerate(output):
if line.startswith('Encountered problems:'):
break
else:
index = -1
lines = ['\t' + line for line in output[index + 1:]]
lines = '\n'.join(lines)
raise RestartDependencyResolutionException(parent,
'failed to install package for {}'.format(requires))
'failed to install package for {}.\n{}'.format(requires, error or lines))
else:
message = '%s "%s" of package "%s" could not be resolved' \
% (typeString, str(requires), parent.versionedName)
Expand Down Expand Up @@ -283,7 +294,7 @@ def _parsePackageInfo(self, packageInfoFile, fatal):
try:
packageInfo = PackageInfo(packageInfoFile)
DependencyResolver.packageInfoCache[packageInfoFile] = packageInfo
except CalledProcessError:
except subprocess.CalledProcessError:
message = 'failed to parse "%s"' % packageInfoFile
sysExit(message) if fatal else warn(message)
return None
Expand Down
7 changes: 4 additions & 3 deletions HaikuPorter/Port.py
Original file line number Diff line number Diff line change
Expand Up @@ -1581,15 +1581,16 @@ def _resolveDependencies(self, dependencyInfoFiles, requiresTypes,
try:
return buildPlatform.resolveDependencies(dependencyInfoFiles,
requiresTypes, repositories, **kwargs)
except (CalledProcessError, LookupError):
except (CalledProcessError, LookupError) as e:
if getOption('buildMaster'):
raise

sysExit(('unable to resolve %s for %s\n'
+ '\tdependency-infos:\n\t\t%s\n'
+ '\trepositories:\n\t\t%s\n')
+ '\trepositories:\n\t\t%s\n'
+ '\tReason: %s')
% (description, self.versionedName,
'\n\t\t'.join(dependencyInfoFiles), repositories))
'\n\t\t'.join(dependencyInfoFiles), repositories, e))

def _createSourcePackage(self, name, rigged):
# copy all recipe attributes from base package, but set defaults
Expand Down