summaryrefslogtreecommitdiffhomepage
path: root/subr.pkg/pkg_clean.subr
blob: 2046c28bea1b936b962b45158027f46e5c513a60 (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
32
33
#
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Lucía Andrea Illanes Albornoz <lucia@luciaillanes.de>
# set +o errexit -o noglob -o nounset is assumed.
#

pkg_clean() {
	local _pc_group_name="${1}" _pc_pkg_name="${2}" _pc_restart_at="${3}";

	if [ "${PKG_NO_CLEAN:-0}" -eq 0 ]; then
		if rtl_lmatch \$ARG_CLEAN_BUILDS "build" ","\
		&& [ "${PKG_NO_CLEAN_BUILD_DIR:-0}" -eq 0 ]; then
			if ! rtl_fileop rm "${PKG_BUILD_DIR}"; then
				return 1;
			fi;
		fi;
		if rtl_lmatch \$ARG_CLEAN_BUILDS "dest" ","; then
			if ! rtl_fileop rm "${PKG_DESTDIR}"; then
				return 1;
			elif [ -e "${PKG_DESTDIR_HOST}" ]\
			&&   ! rtl_fileop rm "${PKG_DESTDIR_HOST}"; then
				return 1;
			fi;
		fi;
		if rtl_lmatch \$ARG_CLEAN_BUILDS "src" ","; then
			if ! rtl_fileop rm "${PKG_BASE_DIR}/${PKG_SUBDIR}"; then
				return 1;
			fi;
		fi;
	fi;
	return 0;
};

# vim:filetype=sh textwidth=0