# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../fhs/fhs.conf
# Copyright (C) 2006 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

srctar=none
createprefix=0
createdocs=0
check_usrlocal=0

makeopt=
makeinstopt=

fhs_create_helper() {
	while read cmd name attribute; do
		if [ -e "$sysroot/$name" ]; then
			echo "Skipping: $name"
			# continue
		elif [ "$cmd" == "m" ]; then
			echo "Creating: $name"
			mkdir "$sysroot/$name"
			[ -z "$attribute" ] ||
				chmod "$attribute" "$sysroot/$name"
		elif [ "$cmd" == "l" -a -n "$attribute" ]; then
			echo "Symlinking: $name -> $attribute"
			ln -s "$attribute" "$sysroot/$name"
		else
			echo_error "Syntax Error: $cmd $name $attribute"
			false
		fi
		add_flist "$sysroot/$name"
	done
}

fhsfiles="$( ls $confdir/fhs-*.{txt,sh} 2> /dev/null | sort )"

fhs_create() {
	local file=

	for file in $fhsfiles; do
		case "$file" in
			*.sh)	echo "loading $file..." 1>&2
				sh $file ;;
			*.txt)	echo "loading $file..." 1>&2
				sed -e '/^[ \t]*$/d;' -e '/^#/d;' $file ;;
		esac | fhs_create_helper
	done
}

hook_add postmake 5 fhs_create

hook_add postdoc 7 "mkdir -p $root$docdir/; cp -vf $( match_source_file -p fhs ) $root$docdir/"