Fix sub-dependency resolution and handling of pkgbase
This commit is contained in:
parent
2b36325b92
commit
67bbf90b5c
1 changed files with 36 additions and 21 deletions
39
packages.py
39
packages.py
|
@ -55,11 +55,18 @@ class Package:
|
||||||
lines = result.stdout.decode('utf-8').split('\n')
|
lines = result.stdout.decode('utf-8').split('\n')
|
||||||
names = []
|
names = []
|
||||||
depends = []
|
depends = []
|
||||||
|
multi_pkgs = False
|
||||||
|
|
||||||
for line_raw in lines:
|
for line_raw in lines:
|
||||||
line = line_raw.lstrip()
|
line = line_raw.lstrip()
|
||||||
if line.startswith('pkgname'):
|
if line.startswith('pkgbase'):
|
||||||
self.name = line.split(' = ')[1]
|
self.name = line.split(' = ')[1]
|
||||||
names.append(self.name)
|
names.append(self.name)
|
||||||
|
multi_pkgs = True
|
||||||
|
if line.startswith('pkgname'):
|
||||||
|
names.append(line.split(' = ')[1])
|
||||||
|
if not multi_pkgs:
|
||||||
|
self.name = line.split(' = ')[1]
|
||||||
if line.startswith('pkgbase') or line.startswith('provides'):
|
if line.startswith('pkgbase') or line.startswith('provides'):
|
||||||
names.append(line.split(' = ')[1])
|
names.append(line.split(' = ')[1])
|
||||||
if line.startswith('depends') or line.startswith('makedepends') or line.startswith('checkdepends') or line.startswith('optdepends'):
|
if line.startswith('depends') or line.startswith('makedepends') or line.startswith('checkdepends') or line.startswith('optdepends'):
|
||||||
|
@ -191,30 +198,39 @@ def discover_packages(package_paths: list[str]) -> dict[str, Package]:
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
package.local_depends.remove(dep)
|
package.local_depends.remove(dep)
|
||||||
|
"""
|
||||||
|
This figures out all dependencies and their sub-dependencies for the selection and adds those packages to the selection.
|
||||||
|
First the top-level packages get selected by searching the paths.
|
||||||
|
Then their dependencies and sub-dependencies and so on get added to the selection.
|
||||||
|
"""
|
||||||
selection = []
|
selection = []
|
||||||
|
deps = []
|
||||||
for package in packages.values():
|
for package in packages.values():
|
||||||
if 'all' in package_paths or package.path in package_paths:
|
if 'all' in package_paths or package.path in package_paths:
|
||||||
selection.append(package)
|
deps.append(package.name)
|
||||||
for dep in package.local_depends:
|
while len(deps) > 0:
|
||||||
if dep in packages:
|
for dep in deps.copy():
|
||||||
selection.append(packages[dep])
|
|
||||||
else:
|
|
||||||
found = False
|
found = False
|
||||||
for p in packages.values():
|
for p in packages.values():
|
||||||
for name in p.names:
|
for name in p.names:
|
||||||
if dep == name:
|
if name == dep:
|
||||||
selection.append(p)
|
selection.append(packages[p.name])
|
||||||
|
deps.remove(dep)
|
||||||
|
# Add the sub-dependencies
|
||||||
|
deps += p.local_depends
|
||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
if found:
|
if found:
|
||||||
break
|
break
|
||||||
if not found:
|
if not found:
|
||||||
logging.fatal(f'Could not find package for "{dep}"')
|
logging.fatal(f'Failed to find dependency {dep}')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
selection = list(set(selection))
|
selection = list(set(selection))
|
||||||
packages = {package.name: package for package in selection}
|
packages = {package.name: package for package in selection}
|
||||||
|
|
||||||
|
logging.debug(f'Figured out selection: {list(map(lambda p: p.path, selection))}')
|
||||||
|
|
||||||
return packages
|
return packages
|
||||||
|
|
||||||
|
|
||||||
|
@ -460,8 +476,6 @@ def cmd_build(verbose, paths):
|
||||||
logging.info('Everything built already')
|
logging.info('Everything built already')
|
||||||
return
|
return
|
||||||
logging.info('Building %s', ', '.join(map(lambda x: x.path, need_build)))
|
logging.info('Building %s', ', '.join(map(lambda x: x.path, need_build)))
|
||||||
with open('.last_built', 'w') as file:
|
|
||||||
file.write('\n'.join(map(lambda x: x.path, need_build)))
|
|
||||||
|
|
||||||
for package in need_build:
|
for package in need_build:
|
||||||
setup_chroot()
|
setup_chroot()
|
||||||
|
@ -523,6 +537,7 @@ def cmd_check(verbose, paths):
|
||||||
'depends': False,
|
'depends': False,
|
||||||
'optdepends': False,
|
'optdepends': False,
|
||||||
'makedepends': False,
|
'makedepends': False,
|
||||||
|
'backup': False,
|
||||||
'install': False,
|
'install': False,
|
||||||
'options': False,
|
'options': False,
|
||||||
commit_key: is_git_package,
|
commit_key: is_git_package,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue