From 620c1dd6fae0f0f83212e9f6b6fb27c1faf67b83 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 22:59:20 +0100 Subject: get.sh: Make xbmkget err on exiting the loop check The idea in this function is that if a file or repo is successfully handled, a return will be performed from the loop. If the loop exits for any reason, an error is thrown. The current code is probably fine, but I can forsee future modifications possibly causing bugs here. Make it unambiguous, by always throwing an error if execution reaches the end of the function. Signed-off-by: Leah Rowe --- include/get.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/get.sh') diff --git a/include/get.sh b/include/get.sh index 667ab398..ab6ff401 100644 --- a/include/get.sh +++ b/include/get.sh @@ -87,7 +87,8 @@ xbmkget() for url in "$2" "$3"; do [ -n "$url" ] && try_file "$url" "$@" && \ eval "[ -$echk \"$4\" ] && return 0" - done && err "$1 $2 $3 $4: not downloaded"; : + done + err "$1 $2 $3 $4: not downloaded"; : } try_file() -- cgit v1.2.1 From cdc0fb49e1c47a013ea99117acbf62e96ec5c652 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 23:07:01 +0100 Subject: get.sh: make xbmkget() easier to understand the intent once again is that this for loop shall return, with zero status, if success is observed. otherwise, the loop breaks and an error is thrown. Signed-off-by: Leah Rowe --- include/get.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/get.sh') diff --git a/include/get.sh b/include/get.sh index ab6ff401..89859454 100644 --- a/include/get.sh +++ b/include/get.sh @@ -85,8 +85,10 @@ xbmkget() echk="f" && [ "$1" = "git" ] && echk="d" for url in "$2" "$3"; do - [ -n "$url" ] && try_file "$url" "$@" && \ - eval "[ -$echk \"$4\" ] && return 0" + [ -n "$url" ] || continue + try_file "$url" "$@" || continue + eval "[ -$echk \"$4\" ] || continue" + return 0 # successful download/copy done err "$1 $2 $3 $4: not downloaded"; : } -- cgit v1.2.1 From f15bb8153a3f2fce6e0aea28ce029c889a2e7c76 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 23:09:37 +0100 Subject: get.sh: stricter URL check in xbmkget() don't skip if the URL is empty. throw an error instead. i decree that all links must be properly initialised, because that is the design of lbmk. where only one link is provided, such as in a local copy operation, the second would succeed no better than the first so two identical paths are given. Signed-off-by: Leah Rowe --- include/get.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/get.sh') diff --git a/include/get.sh b/include/get.sh index 89859454..8280d96b 100644 --- a/include/get.sh +++ b/include/get.sh @@ -85,7 +85,7 @@ xbmkget() echk="f" && [ "$1" = "git" ] && echk="d" for url in "$2" "$3"; do - [ -n "$url" ] || continue + [ -n "$url" ] || err "empty URL given in: xbmkget $*" try_file "$url" "$@" || continue eval "[ -$echk \"$4\" ] || continue" return 0 # successful download/copy -- cgit v1.2.1 From 903f78bf080ee8ad9176022005b81a3d3ac530b3 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 19 May 2025 23:13:29 +0100 Subject: get.sh: add missing check in fetch_project() we check the main url, but not backup urls. this patch fixes that oversight. Signed-off-by: Leah Rowe --- include/get.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/get.sh') diff --git a/include/get.sh b/include/get.sh index 8280d96b..ae2c5a35 100644 --- a/include/get.sh +++ b/include/get.sh @@ -22,7 +22,7 @@ fetch_project() eval "`setvars "" xtree`" eval "`setcfg "config/git/$project/pkg.cfg"`" - chkvars url + chkvars url bkup_url [ -n "$xtree" ] && x_ ./mk -f coreboot "$xtree" [ -z "$depend" ] || for d in $depend ; do -- cgit v1.2.1 From 419733d3073cbfc9f8f67e835b385b2b41e6f045 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 22 May 2025 12:22:07 +0100 Subject: get.sh: re-generate remotes every time that way, when a remote changes in config/, it will be updated automatically, without user intervention. Signed-off-by: Leah Rowe --- include/get.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/get.sh') diff --git a/include/get.sh b/include/get.sh index ae2c5a35..08a561d9 100644 --- a/include/get.sh +++ b/include/get.sh @@ -143,8 +143,10 @@ try_git() [ -d "$gitdest" ] || x_ mkdir -p "${gitdest%/*}" [ -d "$gitdest" ] || x_ mv "$tmpgitcache" "$gitdest" - ( x_ git -C "$gitdest" remote add main "$4" 2>/dev/null ) || : - ( x_ git -C "$gitdest" remote add backup "$5" 2>/dev/null ) || : + ( x_ git -C "$gitdest" remote remove main ) || : + ( x_ git -C "$gitdest" remote remove backup ) || : + x_ git -C "$gitdest" remote add main "$4" + x_ git -C "$gitdest" remote add backup "$5" ( x_ git -C "$gitdest" fetch --all ) || : ( x_ git -C "$gitdest" pull --all ) || :; : } -- cgit v1.2.1 From 0216a3104a50ebf01405f6e04e44d0349567b85e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 22 May 2025 12:43:34 +0100 Subject: get.sh: Always update git remotes Right now, if cache/clone/PROJECT/ already exists, the logic for pulling new changes doesn't execute, and neither does the logic for updating remotes. This is bad when updating revisions, because then manual updating is required, defeating the purpose of xbmk's own automation in this regard. Fix it by only checking the cached download on files, not Git repositories; the try_git function itself will already perform this check, before updating remotes and pulling in new commits from upstream. The updating only happens when a given target directory doesn't exist, e.g. src/flashprog/ or src/grub/default/, so this won't slow down release builds for example. Signed-off-by: Leah Rowe --- include/get.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/get.sh') diff --git a/include/get.sh b/include/get.sh index 08a561d9..6f1b5f1d 100644 --- a/include/get.sh +++ b/include/get.sh @@ -104,7 +104,8 @@ try_file() echk="d" && [ "$2" != "git" ] && echk="f" && \ bad_checksum "$6" "$cached" 2>/dev/null && x_ rm -f "$cached" - eval "[ -$echk \"$cached\" ] || try_$2 \"\$cached\" \"\$@\" || return 1" + evalchk="[ -$echk \"$cached\" ] || " && [ "$2" = "git" ] && evalchk="" + eval "${evalchk}try_$2 \"\$cached\" \"\$@\" || return 1" [ "$2" != "git" ] && [ -f "$5" ] && \ bad_checksum "$6" "$5" 2>/dev/null && x_ cp "$cached" "$5" eval "[ -$echk \"$cached\" ] || return 1" -- cgit v1.2.1