#!/bin/sh

DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
if [ $? -ne 0 ] ||
   [ -z "$DEB_HOST_MULTIARCH" ]; then
  echo "INFO: Nothing to do, this version of Debian does not support multiarch..." 1>&2
  exit 0
fi

directories_to_add_links_into="/lib /usr/lib /usr/include"

for dir in $directories_to_add_links_into
do
  if [ -d "$dir/$DEB_HOST_MULTIARCH" ]; then
    echo "INFO: Linking '$dir/$DEB_HOST_MULTIARCH/*' into '$dir/'" 1>&2
    ln -s $dir/$DEB_HOST_MULTIARCH/* $dir/ 2>/dev/null || true
  else
    echo "INFO: NOT linking anything for '$dir/$DEB_HOST_MULTIARCH/*' as this directory doe not exists..." 1>&2
  fi
done
