diff --git a/genesis/buildgenesis.sh b/genesis/buildgenesis.sh index 8791eb84..7d0c21cc 100644 --- a/genesis/buildgenesis.sh +++ b/genesis/buildgenesis.sh @@ -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 diff --git a/genesis/getlicenses.py b/genesis/getlicenses.py new file mode 100644 index 00000000..c46bcd5d --- /dev/null +++ b/genesis/getlicenses.py @@ -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) + + +