2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Capture license content from related packages

Some files that get gathered into genesis
have their license in a related rpm, but that related rpm does not otherwise get captured.

So pull all correlated license material
in the license capture process.
This commit is contained in:
Jarrod Johnson 2022-08-11 13:42:36 -04:00
parent 047cd6302a
commit 7b3c1e5405
2 changed files with 49 additions and 9 deletions

View File

@ -17,15 +17,12 @@ popd
rm -rf $tdir
cp $tfile rpmlist
cp confluent-genesis.spec confluent-genesis-out.spec
for r in $(cat rpmlist); do
#rpm -qi $r | grep ^License|sed -e 's/^.*:/${r}:/' >> licenselist
for l in $(rpm -qL $r); do
lo=${l#/usr/share/}
lo=${lo#licenses/}
mkdir -p licenses/$(dirname $lo)
cp $l licenses/$lo
echo %license /opt/confluent/genesis/%{arch}/licenses/$lo >> confluent-genesis-out.spec
done
for lic in $(python3 getlicenses.py rpmlist); do
lo=${lic#/usr/share/}
lo=${lo#licenses/}
mkdir -p licenses/$(dirname $lo)
cp $lic licenses/$lo
echo %license /opt/confluent/genesis/%{arch}/licenses/$lo >> confluent-genesis-out.spec
done
cp -f /boot/vmlinuz-$(uname -r) boot/kernel
cp /boot/efi/EFI/BOOT/BOOTX64.EFI boot/efi/boot

43
genesis/getlicenses.py Normal file
View File

@ -0,0 +1,43 @@
import subprocess
import sys
import shlex
def runcmd(cmd):
return subprocess.check_output(shlex.split(cmd)).decode('utf8').split('\n')
def getsrpm(rpm):
rpminfo = runcmd(f'rpm -qi {rpm}')
for inf in rpminfo:
if inf.startswith('Source RPM'):
srpm = inf.split(':', 1)[1].strip()
return srpm
srpmtorpm = {}
rpmtosrpm = {}
allrpmlist = runcmd('rpm -qa')
for rpm in allrpmlist:
if not rpm:
continue
srpm = getsrpm(rpm)
rpmtosrpm[rpm] = srpm
if srpm in srpmtorpm:
srpmtorpm[srpm].add(rpm)
else:
srpmtorpm[srpm] = {rpm}
with open(sys.argv[1]) as rpmlist:
rpmlist = rpmlist.read().split('\n')
licenses = set([])
for rpm in rpmlist:
if not rpm:
continue
srpm = rpmtosrpm[rpm]
for relrpm in srpmtorpm[srpm]:
liclist = runcmd(f'rpm -qL {relrpm}')
for lic in liclist:
licenses.add(lic)
for lic in sorted(licenses):
print(lic)