summaryrefslogtreecommitdiffstats
path: root/postsync.d/eix-update
blob: 729f5c43fa75aa19fa8f80b4f825e9508618fc46 (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
#!/bin/bash

. /etc/init.d/functions.sh

# implement old/new switch for older versions of eix
[ -r "$(dirname $0)/../eix-switch.sh" ] && . "$(dirname $0)/../eix-switch.sh"

EIXCACHE=$(eix-update --print EIX_CACHEFILE)
OVERLAY_CONFIG_DIR="$(dirname $0)/../overlays"

TMPFILE=""
if [ -r "${EIXCACHE}" ]; then
	TMPFILE=$(mktemp -t eix.cache.XXXXXXXX)
	cp "${EIXCACHE}" "${TMPFILE}"
fi

OVERLAY_PARAM=""
for overlay_config in $(ls ${OVERLAY_CONFIG_DIR}); do
	unset LOCATION
	unset SYNC
	unset CACHE_FORMAT

	source ${OVERLAY_CONFIG_DIR}/${overlay_config}
	if [[ -n "${LOCATION}" ]]; then
		if [[ ! -d "${LOCATION}" ]]; then
			mkdir -p "${LOCATION}"
		fi

		OVERLAY_PARAM="${OVERLAY_PARAM} --add-overlay ${LOCATION}"

		if [[ -n ${CACHE_FORMAT} ]]; then
			OVERLAY_PARAM="${OVERLAY_PARAM} -m ${LOCATION} ${CACHE_FORMAT}"
		fi

		OVERLAY_NAME="$(echo ${overlay_config} | sed 's/\.[^\.]*$//')"
		if [[ -n ${SYNC} ]]; then
			echo
			pushd ${LOCATION} > /dev/null 2>&1
			${SYNC} 2>&1 | sed -ue "s/^/${OVERLAY_NAME}> /g"
		
			if [[ "0" -ne "${PIPESTATUS[0]}" ]]; then
				ewarn "Sync of ${OVERLAY_NAME} failed"
			fi

			popd > /dev/null 2>&1
		fi
	fi
done

echo 

eix-update ${OVERLAY_PARAM}

if [ -r "${EIXCACHE}" -a -r "${TMPFILE}" ]; then
	echo

	eix-diff "${TMPFILE}"

	rm -f "${TMPFILE}"
fi