21 lines
1023 B
Python
21 lines
1023 B
Python
#!/usr/bin/env python3
|
|
"""Apply ordinary data/script permissions in the private installation prefix."""
|
|
from pathlib import Path
|
|
for p in Path('debian/tmp').rglob('*'):
|
|
if p.is_symlink() or not p.is_file():continue
|
|
if p.suffix=='.desktop':p.chmod(0o644)
|
|
elif p.suffix in ('.py','.sh'):
|
|
with p.open('rb') as f:head=f.read(128)
|
|
if head.startswith(b'#!'):p.chmod(0o755)
|
|
|
|
# Debian's canonical Bash interpreter path also applies under the private prefix.
|
|
for p in Path('debian/tmp').rglob('*'):
|
|
if p.is_symlink() or not p.is_file() or not (p.stat().st_mode & 0o111):continue
|
|
with p.open('rb') as stream:first=stream.readline(256)
|
|
if first.rstrip(b'\r\n')==b'#!/usr/bin/bash' or first.startswith(b'#!/usr/bin/bash '):
|
|
data=p.read_bytes();p.write_bytes(b'#!/bin/bash'+data[len(b'#!/usr/bin/bash'):])
|
|
|
|
# startplasma invokes this interpreter-less helper through /bin/sh.
|
|
p=Path('debian/tmp/opt/plasma/libexec/plasma-sourceenv.sh')
|
|
if p.is_file() and not p.is_symlink():p.chmod(0o644)
|