DRIVER=hid-generic
HID_ID=0003:00000627:00000001
HID_NAME=QEMU QEMU USB Tablet
HID_PHYS=usb-0000:00:01.2-1/input0
HID_UNIQ=42
MODALIAS=hid:b0003g0001v00000627p00000001
     �Áa–Ým_J*j"Tâ‚ÆZ¸)‹FÿÃ      File not found.
     �Â¾Ã      File not found.
     �Â¾Ã      File not found.
  #   ˆl–ßi~”JC]Šq@¹q°\h*bÑ¿Á„.<ÿ¿Ä ?÷     #!/usr/bin/bash
#
# grubby wrapper to manage BootLoaderSpec files
#
#
# Copyright 2018 Red Hat, Inc.  All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

readonly SCRIPTNAME="${0##*/}"

CMDLINE_LINUX_DEBUG=" systemd.log_level=debug systemd.log_target=kmsg"
LINUX_DEBUG_VERSION_POSTFIX="_with_debugging"
LINUX_DEBUG_TITLE_POSTFIX=" with debugging"

declare -a bls_file
declare -a bls_title
declare -a bls_version
declare -a bls_linux
declare -a bls_initrd
declare -a bls_options
declare -a bls_id

[[ -f /etc/sysconfig/kernel ]] && . /etc/sysconfig/kernel
[[ -f /etc/os-release ]] && . /etc/os-release
read MACHINE_ID < /etc/machine-id
arch=$(uname -m)

if [[ $arch = 's390' || $arch = 's390x' ]]; then
    bootloader="zipl"
else
    bootloader="grub2"
fi

print_error() {
    echo "$1" >&2
    exit 1
}

print_info() {
    echo "$1" >&2
}

if [[ ${#} = 0 ]]; then
    print_error "no action specified"
fi

get_bls_value() {
    local bls="$1" && shift
    local key="$1" && shift

    echo "$(grep "^${key}[ \t]" "${bls}" | sed -e "s!^${key}[ \t]*!!")"
}

set_bls_value() {
    local bls="$1" && shift
    local key="$1" && shift
    local value="$1" && shift

    value=$(echo $value | sed -e 's/\//\\\//g')
    sed -i -e "s/^${key}.*/${key} ${value}/" "${bls}"
}

append_bls_value() {
    local bls="$1" && shift
    local key="$1" && shift
    local value="$1" && shift

    old_value="$(get_bls_value "${bls}" ${key})"
    set_bls_value "${bls}" "${key}" "${old_value}${value}"
}

get_bls_values() {
    count=0
    local -a files
    local IFS=$'\n'
    files=($(for bls in ${blsdir}/*.conf ; do
        if ! [[ -e "${bls}" ]] ; then
            continue
        fi
        bls="${bls%.conf}"
        bls="${bls##*/}"
        echo "${bls}"
    done | /usr/libexec/grubby/rpm-sort -c rpmnvrcmp 2>/dev/null | tac)) || :

    for bls in "${files[@]}" ; do
        blspath="${blsdir}/${bls}.conf"
        bls_file[$count]="${blspath}"
        bls_title[$count]="$(get_bls_value ${blspath} title)"
        bls_version[$count]="$(get_bls_value ${blspath} version)"
        bls_linux[$count]="$(get_bls_value ${blspath} linux)"
        bls_initrd[$count]="$(get_bls_value ${blspath} initrd)"
        bls_options[$count]="$(get_bls_value ${blspath} options)"
        bls_id[$count]="${bls}"

        count=$((count+1))
    done
}

get_default_index() {
    local default=""
    local index="-1"
    local title=""
    local version=""
    if [[ $bootloader = "grub2" ]]; then
	default="$(grep '^saved_entry=' ${env} | sed -e 's/^saved_entry=//')"
    else
	default="$(grep '^default=' ${zipl_config} | sed -e 's/^default=//')"
    fi

    if [[ -z $default ]]; then
	index=0
    elif [[ $default =~ ^[0-9]+$ ]]; then
	index="$default"
    fi

    for i in ${!bls_file[@]}; do
        if [[ $i -eq $index ]]; then
            echo $i
            return
        fi

        if [[ $default = ${bls_id[$i]} || $default = ${bls_title[$i]} ]]; then
            echo $i
            return
        fi
    done
}

display_default_value() {
    local prefix=$(get_prefix)

    case "$display_default" in
        kernel)
            echo "${prefi