Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aboot] add SWI_DEFAULT support in boot0 #2056

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ kernel_params="kernel-params"

aboot_machine="arista_unknown"


# extract mount point from the swi path, e.g., /mnt/flash/sonic.swi --> /mnt/flash
if [ -z "$target_path" ]; then
if [ -z "$swipath" ]; then
Expand All @@ -61,6 +60,7 @@ image_path="$target_path/$image_name"

cmdline_base="$target_path/kernel-params-base"
cmdline_image="$image_path/kernel-cmdline"
boot_config="$target_path/boot-config"

bootconfigvars="KERNEL INITRD CONSOLESPEED PASSWORD NETDEV NETAUTO NETIP NETMASK NETGW NETDOMAIN NETDNS NETHW memtest"
flash_re=" /mnt/flash| /host"
Expand Down Expand Up @@ -88,6 +88,33 @@ clean_flash() {
done
}

update_boot_config() {
local key="$1"
local value="$2"

if grep "$key" "$boot_config" 2>&1 > /dev/null; then
sed -i "s#^$key=.*\$#$key=$value#" "$boot_config"
else
echo "$key=$value" >> "$boot_config"
fi
}

get_boot_config() {
local key="$1"

sed -n "s#^$key=##p" "$boot_config" || :
}

update_next_boot() {
local default="$(get_boot_config SWI_DEFAULT)"

if [ -z "$default" ]; then
echo "warning: no variable SWI_DEFAULT available"
else
update_boot_config SWI "$default"
fi
}

extract_image() {
mkdir -p "$image_path"

Expand All @@ -114,7 +141,9 @@ extract_image() {
fi

## use new reduced-size boot swi
echo "SWI=flash:$image_name/{{ ABOOT_BOOT_IMAGE }}" > "$target_path/boot-config"
local swi_boot_path="flash:$image_name/{{ ABOOT_BOOT_IMAGE }}"
update_boot_config SWI "$swi_boot_path"
update_boot_config SWI_DEFAULT "$swi_boot_path"

## Remove installer swi as it has lots of redundunt contents
rm -f "$swipath"
Expand Down Expand Up @@ -320,6 +349,7 @@ fi

# chainloading using kexec
if $do_kexec; then
update_next_boot
run_kexec
fi