summaryrefslogtreecommitdiff
path: root/auto/clean
blob: 1128427f5b00bb6a669f4173496688c40ebdf558 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

rm -f build.log

# Remove generated files
rm -f config/binary config/bootstrap config/chroot config/common config/source \
      config/kanotix config/chroot_local-packageslists/kanotix-flavours.list
rm -f config/package-lists/compat.list.chroot
if [ -f config/all ]; then
	sed -i '/^. config\/kanotix/d' config/all
	[ ! -s config/all ] && rm -f config/all
fi

# remove kanotix-scripts
grep -oe '^[^ #]*' scripts.urls | grep -oe '[^/]*$' | xargs -i rm -f config/chroot_local-includes/usr/local/bin/{}

# Remove empty directories in config tree
if ls config/*/ > /dev/null 2>&1
then
	rmdir --ignore-fail-on-non-empty config/*/
fi

if [ -d config ]
then
	rmdir --ignore-fail-on-non-empty config
fi

[ $# -eq 0 ] && lb clean noauto

# handle additional kanotix parameters
while [ "$1" ]
do
	case "$1" in
	--help)
		lb clean noauto --help
		echo -e "\nAdditional Options for Kanotix:\n\t[--tmpfs]\n"
		exit 1
		;;
	--all)
		if [ -d tmpfs ]; then
			[ "$(stat --printf "%d\n" . tmpfs | uniq -u)" ] && umount tmpfs
			rmdir tmpfs
		fi
		lb clean noauto --all
		exit 1
		;;
	--tmpfs)
		if [ -d tmpfs ]; then
			[ "$(stat --printf "%d\n" . tmpfs | uniq -u)" ] && umount tmpfs
			rmdir tmpfs
		fi
		;;
	*)
		lb clean noauto "$1"
		;;
	esac
	shift
done

exit 1