From f6cbc501c1602433c466f2e23acf8828f27dbd92 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 30 May 2024 07:29:50 +0100 Subject: import nuke() from cbmk cdce8ba70b cbmk revision: cdce8ba70b863ea3fe0ad7a4d7b27d0c5ca30421 as of date 30 May 2024 Canoeboot provides deblobbing, fully, on all sources, so as to provide a GNU FSDG compliant coreboot distro. Libreboot used to do this but now uses a more pragmatic Binary Blob Reduction Policy, allowing better hardware support in general. See: https://libreboot.org/news/policy.html Well! We sometimes still need to delete files in Libreboot, but for other reasons. For example, the poorly licensed strlcat.c file that we delete from U-Boot, in both projects. I currently hardcode such deletions in lbmk. After this revision, I will start using "nuke.list" files as in cbmk. Simply patching the sources to exclude such files, in this context, is not OK because then we are still including them but as diffs. This is why the nuke() function exists. Import Canoeboot's nuke technology. Signed-off-by: Leah Rowe --- include/git.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/git.sh b/include/git.sh index f5aa34eb..3052d5b4 100755 --- a/include/git.sh +++ b/include/git.sh @@ -46,6 +46,7 @@ prepare_new_tree() cp -R "src/$project/$project" "$tmpgit" || \ $err "prepare_new_tree $project/$tree: can't make tmpclone" git_prep "$PWD/$cfgsdir/$tree/patches" "src/$project/$tree" "update" + nuke "$project/$tree" "$project/$tree" } fetch_project_repo() @@ -61,6 +62,10 @@ fetch_project_repo() x_ ./update trees -f $d done rm -Rf "$tmpgit" || $err "fetch_repo: !rm -Rf $tmpgit" + + for x in config/git/*; do + [ -f "$x" ] && nuke "${x##*/}" "src/${x##*/}"; continue + done } clone_project() @@ -181,3 +186,32 @@ move_repo() [ -n "$xtree" ] && [ ! -d "src/coreboot/$xtree" ] && \ x_ ./update trees -f coreboot "$xtree"; return 0 } + +# can delete from multi- and single-tree projects. +# called from script/trees when downloading sources. +nuke() +{ + del="n" + pjcfgdir="${1%/}" + pjsrcdir="${2%/}" + pjsrcdir="${pjsrcdir#src/}" + [ ! -f "config/$pjcfgdir/nuke.list" ] && return 0 + + while read -r nukefile; do + rmf="$(realpath "src/$pjsrcdir/$nukefile" 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 "$nuke pjcfgdir: can't rm \"$nukefile\"" + printf "nuke %s: deleted \"%s\"\n" "$pjcfgdir" "$rmf" + done < "config/$pjcfgdir/nuke.list" + + [ "${del}" = "y" ] && return 0 + printf "nuke %s: no defined files exist in dir, src/%s\n" 1>&2 \ + "$pjcfgdir" "$pjsrcdir" + printf "(this is not an error)\n" 1>&2 +} -- cgit v1.2.1