Merge pull request #451 from jcvenegas/kernel-patches-per-version

kernel: use patches per kernel version.
This commit is contained in:
GabyCT 2019-04-25 09:47:12 -05:00 committed by GitHub
commit 8ae6755bc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 39 additions and 18 deletions

View File

@ -123,11 +123,19 @@ get_kernel() {
sha256sum -c "${kernel_tarball}.sha256"
tar xf ${kernel_tarball}
tar xf "${kernel_tarball}"
mv "linux-${version}" "${kernel_path}"
}
get_major_kernel_version() {
local version="${1}"
[ -n "${version}" ] || die "kernel version not provided"
major_version=$(echo "${version}" | cut -d. -f1)
minor_version=$(echo "${version}" | cut -d. -f2)
echo "${major_version}.${minor_version}"
}
get_default_kernel_config() {
local version="${1}"
@ -138,9 +146,9 @@ get_default_kernel_config() {
[ -n "${hypervisor}" ] || die "hypervisor not provided"
[ -n "${kernel_arch}" ] || die "kernel arch not provided"
major_version=$(echo "${version}" | cut -d. -f1)
minor_version=$(echo "${version}" | cut -d. -f2)
config="${default_kernel_config_dir}/${kernel_arch}_kata_${hypervisor}_${major_version}.${minor_version}.x"
local kernel_ver
kernel_ver=$(get_major_kernel_version "${version}")
config="${default_kernel_config_dir}/${kernel_arch}_kata_${hypervisor}_${major_kernel}.x"
[ -f "${config}" ] || die "failed to find default config ${config}"
echo "${config}"
}
@ -185,21 +193,32 @@ setup_kernel() {
[ -d "${patches_path}" ] || die " patches path '${patches_path}' does not exist"
kernel_patches=$(find "${patches_path}" -name '*.patch' -type f)
local major_kernel
major_kernel=$(get_major_kernel_version "${kernel_version}")
local patches_dir_for_version="${patches_path}/${major_kernel}.x"
local kernel_patches=""
if [ -d "${patches_dir_for_version}" ]; then
kernel_patches=$(find "${patches_dir_for_version}" -name '*.patch' -type f)
else
info "kernel patches directory does not exit"
pushd "${kernel_path}" >>/dev/null
for p in ${kernel_patches}; do
info "Applying patch $p"
patch -p1 <"$p"
done
fi
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
[ -n "${arch_target}" ] || arch_target="$(uname -m)"
arch_target=$(arch_to_kernel "${arch_target}")
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}")
(
cd "${kernel_path}" || exit 1
for p in ${kernel_patches}; do
info "Applying patch $p"
patch -p1 <"$p"
done
cp "${kernel_config_path}" ./.config
make oldconfig
[ -n "${hypervisor_target}" ] || hypervisor_target="kvm"
[ -n "${kernel_config_path}" ] || kernel_config_path=$(get_default_kernel_config "${kernel_version}" "${hypervisor_target}" "${arch_target}")
cp "${kernel_config_path}" ./.config
make oldconfig
)
}
build_kernel() {

View File

@ -1 +1 @@
34
35

View File

@ -27,7 +27,9 @@ KATA_CONFIG_VERSION=$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version")
KR_SERIES="$(echo $VERSION | cut -d "." -f 1).x"
KR_LTS=$(echo $VERSION | cut -d "." -f 1,2)
KR_PATCHES=$(eval find "${SCRIPT_DIR}/../../kernel/patches" -type f -name "*.patch")
ln -sfT "${SCRIPT_DIR}/../../kernel/patches-${KR_LTS}" "${SCRIPT_DIR}/patches"
KR_PATCHES=$(eval find "${SCRIPT_DIR}/patches" -type f -name "*.patch")
KR_REL=https://www.kernel.org/releases.json
KR_SHA=https://cdn.kernel.org/pub/linux/kernel/v"${KR_SERIES}"/sha256sums.asc
@ -66,6 +68,5 @@ get_git_info
#TODO delete me: used by changelog_update
hash_tag="nocommit"
changelog_update "${VERSION}-${KATA_CONFIG_VERSION}"
ln -sfT "${SCRIPT_DIR}/../../kernel/patches" "${SCRIPT_DIR}/patches"
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}"

View File

@ -218,8 +218,9 @@ parts:
make mrproper
# Apply patches
for patch in ${SNAPCRAFT_STAGE}/kernel/patches/*.patch; do
for patch in ${SNAPCRAFT_STAGE}/kernel/patches/${x_version}/*.patch; do
echo "Applying $(basename "$patch") ..."
patch \
--batch \