<commit_before>#! @bash@/bin/sh -e

shopt -s nullglob

export PATH=/empty
for i in @path@; do PATH=$PATH:$i/bin:$i/sbin; done

default=$1
if test -z "$1"; then
    echo "Syntax: efi-boot-stub-builder.sh <DEFAULT-CONFIG>"
    exit 1
fi

echo "updating the efi system partition..."

# Convert a path to a file in the Nix store such as
# /nix/store/<hash>-<name>/file to <hash>-<name>-<file>.
# Also, efi executables need the .efi extension
cleanName() {
    local path="$1"
    echo "$path" | sed 's|^/nix/store/||' | sed 's|/|-|g' | sed 's|@kernelFile@$|@kernelFile@.efi|'
}

# Copy a file from the Nix store to the EFI system partition
declare -A filesCopied

copyToKernelsDir() {
    local src="$1"
    local dst="@efiSysMountPoint@/efi/nixos/$(cleanName $src)"
    # Don't copy the file if $dst already exists.  This means that we
    # have to create $dst atomically to prevent partially copied
    # kernels or initrd if this script is ever interrupted.
    if ! test -e $dst; then
        local dstTmp=$dst.tmp.$$
        cp $src $dstTmp
        mv $dstTmp $dst
    fi
    filesCopied[$dst]=1
    result=$dst
}

# Copy its kernel, initrd, and startup script to the efi system partition
# Add the efibootmgr entry if requested
addEntry() {
    local path="$1"
    local generation="$2"

    if ! test -e $path/kernel -a -e $path/initrd; then
        return
    fi

    local kernel=$(readlink -f $path/kernel)
    local initrd=$(readlink -f $path/initrd)
    copyToKernelsDir $kernel; kernel=$result
    copyToKernelsDir $initrd; initrd=$result

    local startup="@efiSysMountPoint@/efi/nixos/$(cleanName $(readlink -f $path))-startup.nsh"<commit_msg>efi-boot-stub: Give startup.sh files more descriptive names<commit_after>#! @bash@/bin/sh -e

shopt -s nullglob

export PATH=/empty
for i in @path@; do PATH=$PATH:$i/bin:$i/sbin; done

default=$1
if test -z "$1"; then
    echo "Syntax: efi-boot-stub-builder.sh <DEFAULT-CONFIG>"
    exit 1
fi

echo "updating the efi system partition..."

# Convert a path to a file in the Nix store such as
# /nix/store/<hash>-<name>/file to <hash>-<name>-<file>.
# Also, efi executables need the .efi extension
cleanName() {
    local path="$1"
    echo "$path" | sed 's|^/nix/store/||' | sed 's|/|-|g' | sed 's|@kernelFile@$|@kernelFile@.efi|'
}

# Copy a file from the Nix store to the EFI system partition
declare -A filesCopied

copyToKernelsDir() {
    local src="$1"
    local dst="@efiSysMountPoint@/efi/nixos/$(cleanName $src)"
    # Don't copy the file if $dst already exists.  This means that we
    # have to create $dst atomically to prevent partially copied
    # kernels or initrd if this script is ever interrupted.
    if ! test -e $dst; then
        local dstTmp=$dst.tmp.$$
        cp $src $dstTmp
        mv $dstTmp $dst
    fi
    filesCopied[$dst]=1
    result=$dst
}

# Copy its kernel, initrd, and startup script to the efi system partition
# Add the efibootmgr entry if requested
addEntry() {
    local path="$1"
    local generation="$2"

    if ! test -e $path/kernel -a -e $path/initrd; then
        return
    fi

    local kernel=$(readlink -f $path/kernel)
    local initrd=$(readlink -f $path/initrd)
    copyToKernelsDir $kernel; kernel=$result
    copyToKernelsDir $initrd; initrd=$result

    local startup="@efiSysMountPoint@/efi/nixos/generation-$generation-startup.nsh"
{'fraction_non_alphanumeric': 0.13385121003884076, 'fraction_numerical': 0.004780400358530027, 'mean_word_length': 3.2433460076045626, 'pattern_counts': {'":': 0, '<': 15, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2977904', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1149, 'n_words': 374}