The problem was an existing /var/lib/mysql-upgrade/DATADIR.link file, which caused the soft link backup mechanism to fail.
This can be fixed manually be deleting /var/lib/mysql-upgrade/DATADIR.link and running apt-get -f install.
To fix the preinst script, just change the line
cp -d "$checkdir" "$UPGRADEDIR/$dir.link"
to
cp -dT "$checkdir" "$UPGRADEDIR/$dir.link"
The problem was an existing /var/lib/ mysql-upgrade/ DATADIR. link file, which caused the soft link backup mechanism to fail.
This can be fixed manually be deleting /var/lib/ mysql-upgrade/ DATADIR. link and running apt-get -f install.
To fix the preinst script, just change the line
cp -d "$checkdir" "$UPGRADEDIR/ $dir.link"
to
cp -dT "$checkdir" "$UPGRADEDIR/ $dir.link"