<commit_before>#!/bin/bash

source /tmp/inhibitor/sh/inhibitor-functions.sh || exit 1


install_kernel() {
    local grub_install_hack=false

    ROOT=${KROOT} \
        USE=symlink \
        run_emerge -u --oneshot --nodeps ${KERNEL_PKG}              || die "Failed to emerge ${KERNEL_PKG}"
    pushd "${KROOT}"/usr/src/linux-${KERNEL_RELEASE} &>/dev/null    || die "Failed to cd to kernel source"
    cp ${KERNEL_KCONFIG} .config                                    || die "Failed to copy kconfig"
    einfo "Building kernel"
    make $(portageq envvar / MAKEOPTS)                              || die "Kernel build failed"
    einfo "Installing kernel"

    # mkboot (called by installkernel) likes grub-install to exist.
    # XXX:  Fixed in sys-apps/debianutils-3.1.3
    if [ ! -x /sbin/grub-install ]; then
        touch /sbin/grub-install
        chmod +x /sbin/grub-install
        grub_install_hack=true
    fi

    make INSTALL_PATH=${KROOT}/boot/ install                        || die "Kernel install failed"

    ${grub_install_hack} && rm -f /sbin/grub-install

    ln -snf vmlinuz-${KERNEL_RELEASE} ${KROOT}/boot/kernel
    ln -snf System.map-${KERNEL_RELEASE} ${KROOT}/boot/System.map
    rm -f ${KROOT}/boot/config-${KERNEL_RELEASE}
    einfo "Installing modules"
    make \
        INSTALL_MOD_PATH=${KROOT} \
        modules_install                                             || die "Kernel module install failed"
    popd &>/dev/null
}

post_kern_merge() {
    local rc
    if [ "${POST_KERN_PKGS:0:1}" == "@" ]; then
        POST_KERN_PKGS=""
    fi

    for i in ${GENKERNEL}; do
        case "${i}" in
            --splash=*)
                POST_KERN_PKGS="${POST_KERN_PKGS} media-gfx/splashutils"
                ;;
            *)
                ;;
        esac
    done

    if [ -z "${POST_KERN_PKGS}" ]; then
        return
    fi
  
    mkdir -p /etc/portage/profile/ &>/dev/null
    echo 'sys-kernel/gentoo-sources-99' >> /etc/portage/profile/package.provided
    local old_sym=$(readlink /usr/src/linux)

    einfo "Installing post kernel build packages"
    ln -snf ${KROOT}/usr/src/linux-${KERNEL_RELEASE} /usr/src/linux 
    DIE_ON_FAIL=0 run_emerge -u ${POST_KERN_PKGS}
    rc=$?
    
    if [ -z "${old_sym}" ]; then
        rm /usr/src/linux
    else
        ln -snf ${old_sym} /usr/src/linux
    fi

    sed -i '/sys-kernel\/gentoo-sources-99/d' /etc/portage/profile/package.provided
    [ -s /etc/portage/profile/package.provided ] \
        || rm -f /etc/portage/profile/package.provided
    rmdir /etc/portage/profile/package.provided/ &>/dev/null

    if [ ${rc} -ne 0 ]; then
        die "emerge failed."
    fi
}
    
install_initramfs() {
    local rm_genkernel=true
    local kname=${KPN%-sources-*}
<commit_msg>kernel:  Fix initramfs search pattern<commit_after>#!/bin/bash

source /tmp/inhibitor/sh/inhibitor-functions.sh || exit 1


install_kernel() {
    local grub_install_hack=false

    ROOT=${KROOT} \
        USE=symlink \
        run_emerge -u --oneshot --nodeps ${KERNEL_PKG}              || die "Failed to emerge ${KERNEL_PKG}"
    pushd "${KROOT}"/usr/src/linux-${KERNEL_RELEASE} &>/dev/null    || die "Failed to cd to kernel source"
    cp ${KERNEL_KCONFIG} .config                                    || die "Failed to copy kconfig"
    einfo "Building kernel"
    make $(portageq envvar / MAKEOPTS)                              || die "Kernel build failed"
    einfo "Installing kernel"

    # mkboot (called by installkernel) likes grub-install to exist.
    # XXX:  Fixed in sys-apps/debianutils-3.1.3
    if [ ! -x /sbin/grub-install ]; then
        touch /sbin/grub-install
        chmod +x /sbin/grub-install
        grub_install_hack=true
    fi

    make INSTALL_PATH=${KROOT}/boot/ install                        || die "Kernel install failed"

    ${grub_install_hack} && rm -f /sbin/grub-install

    ln -snf vmlinuz-${KERNEL_RELEASE} ${KROOT}/boot/kernel
    ln -snf System.map-${KERNEL_RELEASE} ${KROOT}/boot/System.map
    rm -f ${KROOT}/boot/config-${KERNEL_RELEASE}
    einfo "Installing modules"
    make \
        INSTALL_MOD_PATH=${KROOT} \
        modules_install                                             || die "Kernel module install failed"
    popd &>/dev/null
}

post_kern_merge() {
    local rc
    if [ "${POST_KERN_PKGS:0:1}" == "@" ]; then
        POST_KERN_PKGS=""
    fi

    for i in ${GENKERNEL}; do
        case "${i}" in
            --splash=*)
                POST_KERN_PKGS="${POST_KERN_PKGS} media-gfx/splashutils"
                ;;
            *)
                ;;
        esac
    done

    if [ -z "${POST_KERN_PKGS}" ]; then
        return
    fi
  
    mkdir -p /etc/portage/profile/ &>/dev/null
    echo 'sys-kernel/gentoo-sources-99' >> /etc/portage/profile/package.provided
    local old_sym=$(readlink /usr/src/linux)

    einfo "Installing post kernel build packages"
    ln -snf ${KROOT}/usr/src/linux-${KERNEL_RELEASE} /usr/src/linux 
    DIE_ON_FAIL=0 run_emerge -u ${POST_KERN_PKGS}
    rc=$?
    
    if [ -z "${old_sym}" ]; then
        rm /usr/src/linux
    else
        ln -snf ${old_sym} /usr/src/linux
    fi

    sed -i '/sys-kernel\/gentoo-sources-99/d' /etc/portage/profile/package.provided
    [ -s /etc/portage/profile/package.provided ] \
        || rm -f /etc/portage/profile/package.provided
    rmdir /etc/portage/profile/package.provided/ &>/dev/null

    if [ ${rc} -ne 0 ]; then
        die "emerge failed."
    fi
}
    
install_initramfs() {
    local rm_genkernel=true
    local kname=${KPN%-sources*}

{'fraction_non_alphanumeric': 0.13432027441776495, 'fraction_numerical': 0.004332912077992418, 'mean_word_length': 1.9897463572584997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '707684', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1815, 'n_words': 404}