mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 12:33:02 +02:00
Previously, when the `proto://path` format of `bootfile` was used, the transformed argument sent to either tftp or wget would also be stored in `bootfile` overriding the original value set by the user. If the first boot attempt failed for some reason, the protocol information was stripped from `bootfile` and the second attempt would then default to TFTP, even if the user had originally specified `http://...`. Therefore, store the transformed value in a separate variable. For some reason, setexpr's parsing of regex escapes changes when this mode is used, so we need double backslashes to fetch match groups instead of 1. Yikes. Fixes #724
33 lines
965 B
Bash
33 lines
965 B
Bash
setenv autoload no
|
|
|
|
if test -n "${ipaddr}" || dhcp; then
|
|
setenv proto tftp
|
|
setenv dltool tftpboot
|
|
setenv dlfile "${bootfile}"
|
|
|
|
if setexpr proto sub "^(http|tftp)://.*" "\\1" "${bootfile}"; then
|
|
if test "${proto}" = "http"; then
|
|
setenv dltool wget
|
|
setexpr dlfile sub "^http://([^/]+?)/(.*)" "\\1:/\\2" "${bootfile}"
|
|
else
|
|
setexpr dlfile sub "^tftp://([^/]+?)/(.*)" "\\1:\\2" "${bootfile}"
|
|
fi
|
|
fi
|
|
|
|
if ${dltool} ${ramdisk_addr_r} "${dlfile}"; then
|
|
setenv old_fdt_addr ${fdt_addr}
|
|
if fdt addr ${ramdisk_addr_r}; then
|
|
fdt get value sqoffs /images/rootfs data-position
|
|
fdt get value sqsize /images/rootfs data-size
|
|
fdt addr ${old_fdt_addr}
|
|
|
|
setexpr sqaddr ${ramdisk_addr_r} + ${sqoffs}
|
|
setexpr sqblkcnt ${sqsize} / 0x200
|
|
setexpr sqkbsize ${sqsize} / 0x400
|
|
|
|
setenv bootargs_root "root=/dev/ram0 ramdisk_size=0x${sqkbsize} initrd=0x${sqaddr},${sqsize}"
|
|
setenv prepared ok
|
|
fi
|
|
fi
|
|
fi
|