From f3c46c621c1468547c7d030b7b2c08c83b46ec63 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Mon, 13 Jul 2026 11:25:29 +0200 Subject: [PATCH] improve license checking for newly build packages --- rpm-preamble.file | 64 ++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/rpm-preamble.file b/rpm-preamble.file index b60259ea5ee..2eeb82f0bf0 100644 --- a/rpm-preamble.file +++ b/rpm-preamble.file @@ -450,32 +450,44 @@ fi %define go_package_arch %{_arch} %endif + %define install_package_license_init _PKGTOOLS_PACKAGE_SOURCE_DIRECTORY="$(/bin/pwd)" -%if %(case %{pkgcategory}/%{pkgname} in (external/py3-* | lcg/SCRAM* | cms/* | *-toolfile ) echo 1 ;; (*) echo 0 ;; esac) == 1 -%define install_package_license echo "Skipping license checking for %{pkgcategory}/%{pkgname}" -%else %define install_package_license \ pushd ${_PKGTOOLS_PACKAGE_SOURCE_DIRECTORY} \ - KEEP_LICENSE_DIR=1 \ - if [ ! -d "%{i}/license" ] ; then mkdir -p "%{i}/license" ; KEEP_LICENSE_DIR=0; fi \ - if [ "%{?package_license_file:%package_license_file}" != "" ] ; then \ - found=0 \ - for f in %{package_license_file} ; do if [ -f "$f" ] ; then found=1 ; install -m 644 "$f" "%{i}/license/" ; fi; done \ - if [ $found -eq 0 ] ; then echo "ERROR: Unable to find license file '%{package_license_file}'" ; exit 1 ; fi \ - else \ - find . -maxdepth 1 -type f \\\ - \\\( -iname 'LICENSE*' -o -iname 'LICENCE*' -o \\\ - -iname 'COPYING*' -o -iname 'COPYRIGHT*' -o \\\ - -iname 'NOTICE*' -o -iname 'LEGAL*' -o \\\ - -iname 'UNLICENSE*' \\\) \\\ - -exec install -m 644 {} "%{i}/license/" \\\; \ - for d in LICENSES licenses license legal; do [ -d $d ] && rsync -a $d/ %{i}/license/ ; done \ - fi \ - popd \ - if [ -n "$(ls -A %{i}/license 2>/dev/null)" ] ; then \ - echo "Found License: $(ls %{i}/license)" \ - else \ - [ ${KEEP_LICENSE_DIR} -eq 1 ] || rm -rf %{i}/license \ - echo "WARNING: No license files found" \ - fi -%endif + license_dir="%{i}/etc/profile.d/license" \ + mkdir -p ${license_dir} \ + if [ "%{?package_license_file:%package_license_file}" != "" ] ; then \ + found=0 \ + for f in %{package_license_file} ; do if [ -f "$f" ] ; then found=1 ; install -m 644 "$f" "${license_dir}/" ; fi; done \ + if [ $found -eq 0 ] ; then echo "LICENSE: Error, unable to find license file '%{package_license_file}'" ; exit 1 ; fi \ + echo "LICENSE: Found $(ls ${license_dir})" \ + else \ + check_license=1 \ + case %{pkgcategory}/%{pkgname} in \ + cms/vdt ) ;; \ + external/py3-* | lcg/SCRAM* | cms/* | *-toolfile | external/geant4-G4* | external/geant4data | external/actsdata ) \ + check_license=0 \ + ;; \ + esac \ + if [ "${check_license}" -eq 0 ] ; then \ + echo "LICENSE: Skipped license checking for %{pkgcategory}/%{pkgname}" \ + rm -rf ${license_dir} \ + else \ + [ "%{?package_license_dir:%package_license_dir}" != "" ] && pushd "%{package_license_dir}" \ + find . -maxdepth 1 -type f \\\ + \\\( -iname 'LICENSE*' -o -iname 'LICENCE*' -o \\\ + -iname 'COPYING*' -o -iname 'COPYRIGHT*' -o \\\ + -iname 'NOTICE*' -o -iname 'LEGAL*' -o \\\ + -iname 'UNLICENSE*' \\\) \\\ + -exec install -m 644 {} "${license_dir}/" \\\; \ + for d in LICENSES licenses license legal; do [ -d $d ] && rsync -a $d/ "${license_dir}/" ; done \ + [ "%{?package_license_dir:%package_license_dir}" != "" ] && popd \ + if [ -n "$(ls -A ${license_dir} 2>/dev/null)" ] ; then \ + echo "LICENSE: Found $(ls ${license_dir})" \ + else \ + rm -rf ${license_dir} \ + echo "LICENSE: Warning, no license files found" \ + fi \ + fi \ + fi \ + popd