Add default_cleanup_srcdir

In some cases, a simple rm -rf is not sufficent to clean srcdir.
One such case is the new go module system, that marks everything as
read-only - thus only letting root rm -rf it without a chmod.
There is a command intended to clean them - `go clean -modcache`.
However, for that to work, GOPATH must be defined and existent.
Running chmod for all srcdir cleanups makes no sense, nor does enforcing
root, or putting global overrides just for go.

This patch allows overriding what happens on `cleanup srcdir`, by
overriding cleanup_srcdir, and allows the use of default_cleanup_srcdir.

In our go example, it might be used as such:

cleanup_srcdir() {
	go clean -modcache
	default_cleanup_srcdir
}
This commit is contained in:
Chloe Kudryavtsev 2018-12-08 13:22:44 -05:00 committed by Natanael Copa
parent 30d296ddb3
commit 6a6310f030
1 changed files with 9 additions and 1 deletions

View File

@ -76,6 +76,14 @@ want_check() {
return 0
}
default_cleanup_srcdir() {
rm -rf "$srcdir"
}
cleanup_srcdir() {
default_cleanup_srcdir
}
cleanup() {
local i=
[ -z "$subpkgdir" ] && set_xterm_title ""
@ -90,7 +98,7 @@ cleanup() {
abuild-rmtemp "$BUILD_ROOT"
fi;;
pkgdir) msg "Cleaning up pkgdir"; rm -rf "$pkgbasedir";;
srcdir) msg "Cleaning up srcdir"; rm -rf "$srcdir";;
srcdir) msg "Cleaning up srcdir"; cleanup_srcdir;;
deps)
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
msg "Uninstalling dependencies..."