summaryrefslogblamecommitdiffstats
path: root/postsync.d/eix-update
blob: a94196f7dbc1980a8dc8e6ee6d2886f7bae75c4f (plain) (tree)
1
2
3
4



                          















                                                             




                                                 




                                                                                       












                                                                              


          

     
                                                                                                                                                


                                                






                                                                 


                          
#!/bin/bash

. /etc/init.d/functions.sh

EIXCACHE=$(update-eix --print EIX_CACHEFILE)
OVERLAY_CONFIG_DIR="$(update-eix --print EIXCFGDIR)/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 

( [ -x /usr/bin/eix-update ] && /usr/bin/eix-update ${OVERLAY_PARAM} ) || ( [ -x /usr/bin/update-eix ] && /usr/bin/update-eix ${OVERLAY_PARAM} )

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

	if [ -x /usr/bin/eix-diff ] ; then
		eix-diff "${TMPFILE}"
	else
		[ -x /usr/bin/diff-eix ] && diff-eix "${TMPFILE}"
	fi

	echo
	rm -f "${TMPFILE}"
fi