# 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 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 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 "$pjcfgdir/blobs: can't rm \"$blobfile\"" printf "nuke %s: deleted \"%s\"\n" "$pjcfgdir" "$rmf" done < "config/$pjcfgdir/nuke.list" [ "${del}" = "y" ] && return 0 printf "nuke %s: no defined blobs exist in dir, src/%s\n" 1>&2 \ "$pjcfgdir" "$pjsrcdir" printf "(this is not an error)\n" 1>&2 }