Files

33 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Assign each private Frameworks/provider file to one runtime or dev package."""
import json
from pathlib import Path
def development(path,policy):
if policy.get('development_only'):return True
p=Path(path).relative_to('opt/plasma')
# These unversioned ELF libraries are needed by installed daemons/QML plugins.
runtime={'kactivitymanagerd':{'libkactivitymanagerd_plugin.so'},
'kinfocenter':{'libKInfoCenterInternal.so'},
'plasma-nm':{'libplasmanm_editor.so','libplasmanm_internal.so','libplasmanm_cellular.so'},
'plasma-systemmonitor':{'libPlasmaSystemMonitorPage.so','libPlasmaSystemMonitorTable.so'}}
if p.parent==Path('lib') and p.name in runtime.get(policy['module'],set()):return False
return (p.parts[0]=='include'
or str(p).startswith(('lib/cmake/','lib/pkgconfig/','share/pkgconfig/','share/ECM/'))
or (p.parent==Path('lib') and p.suffix in ('.so','.a','.prl'))
or (policy['module']=='wayland-runtime' and str(p) in ('bin/wayland-scanner','share/wayland/wayland.dtd','share/wayland/wayland.xml')))
if __name__=='__main__':
policy=json.loads(Path('debian/package-policy.json').read_text());root=Path('debian/tmp')
groups={name:[] for name in policy['packages']};base='plasma-next-'+policy['module']
for p in sorted(root.rglob('*')):
if not p.is_symlink() and not p.is_file():continue
path=str(p.relative_to(root));key=base+'-dev' if development(path,policy) else base
if key not in groups:raise ValueError('Unexpected package category: '+path)
groups[key].append(path)
for key,files in groups.items():
if not files:raise ValueError('Empty package: '+key)
# Compat 13 substitutes these after splitting fields on whitespace.
escaped=[p.replace('$','${Dollar}').replace(' ','${Space}').replace('\t','${Tab}') for p in files]
Path('debian/'+key+'.install').write_text('\n'.join(escaped)+'\n')