From 23f33a8420827661ee189fba4fc860da1fdc7b94 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 31 Jan 2023 08:52:32 -0500 Subject: [PATCH] Revamp license gathering for genesis --- genesis/buildgenesis.sh | 8 ++++++-- genesis/getlicenses.py | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/genesis/buildgenesis.sh b/genesis/buildgenesis.sh index b8923aef..53de8561 100644 --- a/genesis/buildgenesis.sh +++ b/genesis/buildgenesis.sh @@ -18,7 +18,11 @@ popd rm -rf $tdir cp $tfile rpmlist cp confluent-genesis.spec confluent-genesis-out.spec -for lic in $(python3 getlicenses.py rpmlist); do +python3 getlicenses.py > /tmp/tmpliclist +if [ $? -ne 0 ]; then + exit 1 +fi +for lic in $(cat /tmp/tmpliclist); do lo=${lic#/usr/share/} lo=${lo#licenses/} fname=$(basename $lo) @@ -45,7 +49,7 @@ cp /usr/share/doc/ipmitool/COPYING licenses/ipmitool echo %license /opt/confluent/genesis/%{arch}/licenses/ipmitool/COPYING >> confluent-genesis-out.spec cp -f /boot/vmlinuz-$(uname -r) boot/kernel cp /boot/efi/EFI/BOOT/BOOTX64.EFI boot/efi/boot -cp /boot/efi/EFI/centos/grubx64.efi boot/efi/boot/grubx64.efi +find /boot/efi -name grubx64.efi -exec cp {} boot/efi/boot/grubx64.efi \; mkdir -p ~/rpmbuild/SOURCES/ tar cf ~/rpmbuild/SOURCES/confluent-genesis.tar boot rpmlist licenses rpmbuild -bb confluent-genesis-out.spec diff --git a/genesis/getlicenses.py b/genesis/getlicenses.py index 99bb8484..01a858f8 100644 --- a/genesis/getlicenses.py +++ b/genesis/getlicenses.py @@ -28,6 +28,7 @@ for rpm in allrpmlist: with open(sys.argv[1]) as rpmlist: rpmlist = rpmlist.read().split('\n') licenses = set([]) +licensesbyrpm = {} for rpm in rpmlist: if not rpm: continue @@ -37,11 +38,47 @@ for rpm in rpmlist: for relrpm in srpmtorpm[srpm]: liclist = runcmd(f'rpm -qL {relrpm}') for lic in liclist: + if not lic: + continue if lic == '(contains no files)': continue + licensesbyrpm[rpm] = lic licenses.add(lic) for lic in sorted(licenses): print(lic) - +manualrpms = [ + 'ipmitool', + 'almalinux-release', + 'libaio', + 'hwdata', + 'snmp', + 'libnl3', + 'libbpf', # this is covered by kernel + 'sqlite', # public domain + 'linux-firmware', #all pertinent licenses are stripped out + 'xfsprogs', # manually added by hand below (not in rpm) + 'tmux', # use the extracttmuxlicenses on the source to generate NOTICE below +] +manuallicenses = [ + '/usr/share/doc/ipmitool/COPYING', + '/usr/share/doc/libaio/COPYING', + '/usr/share/doc/net-snmp/COPYING', + '/usr/share/doc/libnl3/COPYING', + '/usr/share/licenses/xfsprogs/GPL-2.0', + '/usr/share/licenses/xfsprogs/LGPL-2.1', + '/usr/share/licenses/tmux/NOTICE', +] +for lic in manuallicenses: + print(lic) +for rpm in rpmlist: + if not rpm: + continue + for manualrpm in manualrpms: + if manualrpm in rpm: + break + else: + if rpm not in licensesbyrpm: + raise Exception('Unresolved license info for ' + rpm) + print("UH OH: " + rpm)