#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2019 Christopher Bratusek		#
#							#
#########################################################

post_install () {
	if [[ ! ${DISABLE_POSTINSTALL} ]]; then
		post_install_message
		gtk-update-icon-cache -q -f "${PREFIX}"/share/icons/hicolor
	fi
}

post_remove () {
	echo -n
}

installdirs_create ()
{
	echo -e "\t${WHITE}+${MAGENTA} directories"
	mkdir -p "${DESTDIR}/${DATADIR}"
	for directory in "${DATADIR_LIST[@]}"; do
		mkdir -p "${DESTDIR}/${DATADIR}/${directory}"
	done

	mkdir -p "${DESTDIR}/${LOCALEDIR}"
	for directory in "${LOCALEDIR_LIST[@]}"; do
		mkdir -p "${DESTDIR}/${LOCALEDIR}/${directory}"
	done

	mkdir -p "${DESTDIR}/${BINDIR}" "${DESTDIR}/${ICONDIR}" \
		"${DESTDIR}/${PCDIR}" "${DESTDIR}/${DOCDIR}" \
		"${DESTDIR}/${DESKTOPDIR}" "${DESTDIR}/${MANDIR}"
}

inst ()
{
	FILE=${2/:*}
	DEST=${2/*:}

	case ${1} in
		bin )	install -m755 ${FILE} "${DESTDIR}/${DEST}" ;;
		man )	install -m644 ${FILE}.gz "${DESTDIR}/${DEST}" ;;
		* )	install -m644 ${FILE} "${DESTDIR}/${DEST}" ;;
	esac
}

install_bsng () {
	echo -e "\t${WHITE}+${YELLOW} data files"
	for file in "${DATA_FILES[@]}" "${LOCALE_FILES[@]}" \
		"${PC_FILES[@]}" "${ICON_FILES[@]}"; do
		inst data "${file}"
	done

	echo -e "\t${WHITE}+${GREEN} executable files"
	for file in "${BIN_FILES[@]}"; do
		inst bin "${file}"
	done

	echo -e "\t${WHITE}+${CYAN} documentation and manual pages"
	for file in "${DOC_FILES[@]}"; do
		inst doc "${file}"
	done

	for file in "${MAN_FILES[@]}"; do
		inst man "${file}"
	done
}

remove_bsng () {
	echo -e "\t${WHITE}+${RED} all files"
	for file in "${REMOVE_FILES[@]}"; do
		rm -rf "${file}"
	done
}
