summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_clean.sh
blob: 18e332571743d20e013bcc510143b4ea018d4550 (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
#!/bin/bash
#
# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

ptxd_make_clean() {
    local directory="${1}"

    if [ -e "${directory}" ]; then
	if [ -h "${directory}" ! -d "${directory}" ]; then
	    rm -f "${directory}"
	elif [ -n "${PTXDIST_FORCE}" ]; then
	    : # always delete with --force
	elif [ -d "${directory}/.git" ]; then
	    ptxd_bailout "Refusing to delete git repository" \
		"$(ptxd_print_path "${directory}")" \
		"Delete anyways with --force."
	fi
	rm -rf "${directory}"
    fi
}
export -f ptxd_make_clean