lbmk scripts: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>9020vga
parent
b111f4840a
commit
b0e5fc9d9c
|
@ -120,32 +120,26 @@ clone_project()
|
||||||
|
|
||||||
git_reset_rev()
|
git_reset_rev()
|
||||||
{
|
{
|
||||||
(
|
git -C "${1}" reset --hard ${2} || err "!git reset ${1} <- ${2}"
|
||||||
cd "${1}" || err "git_reset_rev: !cd ${1}"
|
|
||||||
git reset --hard ${2} || err "!git reset ${1} <- ${2}"
|
|
||||||
if [ "${project}" != "coreboot" ] && [ "${project}" != "u-boot" ] && \
|
if [ "${project}" != "coreboot" ] && [ "${project}" != "u-boot" ] && \
|
||||||
[ -f ".gitmodules" ]; then
|
[ -f "${1}/.gitmodules" ]; then
|
||||||
git submodule update --init --checkout || \
|
git -C "${1}" submodule update --init --checkout || \
|
||||||
err "git_reset_rev ${1}: can't download submodules"
|
err "git_reset_rev ${1}: can't download submodules"
|
||||||
fi
|
fi
|
||||||
) || err "git reset fail"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
git_am_patches()
|
git_am_patches()
|
||||||
{
|
{
|
||||||
sdir="${1}" # assumed to be absolute path
|
sdir="${1}" # assumed to be absolute path
|
||||||
patchdir="${2}" # ditto
|
patchdir="${2}" # ditto
|
||||||
(
|
|
||||||
cd "${sdir}" || err "git_am_patches: !cd ${sdir}"
|
|
||||||
for patch in "${patchdir}/"*; do
|
for patch in "${patchdir}/"*; do
|
||||||
[ -L "${patch}" ] && continue
|
[ -L "${patch}" ] && continue
|
||||||
[ -f "${patch}" ] || continue
|
[ -f "${patch}" ] || continue
|
||||||
git am "${patch}" || patchfail="y"
|
git -C "${sdir}" am "${patch}" || patchfail="y"
|
||||||
[ "${patchfail}" != "y" ] && continue
|
[ "${patchfail}" != "y" ] && continue
|
||||||
git am --abort || err "${sdir}: !git am --abort"
|
git -C "${sdir}" am --abort || err "${sdir}: !git am --abort"
|
||||||
err "!git am ${patch} -> ${sdir}"
|
err "!git am ${patch} -> ${sdir}"
|
||||||
done
|
done
|
||||||
) || err "PATCH FAILURE"
|
|
||||||
for patches in "${patchdir}/"*; do
|
for patches in "${patchdir}/"*; do
|
||||||
[ -L "${patches}" ] && continue
|
[ -L "${patches}" ] && continue
|
||||||
[ ! -d "${patches}" ] && continue
|
[ ! -d "${patches}" ] && continue
|
||||||
|
|
|
@ -58,9 +58,8 @@ EOF
|
||||||
check_defconfig()
|
check_defconfig()
|
||||||
{
|
{
|
||||||
for x in "${1}"/config/*; do
|
for x in "${1}"/config/*; do
|
||||||
[ -f "${x}" ] && return 0
|
[ -f "${x}" ] && return 1
|
||||||
done
|
done
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_coreboot_utils()
|
handle_coreboot_utils()
|
||||||
|
|
|
@ -19,7 +19,7 @@ kmapdir="config/grub/keymap"
|
||||||
|
|
||||||
# Disable all payloads by default.
|
# Disable all payloads by default.
|
||||||
# target.cfg files have to specifically enable [a] payload(s)
|
# target.cfg files have to specifically enable [a] payload(s)
|
||||||
pv="payload_grub payload_grub_withseabios payload_seabios payload_memtest"
|
pv="payload_grub payload_grub_withseabios payload_seabios payload_memtest t"
|
||||||
pv="${pv} payload_seabios_withgrub payload_seabios_grubonly payload_uboot memtest_bin"
|
pv="${pv} payload_seabios_withgrub payload_seabios_grubonly payload_uboot memtest_bin"
|
||||||
v="romdir cbrom initmode displaymode cbcfg targetdir tree arch"
|
v="romdir cbrom initmode displaymode cbcfg targetdir tree arch"
|
||||||
v="${v} grub_timeout ubdir vendorfiles board grub_scan_disk uboot_config"
|
v="${v} grub_timeout ubdir vendorfiles board grub_scan_disk uboot_config"
|
||||||
|
@ -63,7 +63,7 @@ main()
|
||||||
|
|
||||||
[ -z "${targets}" ] && err "No ROM images were compiled"
|
[ -z "${targets}" ] && err "No ROM images were compiled"
|
||||||
printf "\nROM images available in these directories:\n"
|
printf "\nROM images available in these directories:\n"
|
||||||
printf "%s^^ ROM images available in these directories.\n\n" "${targets}"
|
printf "%s^^ ROM images available in these directories.\n\n" "$targets"
|
||||||
|
|
||||||
printf "DO NOT flash ROM images from elf/ - please use bin/ instead.\n"
|
printf "DO NOT flash ROM images from elf/ - please use bin/ instead.\n"
|
||||||
}
|
}
|
||||||
|
@ -77,29 +77,21 @@ check_target()
|
||||||
# Override the above defaults using target.cfg
|
# Override the above defaults using target.cfg
|
||||||
. "${targetdir}/target.cfg"
|
. "${targetdir}/target.cfg"
|
||||||
|
|
||||||
[ -z "${grub_scan_disk}" ] && \
|
[ -z "${grub_scan_disk}" ] && grub_scan_disk="both"
|
||||||
grub_scan_disk="both"
|
|
||||||
[ "${grub_scan_disk}" != "both" ] && [ "${grub_scan_disk}" != "ata" ] \
|
[ "${grub_scan_disk}" != "both" ] && [ "${grub_scan_disk}" != "ata" ] \
|
||||||
&& [ "${grub_scan_disk}" != "ahci" ] && \
|
&& [ "${grub_scan_disk}" != "ahci" ] && \
|
||||||
grub_scan_disk="both"
|
grub_scan_disk="both"
|
||||||
|
|
||||||
[ -z "${tree}" ] && \
|
[ -z "$arch" ] && err "$board: arch not defined"
|
||||||
err "Target '${board}' defines no tree. Skipping build."
|
[ -z "$tree" ] && err "$board: tree not defined"
|
||||||
[ -z "${arch}" ] && \
|
|
||||||
err "Target '${board}' defines no arch. Skipping build."
|
|
||||||
|
|
||||||
[ "${payload_memtest}" != "y" ] && \
|
[ "${payload_memtest}" != "y" ] && payload_memtest="n"
|
||||||
payload_memtest="n"
|
[ "${payload_grub_withseabios}" = "y" ] && payload_grub="y"
|
||||||
[ "${payload_grub_withseabios}" = "y" ] && \
|
|
||||||
payload_grub="y"
|
|
||||||
[ "${payload_grub_withseabios}" = "y" ] && \
|
[ "${payload_grub_withseabios}" = "y" ] && \
|
||||||
eval "$(setvars "y" payload_seabios payload_seabios_withgrub)"
|
eval "$(setvars "y" payload_seabios payload_seabios_withgrub)"
|
||||||
[ "${payload_seabios_withgrub}" = "y" ] && \
|
[ "$payload_seabios_withgrub" = "y" ] && payload_seabios="y"
|
||||||
payload_seabios="y"
|
[ "$payload_seabios_grubonly" = "y" ] && payload_seabios="y"
|
||||||
if [ "${payload_seabios_grubonly}" = "y" ]; then
|
[ "$payload_seabios_grubonly" = "y" ] && payload_seabios_withgrub="y"
|
||||||
payload_seabios="y"
|
|
||||||
payload_seabios_withgrub="y"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The reverse logic must not be applied. If SeaBIOS-with-GRUB works,
|
# The reverse logic must not be applied. If SeaBIOS-with-GRUB works,
|
||||||
# that doesn't mean GRUB-withSeaBIOS will. For example, the board
|
# that doesn't mean GRUB-withSeaBIOS will. For example, the board
|
||||||
|
@ -220,13 +212,14 @@ build_roms()
|
||||||
cbcfg="${1}"
|
cbcfg="${1}"
|
||||||
if [ ! -f "${cbcfg}" ]; then
|
if [ ! -f "${cbcfg}" ]; then
|
||||||
printf "'%s' does not exist. Skipping build for %s %s %s\n" \
|
printf "'%s' does not exist. Skipping build for %s %s %s\n" \
|
||||||
"${cbcfg}" "${board}" "${displaymode}" "${initmode}" 1>&2
|
"$cbcfg" "$board" "$displaymode" "$initmode" 1>&2
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
x_ ./update trees -b coreboot ${board}
|
x_ ./update trees -b coreboot ${board}
|
||||||
|
|
||||||
_cbrom="elf/coreboot_nopayload_DO_NOT_FLASH/${board}/${initmode}_${displaymode}"
|
_cbrom="elf/coreboot_nopayload_DO_NOT_FLASH"
|
||||||
|
_cbrom="${_cbrom}/${board}/${initmode}_${displaymode}"
|
||||||
[ "${initmode}" = "normal" ] && \
|
[ "${initmode}" = "normal" ] && \
|
||||||
_cbrom="${_cbrom%"_${displaymode}"}"
|
_cbrom="${_cbrom%"_${displaymode}"}"
|
||||||
_cbrom="${_cbrom}/coreboot.rom"
|
_cbrom="${_cbrom}/coreboot.rom"
|
||||||
|
@ -248,10 +241,9 @@ build_roms()
|
||||||
build_seabios_roms()
|
build_seabios_roms()
|
||||||
{
|
{
|
||||||
if [ "${payload_seabios_withgrub}" = "y" ]; then
|
if [ "${payload_seabios_withgrub}" = "y" ]; then
|
||||||
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
t=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
||||||
x_ cp "${cbrom}" "${tmprom}"
|
x_ cp "${cbrom}" "${t}"
|
||||||
x_ build_grub_roms "${tmprom}" "seabios_withgrub"
|
x_ build_grub_roms "${t}" "seabios_withgrub"
|
||||||
x_ rm -f "${tmprom}"
|
|
||||||
else
|
else
|
||||||
t=$(mkSeabiosRom "${cbrom}" "fallback/payload") || \
|
t=$(mkSeabiosRom "${cbrom}" "fallback/payload") || \
|
||||||
err "build_seabios_roms: cannot build tmprom"
|
err "build_seabios_roms: cannot build tmprom"
|
||||||
|
@ -259,8 +251,8 @@ build_seabios_roms()
|
||||||
[ "${initmode}" = "normal" ] && newrom="${romdir}/seabios" \
|
[ "${initmode}" = "normal" ] && newrom="${romdir}/seabios" \
|
||||||
&& newrom="${newrom}_${board}_${initmode}"
|
&& newrom="${newrom}_${board}_${initmode}"
|
||||||
x_ moverom "${t}" "${newrom}.rom"
|
x_ moverom "${t}" "${newrom}.rom"
|
||||||
x_ rm -f "${t}"
|
|
||||||
fi
|
fi
|
||||||
|
x_ rm -f "${t}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make separate ROM images with GRUB payload, for each supported keymap
|
# Make separate ROM images with GRUB payload, for each supported keymap
|
||||||
|
@ -270,11 +262,11 @@ build_grub_roms()
|
||||||
payload1="${2}" # allow values: grub, seabios, seabios_withgrub
|
payload1="${2}" # allow values: grub, seabios, seabios_withgrub
|
||||||
|
|
||||||
grub_cbfs="fallback/payload"
|
grub_cbfs="fallback/payload"
|
||||||
[ "${payload1}" = "grub" ] && [ "${payload_grub_withseabios}" = "y" ] \
|
[ "$payload1" = "grub" ] && [ "$payload_grub_withseabios" = "y" ] \
|
||||||
&& x_ mv "$(mkSeabiosRom "${tmprom}" "seabios.elf")" "${tmprom}"
|
&& x_ mv "$(mkSeabiosRom "$tmprom" "seabios.elf")" "$tmprom"
|
||||||
[ "${payload1}" != "grub" ] && [ "${payload_seabios_withgrub}" = "y" ] \
|
[ "$payload1" != "grub" ] && [ "$payload_seabios_withgrub" = "y" ] \
|
||||||
&& grub_cbfs="img/grub2" && \
|
&& grub_cbfs="img/grub2" && \
|
||||||
x_ mv "$(mkSeabiosRom "${tmprom}" fallback/payload)" "${tmprom}"
|
x_ mv "$(mkSeabiosRom "$tmprom" fallback/payload)" "$tmprom"
|
||||||
|
|
||||||
# we only need insert grub.elf once, for each coreboot config:
|
# we only need insert grub.elf once, for each coreboot config:
|
||||||
x_ "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
|
x_ "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
|
||||||
|
@ -285,14 +277,15 @@ build_grub_roms()
|
||||||
[ "${displaymode}" = "corebootfb" ]; then
|
[ "${displaymode}" = "corebootfb" ]; then
|
||||||
backgroundfile="config/grub/background/${grub_background}"
|
backgroundfile="config/grub/background/${grub_background}"
|
||||||
"${cbfstool}" "${tmprom}" add -f ${backgroundfile} \
|
"${cbfstool}" "${tmprom}" add -f ${backgroundfile} \
|
||||||
-n background.png -t raw || err "insert background, ${backgroundfile}"
|
-n background.png -t raw || \
|
||||||
|
err "insert background, ${backgroundfile}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmpcfg=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
tmpcfg=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
||||||
printf "set grub_scan_disk=\"%s\"\n" "${grub_scan_disk}" >"${tmpcfg}" \
|
printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" >"$tmpcfg" \
|
||||||
|| err "set grub_scandisk, ${grub_scan_disk}, ${tmpcfg}"
|
|| err "set grub_scandisk, $grub_scan_disk, $tmpcfg"
|
||||||
[ "${grub_scan_disk}" = "both" ] || \
|
[ "${grub_scan_disk}" = "both" ] || \
|
||||||
x_ "${cbfstool}" "${tmprom}" add -f "${tmpcfg}" -n scan.cfg -t raw
|
x_ "$cbfstool" "$tmprom" add -f "$tmpcfg" -n scan.cfg -t raw
|
||||||
printf "set timeout=%s\n" "${grub_timeout}" > "${tmpcfg}" || \
|
printf "set timeout=%s\n" "${grub_timeout}" > "${tmpcfg}" || \
|
||||||
err "set timeout, ${grub_timeout}, ${tmpcfg}"
|
err "set timeout, ${grub_timeout}, ${tmpcfg}"
|
||||||
[ -z "${grub_timeout}" ] || x_ "${cbfstool}" "${tmprom}" add \
|
[ -z "${grub_timeout}" ] || x_ "${cbfstool}" "${tmprom}" add \
|
||||||
|
@ -332,7 +325,7 @@ mkGrubRom() {
|
||||||
|
|
||||||
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
||||||
x_ cp "${_cbrom}" "${tmprom}"
|
x_ cp "${_cbrom}" "${tmprom}"
|
||||||
x_ "${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw
|
x_ "$cbfstool" "$tmprom" add -f "$keymapcfg" -n keymap.cfg -t raw
|
||||||
|
|
||||||
printf "%s\n" "${tmprom}"
|
printf "%s\n" "${tmprom}"
|
||||||
}
|
}
|
||||||
|
@ -348,7 +341,7 @@ mkSeabiosRom() {
|
||||||
x_ cp "${_cbrom}" "${tmprom}"
|
x_ cp "${_cbrom}" "${tmprom}"
|
||||||
x_ "${cbfstool}" "${tmprom}" add-payload -f "${_seabioself}" \
|
x_ "${cbfstool}" "${tmprom}" add-payload -f "${_seabioself}" \
|
||||||
-n "${_seabios_cbfs_path}" -c lzma
|
-n "${_seabios_cbfs_path}" -c lzma
|
||||||
x_ "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup
|
x_ "$cbfstool" "$tmprom" add-int -i 3000 -n etc/ps2-keyboard-spinup
|
||||||
|
|
||||||
z="2"; [ "${initmode}" = "vgarom" ] && z="0"
|
z="2"; [ "${initmode}" = "vgarom" ] && z="0"
|
||||||
x_ "${cbfstool}" "${tmprom}" add-int -i $z -n etc/pci-optionrom-exec
|
x_ "${cbfstool}" "${tmprom}" add-int -i $z -n etc/pci-optionrom-exec
|
||||||
|
@ -369,7 +362,7 @@ mkSeabiosGrubonlyRom()
|
||||||
tmpbootorder=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
tmpbootorder=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
||||||
|
|
||||||
# only load grub, by inserting a custom bootorder file
|
# only load grub, by inserting a custom bootorder file
|
||||||
printf "/rom@img/grub2\n" > "${tmpbootorder}" || err "printf bootorder"
|
printf "/rom@img/grub2\n" > "$tmpbootorder" || err "printf bootorder"
|
||||||
x_ "${cbfstool}" "${_grubrom}" \
|
x_ "${cbfstool}" "${_grubrom}" \
|
||||||
add -f "${tmpbootorder}" -n bootorder -t raw
|
add -f "${tmpbootorder}" -n bootorder -t raw
|
||||||
x_ rm -f "${tmpbootorder}"
|
x_ rm -f "${tmpbootorder}"
|
||||||
|
|
|
@ -36,11 +36,9 @@ main()
|
||||||
[ -z "${_f}" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
|
[ -z "${_f}" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
|
||||||
[ -z "${project}" ] && err "project name not specified"
|
[ -z "${project}" ] && err "project name not specified"
|
||||||
|
|
||||||
if [ -f "config/${project}/build.list" ]; then
|
_cmd="build_projects"
|
||||||
build_targets $@
|
[ -f "config/${project}/build.list" ] && _cmd="build_targets"
|
||||||
else
|
$_cmd $@
|
||||||
build_projects $@
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build_projects()
|
build_projects()
|
||||||
|
@ -103,7 +101,7 @@ handle_targets()
|
||||||
x_ handle_defconfig
|
x_ handle_defconfig
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "${target1}" = "utils" ] && [ "${project}" = "coreboot" ] && return 0
|
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && return 0
|
||||||
[ -z "${mode}" ] || return 0
|
[ -z "${mode}" ] || return 0
|
||||||
printf "Done! The files are stored under %s/\n\n" "${elfdir}"
|
printf "Done! The files are stored under %s/\n\n" "${elfdir}"
|
||||||
}
|
}
|
||||||
|
@ -161,10 +159,7 @@ handle_src_tree()
|
||||||
x_ ./update trees -f "${project}" "${target}"
|
x_ ./update trees -f "${project}" "${target}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ "${target1}" = "utils" ] && [ "${project}" = "coreboot" ] && return 0
|
[ "$target1" = "utils" ] && [ "$project" = "coreboot" ] && return 0
|
||||||
[ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && return 0
|
|
||||||
|
|
||||||
# u-boot and coreboot are both compiled with coreboot's crossgcc
|
|
||||||
[ -z "${mode}" ] || return 0
|
[ -z "${mode}" ] || return 0
|
||||||
check_cross_compiler
|
check_cross_compiler
|
||||||
}
|
}
|
||||||
|
@ -199,7 +194,7 @@ check_cross_compiler()
|
||||||
|
|
||||||
check_config()
|
check_config()
|
||||||
{
|
{
|
||||||
[ ! -f "${config}" ] && \
|
[ -f "${config}" ] || \
|
||||||
err "check_config: ${project}/${target}: configs missing"
|
err "check_config: ${project}/${target}: configs missing"
|
||||||
|
|
||||||
dest_dir="${elfdir}/${target}/${config_name}"
|
dest_dir="${elfdir}/${target}/${config_name}"
|
||||||
|
@ -224,8 +219,8 @@ handle_makefile()
|
||||||
if [ -e "${codedir}/.git" ] && [ "${project}" = "u-boot" ] && \
|
if [ -e "${codedir}/.git" ] && [ "${project}" = "u-boot" ] && \
|
||||||
[ "${mode}" = "distclean" ]; then
|
[ "${mode}" = "distclean" ]; then
|
||||||
x_ git -C "${codedir}" clean -fdx
|
x_ git -C "${codedir}" clean -fdx
|
||||||
elif [ "${mode}" = "oldconfig" ] || [ "${mode}" = "olddefconfig" ] || \
|
elif [ "$mode" = "oldconfig" ] || [ "$mode" = "olddefconfig" ] || \
|
||||||
[ "${mode}" = "menuconfig" ] || [ "${mode}" = "nconfig" ]; then
|
[ "$mode" = "menuconfig" ] || [ "$mode" = "nconfig" ]; then
|
||||||
x_ cp "${codedir}/.config" "${config}"
|
x_ cp "${codedir}/.config" "${config}"
|
||||||
elif [ "${mode}" = "savedefconfig" ]; then
|
elif [ "${mode}" = "savedefconfig" ]; then
|
||||||
x_ cp "${codedir}/defconfig" "${config}"
|
x_ cp "${codedir}/defconfig" "${config}"
|
||||||
|
|
|
@ -32,7 +32,7 @@ main()
|
||||||
boarddir="${cbcfgsdir}/${board}"
|
boarddir="${cbcfgsdir}/${board}"
|
||||||
_b="${board%%_*mb}" # shorthand (avoid duplicating config per rom size)
|
_b="${board%%_*mb}" # shorthand (avoid duplicating config per rom size)
|
||||||
|
|
||||||
check_defconfig "${boarddir}" || exit 0
|
check_defconfig "${boarddir}" && exit 0
|
||||||
detect_firmware && exit 0
|
detect_firmware && exit 0
|
||||||
scan_config "${_b}" "config/vendor" "err"
|
scan_config "${_b}" "config/vendor" "err"
|
||||||
|
|
||||||
|
@ -54,16 +54,13 @@ detect_firmware()
|
||||||
|
|
||||||
build_dependencies()
|
build_dependencies()
|
||||||
{
|
{
|
||||||
[ -d "${cbdir}" ] || \
|
[ -d "${cbdir}" ] || x_ ./update trees -f coreboot ${cbdir##*/}
|
||||||
x_ ./update trees -f coreboot ${cbdir##*/}
|
|
||||||
for d in uefitool biosutilities bios_extract; do
|
for d in uefitool biosutilities bios_extract; do
|
||||||
[ -d "src/${d}" ] && continue
|
[ -d "src/${d}" ] && continue
|
||||||
x_ ./update trees -f "${d}"
|
x_ ./update trees -f "${d}"
|
||||||
done
|
done
|
||||||
[ -f "${uefiextract}" ] || \
|
[ -f "${uefiextract}" ] || x_ ./update trees -b uefitool
|
||||||
x_ ./update trees -b uefitool
|
[ -f "${kbc1126_ec_dump}" ] || x_ make -C "${cbdir}/util/kbc1126"
|
||||||
[ -f "${kbc1126_ec_dump}" ] || \
|
|
||||||
x_ make -C "${cbdir}/util/kbc1126"
|
|
||||||
[ -f "${cbfstool}" ] && [ -f "${ifdtool}" ] && return 0
|
[ -f "${cbfstool}" ] && [ -f "${ifdtool}" ] && return 0
|
||||||
x_ ./update trees -b coreboot utils default
|
x_ ./update trees -b coreboot utils default
|
||||||
}
|
}
|
||||||
|
@ -71,19 +68,17 @@ build_dependencies()
|
||||||
download_vendorfiles()
|
download_vendorfiles()
|
||||||
{
|
{
|
||||||
[ -z "${CONFIG_HAVE_ME_BIN}" ] || \
|
[ -z "${CONFIG_HAVE_ME_BIN}" ] || \
|
||||||
fetch "intel_me" "${DL_url}" "${DL_url_bkup}" "${DL_hash}" \
|
fetch intel_me "$DL_url" "$DL_url_bkup" "$DL_hash" \
|
||||||
"${CONFIG_ME_BIN_PATH}"
|
"${CONFIG_ME_BIN_PATH}"
|
||||||
[ -z "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" ] || \
|
[ -z "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" ] || \
|
||||||
fetch "sch5545ec" "${SCH5545EC_DL_url}" \
|
fetch sch5545ec "$SCH5545EC_DL_url" "$SCH5545EC_DL_url_bkup" \
|
||||||
"${SCH5545EC_DL_url_bkup}" "${SCH5545EC_DL_hash}" \
|
"$SCH5545EC_DL_hash" "$CONFIG_SMSC_SCH5545_EC_FW_FILE"
|
||||||
"${CONFIG_SMSC_SCH5545_EC_FW_FILE}"
|
|
||||||
[ -z "${CONFIG_KBC1126_FIRMWARE}" ] || \
|
[ -z "${CONFIG_KBC1126_FIRMWARE}" ] || \
|
||||||
fetch "kbc1126ec" "${EC_url}" "${EC_url_bkup}" "${EC_hash}" \
|
fetch kbc1126ec "$EC_url" "$EC_url_bkup" "$EC_hash" \
|
||||||
"${CONFIG_KBC1126_FW1}"
|
"${CONFIG_KBC1126_FW1}"
|
||||||
[ -z "${CONFIG_VGA_BIOS_FILE}" ] || \
|
[ -z "${CONFIG_VGA_BIOS_FILE}" ] || \
|
||||||
fetch "e6400vga" "${E6400_VGA_DL_url}" \
|
fetch "e6400vga" "$E6400_VGA_DL_url" "$E6400_VGA_DL_url_bkup" \
|
||||||
"${E6400_VGA_DL_url_bkup}" "${E6400_VGA_DL_hash}" \
|
"$E6400_VGA_DL_hash" "$CONFIG_VGA_BIOS_FILE"
|
||||||
"${CONFIG_VGA_BIOS_FILE}"
|
|
||||||
[ -z "${CONFIG_HAVE_MRC}" ] && return 0
|
[ -z "${CONFIG_HAVE_MRC}" ] && return 0
|
||||||
fetch "mrc" "$MRC_url" "$MRC_url_bkup" "$MRC_hash" "$CONFIG_MRC_FILE"
|
fetch "mrc" "$MRC_url" "$MRC_url_bkup" "$MRC_hash" "$CONFIG_MRC_FILE"
|
||||||
}
|
}
|
||||||
|
@ -95,30 +90,27 @@ fetch()
|
||||||
dl_bkup="${3}"
|
dl_bkup="${3}"
|
||||||
dlsum="${4}"
|
dlsum="${4}"
|
||||||
[ "${5}" = "/dev/null" ] && return 0
|
[ "${5}" = "/dev/null" ] && return 0
|
||||||
[ "${5# }" = "${5}" ] || err "fetch: space not allowed in _dest: '${5}'"
|
[ "${5# }" = "$5" ] || err "fetch: space not allowed in _dest: '$5'"
|
||||||
[ "${5#/}" = "${5}" ] || err "fetch: absolute path not allowed: '${5}'"
|
[ "${5#/}" = "$5" ] || err "fetch: absolute path not allowed: '$5'"
|
||||||
_dest="${5##*../}"
|
_dest="${5##*../}"
|
||||||
_dl="${vendir}/cache/${dlsum}"
|
_dl="${vendir}/cache/${dlsum}"
|
||||||
dl_fail=""
|
eval "$(setvars "n" dl_fail is_rom)"
|
||||||
|
|
||||||
x_ mkdir -p "${_dl%/*}"
|
x_ mkdir -p "${_dl%/*}"
|
||||||
|
|
||||||
is_rom="n"
|
|
||||||
if [ "${dl}" = "rom" ] || [ "${dl_bkup}" = "rom" ]; then
|
if [ "${dl}" = "rom" ] || [ "${dl_bkup}" = "rom" ]; then
|
||||||
dl_fail="n"
|
|
||||||
is_rom="y"
|
is_rom="y"
|
||||||
else
|
else
|
||||||
dl_fail="y"
|
dl_fail="y"
|
||||||
vendor_checksum "${dlsum}" "${_dl}" && dl_fail="n"
|
vendor_checksum "${dlsum}" "${_dl}" || dl_fail="n"
|
||||||
fi
|
fi
|
||||||
for url in "${dl}" "${dl_bkup}"; do
|
for url in "${dl}" "${dl_bkup}"; do
|
||||||
[ "${dl_fail}" = "n" ] && break
|
[ "${dl_fail}" = "n" ] && break
|
||||||
[ -z "${url}" ] && continue
|
[ -z "${url}" ] && continue
|
||||||
x_ rm -f "${_dl}"
|
x_ rm -f "${_dl}"
|
||||||
curl --location --retry 3 -A "${_ua}" "${url}" -o "${_dl}" || \
|
curl --location --retry 3 -A "$_ua" "$url" -o "$_dl" || \
|
||||||
wget --tries 3 -U "${_ua}" "${url}" -O "${_dl}" || \
|
wget --tries 3 -U "$_ua" "$url" -O "$_dl" || continue
|
||||||
continue
|
vendor_checksum "${dlsum}" "${_dl}" || dl_fail="n"
|
||||||
vendor_checksum "${dlsum}" "${_dl}" && dl_fail="n"
|
|
||||||
done
|
done
|
||||||
[ "${dl_fail}" = "y" ] && \
|
[ "${dl_fail}" = "y" ] && \
|
||||||
err "fetch ${dlsum}: matched file unavailable"
|
err "fetch ${dlsum}: matched file unavailable"
|
||||||
|
@ -133,16 +125,15 @@ fetch()
|
||||||
|
|
||||||
vendor_checksum()
|
vendor_checksum()
|
||||||
{
|
{
|
||||||
[ "$(sha512sum "${2}" | awk '{print $1}')" != "${1}" ] || return 0
|
[ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
|
||||||
printf "Bad checksum for file: %s\n" "${2}" 1>&2
|
printf "Bad checksum for file: %s\n" "$2" 1>&2
|
||||||
rm -f "${2}" || :
|
rm -f "$2" || :
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirs()
|
mkdirs()
|
||||||
{
|
{
|
||||||
if [ -f "${1}" ]; then
|
if [ -f "${1}" ]; then
|
||||||
printf "mkdirs %s %s: already downloaded\n" "${1}" "${2}" 1>&2
|
printf "mkdirs %s %s: already downloaded\n" "$1" "$2" 1>&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
mkdir -p "${1%/*}" || err "mkdirs: !mkdir -p ${1%/*}"
|
mkdir -p "${1%/*}" || err "mkdirs: !mkdir -p ${1%/*}"
|
||||||
|
@ -161,8 +152,7 @@ extract_intel_me()
|
||||||
{
|
{
|
||||||
_me="${PWD}/${_dest}" # must always be an absolute path
|
_me="${PWD}/${_dest}" # must always be an absolute path
|
||||||
cdir="${PWD}/${appdir}" # must always be an absolute path
|
cdir="${PWD}/${appdir}" # must always be an absolute path
|
||||||
[ $# -gt 0 ] && _me="${1}"
|
[ $# -gt 0 ] && _me="${1}" && cdir="${2}"
|
||||||
[ $# -gt 0 ] && cdir="${2}"
|
|
||||||
[ -f "${_me}" ] && return 0
|
[ -f "${_me}" ] && return 0
|
||||||
|
|
||||||
sdir="$(mktemp -d)"
|
sdir="$(mktemp -d)"
|
||||||
|
@ -196,9 +186,8 @@ extract_intel_me()
|
||||||
|
|
||||||
extract_archive()
|
extract_archive()
|
||||||
{
|
{
|
||||||
innoextract "${1}" -d "${2}" || python "${pfs_extract}" "${1}" -e || \
|
innoextract "$1" -d "$2" || python "$pfs_extract" "$1" -e || 7z x "$1" \
|
||||||
7z x "${1}" -o"${2}" || unar "${1}" -o "${2}" || \
|
-o"$2" || unar "$1" -o "$2" || unzip "$1" -d "$2" || return 1
|
||||||
unzip "${1}" -d "${2}" || return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extract_kbc1126ec()
|
extract_kbc1126ec()
|
||||||
|
@ -227,12 +216,10 @@ extract_kbc1126ec()
|
||||||
|
|
||||||
extract_e6400vga()
|
extract_e6400vga()
|
||||||
{
|
{
|
||||||
[ -z "${E6400_VGA_offset}" ] && \
|
for v in E6400_VGA_offset E6400_VGA_romname; do
|
||||||
err "extract_e6400vga: E6400 VGA offset not defined"
|
eval "[ -z \"\$$v\" ] && err \"extract_e6400vga: $v undefined\""
|
||||||
[ -z "${E6400_VGA_romname}" ] && \
|
done
|
||||||
err "extract_e6400vga: E6400 VGA ROM name not defined"
|
tail -c +$E6400_VGA_offset "$_dl" | gunzip > "$appdir/bios.bin" || :
|
||||||
tail -c +${E6400_VGA_offset} "${_dl}" | \
|
|
||||||
gunzip >"${appdir}/bios.bin" || :
|
|
||||||
(
|
(
|
||||||
x_ cd "${appdir}"
|
x_ cd "${appdir}"
|
||||||
[ -f "bios.bin" ] || err "extract_e6400vga: can't extract bios.bin"
|
[ -f "bios.bin" ] || err "extract_e6400vga: can't extract bios.bin"
|
||||||
|
@ -247,8 +234,7 @@ extract_e6400vga()
|
||||||
extract_sch5545ec()
|
extract_sch5545ec()
|
||||||
{
|
{
|
||||||
# full system ROM (UEFI), to extract with UEFIExtract:
|
# full system ROM (UEFI), to extract with UEFIExtract:
|
||||||
_bios="${_dl}_extracted/Firmware"
|
_bios="${_dl}_extracted/Firmware/1 ${dlsum} -- 1 System BIOS vA.28.bin"
|
||||||
_bios="${_bios}/1 ${dlsum} -- 1 System BIOS vA.28.bin"
|
|
||||||
# this is the SCH5545 firmware, inside of the extracted UEFI ROM:
|
# this is the SCH5545 firmware, inside of the extracted UEFI ROM:
|
||||||
_sch5545ec_fw="${_bios}.dump/4 7A9354D9-0468-444A-81CE-0BF617D890DF"
|
_sch5545ec_fw="${_bios}.dump/4 7A9354D9-0468-444A-81CE-0BF617D890DF"
|
||||||
_sch5545ec_fw="${_sch5545ec_fw}/54 D386BEB8-4B54-4E69-94F5-06091F67E0D3"
|
_sch5545ec_fw="${_sch5545ec_fw}/54 D386BEB8-4B54-4E69-94F5-06091F67E0D3"
|
||||||
|
|
|
@ -135,11 +135,9 @@ patch_release_roms()
|
||||||
x_ cd "${_tmpdir}/bin/"* # TODO: very dodgy, re-write accordingly
|
x_ cd "${_tmpdir}/bin/"* # TODO: very dodgy, re-write accordingly
|
||||||
|
|
||||||
# NOTE: For compatibility with older rom releases, defer to sha1
|
# NOTE: For compatibility with older rom releases, defer to sha1
|
||||||
[ "${nukemode}" = "nuke" ] || \
|
[ "${nukemode}" = "nuke" ] || sha512sum --status -c vendorhashes || \
|
||||||
sha512sum --status -c vendorhashes || \
|
sha1sum --status -c vendorhashes || sha512sum --status -c \
|
||||||
sha1sum --status -c vendorhashes || \
|
blobhashes || sha1sum --status -c blobhashes || \
|
||||||
sha512sum --status -c blobhashes || \
|
|
||||||
sha1sum --status -c blobhashes || \
|
|
||||||
err "patch_release_roms: ROMs did not match expected hashes"
|
err "patch_release_roms: ROMs did not match expected hashes"
|
||||||
) || err "can't verify vendor hashes"
|
) || err "can't verify vendor hashes"
|
||||||
|
|
||||||
|
@ -168,10 +166,10 @@ patch_rom()
|
||||||
# may sometimes insert certain vendor files at the wrong offset)
|
# may sometimes insert certain vendor files at the wrong offset)
|
||||||
# (unless nomicrocode is the only config provided)
|
# (unless nomicrocode is the only config provided)
|
||||||
[ "${rom}" != "${rom%_nomicrocode.rom}.rom" ] && \
|
[ "${rom}" != "${rom%_nomicrocode.rom}.rom" ] && \
|
||||||
[ -f "${rom%_nomicrocode.rom}.rom" ] && \
|
[ -f "${rom%_nomicrocode.rom}.rom" ] && \
|
||||||
[ "${release}" = "y" ] && return 0
|
[ "${release}" = "y" ] && return 0
|
||||||
|
|
||||||
x_ check_defconfig "${boarddir}"
|
check_defconfig "$boarddir" && err "patch_rom $boarddir: no configs"
|
||||||
|
|
||||||
set -- "${boarddir}/config/"*
|
set -- "${boarddir}/config/"*
|
||||||
. "${1}" 2>/dev/null
|
. "${1}" 2>/dev/null
|
||||||
|
@ -185,8 +183,7 @@ patch_rom()
|
||||||
"${CONFIG_KBC1126_FW1_OFFSET}" && \
|
"${CONFIG_KBC1126_FW1_OFFSET}" && \
|
||||||
inject "ecfw2.bin" "$CONFIG_KBC1126_FW2" "raw" \
|
inject "ecfw2.bin" "$CONFIG_KBC1126_FW2" "raw" \
|
||||||
"${CONFIG_KBC1126_FW2_OFFSET}"
|
"${CONFIG_KBC1126_FW2_OFFSET}"
|
||||||
[ -n "${CONFIG_VGA_BIOS_FILE}" ] && \
|
[ -n "$CONFIG_VGA_BIOS_FILE" ] && [ -n "$CONFIG_VGA_BIOS_ID" ] && \
|
||||||
[ -n "${CONFIG_VGA_BIOS_ID}" ] && \
|
|
||||||
inject "pci${CONFIG_VGA_BIOS_ID}.rom" \
|
inject "pci${CONFIG_VGA_BIOS_ID}.rom" \
|
||||||
"${CONFIG_VGA_BIOS_FILE}" "optionrom"
|
"${CONFIG_VGA_BIOS_FILE}" "optionrom"
|
||||||
[ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] && \
|
[ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] && \
|
||||||
|
|
Loading…
Reference in New Issue