summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--[-rwxr-xr-x]include/git.sh40
-rw-r--r--[-rwxr-xr-x]include/lib.sh31
-rw-r--r--[-rwxr-xr-x]include/mrc.sh0
-rw-r--r--include/rom.sh66
-rw-r--r--[-rwxr-xr-x]include/vendor.sh12
5 files changed, 105 insertions, 44 deletions
diff --git a/include/git.sh b/include/git.sh
index b0acd7dc..f8441f33 100755..100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -2,8 +2,8 @@
# Copyright (c) 2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
-eval `setvars "" loc url bkup_url subfile mdir subhash subrepo subrepo_bkup \
- depend subfile_bkup`
+eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
+ depend subfile_bkup repofail`
fetch_targets()
{
@@ -12,8 +12,8 @@ fetch_targets()
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
- git_prep "$loc" "$loc" "$PWD/$cfgsdir/$tree/patches" \
- "${loc%/*}/$tree" u; nuke "$project/$tree" "$project/$tree"
+ git_prep "$loc" "$loc" "$PWD/$configdir/$tree/patches" \
+ "src/$project/$tree" u; nuke "$project/$tree" "$project/$tree"
}
fetch_project()
@@ -37,7 +37,8 @@ fetch_project()
clone_project()
{
- loc="src/$project/$project" && singletree "$project" && loc="${loc%/*}"
+ loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
+ loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
e "$loc" d && return 0
@@ -61,17 +62,15 @@ git_prep()
[ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \
[ "$xtree" != "$tree" ] && link_crossgcc "$_loc"
- [ "$XBMK_RELEASE" = "y" ] && [ "$_loc" != "src/$project/$project" ] \
- && rmgit "$tmpgit"
+ [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \
+ rmgit "$tmpgit"
move_repo "$_loc"
}
prep_submodules()
{
- mdir="$PWD/config/submodule/$project"
- [ -n "$tree" ] && mdir="$mdir/$tree"
-
[ -f "$mdir/module.list" ] && while read -r msrcdir; do
fetch_submodule "$msrcdir"
done < "$mdir/module.list"; return 0
@@ -103,9 +102,28 @@ fetch_submodule()
tmpclone()
{
- git clone $1 "$3" || git clone $2 "$3" || $err "!clone $1 $2 $3 $4 $5"
+ [ "$repofail" = "y" ] && \
+ 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 || :
+ else
+ git clone $1 "$repodir" || git clone $2 "$repodir" || \
+ $err "!clone $1 $2 $repodir $4 $5"
+ fi
+ (
+ [ $# -gt 5 ] || git clone "$repodir" "$3" || $err "!clone $repodir $3"
git -C "$3" reset --hard "$4" || $err "!reset $1 $2 $3 $4 $5"
git_am_patches "$3" "$5"
+ ) || repofail="y"
+
+ [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone $@ retry
+ [ "$repofail" = "y" ] && $err "!clone $1 $2 $3 $4 $5"; :
}
git_am_patches()
diff --git a/include/lib.sh b/include/lib.sh
index 52187734..2cd8c0d7 100755..100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -37,7 +37,7 @@ chkvars()
}
eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \
- aur_notice cfgsdir datadir version relname`
+ aur_notice configdir datadir version relname`
for fv in projectname projectsite version versiondate; do
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
@@ -88,6 +88,14 @@ if [ -z "${TMPDIR+x}" ]; then
xbmk_parent="y"
fi
+# XBMK_CACHE is a directory, for caching downloads and git repositories
+[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$PWD/cache"
+[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$PWD/cache" ] && \
+ $err "cachedir is default, $PWD/cache, but it exists and is a symlink"
+[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file"
+
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
@@ -180,18 +188,21 @@ singletree()
download()
{
- dl_fail="y" # 1 url, 2 url backup, 3 destination, 4 checksum
- vendor_checksum "$4" "$3" 2>/dev/null || dl_fail="n"
+ cached="$XBMK_CACHE/file/$4"
+ dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum
+ vendor_checksum "$4" "$cached" 2>/dev/null && dl_fail="y"
[ "$dl_fail" = "n" ] && e "$3" f && return 0
- x_ mkdir -p "${3%/*}" && for url in "$1" "$2"; do
+ mkdir -p "${3%/*}" "$XBMK_CACHE/file" || \
+ $err "!mkdir '$3' '$XBMK_CACHE/file'"
+ for url in "$1" "$2"; do
[ "$dl_fail" = "n" ] && break
[ -z "$url" ] && continue
- x_ rm -f "$3"
- curl --location --retry 3 -A "$_ua" "$url" -o "$3" || \
- wget --tries 3 -U "$_ua" "$url" -O "$3" || continue
- vendor_checksum "$4" "$3" || dl_fail="n"
- done;
- [ "$dl_fail" = "y" ] && $err "$1 $2 $3 $4: not downloaded"; return 0
+ rm -f "$cached" || $err "!rm -f '$cached'"
+ curl --location --retry 3 -A "$_ua" "$url" -o "$cached" || \
+ wget --tries 3 -U "$_ua" "$url" -O "$cached" || continue
+ vendor_checksum "$4" "$cached" || dl_fail="n"
+ done; [ "$dl_fail" = "y" ] && $err "$1 $2 $3 $4: not downloaded"
+ [ "$cached" = "$3" ] || cp "$cached" "$3" || $err "!d cp $cached $3"; :
}
vendor_checksum()
diff --git a/include/mrc.sh b/include/mrc.sh
index 2e00d9f9..2e00d9f9 100755..100644
--- a/include/mrc.sh
+++ b/include/mrc.sh
diff --git a/include/rom.sh b/include/rom.sh
index 7ffd685d..ed3dddf2 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -8,6 +8,7 @@
mkserprog()
{
+ [ "$_f" = "-d" ] && return 0 # dry run
basename -as .h "$serdir/"*.h > "$TMPDIR/ser" || $err "!mk $1 $TMPDIR"
while read -r sertarget; do
@@ -26,25 +27,53 @@ mkserprog()
mkpayload_grub()
{
eval `setvars "" grub_modules grub_install_modules`
- eval `setcfg "$grubdata/module/$tree"`
+ $dry eval `setcfg "$grubdata/module/$tree"`
- x_ rm -f "$cdir/grub.elf"
+ $dry x_ rm -f "$srcdir/grub.elf"
- "${cdir}/grub-mkstandalone" --grub-mkimage="${cdir}/grub-mkimage" \
- -O i386-coreboot -o "${cdir}/grub.elf" -d "${cdir}/grub-core/" \
+ $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" \
- "/boot/grub/grub_default.cfg=${cdir}/.config" \
+ "/boot/grub/grub_default.cfg=${srcdir}/.config" \
"/boot/grub/grub.cfg=$grubdata/memdisk.cfg" \
"/background.png=$grubdata/background/background1280x800.png" || \
$err "$tree: cannot build grub.elf"; return 0
}
+mkvendorfiles()
+{
+ check_coreboot_utils "$tree"
+ printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
+ $err "!mk $srcdir .coreboot-version"
+ [ -z "$mode" ] && [ "$target" != "$tree" ] && \
+ x_ ./vendor download $target; return 0
+}
+
+check_coreboot_utils()
+{
+ for util in cbfstool ifdtool; do
+ [ "$badhash" = "n" ] || rm -f "elf/$util/$1/$util" || \
+ $err "!rm badelf elf/$util/$1/$util"
+ e "elf/$util/$1/$util" f && continue
+
+ utilelfdir="elf/$util/$1"
+ utilsrcdir="src/coreboot/$1/util/$util"
+
+ utilmode="" && [ -n "$mode" ] && utilmode="clean"
+ x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
+ [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ] && \
+ x_ mkdir -p "$utilelfdir" && \
+ x_ cp "$utilsrcdir/$util" "elf/$util/$1"
+ [ -z "$mode" ] || x_ rm -Rf "$utilelfdir"; continue
+ done; return 0
+}
+
mkcorebootbin()
{
[ "$target" = "$tree" ] && return 0
- tmprom="$cdir/build/coreboot.rom"
+ tmprom="$srcdir/build/coreboot.rom"
initmode="${defconfig##*/}"; displaymode="${initmode##*_}"
initmode="${initmode%%_*}"
[ -n "$displaymode" ] && displaymode="_$displaymode"
@@ -54,7 +83,7 @@ mkcorebootbin()
[ "$payload_uboot" = "y" ] || payload_seabios="y"
[ "$payload_grub" = "y" ] && payload_seabios="y"
[ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "y" ] && \
- $err "$target: U-Boot and SeaBIOS/GRUB are both enabled."
+ $dry $err "$target: U-Boot and SeaBIOS/GRUB are both enabled."
[ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata"
@@ -63,18 +92,19 @@ mkcorebootbin()
[ "$payload_memtest" = "y" ] || payload_memtest="n"
[ "$(uname -m)" = "x86_64" ] || payload_memtest="n"
-
- x_ ./update trees -b coreboot utils $tree
-
- [ "$payload_seabios" = "y" ] && pname="seabios" && add_seabios
- [ "$payload_uboot" = "y" ] && pname="uboot" && add_uboot
-
+ if 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" # coreboot's build system added payloads
+ fi
newrom="bin/$target/${pname}_${target}_$initmode$displaymode.rom"
- x_ mkdir -p "${newrom%/*}"; x_ mv "$tmprom" "$newrom"
+ $dry x_ mkdir -p "${newrom%/*}"; $dry x_ mv "$tmprom" "$newrom"
[ "$XBMK_RELEASE" = "y" ] || return 0
- mksha512sum "$newrom" "vendorhashes"
- ./vendor inject -r "$newrom" -b "$target" -n nuke || $err "!n $newrom"
+ $dry mksha512sum "$newrom" "vendorhashes"; $dry ./vendor inject \
+ -r "$newrom" -b "$target" -n nuke || $err "!nuke $newrom"
}
add_seabios()
@@ -117,6 +147,6 @@ add_uboot()
mkcoreboottar()
{
- [ "$target" = "$tree" ] && return 0
- [ "$XBMK_RELEASE" = "y" ] && mkrom_tarball "bin/$target"; return 0
+ [ "$target" = "$tree" ] && return 0; [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$release" != "n" ] && $dry mkrom_tarball "bin/$target"; return 0
}
diff --git a/include/vendor.sh b/include/vendor.sh
index 75f7e051..ace3f7ce 100755..100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -56,7 +56,7 @@ bootstrap()
[ -d "${kbc1126_ec_dump%/*}" ] && x_ make -C "$cbdir/util/kbc1126"
[ -n "$MRC_refcode_cbtree" ] && \
cbfstoolref="elf/cbfstool/$MRC_refcode_cbtree/cbfstool" && \
- x_ ./update trees -b coreboot utils $MRC_refcode_cbtree; return 0
+ x_ ./update trees -d coreboot $MRC_refcode_cbtree; return 0
}
getfiles()
@@ -78,11 +78,12 @@ getfiles()
fetch()
{
dl_type="$1"; dl="$2"; dl_bkup="$3"; dlsum="$4"; _dest="${5##*../}"
- [ "$5" = "/dev/null" ] && return 0; _dl="$vendir/cache/$dlsum"
+ [ "$5" = "/dev/null" ] && return 0; _dl="$XBMK_CACHE/file/$dlsum"
download "$dl" "$dl_bkup" "$_dl" "$dlsum"
- x_ rm -Rf "${_dl}_extracted"
+ rm -Rf "${_dl}_extracted" || \
+ $err "!rm -Rf ${_ul}_extracted"
e "$_dest" f && return 0
mkdir -p "${_dest%/*}" || $err "mkdirs: !mkdir -p ${_dest%/*}"
@@ -248,7 +249,8 @@ detect_board()
path="$1"
filename="$(basename "$path")"
case "$filename" in
- grub_*|seagrub_*) board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
+ grub_*|seagrub_*|custom_*)
+ board="$(echo "$filename" | cut -d '_' -f2-3)" ;;
seabios_withgrub_*)
board="$(echo "$filename" | cut -d '_' -f3-4)" ;;
*.tar.xz)
@@ -275,7 +277,7 @@ readcfg()
cbfstool="elf/cbfstool/$tree/cbfstool"
ifdtool="elf/ifdtool/$tree/ifdtool"
- x_ ./update trees -b coreboot utils $tree
+ x_ ./update trees -d coreboot $tree
}
patch_release_roms()