summaryrefslogtreecommitdiffstats
path: root/postsync.d/regen-overlays
blob: 89d70dddba65d1f17d4413b6cf295ca130fad6d5 (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
#!/bin/bash

. /etc/init.d/functions.sh

OVERLAY_CONFIG_DIR="$(dirname $0)/../overlays"

ebegin "Regenerating overlay config ..."

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

if [ ! -f "${OVERLAY_CONFIG_DIR}/make.conf" ] ;  then
	ewarn "${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}" && -d "${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
	ewarn "\"source ${OVERLAY_CONFIG_DIR}/make.conf\" not found in /etc/make.conf"
fi

eend 0