summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-07-26 15:24:00 +0100
committerLeah Rowe <leah@libreboot.org>2024-07-26 15:49:49 +0100
commit7fa6052de036f81b54a93bf2f707f563205f176b (patch)
tree009ea8e1c23e59111d9965aa5623583f6702f85b /include
parent3bd290f6a615c0bf9f8e9095b96e9f30bf2d49bf (diff)
general code cleanup in the build system
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/git.sh31
-rw-r--r--include/lib.sh16
-rw-r--r--include/rom.sh34
-rw-r--r--include/vendor.sh83
4 files changed, 54 insertions, 110 deletions
diff --git a/include/git.sh b/include/git.sh
index f8441f33..8c86b4c2 100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -8,7 +8,7 @@ eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
fetch_targets()
{
[ -n "$tree_depend" ] && [ "$tree_depend" != "$tree" ] && \
- x_ ./update trees -f "$project" "$tree_depend"
+ x_ ./mk -f "$project" "$tree_depend"
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
@@ -23,10 +23,10 @@ fetch_project()
chkvars url
- [ -n "$xtree" ] && x_ ./update trees -f coreboot "$xtree"
+ [ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree"
[ -z "$depend" ] || for d in $depend ; do
printf "'%s' needs '%s'; grabbing '%s'\n" "$project" "$d" "$d"
- x_ ./update trees -f $d
+ x_ ./mk -f $d
done
clone_project
@@ -39,32 +39,24 @@ clone_project()
{
loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
loc="src/$project"
-
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
- e "$loc" d && return 0
- remkdir "${tmpgit%/*}"
- git_prep "$url" "$bkup_url" "$PWD/config/$project/patches" "$loc"
+ e "$loc" d missing && remkdir "${tmpgit%/*}" && git_prep \
+ "$url" "$bkup_url" "$PWD/config/$project/patches" "$loc"; :
}
git_prep()
{
- _patchdir="$3" # $1 and $2 are gitrepo and gitrepo_backup
- _loc="$4"
-
- chkvars rev
+ _patchdir="$3"; _loc="$4" # $1 and $2 are gitrepo and gitrepo_backup
- tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
+ chkvars rev; tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
if singletree "$project" || [ $# -gt 4 ]; then
- prep_submodules "$_loc"
- fi
+ prep_submodules "$_loc"; fi
[ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \
[ "$xtree" != "$tree" ] && link_crossgcc "$_loc"
-
[ "$XBMK_RELEASE" = "y" ] && \
- [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \
- rmgit "$tmpgit"
+ [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && rmgit "$tmpgit"
move_repo "$_loc"
}
@@ -87,7 +79,6 @@ fetch_submodule()
_seval="if [ -n \"\$sub$xt\" ] || [ -n \"\$sub${xt}_bkup\" ]"
eval "$_seval; then st=\"\$st \$xt\"; fi"
done
-
st="${st# }" && [ "$st" = "repo file" ] && $err "$mdir: repo+file"
[ -z "$st" ] && return 0 # subrepo/subfile not defined
@@ -103,12 +94,12 @@ fetch_submodule()
tmpclone()
{
[ "$repofail" = "y" ] && \
- printf "Cached clone failed; trying online.\n" 1>&2
- repofail="n"
+ printf "Cached clone failed; trying online.\n" 1>&2; repofail="n"
[ $# -lt 6 ] || rm -Rf "$3" || $err "git retry: !rm $3 ($1)"
repodir="$XBMK_CACHE/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3"
mkdir -p "$XBMK_CACHE/repo" || $err "!rmdir $XBMK_CACHE/repo"
+
if [ -d "$repodir" ] && [ $# -lt 6 ]; then
git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \
|| sleep 3 || git -C "$repodir" pull || :
diff --git a/include/lib.sh b/include/lib.sh
index 2cd8c0d7..586ecde1 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -7,8 +7,6 @@ export LC_COLLATE=C
export LC_ALL=C
_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
-kbnotice="Insert a .gkb file from config/data/grub/keymap/ as keymap.gkb \
-if you want a custom keymap in GRUB; use cbfstool from elf/cbfstool."
ifdtool="elf/ifdtool/default/ifdtool"
cbfstool="elf/cbfstool/default/cbfstool"
@@ -58,8 +56,7 @@ e()
estr="[ -$es_t \"\$1\" ] || return 1"
[ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="missing"
- eval "$estr"
- printf "%s %s\n" "$1" "$es2" 1>&2
+ eval "$estr"; printf "%s %s\n" "$1" "$es2" 1>&2
}
install_packages()
@@ -121,8 +118,7 @@ versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
for p in projectname version versiondate projectsite; do
- chkvars "$p"
- eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
+ chkvars "$p"; eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
done
relname="$projectname-$version"
export LOCALVERSION="-$projectname-${version%%-*}"
@@ -147,8 +143,7 @@ mkrom_tarball()
printf "%s\n" "$versiondate" > "$1/versiondate" || $err "$1 !vdate"
printf "%s\n" "$projectname" > "$1/projectname" || $err "$1 !pname"
- mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
- x_ rm -Rf "$1"
+ mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"; x_ rm -Rf "$1"; :
}
mktarball()
@@ -182,7 +177,7 @@ rmgit()
singletree()
{
for targetfile in "config/${1}/"*/target.cfg; do
- [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1
+ [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1; :
done; return 0
}
@@ -208,8 +203,7 @@ download()
vendor_checksum()
{
[ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
- printf "Bad checksum for file: %s\n" "$2" 1>&2
- rm -f "$2" || :
+ printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; :
}
cbfs()
diff --git a/include/rom.sh b/include/rom.sh
index 8e33a564..80643c48 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -28,10 +28,8 @@ mkpayload_grub()
{
eval `setvars "" grub_modules grub_install_modules`
$dry eval `setcfg "$grubdata/module/$tree"`
-
- $dry x_ rm -f "$srcdir/grub.elf"
-
- $dry "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \
+ $dry x_ rm -f "$srcdir/grub.elf"; $dry \
+ "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \
-O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \
--fonts= --themes= --locales= --modules="$grub_modules" \
--install-modules="$grub_install_modules" \
@@ -79,15 +77,10 @@ check_coreboot_utils()
mkcorebootbin()
{
- $dry realmkcorebootbin; :
-}
-
-realmkcorebootbin()
-{
[ "$target" = "$tree" ] && return 0
tmprom="$TMPDIR/coreboot.rom"
- mv "$srcdir/build/coreboot.rom" "$tmprom" || $err "!mktmprom"
+ $dry x_ cp "$srcdir/build/coreboot.rom" "$tmprom"
initmode="${defconfig##*/}"; displaymode="${initmode##*_}"
initmode="${initmode%%_*}"
@@ -107,12 +100,12 @@ realmkcorebootbin()
[ "$payload_memtest" = "y" ] || payload_memtest="n"
[ "$(uname -m)" = "x86_64" ] || payload_memtest="n"
- if grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then
+ if $dry grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then
[ "$payload_seabios" = "y" ] && pname="seabios" && \
$dry add_seabios
[ "$payload_uboot" = "y" ] && pname="uboot" && $dry add_uboot
else
- pname="custom" && cprom; :
+ pname="custom" && $dry cprom; :
fi; :
}
@@ -149,10 +142,8 @@ mkseagrub()
{
cbfs "$tmprom" "$grubdata/bootorder" bootorder raw
for keymap in config/data/grub/keymap/*.gkb; do
- [ -f "$keymap" ] || continue
- keymap="${keymap##*/}"
- cprom "${keymap%.gkb}"
- done
+ [ -f "$keymap" ] && cprom "${keymap##*/}"; :
+ done; :
}
add_uboot()
@@ -168,11 +159,11 @@ add_uboot()
cprom()
{
newrom="bin/$target/${pname}_${target}_$initmode$displaymode.rom"
- [ $# -gt 0 ] && newrom="${newrom%.rom}_$1.rom"
+ [ $# -gt 0 ] && newrom="${newrom%.rom}_${1%.gkb}.rom"
x_ mkdir -p "bin/$target"
x_ cp "$tmprom" "$newrom" && [ $# -gt 0 ] && \
- cbfs "$newrom" "config/data/grub/keymap/$1.gkb" keymap.gkb raw
+ cbfs "$newrom" "config/data/grub/keymap/$1" keymap.gkb raw
[ "$XBMK_RELEASE" = "y" ] || return 0
$dry mksha512sum "$newrom" "vendorhashes"; $dry ./vendor inject \
@@ -181,11 +172,6 @@ cprom()
mkcoreboottar()
{
- $dry realmkcoreboottar
-}
-
-realmkcoreboottar()
-{
[ "$target" = "$tree" ] && return 0; [ "$XBMK_RELEASE" = "y" ] && \
- [ "$release" != "n" ] && $dry mkrom_tarball "bin/$target"; return 0
+ [ "$release" != "n" ] && $dry mkrom_tarball "bin/$target"; :
}
diff --git a/include/vendor.sh b/include/vendor.sh
index ace3f7ce..a6e82271 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -25,10 +25,8 @@ eval `setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \
vendor_download()
{
- export PATH="$PATH:/sbin"
-
- [ $# -gt 0 ] || $err "No argument given"
- board="$1" && readcfg && readkconfig && bootstrap && getfiles; return 0
+ [ $# -gt 0 ] || $err "No argument given"; export PATH="$PATH:/sbin"
+ board="$1"; readcfg && readkconfig && bootstrap && getfiles; :
}
readkconfig()
@@ -49,14 +47,14 @@ readkconfig()
bootstrap()
{
- x_ ./update trees -f coreboot ${cbdir##*/}
+ x_ ./mk -f coreboot ${cbdir##*/}
for d in uefitool biosutilities bios_extract; do
- x_ ./update trees -b "$d"
+ x_ ./mk -b "$d"
done
[ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126"
[ -n "$MRC_refcode_cbtree" ] && \
cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \
- x_ ./update trees -d coreboot $MRC_refcode_cbtree; return 0
+ x_ ./mk -d coreboot $MRC_refcode_cbtree; return 0
}
getfiles()
@@ -68,9 +66,8 @@ getfiles()
"$CONFIG_SMSC_SCH5545_EC_FW_FILE"
[ -z "$CONFIG_KBC1126_FIRMWARE" ] || fetch kbc1126ec "$EC_url" \
"$EC_url_bkup" "$EC_hash" "$CONFIG_KBC1126_FW1"
- [ -z "$CONFIG_VGA_BIOS_FILE" ] || fetch "e6400vga" \
- "$E6400_VGA_DL_url" "$E6400_VGA_DL_url_bkup" "$E6400_VGA_DL_hash" \
- "$CONFIG_VGA_BIOS_FILE"
+ [ -z "$CONFIG_VGA_BIOS_FILE" ] || fetch e6400vga "$E6400_VGA_DL_url" \
+ "$E6400_VGA_DL_url_bkup" "$E6400_VGA_DL_hash" "$CONFIG_VGA_BIOS_FILE"
[ -z "$CONFIG_HAVE_MRC" ] || fetch "mrc" "$MRC_url" "$MRC_url_bkup" \
"$MRC_hash" "$CONFIG_MRC_FILE"; return 0
}
@@ -82,33 +79,27 @@ fetch()
download "$dl" "$dl_bkup" "$_dl" "$dlsum"
- rm -Rf "${_dl}_extracted" || \
- $err "!rm -Rf ${_ul}_extracted"
+ rm -Rf "${_dl}_extracted" || $err "!rm -Rf ${_ul}_extracted"
e "$_dest" f && return 0
mkdir -p "${_dest%/*}" || $err "mkdirs: !mkdir -p ${_dest%/*}"
- remkdir "$appdir"
- extract_archive "$_dl" "$appdir" || [ "$dl_type" = "e6400vga" ] || \
- $err "mkdirs $_dest $dl_type: !extract"
-
- eval "extract_$dl_type"
- set -u -e
+ remkdir "$appdir"; extract_archive "$_dl" "$appdir" || \
+ [ "$dl_type" = "e6400vga" ] || $err "mkd $_dest $dl_type: !extract"
- e "$_dest" f missing && $err "!extract_$dl_type"; return 0
+ eval "extract_$dl_type"; set -u -e
+ e "$_dest" f missing && $err "!extract_$dl_type"; :
}
extract_intel_me()
{
e "$mecleaner" f not && $err "$cbdir: me_cleaner missing"
- _me="$PWD/$_dest" # must always be an absolute path
- cdir="$PWD/$appdir" # must always be an absolute path
+ _me="$PWD/$_dest"; cdir="$PWD/$appdir"
[ $# -gt 0 ] && _me="${1}" && cdir="$2"
e "$_me" f && return 0
- sdir="$(mktemp -d)"
- [ -z "$sdir" ] && return 0
+ sdir="$(mktemp -d)"; [ -z "$sdir" ] && return 0
mkdir -p "$sdir" || $err "extract_intel_me: !mkdir -p \"$sdir\""
set +u +e
@@ -131,8 +122,7 @@ extract_intel_me()
else
continue
fi
- cdir="$1"
- [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}"
+ cdir="$1"; [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}"
cd "$cdir" || :
done
)
@@ -149,8 +139,7 @@ extract_kbc1126ec()
{
e "$kbc1126_ec_dump" f missing && $err "$cbdir: kbc1126 util missing"
(
- x_ cd "$appdir/"
- mv Rompaq/68*.BIN ec.bin || :
+ x_ cd "$appdir/"; mv Rompaq/68*.BIN ec.bin || :
if [ ! -f "ec.bin" ]; then
unar -D ROM.CAB Rom.bin || unar -D Rom.CAB Rom.bin || \
unar -D 68*.CAB Rom.bin || $err "can't extract Rom.bin"
@@ -195,14 +184,10 @@ extract_sch5545ec()
vendor_inject()
{
- set +u +e
-
- [ $# -lt 1 ] && $err "No options specified."
+ set +u +e; [ $# -lt 1 ] && $err "No options specified."
[ "$1" = "listboards" ] && eval "ls -1 config/coreboot || :; exit 0"
- archive="$1"
-
- while getopts n:r:b:m: option; do
+ archive="$1"; while getopts n:r:b:m: option; do
case "$option" in
n) nukemode="$OPTARG" ;;
r) rom="$OPTARG" ;;
@@ -215,11 +200,7 @@ vendor_inject()
check_board || return 0
[ "$nukemode" = "nuke" ] || x_ ./vendor download $board
[ "$vrelease" != "y" ] && patch_rom "$rom"
- [ "$vrelease" = "y" ] && patch_release_roms
-
- [ "$nukemode" = "nuke" ] && return 0
- printf "Friendly reminder (this is *not* an error message):\n"
- printf "Make sure the files were inserted. ALSO:\n%s\n" "$kbnotice"
+ [ "$vrelease" = "y" ] && patch_release_roms; :
}
check_board()
@@ -246,15 +227,13 @@ check_release()
# It will only succeed if the filename is not changed from the build/download
detect_board()
{
- path="$1"
- filename="$(basename "$path")"
+ path="$1"; filename="$(basename "$path")"
case "$filename" in
grub_*|seagrub_*|custom_*)
board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
seabios_withgrub_*)
board="$(echo "$filename" | cut -d '_' -f3-4)" ;;
- *.tar.xz)
- _stripped_prefix="${filename#*_}"
+ *.tar.xz) _stripped_prefix="${filename#*_}"
board="${_stripped_prefix%.tar.xz}" ;;
*) $err "detect_board $filename: could not detect board type"
esac; printf "%s\n" "$board"
@@ -265,10 +244,8 @@ readcfg()
if [ "$board" = "serprog_rp2040" ] || \
[ "$board" = "serprog_stm32" ]; then
return 1
- fi
- boarddir="$cbcfgsdir/$board"
- eval `setcfg "$boarddir/target.cfg"`
- chkvars vcfg tree
+ fi; boarddir="$cbcfgsdir/$board"
+ eval `setcfg "$boarddir/target.cfg"`; chkvars vcfg tree
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
@@ -277,13 +254,12 @@ readcfg()
cbfstool="elf/cbfstool/$tree/cbfstool"
ifdtool="elf/ifdtool/$tree/ifdtool"
- x_ ./update trees -d coreboot $tree
+ x_ ./mk -d coreboot $tree
}
patch_release_roms()
{
- remkdir "tmp/romdir"
- tar -xf "$archive" -C "tmp/romdir" || \
+ remkdir "tmp/romdir"; tar -xf "$archive" -C "tmp/romdir" || \
$err "patch_release_roms: !tar -xf \"$archive\" -C \"tmp/romdir\""
for x in "tmp/romdir/bin/"*/*.rom ; do
@@ -311,9 +287,7 @@ patch_release_roms()
patch_rom()
{
- rom="$1"
-
- . "$(check_defconfig "$boarddir")" 2>/dev/null || exit 0
+ rom="$1"; . "$(check_defconfig "$boarddir")" 2>/dev/null || exit 0
[ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \
"mrc" "0xfffa0000"
@@ -324,8 +298,7 @@ patch_rom()
"$CONFIG_KBC1126_FW1" raw "$CONFIG_KBC1126_FW1_OFFSET" && inject \
ecfw2.bin "$CONFIG_KBC1126_FW2" raw "$CONFIG_KBC1126_FW2_OFFSET"
[ -n "$CONFIG_VGA_BIOS_FILE" ] && [ -n "$CONFIG_VGA_BIOS_ID" ] && \
- inject "pci$CONFIG_VGA_BIOS_ID.rom" \
- "$CONFIG_VGA_BIOS_FILE" "optionrom"
+ inject "pci$CONFIG_VGA_BIOS_ID.rom" "$CONFIG_VGA_BIOS_FILE" optionrom
[ "$CONFIG_INCLUDE_SMSC_SCH5545_EC_FW" = "y" ] && \
[ -n "$CONFIG_SMSC_SCH5545_EC_FW_FILE" ] && \
inject sch5545_ecfw.bin "$CONFIG_SMSC_SCH5545_EC_FW_FILE" raw
@@ -359,7 +332,7 @@ inject()
[ "$_t" != "stage" ] || "$cbfstool" "$rom" add-stage -f \
"$_dest" -n "$cbfsname" -t stage -c lzma || $err "$rom: !add ref"
[ "$_t" = "stage" ] || "$cbfstool" "$rom" add -f "$_dest" \
- -n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)"
+ -n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)"; :
}
modify_gbe()