#!/bin/echo Source me: .
#
# Copyright (c) 2002-2004 by Frederick Bruckman
# All rights reserved.

# Build the indexes, by sourcing the "mk_index.sh" script. The script
# kinda sorta does the right thing all by itself, but doesn't recover
# from errors well, so use it to build the lists in a temporary
# directory, then rotate them into place after completion.
#
mk_index () {
	SAVED_PKGORDERDIR="$PKGORDERDIR"
	PKGORDERDIR="$(mktemp -dt pkgorder)"
	. "${PKGORDER_LIBDIR}"/mk_index.sh
	cd "$PKGORDERDIR"
	if [ -s "dir_to_dependencies" -a -s "dir_to_dependents" -a -s \
		"dir_to_pkgname" -a -s "sorted_dirs" ]
	then
		mkdir -p "$SAVED_PKGORDERDIR"
		pax -r -w -pe . "$SAVED_PKGORDERDIR"
		rm -r "$PKGORDERDIR"
	fi
}
