( cd usr/share/cups/model ; rm -rf foomatic-ppds )
( cd usr/share/cups/model ; ln -sf /usr/share/ppd foomatic-ppds )
( cd usr/share/applications ; rm -rf hplip.desktop )
( cd usr/share/applications ; ln -sf /usr/share/hplip/data/hplip.desktop hplip.desktop )
( cd usr/lib/sane ; rm -rf libsane-hpaio.so )
( cd usr/lib/sane ; ln -sf ../libsane-hpaio.so.1.0.0 libsane-hpaio.so )
( cd usr/lib/sane ; rm -rf libsane-hpaio.so.1.0.0 )
( cd usr/lib/sane ; ln -sf ../libsane-hpaio.so.1.0.0 libsane-hpaio.so.1.0.0 )
( cd usr/lib/sane ; rm -rf libsane-hpaio.so.1 )
( cd usr/lib/sane ; ln -sf ../libsane-hpaio.so.1.0.0 libsane-hpaio.so.1 )
( cd usr/lib ; rm -rf libhpip.so )
( cd usr/lib ; ln -sf libhpip.so.0.0.1 libhpip.so )
( cd usr/lib ; rm -rf libsane-hpaio.so )
( cd usr/lib ; ln -sf libsane-hpaio.so.1.0.0 libsane-hpaio.so )
( cd usr/lib ; rm -rf libsane-hpaio.so.1 )
( cd usr/lib ; ln -sf libsane-hpaio.so.1.0.0 libsane-hpaio.so.1 )
( cd usr/lib/cups/filter ; rm -rf foomatic-rip )
( cd usr/lib/cups/filter ; ln -sf /usr/bin/foomatic-rip foomatic-rip )
( cd usr/lib ; rm -rf libhpip.so.0 )
( cd usr/lib ; ln -sf libhpip.so.0.0.1 libhpip.so.0 )
( cd usr/bin ; rm -rf hp-colorcal )
( cd usr/bin ; ln -sf ../share/hplip/colorcal hp-colorcal )
( cd usr/bin ; rm -rf hp-testpage )
( cd usr/bin ; ln -sf ../share/hplip/testpage hp-testpage )
( cd usr/bin ; rm -rf hp-unload )
( cd usr/bin ; ln -sf ../share/hplip/unload hp-unload )
( cd usr/bin ; rm -rf hp-fab )
( cd usr/bin ; ln -sf ../share/hplip/fab hp-fab )
( cd usr/bin ; rm -rf hp-sendfax )
( cd usr/bin ; ln -sf ../share/hplip/sendfax hp-sendfax )
( cd usr/bin ; rm -rf hp-info )
( cd usr/bin ; ln -sf ../share/hplip/info hp-info )
( cd usr/bin ; rm -rf hp-clean )
( cd usr/bin ; ln -sf ../share/hplip/clean hp-clean )
( cd usr/bin ; rm -rf hp-toolbox )
( cd usr/bin ; ln -sf ../share/hplip/toolbox hp-toolbox )
( cd usr/bin ; rm -rf hp-levels )
( cd usr/bin ; ln -sf ../share/hplip/levels hp-levels )
( cd usr/bin ; rm -rf hp-align )
( cd usr/bin ; ln -sf ../share/hplip/align hp-align )
( cd usr/bin ; rm -rf hp-timedate )
( cd usr/bin ; ln -sf ../share/hplip/timedate hp-timedate )
( cd usr/bin ; rm -rf hp-makecopies )
( cd usr/bin ; ln -sf ../share/hplip/makecopies hp-makecopies )
( cd usr/bin ; rm -rf hp-makeuri )
( cd usr/bin ; ln -sf ../share/hplip/makeuri hp-makeuri )
( cd usr/bin ; rm -rf hp-print )
( cd usr/bin ; ln -sf ../share/hplip/print hp-print )
( cd usr/bin ; rm -rf hp-firmware )
( cd usr/bin ; ln -sf ../share/hplip/firmware hp-firmware )
( cd usr/bin ; rm -rf hp-check )
( cd usr/bin ; ln -sf ../share/hplip/check hp-check )
( cd usr/bin ; rm -rf hp-probe )
( cd usr/bin ; ln -sf ../share/hplip/probe hp-probe )
( cd usr/bin ; rm -rf hp-setup )
( cd usr/bin ; ln -sf ../share/hplip/setup hp-setup )

config() {
  NEW="$1"
  OLD="`dirname $NEW`/`basename $NEW .new`"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

# Keep same perms on rc.hplip.new:
if [ -e etc/rc.d/rc.hplip ]; then
  cp -a etc/rc.d/rc.hplip etc/rc.d/rc.hplip.new.incoming
  cat etc/rc.d/rc.hplip.new > etc/rc.d/rc.hplip.new.incoming
  mv etc/rc.d/rc.hplip.new.incoming etc/rc.d/rc.hplip.new
fi

config etc/rc.d/rc.hplip.new
config etc/hp/hplip.conf.new

if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database /usr/share/applications >/dev/null 2>&1
fi

