Fall back to source repository license files if not in portage

When a license file is newly added, portage may not yet have it in the
shared folder and the license inclusion step fails.
Fall back to the source repositories and look for the license file
there, too. Print a warning if not found instead of failing to build.
This commit is contained in:
Kai Lüke 2021-01-20 12:09:33 +01:00
parent dac588de9e
commit bd34d059f3

View File

@ -452,8 +452,23 @@ EOF
sudo lbzip2 -9 "${root_fs_dir}"/usr/share/licenses/licenses.json sudo lbzip2 -9 "${root_fs_dir}"/usr/share/licenses/licenses.json
# Copy all needed licenses to a "common" subdirectory and compress them # Copy all needed licenses to a "common" subdirectory and compress them
local license_list # define before assignment because it would mask any error local license_list # define before assignment because it would mask any error
license_list="$(jq -r '.[] | "/var/gentoo/repos/gentoo/licenses/\(.licenses | .[])"' "${json_input}" | sort | uniq)" license_list="$(jq -r '.[] | "\(.licenses | .[])"' "${json_input}" | sort | uniq)"
sudo cp ${license_list} "${root_fs_dir}"/usr/share/licenses/common/ local license_dirs=(
"/mnt/host/source/src/third_party/coreos-overlay/licenses/"
"/mnt/host/source/src/third_party/portage-stable/"
"/var/gentoo/repos/gentoo/licenses/"
"none"
)
for license_file in ${license_list}; do
for license_dir in ${license_dirs[*]}; do
if [ "${license_dir}" = "none" ]; then
warn "The license file \"${license_file}\" was not found"
elif [ -f "${license_dir}${license_file}" ]; then
sudo cp "${license_dir}${license_file}" "${root_fs_dir}"/usr/share/licenses/common/
break
fi
done
done
# Compress the licenses just with gzip because there is no big difference as they are single files # Compress the licenses just with gzip because there is no big difference as they are single files
sudo gzip -9 "${root_fs_dir}"/usr/share/licenses/common/* sudo gzip -9 "${root_fs_dir}"/usr/share/licenses/common/*
} }