# Enable our apt sources on CD, DVD and PXE installs.
# Must run before 020-apt-get-update
case "$MODE" in
    configure)
        # Skip mirror check if installing from our unsigned CD.
        if [ file:///media/cdrom = "$option_mirror_value" ] ; then
            echo "Detected CD install, disabling APT repository checking."
            LTSP_CDROM_INSTALL=true
            APT_GET_OPTS="$APT_GET_OPTS \
                           --allow-unauthenticated"
            # Make sure LTSP use a local repository if it is used by
            # the system too.  FIXME Should really check the CD for list
            # of components.
            if grep ^deb /etc/apt/sources.list | grep ' local' ; then
                COMPONENTS="$COMPONENTS local"
            fi

            # also disable gpg verification for debootstrap,
            # used in ltsp 5.1.10-2
            DEBOOTSTRAP_KEYRING=""
        fi
        ;;
    after-install)
        # Use same source list as the host system, modulo CDs
        echo "Appending the host sources.list to ltsp sources.list."
        grep -v cdrom: /etc/apt/sources.list >> $ROOT/etc/apt/sources.list
        if [ "true" = "$LTSP_CDROM_INSTALL" ]; then
            # purge Packages and Release files that debootstrap may have copied
            # incorrectly, which prevents apt from fetching the correct files?
            rm $ROOT/var/lib/apt/lists/*Packages $ROOT/var/lib/apt/lists/*Release || true
        fi
        ;;
esac
