16 lines
783 B
Python
16 lines
783 B
Python
#!/usr/bin/env python3
|
|
"""Ship original upstream license/notice texts without filename collisions."""
|
|
import json,shutil
|
|
from pathlib import Path
|
|
policy=json.loads(Path('debian/package-policy.json').read_text())
|
|
package=policy['packages'][0];dest=Path('debian')/package/'usr/share/doc'/package/'upstream-licenses'
|
|
files=[]
|
|
for p in Path('.').rglob('*'):
|
|
if not p.is_file() or p.is_symlink() or p.parts[0] in ('debian','obj-module','.git','.pc'):continue
|
|
n=p.name.upper()
|
|
if n.startswith(('LICENSE','LICENCE','COPYING','NOTICE','COPYRIGHT')) or 'LICENSES' in p.parts:
|
|
files.append(p)
|
|
for p in files:
|
|
target=dest/p;target.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(p,target)
|
|
if not files:raise ValueError('No upstream license/notice files found')
|