summaryrefslogtreecommitdiffstats
path: root/postsync.d/regen-overlays
blob: 4788e85c8be6812e7f281305f006c00542b9caae (plain) (blame)
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
61
62
#!/bin/bash
OVERLAY_CONFIG_DIR="$(update-eix --print EIXCFGDIR)/overlays"

# error
eecho() {
	case "x${NOCOLOR}" in
		x[y,Y][e,E][s,S]|x-[t,T][r,R][u,U][e,E]|x)
			echo -ne '\e[1;31m * \e[0m';;
		x*)
			echo -n " * ";;
	esac

	echo "$*"
}

# warning
wecho() {
	case "x${NOCOLOR}" in
		x[y,Y][e,E][s,S]|x-[t,T][r,R][u,U][e,E]|x)
			echo -ne '\e[1;33m * \e[0m';;
		x*)
			echo -n " * ";;
	esac

	echo "$*"
}

# info
iecho() {
	echo ">>> $*"
}

iecho "Regenerating overlay config ..."

if [ ! -d "${OVERLAY_CONFIG_DIR}" ] ; then
	eecho "${OVERLAY_CONFIG_DIR} does not exists!"
	return 1 
fi

if [ ! -f "${OVERLAY_CONFIG_DIR}/make.conf" ] ;  then
	wecho "${OVERLAY_CONFIG_DIR}/make.conf does not exists, creating..."
	touch "${OVERLAY_CONFIG_DIR}/make.conf"
fi 

echo "PORTDIR_OVERLAY=\"\${PORTDIR_OVERLAY}" > "${OVERLAY_CONFIG_DIR}/make.conf"

for overlay_config in $(ls ${OVERLAY_CONFIG_DIR}); do
    unset LOCATION

	if [[ "${overlay_config}" != "make.conf" ]] ; then
	    source ${OVERLAY_CONFIG_DIR}/${overlay_config}
   		if [[ -n "${LOCATION}" ]]; then
       		echo "	${LOCATION}" >> "${OVERLAY_CONFIG_DIR}/make.conf"
		fi
	fi
done

echo "\"" >> "${OVERLAY_CONFIG_DIR}/make.conf"

if [[ -z "$(grep "^[ \t]*source ${OVERLAY_CONFIG_DIR}/make.conf" /etc/make.conf)" ]] ; then
	wecho "\"source ${OVERLAY_CONFIG_DIR}/make.conf\" not found in /etc/make.conf"
fi