diff options
| author | Leah Rowe <leah@libreboot.org> | 2024-06-09 10:42:10 +0100 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2024-06-09 10:42:10 +0100 | 
| commit | 77e482aae607e0c9d13ff6263823f816db2c5372 (patch) | |
| tree | 980d358bc20029c0b6b2118543ba7e15efa5bd51 | |
| parent | 42e979509b66243593ca4407439c4e46a68d5e6c (diff) | |
git.sh: simplify nuke()
do not over-engineer such a trivial thing.
seriously. all we're doing is nuking some files.
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rwxr-xr-x | include/git.sh | 25 | 
1 files changed, 4 insertions, 21 deletions
| diff --git a/include/git.sh b/include/git.sh index 5fe41fb3..23110ff3 100755 --- a/include/git.sh +++ b/include/git.sh @@ -181,27 +181,10 @@ move_repo()  # called from script/trees when downloading sources.  nuke()  { -	del="n" -	pjcfgdir="${1%/}" -	pjsrcdir="${2%/}" -	pjsrcdir="${pjsrcdir#src/}" -	[ ! -f "config/$pjcfgdir/nuke.list" ] && return 0 +	e "config/${1%/}/nuke.list" f missing && 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 +		rmf="${2%/}/$nukefile" && [ -L "$rmf" ] && continue +		e "$rmf" e missing || rm -Rf "$rmf" || $err "!rm $rmf, ${2%/}" +	done < "config/${1%/}/nuke.list"; return 0  } | 
