| # Copyright 2021 Google LLC |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # Check for EAPI 5+ |
| case "${EAPI:-0}" in |
| 0|1|2|3|4) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;; |
| 5|6) inherit eapi7-ver ;; |
| 7) ;; |
| esac |
| inherit cos-kernel |
| |
| _build_kernel_config() { |
| "${FILESDIR}"/build_kernel_config.py --base "${FILESDIR}/config.kernel" "${@}" "${FILESDIR}/common" "${FILESDIR}" |
| } |
| |
| _generate() { |
| CHROMEOS_KERNEL_CONFIG="${TMPDIR}/kernel.config" |
| einfo "Generating kernel config at ${CHROMEOS_KERNEL_CONFIG}..." |
| _build_kernel_config > "${CHROMEOS_KERNEL_CONFIG}" |
| echo "# CONFIG_LOCALVERSION_AUTO is not set" >> "${CHROMEOS_KERNEL_CONFIG}" |
| } |
| |
| _verify() { |
| einfo "Verifying Config..." |
| _build_kernel_config --verify "$(cros-workon_get_build_dir)/.config" |
| } |
| |
| |
| gmec-kernel_src_configure() { |
| _generate || die "Error generating kernel config..." |
| cos-kernel_src_configure |
| _verify || die "$(_verify)" |
| } |
| |
| _rename_artifact() { |
| local path="${1}" |
| local old="${2}" |
| local kernel="${3}" |
| local name="$(basename "${path}")" |
| local new_name="${name/${old}/${kernel}}" |
| local new_path="$(dirname "${path}")/${new_name}" |
| if [[ -e "${new_path}" ]]; then |
| return 0 |
| fi |
| mv "${path}" "${new_path}" |
| } |
| |
| _rename_kernel_artifact() { |
| _rename_artifact "${1}" "kernel" "${2}" |
| } |
| |
| gmec-kernel_src_install() { |
| cos-kernel_src_install |
| |
| # Because we install both a vanilla and RT kernel, fix up the artifacts to |
| # have unique names. |
| if [[ -n "${GMEC_KERNEL_SUFFIX}" ]]; then |
| einfo "Fixing up artifacts..." |
| _rename_kernel_artifact "${D}/opt/google/src/kernel-src.tar.gz" "kernel-${GMEC_KERNEL_SUFFIX}" |
| _rename_kernel_artifact "${D}/opt/google/src/kernel-headers.tgz" "kernel-${GMEC_KERNEL_SUFFIX}" |
| _rename_kernel_artifact "${D}/etc/kernel_info" "kernel_${GMEC_KERNEL_SUFFIX}" |
| _rename_artifact "${D}/boot/vmlinuz" "vmlinuz" "vmlinuz-${GMEC_KERNEL_SUFFIX}" |
| _rename_kernel_artifact "${D}/etc/kernel_commit" "kernel-${GMEC_KERNEL_SUFFIX}" |
| _rename_kernel_artifact "${D}/etc/kernel_info" "kernel-${GMEC_KERNEL_SUFFIX}" |
| _rename_artifact "${D}/etc/os-release.d/KERNEL_COMMIT_ID" "KERNEL" "KERNEL_${GMEC_KERNEL_SUFFIX^^}" |
| _rename_artifact "${D}/etc/toolchain_env" "toolchain" "toolchain_${GMEC_KERNEL_SUFFIX}" |
| _rename_artifact "${D}/usr/lib/debug/boot/vmlinux" "vmlinux" "vmlinux-${GMEC_KERNEL_SUFFIX}" |
| _rename_artifact "${D}/usr/lib/debug/boot/vmlinux.debug" "vmlinux.debug" "vmlinuz-${GMEC_KERNEL_SUFFIX}.debug" |
| fi |
| |
| # Lakitu uses this to sign their nvidia drivers, but EdgeOS doesn't need it. |
| rm "${D}"/etc/ima/pubkey.x509 |
| } |