case "$MODE" in
    commandline)
        add_option "install-package-lists" "`eval_gettext "installs lists of packages contained in files"`" "advanced" "true"
        # Example: install-package-lists '/etc/ltsp/common.packages,/etc/ltsp/primary.packages'
        # Those files can contain multiple packages and even comments starting
        # with hashes (#). It offers an easy way to customize fat clients
        # installations.
        # For simplicity, it ONLY takes effect if FAT_CLIENT_DESKTOPS is also
        # set.
        ;;

    configure)
        if [ -n "$option_install_package_lists_value" ]; then
            PACKAGE_LISTS=$(echo $option_install_package_lists_value | tr ',' ' ')
        fi
        ;;

    after-install)
        test -n "$FAT_CLIENT_DESKTOPS" || return 0

        # Install each package list separately, because they might be too big
        # and `apt-get install` has problems with > 4 Gb installations:
        #     https://bugs.launchpad.net/ubuntu/+source/ltsp/+bug/504620
        # Hoping that's enough and there's no need to install each package
        # seperately...

        error() {
            echo "$@" >&2
            echo "$@" >> /var/log/sch-scripts.log
        }

        for list in $PACKAGE_LISTS; do
            if [ ! -f "$list" ]; then
                error "ERROR: Package list file '$list' does not exist."
                continue
            fi
            # Sanitize the list, removing comments and commas.
            packages=$(sed -e 's/#.*//g' -e 's/,//g' "$list")
            # Consolidate spaces.
            packages=$(echo $packages)
            echo "Installing package list '$list'"

            if ! chroot $ROOT apt-get $APT_GET_OPTS install $packages; then
                error "ERROR while installing package list $list.
Please install it manually after the chroot is built."
            fi
        done
    ;;
esac
