aboutsummaryrefslogtreecommitdiff
path: root/lib/actions/clean.bash
blob: 0ed521d5b8c20249ce9c2d2f4893a2ecbcb531aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash

action() {
	local OPTIND
	local clean_source

	while getopts ":s" opt
	do
		case "$opt" in
			s) clean_src=1 ;;
			*) emerg "Invalid option specified: $opt" ;;
		esac
	done

	shift $(( OPTIND - 1 ))

	shopt -s extglob

	rm -fr -- "!($BASEDIR/bin/rstar)"
	rm -fr -- "$BASEDIR/dist"
	rm -fr -- "$BASEDIR/include"
	rm -fr -- "$BASEDIR/lib/libmoar.so"
	rm -fr -- "$BASEDIR/share"

	# Cleaning the sources is not desired for end-users, but convenient for
	# maintainers. As such, this one is put behind an opt.
	if [[ $clean_src ]]
	then
		rm -fr -- "$BASEDIR/src"
	fi
}