33 lines
1.1 KiB
Bash
33 lines
1.1 KiB
Bash
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# SPDX-FileCopyrightText: 2020,2021,2023,2024 Leah Rowe <leah@libreboot.org>
|
|
|
|
# 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"
|
|
}
|