From 00d22f20829251f55cd2e859d6fae9a61220c072 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 06:53:25 +0100 Subject: lbmk: Unified local ./tmp handling Make it an absolute directory, relative to xbmktmp. Signed-off-by: Leah Rowe --- include/git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 9be79527..37f5bbae 100644 --- a/include/git.sh +++ b/include/git.sh @@ -5,7 +5,7 @@ eval "`setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \ depend subfile_bkup repofail`" -tmpgit="$xbmkpwd/tmp/gitclone" +tmpgit="$xbmklocal/gitclone" fetch_targets() { -- cgit v1.2.1 From 54291ebb7209c314bb52f507bc6a1ecf2a28fbc9 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 4 May 2025 09:56:21 +0100 Subject: lbmk: MUCH safer err function Don't directly call a variable. Call a function that checks the variable instead. The new err function also checks whether an exit was actually done, and exits 1 if not. If an exit was done by the given function, but the exit was zero, this is also corrected to perform an exit 1. This fixes a longstanding design flaw of lbmk. Signed-off-by: Leah Rowe --- include/git.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 37f5bbae..ded12625 100644 --- a/include/git.sh +++ b/include/git.sh @@ -63,7 +63,7 @@ git_prep() [ "$XBMK_RELEASE" = "y" ] && rmgit "$tmpgit" [ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}" - mv "$tmpgit" "$_loc" || $err "git_prep: !mv $tmpgit $_loc" + mv "$tmpgit" "$_loc" || err "git_prep: !mv $tmpgit $_loc" } # return 0 if project is single-tree, otherwise 1 @@ -80,20 +80,20 @@ fetch_submodule() mcfgdir="$mdir/${1##*/}"; eval \ "`setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup st`" [ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \ - $err "! . $mcfgdir/module.cfg" + err "! . $mcfgdir/module.cfg" for xt in repo file; do _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" + st="${st# }" && [ "$st" = "repo file" ] && err "$mdir: repo+file" [ -z "$st" ] && return 0 # subrepo/subfile not defined chkvars "sub${st}" "sub${st}_bkup" "subhash" [ "$st" = "file" ] && xbmkget "$subfile" "$subfile_bkup" \ "$tmpgit/$1" "$subhash" && return 0 - rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'" + rm -Rf "$tmpgit/$1" || err "!rm '$mdir' '$1'" tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subhash" \ "$mdir/${1##*/}/patches" } @@ -105,25 +105,25 @@ tmpclone() repofail="n" - [ $# -lt 6 ] || rm -Rf "$3" || $err "git retry: !rm $3 ($1)" + [ $# -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" + mkdir -p "$XBMK_CACHE/repo" || err "!rmdir $XBMK_CACHE/repo" if [ "$livepull" = "y" ] && [ ! -d "$repodir" ]; then git clone "$1" "$repodir" || git clone $2 "$repodir" || \ - $err "!clone $1 $2 $repodir $4 $5" # + err "!clone $1 $2 $repodir $4 $5" # elif [ -d "$repodir" ] && [ $# -lt 6 ]; then git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \ || sleep 3 || git -C "$repodir" pull || : fi ( - [ $# -gt 5 ] || git clone "$repodir" "$3" || $err "!clone $repodir $3" - git -C "$3" reset --hard "$4" || $err "!reset $1 $2 $3 $4 $5" + [ $# -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"; : + [ "$repofail" = "y" ] && err "!clone $1 $2 $3 $4 $5"; : } git_am_patches() @@ -132,7 +132,7 @@ git_am_patches() [ -L "$p" ] && continue [ -e "$p" ] || continue [ -d "$p" ] && git_am_patches "$1" "$p" && continue - [ ! -f "$p" ] || git -C "$1" am "$p" || $err "$1 $2: !am $p" + [ ! -f "$p" ] || git -C "$1" am "$p" || err "$1 $2: !am $p" done; : } @@ -140,6 +140,6 @@ nuke() { e "config/${1%/}/nuke.list" f missing || while read -r nukefile; do rmf="src/${2%/}/$nukefile" && [ -L "$rmf" ] && continue - e "$rmf" e missing || rm -Rf "$rmf" || $err "!rm $rmf, ${2%/}" + e "$rmf" e missing || rm -Rf "$rmf" || err "!rm $rmf, ${2%/}" done < "config/${1%/}/nuke.list"; : } -- cgit v1.2.1 From 62ec3dac07584d6ab8e7f86587e730b3d159e8ef Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 15:31:33 +0100 Subject: git.sh: move singletree() to lib.sh it's also used by mk, to determine which build function to use (build_project or build_targets). Signed-off-by: Leah Rowe --- include/git.sh | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index ded12625..7995df06 100644 --- a/include/git.sh +++ b/include/git.sh @@ -66,15 +66,6 @@ git_prep() mv "$tmpgit" "$_loc" || err "git_prep: !mv $tmpgit $_loc" } -# return 0 if project is single-tree, otherwise 1 -# e.g. coreboot is multi-tree, so 1 -singletree() -{ - for targetfile in "config/${1}/"*/target.cfg; do - [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1; : - done; : -} - fetch_submodule() { mcfgdir="$mdir/${1##*/}"; eval \ -- cgit v1.2.1 From 282b939d9dae58f2ef128b3a866ba8640f87739b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 21:33:29 +0100 Subject: init.sh: New function dx_ to execute path files Generated by find, this is a wrapper in place of using for loops everywhere. This simplification temporarily increases the amount of code, because we don't do this a lot, but this will reduce the growth of the build system code size in future changes. Signed-off-by: Leah Rowe --- include/git.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 7995df06..535c7d6e 100644 --- a/include/git.sh +++ b/include/git.sh @@ -54,9 +54,7 @@ git_prep() chkvars rev tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir" if singletree "$project" || [ $# -gt 4 ]; then - [ -f "$mdir/module.list" ] && while read -r msrcdir; do - fetch_submodule "$msrcdir" - done < "$mdir/module.list"; : + dx_ fetch_submodule "$mdir/module.list" fi [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \ -- cgit v1.2.1 From e8be3fd1d41c3c0a81c2cfecb3fa68271ad794ca Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 6 May 2025 11:09:39 +0100 Subject: git.sh: Simplify git am handling fx_ and fe_ really are the best shell functions ever. really. they're the best. Signed-off-by: Leah Rowe --- include/git.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'include/git.sh') diff --git a/include/git.sh b/include/git.sh index 535c7d6e..0a05b5ab 100644 --- a/include/git.sh +++ b/include/git.sh @@ -108,23 +108,13 @@ tmpclone() ( [ $# -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" + fx_ "eval x_ git -C \"$3\" am" "$5" -type f ) || repofail="y" [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone "$@" retry [ "$repofail" = "y" ] && err "!clone $1 $2 $3 $4 $5"; : } -git_am_patches() -{ - for p in "$2/"*; do - [ -L "$p" ] && continue - [ -e "$p" ] || continue - [ -d "$p" ] && git_am_patches "$1" "$p" && continue - [ ! -f "$p" ] || git -C "$1" am "$p" || err "$1 $2: !am $p" - done; : -} - nuke() { e "config/${1%/}/nuke.list" f missing || while read -r nukefile; do -- cgit v1.2.1