Skip to content

Commit

Permalink
Fix #256.
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarL committed Oct 10, 2023
1 parent f197120 commit 5575787
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
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

0 comments on commit 5575787

Please sign in to comment.