Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 38 additions & 26 deletions rpm-preamble.file
Original file line number Diff line number Diff line change
Expand Up @@ -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