From 0d7c249c9b060441505641d3b30ea9ec1a5fda1b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 25 May 2024 11:35:50 +0100 Subject: [PATCH] move deblob function to new file "deblob.sh" i'm importing some changes from lbmk and they go at the end of git.sh, in the diffs. moving the deblob function to its own file will allow me to cherry-pick with fewer merge conflicts. Signed-off-by: Leah Rowe --- include/deblob.sh | 32 ++++++++++++++++++++++++++++++++ include/git.sh | 30 ------------------------------ script/trees | 1 + 3 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 include/deblob.sh diff --git a/include/deblob.sh b/include/deblob.sh new file mode 100644 index 0000000..73ff3e5 --- /dev/null +++ b/include/deblob.sh @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: 2020,2021,2023,2024 Leah Rowe + +# can delete from multi- and single-tree projects. +# called from build_projects() and handle_src_tree() on script/update/trees +nukeblobs() +{ + del="n" + pjcfgdir="${1%/}" + pjsrcdir="${2%/}" + pjsrcdir="${pjsrcdir#src/}" + [ ! -f "config/${pjcfgdir}/blobs.list" ] && return 0 + + while read -r blobfile; do + rmf="$(realpath "src/${pjsrcdir}/${blobfile}" 2>/dev/null)" || \ + continue + [ -L "${rmf}" ] && continue # we will delete the actual file + [ "${rmf#${PWD}/src/${pjsrcdir}}" = "${rmf}" ] && continue + [ "${rmf#${PWD}/src/}" = "${pjsrcdir}" ] && continue + rmf="${rmf#${PWD}/}" + [ -e "${rmf}" ] || continue + del="y" + rm -Rf "${rmf}" || \ + $err "nukeblobs ${pjcfgdir}/blobs: can't rm \"${blobfile}\"" + printf "nukeblobs %s: deleted \"%s\"\n" "${pjcfgdir}" "${rmf}" + done < "config/${pjcfgdir}/blobs.list" + + [ "${del}" = "y" ] && return 0 + printf "nukeblobs %s: no defined blobs exist in dir, src/%s\n" 1>&2 \ + "${pjcfgdir}" "${pjsrcdir}" + printf "(this is not an error)\n" +} diff --git a/include/git.sh b/include/git.sh index f2ddc91..f32b9b8 100755 --- a/include/git.sh +++ b/include/git.sh @@ -147,33 +147,3 @@ git_am_patches() git_am_patches "$1" "$_patches"; continue done } - -# can delete from multi- and single-tree projects. -# called from build_projects() and handle_src_tree() on script/update/trees -nukeblobs() -{ - del="n" - pjcfgdir="${1%/}" - pjsrcdir="${2%/}" - pjsrcdir="${pjsrcdir#src/}" - [ ! -f "config/${pjcfgdir}/blobs.list" ] && return 0 - - while read -r blobfile; do - rmf="$(realpath "src/${pjsrcdir}/${blobfile}" 2>/dev/null)" || \ - continue - [ -L "${rmf}" ] && continue # we will delete the actual file - [ "${rmf#${PWD}/src/${pjsrcdir}}" = "${rmf}" ] && continue - [ "${rmf#${PWD}/src/}" = "${pjsrcdir}" ] && continue - rmf="${rmf#${PWD}/}" - [ -e "${rmf}" ] || continue - del="y" - rm -Rf "${rmf}" || \ - $err "nukeblobs ${pjcfgdir}/blobs: can't rm \"${blobfile}\"" - printf "nukeblobs %s: deleted \"%s\"\n" "${pjcfgdir}" "${rmf}" - done < "config/${pjcfgdir}/blobs.list" - - [ "${del}" = "y" ] && return 0 - printf "nukeblobs %s: no defined blobs exist in dir, src/%s\n" 1>&2 \ - "${pjcfgdir}" "${pjsrcdir}" - printf "(this is not an error)\n" -} diff --git a/script/trees b/script/trees index a68b112..8a82ffd 100755 --- a/script/trees +++ b/script/trees @@ -8,6 +8,7 @@ set -u -e . "include/option.sh" . "include/git.sh" +. "include/deblob.sh" eval "$(setvars "" xarch cfgsdir codedir config config_name xlang mode \ elfdir listfile project target target_dir targets tree _f target1 \