config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then 
    rm $NEW
  fi
}

config etc/lircd.conf.new
config etc/lircmd.conf.new
config etc/lircrc.new
config etc/logrotate.d/lirc.new

if [ -x sbin/depmod ]; then
  chroot . /sbin/depmod -ae 3.10.17-smp 1> /dev/null 2> /dev/null
fi
( cd usr/bin ; rm -rf lirc-setup )
( cd usr/bin ; ln -sf ../lib/python3.5/site-packages/lirc/lirc-setup lirc-setup )
( cd usr/lib ; rm -rf liblirc.so.0 )
( cd usr/lib ; ln -sf liblirc.so.0.0.0 liblirc.so.0 )
( cd usr/lib ; rm -rf libirrecord.so.0 )
( cd usr/lib ; ln -sf libirrecord.so.0.0.0 libirrecord.so.0 )
( cd usr/lib ; rm -rf liblirc_driver.so.0 )
( cd usr/lib ; ln -sf liblirc_driver.so.0.0.0 liblirc_driver.so.0 )
( cd usr/lib ; rm -rf libirrecord.so )
( cd usr/lib ; ln -sf libirrecord.so.0.0.0 libirrecord.so )
( cd usr/lib/python3.5/site-packages/lirc ; rm -rf configs )
( cd usr/lib/python3.5/site-packages/lirc ; ln -sf ../../../../share/lirc/configs configs )
( cd usr/lib ; rm -rf liblirc_client.so.0 )
( cd usr/lib ; ln -sf liblirc_client.so.0.3.0 liblirc_client.so.0 )
( cd usr/lib ; rm -rf liblirc_client.so )
( cd usr/lib ; ln -sf liblirc_client.so.0.3.0 liblirc_client.so )
( cd usr/lib ; rm -rf liblirc_driver.so )
( cd usr/lib ; ln -sf liblirc_driver.so.0.0.0 liblirc_driver.so )
( cd usr/lib ; rm -rf liblirc.so )
( cd usr/lib ; ln -sf liblirc.so.0.0.0 liblirc.so )
( cd usr/share/doc/lirc/html ; rm -rf api-docs )
( cd usr/share/doc/lirc/html ; ln -sf lirc.org/api-docs/html/index.html api-docs )
( cd usr/share/doc/lirc/html ; rm -rf lirc.org )
( cd usr/share/doc/lirc/html ; ln -sf ../lirc.org lirc.org )
( cd usr/share/doc/lirc/html ; rm -rf images )
( cd usr/share/doc/lirc/html ; ln -sf ../images images )
( cd usr/share/doc/lirc/lirc.org/html ; rm -rf api-docs )
( cd usr/share/doc/lirc/lirc.org/html ; ln -sf ../api-docs/html/index.html api-docs )
( cd usr/share/doc/lirc/lirc.org/html ; rm -rf lirc.org )
( cd usr/share/doc/lirc/lirc.org/html ; ln -sf .. lirc.org )
