#!/bin/sh

set -e

# Source the debconf library
. /usr/share/debconf/confmodule

db_fset swiftlang/link_swift seen false
db_fset swiftlang/other_swift seen false

# Only offer linking on install
if [ "$1" = "install" ] || [ "$1" = "configure" ]; then
    # Link to swift?
    if [ -f /usr/bin/swift -a ! -h /usr/bin/swift ]; then
        #echo "Found existing /usr/bin/swift binary file"
        db_input high swiftlang/other_swift || true
        db_go
    else
        # Leave any existing symbolic links in place
        if [ ! -h /usr/bin/swift ]; then
            #echo "Okay to make a new symbolic link"
            db_input high swiftlang/link_swift || true
            db_go
        fi
    fi
fi
