<commit_before>#!/bin/bash

mkgrubcfg() {
    local kernel="$1"
    local namesuffix="$2"
    shift
    shift
    mkgrubcfg1 "$kernel" "$@" |
    sed 's/^\(menuentry.*\)\(" {\)/\1'"$namesuffix"'\2/'
}

mkgrubcfg1() {
    local kernel="$1"
    shift

cat <<EOF
menuentry "irq+pic+console+shell" {
    multiboot (cd)/$kernel
    module (cd)/kern/irq.mod
    module (cd)/kern/pic.mod
    module (cd)/kern/console.mod
    module (cd)/user/shell.mod
    boot
}

menuentry "lwIP" {
    multiboot (cd)/$kernel
    module (cd)/kern/irq.mod irq
    module (cd)/kern/pic.mod pic
    module (cd)/kern/console.mod console
    module (cd)/cuser/acpica.mod acpica
    module (cd)/cuser/e1000.mod e1000
    module (cd)/cuser/apic.mod apic
    module (cd)/cuser/lwip.mod lwip
    boot
}

menuentry "fbtest" {
    multiboot (cd)/$kernel
    module (cd)/kern/irq.mod
    module (cd)/kern/pic.mod
    module (cd)/kern/console.mod
    module (cd)/cuser/acpica.mod acpica
    module (cd)/cuser/bochsvga.mod bochs
    module (cd)/cuser/fbtest.mod fbtest
    boot
}

menuentry "timer_test" {
    multiboot (cd)/$kernel
    module (cd)/kern/irq.mod
    module (cd)/kern/pic.mod
    module (cd)/kern/console.mod
    module (cd)/cuser/apic.mod
    module (cd)/cuser/timer_test.mod
    boot
}

menuentry "zeropage+test_maps" {
    multiboot (cd)/$kernel
    module (cd)/kern/irq.mod
    module (cd)/kern/pic.mod
    module (cd)/kern/console.mod
    module (cd)/cuser/zeropage.mod
    module (cd)/cuser/test_maps.mod
    boot
}

menuentry "ACPICA" {
    multiboot (cd)/$kernel
    module (cd)/kern/irq.mod
    module (cd)/kern/pic.mod
    module (cd)/kern/console.mod
    module (cd)/cuser/acpica.mod
    boot
}

menuentry "puts+xmm" {
    multiboot (cd)/$kernel
    module (cd)/user/test_puts.mod
    module (cd)/user/test_xmm.mod
    boot
}

EOF

while [ $# -gt 0 ]; do
    echo "menuentry \"${1#user/}\" {"
    echo "    multiboot (cd)/$kernel"
    echo "    module (cd)/$1.mod"
    echo "    boot"
    echo "}"
    shift
done

cat <<EOF
menuentry "idle" {
    multiboot (cd)/$kernel
    boot
}
EOF
}

if [ -f out/grub/kernel ]; then
    mkgrubcfg kernel " (rust)" "$@"
fi
mkgrubcfg kstart.b "" "$@"<commit_msg>Remove hardcoded (cd) prefix, let Grub figure it out<commit_after>#!/bin/bash

mkgrubcfg() {
    local kernel="$1"
    local namesuffix="$2"
    shift
    shift
    mkgrubcfg1 "$kernel" "$@" |
    sed 's/^\(menuentry.*\)\(" {\)/\1'"$namesuffix"'\2/'
}

mkgrubcfg1() {
    local kernel="$1"
    shift

cat <<EOF
menuentry "irq+pic+console+shell" {
    multiboot /$kernel
    module /kern/irq.mod
    module /kern/pic.mod
    module /kern/console.mod
    module /user/shell.mod
    boot
}

menuentry "lwIP" {
    multiboot /$kernel
    module /kern/irq.mod irq
    module /kern/pic.mod pic
    module /kern/console.mod console
    module /cuser/acpica.mod acpica
    module /cuser/e1000.mod e1000
    module /cuser/apic.mod apic
    module /cuser/lwip.mod lwip
    boot
}

menuentry "fbtest" {
    multiboot /$kernel
    module /kern/irq.mod
    module /kern/pic.mod
    module /kern/console.mod
    module /cuser/acpica.mod acpica
    module /cuser/bochsvga.mod bochs
    module /cuser/fbtest.mod fbtest
    boot
}

menuentry "timer_test" {
    multiboot /$kernel
    module /kern/irq.mod
    module /kern/pic.mod
    module /kern/console.mod
    module /cuser/apic.mod
    module /cuser/timer_test.mod
    boot
}

menuentry "zeropage+test_maps" {
    multiboot /$kernel
    module /kern/irq.mod
    module /kern/pic.mod
    module /kern/console.mod
    module /cuser/zeropage.mod
    module /cuser/test_maps.mod
    boot
}

menuentry "ACPICA" {
    multiboot /$kernel
    module /kern/irq.mod
    module /kern/pic.mod
    module /kern/console.mod
    module /cuser/acpica.mod
    boot
}

menuentry "puts+xmm" {
    multiboot /$kernel
    module /user/test_puts.mod
    module /user/test_xmm.mod
    boot
}

EOF

while [ $# -gt 0 ]; do
    echo "menuentry \"${1#user/}\" {"
    echo "    multiboot /$kernel"
    echo "    module /$1.mod"
    echo "    boot"
    echo "}"
    shift
done

cat <<EOF
menuentry "idle" {
    multiboot /$kernel
    boot
}
EOF
}

if [ -f out/grub/kernel ]; then
    mkgrubcfg kernel " (rust)" "$@"
fi
mkgrubcfg kstart.b "" "$@"
{'fraction_non_alphanumeric': 0.14791224345364473, 'fraction_numerical': 0.008492569002123142, 'mean_word_length': 2.4499593165174938, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3336460', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1639, 'n_words': 342}