#!/bin/sh

. /usr/share/alterator/build/backend3.sh

license="/usr/share/install2/data/license.txt"

on_message()
{
        case "$in_action" in
        	read)
			local suffix=
			[ -n "$INSTALLER_LANGUAGE" -a "$INSTALLER_LANGUAGE" != "POSIX" -a "$INSTALLER_LANGUAGE" != "C" ] &&
				suffix="$(printf %s "$INSTALLER_LANGUAGE" |
						sed -r -e 's,[a-z]+_([^\.]+)(\..*)?,\1,' |
						tr '[:upper:]' '[:lower:]')" ||
				suffix="all"

			local license_file="$license.$suffix"
			[ -s "$license_file" ] ||
				license_file="$license.all"

			printf '(license "%s")' "$(cat "$license_file" |simple_quote)"
                        ;;
		*)
			echo '#f'
			;;
        esac
}

message_loop
