Name:          skype
Version:       @SRPMVERSION@
Release:       @SRPMRELEASE@
Epoch:         1
Summary:       An Internet voice and video communication software
Group:         Graphical Desktop/Applications/Internet
Vendor:        @vendor@
Distribution:  @distribution@
Packager:      Silvan Calarco <silvan.calarco@mambasoft.it>
URL:           http://www.skype.com
Source:        LICENSE
License:       Non Distributable
BuildPrereq:   wget
BuildPrereq:   /usr/bin/tempfile
# NOTE: requires the backward compatible version of the libstdc++ library
Requires:      pulseaudio
BuildRoot:     %{_tmppath}/%{name}-%{version}-root

%description
An Internet voice and video communication software.

%prep
%setup -c -n %{name}-%{version} -D -T

# don't strip files to prevent breaking internal binary CRC ckeck
%define __os_install_post /usr/lib/rpm/brp-infodir

[ -r /etc/sysconfig/@sysconfigfile@ ] || exit 1
. /etc/sysconfig/@sysconfigfile@

[ "${SKYPE_PCK}" ] && \
   SKYPE_PCK_DEST=${SKYPE_PCK} ||
   SKYPE_PCK_DEST=skype-latest.tar.bz2
[ "${SKYPE_URL}" ] || \
   SKYPE_URL="http://www.skype.com/go/getskype-linux-dynamic"

tmpdir=$(mktemp -q -d -t skype.XXXXXXXX)
[ $? -eq 0 ] || exit 1

wget -nv --timeout=10 --tries=2 \
   ${SKYPE_URL}${SKYPE_PCK} -P ${tmpdir}

SKYPE_ARCHIVE="`ls ${tmpdir}/*skype-* 2>/dev/null`"
[ -f ${SKYPE_ARCHIVE} ] || exit 1

tar xf ${SKYPE_ARCHIVE} --strip-components=1

%build -q

%install
[ "%{buildroot}" != / ] && rm -rf %{buildroot}

install -D skype \
    %{buildroot}%{_bindir}/skype
install -D skype.desktop \
    %{buildroot}%{_datadir}/applications/skype.desktop
install -D icons/SkypeBlue_48x48.png \
    %{buildroot}%{_datadir}/icons/skype.png
install -D icons/SkypeBlue_48x48.png \
    %{buildroot}%{_datadir}/pixmaps/skype.png
install -d %{buildroot}%{_datadir}/skype
cp -a avatars lang sounds %{buildroot}%{_datadir}/skype/

cp %{S:0} LICENSE

rm -fr ${tmpdir}

# create a v4l1_compat desktop link
cat > %{buildroot}%{_datadir}/applications/skype-v4l1.desktop << _EOF
[Desktop Entry]
Name=Skype (v4l1 webcam compatibility)
Name[it]=Skype (compatibilità webcam v4l1)
Comment=Skype Internet Telephony
Exec=LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype
Icon=skype.png
Terminal=0
Type=Application
Encoding=UTF-8
Categories=Network;Application;
MimeType=x-scheme-handler/skype;
X-KDE-Protocols=skype
_EOF

cat > %{buildroot}%{_datadir}/applications/skype-v4l2.desktop << _EOF
[Desktop Entry]
Name=Skype (v4l2 webcam fixes)
Name[it]=Skype (correzioni webcam v4l2)
Comment=Skype Internet Telephony
Exec=LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so skype
Icon=skype.png
Terminal=0
Type=Application
Encoding=UTF-8
Categories=Network;Application;
MimeType=x-scheme-handler/skype;
X-KDE-Protocols=skype
_EOF

%clean
[ "%{buildroot}" != / ] && rm -rf %{buildroot}

%files
%defattr(-,root,root)
%{_bindir}/skype
%{_datadir}/applications/skype.desktop
%{_datadir}/applications/skype-v4l1.desktop
%{_datadir}/applications/skype-v4l2.desktop
%{_datadir}/icons/skype.png
%{_datadir}/pixmaps/skype.png
%dir %{_datadir}/skype
%{_datadir}/skype/avatars/*.png
%{_datadir}/skype/lang/*
%{_datadir}/skype/sounds/*.wav
%doc LICENSE README

%changelog
* Mon Dec 10 2012 Silvan Calarco <silvan.calarco@mambasoft.it> 4.2.0.20-1mamba
- added v4l1 and v4l2 webcam compatibility desktop entries

* Thu Sep 10 2009 Silvan Calarco <silvan.calarco@mambasoft.it> 2.1.0.47-2mamba
- specfile fixed for 2.1.0.47

* Wed May 28 2008 Silvan Calarco <silvan.calarco@mambasoft.it> 2.0.0.68-1mamba
- specfile creation
