# Add TDE library directory:
[[ $(cat etc/ld.so.conf|head -n1) != /usr/lib64 ]] && sed -i "1i /usr/lib64" etc/ld.so.conf

# Add TQt library directory:
[[ $(cat etc/ld.so.conf|head -n1) != /usr/lib64 ]] && sed -i "1i /usr/lib64" etc/ld.so.conf

[[ -x /sbin/ldconfig ]] && /sbin/ldconfig

## This could be a rebuild or upgradepkg running installpkg twice,
## so delete any previous routine
sed -i '/Update PKG_CONFIG_PATH for TDE/,+11d' etc/profile.d/pkgconfig.sh

echo '# Update PKG_CONFIG_PATH for TDE:
## remove duplicated paths:
PKG_CONFIG_PATH=$(echo $PKG_CONFIG_PATH| tr : \\n | awk '"'!seen[\$0]++'"' | tr \\n :|sed '"'s|:$||'"')
#
## add path for INSTALL_TDE ..
[[ ! $PKG_CONFIG_PATH == */usr/lib64/pkgconfig* ]] && \
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib64/pkgconfig
## .. and for TQTDIR if different
[[ ! $PKG_CONFIG_PATH == */usr/lib64/pkgconfig* ]] && \
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib64/pkgconfig
#
export PKG_CONFIG_PATH' >> etc/profile.d/pkgconfig.sh

## csh
# Update PKG_CONFIG_PATH:
[[ ! $( grep /usr/lib64/pkgconfig etc/profile.d/pkgconfig.csh ) ]] && \
sed -i "s|pkgconfig$|pkgconfig:/usr/lib64/pkgconfig|" etc/profile.d/pkgconfig.csh
[[ ! $( grep /usr/lib64/pkgconfig etc/profile.d/pkgconfig.csh ) ]] && \
sed -i "s|pkgconfig$|pkgconfig:/usr/lib64/pkgconfig|" etc/profile.d/pkgconfig.csh

# Update the desktop database:
/usr/bin/update-desktop-database ./usr/share/applications

# Update hicolor theme cache:
/usr/bin/gtk-update-icon-cache -f -t ./usr/share/icons/hicolor

# Update the mime database:
/usr/bin/update-mime-database -Vn usr/share/mime

( cd usr/lib64 ; rm -rf libtqassistantclient.so )
( cd usr/lib64 ; ln -sf libtqassistantclient.so.1.0.0 libtqassistantclient.so )
( cd usr/lib64 ; rm -rf libtqassistantclient.so.1 )
( cd usr/lib64 ; ln -sf libtqassistantclient.so.1.0.0 libtqassistantclient.so.1 )
( cd usr/lib64 ; rm -rf libtqassistantclient.so.1.0 )
( cd usr/lib64 ; ln -sf libtqassistantclient.so.1.0.0 libtqassistantclient.so.1.0 )
( cd usr/lib64 ; rm -rf libtqt-mt.so )
( cd usr/lib64 ; ln -sf libtqt-mt.so.3.5.0 libtqt-mt.so )
( cd usr/lib64 ; rm -rf libtqt-mt.so.3 )
( cd usr/lib64 ; ln -sf libtqt-mt.so.3.5.0 libtqt-mt.so.3 )
( cd usr/lib64 ; rm -rf libtqt-mt.so.3.5 )
( cd usr/lib64 ; ln -sf libtqt-mt.so.3.5.0 libtqt-mt.so.3.5 )
( cd usr/lib64 ; rm -rf libtqui.so )
( cd usr/lib64 ; ln -sf libtqui.so.1.0.0 libtqui.so )
( cd usr/lib64 ; rm -rf libtqui.so.1 )
( cd usr/lib64 ; ln -sf libtqui.so.1.0.0 libtqui.so.1 )
( cd usr/lib64 ; rm -rf libtqui.so.1.0 )
( cd usr/lib64 ; ln -sf libtqui.so.1.0.0 libtqui.so.1.0 )
( cd usr/lib64/tqt/mkspecs ; rm -rf default )
( cd usr/lib64/tqt/mkspecs ; ln -sf linux-g++ default )
