On 11/06/11 18:03, Anssi Hannula wrote:

OK, here goes :)

- I see you didn't get what I meant with the versionized filelist files.
   The idea was that if someone updates the package to a new skype
   version, the rpmbuild process would fail if one didn't touch the
   filelist files.  With your changes such a failure doesn't happen.
   You need to use lang-%{version}.txt instead, so that when someone
   updates %version, it will automatically start failing until the lang
   list file is updated/moved.

I did follow - just had brain fail when implementing it - sorted now.


- Best to add a comment in the %post script to remind that any new files
   need to have a %ghost entry created.
   (btw: an alternative idea is to create a post-script and the filelist
    at the same time in a single for loop in %build/%install, so that
    the lists can never get out of sync as they are created from a single
    list; however, your current solution is adequate as well)

Note added - keep it simple.


- Why define %tmpextdir instead of using $newtmp directly? Quite
   confusing as %variables are defined at build-time while $variables
   at run-time.

Quite ! - Fixed.


- You don't check for failures. If the mktemp call fails, you extract
   the tarball into /root etc.etc.. You need to check for failures on
   the mktemp/mkdir/cd commands (mktemp failure can be detected by
   checking if $newtmp string is empty), or alternatively run "set -e"
   to make the shell exit on failures (this leaves the tmpdir polluted,
   but it doesn't matter as much as it is an uncommon failure case and
   /tmp is cleaned periodically anyway).

Added some checks - with clean-up of previously created dirs etc on fail.


- Dot in Summary.

?? I don't see one.


- Noarch seems wrong to me.

Pass. I wondered about that. It uses 32 bit libs in both arch, and seems to test OK in both, but I am open to suggestions.

Barry
%define name            get-skype
%define version         2.2.0.35
%define release         %mkrel 7
%define instdir         %{_datadir}/skype
%define langdir         %{instdir}/lang
%define avatardir       %{instdir}/avatars
%define sounddir        %{instdir}/sounds
%define icondir         %{instdir}/icons
%define md5             6e28002c0086fae5206e2d242c3edcfa
%define mytmp           %{_localstatedir}/lib/%{name}

Summary:        Download and Install Skype.
Name:           %{name}
Version:        %{version}
Release:        %{release}
License:        Proprietary
Group:          Networking/Instant messaging
URL:            http://www.skype.com
Buildarch:      noarch
Requires:       wget
Requires:       liblcms1
Requires:       libmng1
Requires:       libqtcore4
Requires:       libqtdbus4
Requires:       libqtnetwork4
Requires:       libqtgui4
Requires:       libqtsvg4
Requires:       libqtxml4
Requires:       libxscrnsaver1
Requires:       libxv1
Requires:       libv4l-wrappers

# The following are lists of filenames (124 in total) placed 
# in versioned text files to save clutter in the spec file.
Source0:        avatars-%{version}.txt
Source1:        sounds-%{version}.txt
Source2:        lang-%{version}.txt

%description

This is an installer for Skype-%{version}.

This package does not contain any files as the Skype license does not allow 
distribution.
By installing this package you will download and install Skype from skype.com.
You must accept the Skype EULA before using it.
Please be patient, this is a 23MB download and may take some time.
Uninstalling this package will uninstall Skype from your system.

%pre

mkdir %{mytmp}
[[ -d %{mytmp} ]] || exit 1
cd %{mytmp}
wget -nc "http://download.skype.com/linux/skype-%{version}.tar.bz2";

md5chk=$(md5sum skype-%{version}.tar.bz2 | cut -d' ' -f1)
if [[ %{md5} != $md5chk ]]; then
rm skype-%{version}.tar.bz2
cd ..
rm -r %{mytmp}
echo "Error - download checksum failed"
exit 1
fi

%install

rm -rf $RPM_BUILD_ROOT
install -d -m 0755 %buildroot%{_bindir}
install -d -m 0755 %buildroot%{_datadir}/applications
touch %buildroot%{_datadir}/applications/skype.desktop

install -d -m 0755 %buildroot%{instdir}
touch %buildroot%{instdir}/{skype.desktop,skype,skype.conf,LICENSE,README}

install -d -m 0755 %buildroot%{langdir}
while read line; do
touch %buildroot%{langdir}/skype_"$line"
done < %{SOURCE2}

install -d -m 0755 %buildroot%{instdir}/icons
install -d -m 0755 %buildroot%{_iconsdir}
touch %buildroot%{_iconsdir}/skype.png
for i in 16 32 48; do
touch %buildroot%{_iconsdir}/SkypeBlue_${i}x${i}.png
touch %buildroot%{instdir}/icons/SkypeBlue_${i}x${i}.png
done

install -d -m 0755 %buildroot%{avatardir}
while read line; do
touch %buildroot%{avatardir}/"$line"
done < %{SOURCE0}

install -d -m 0755 %buildroot%{sounddir}
while read line; do
touch %buildroot%{sounddir}/"$line"
done < %{SOURCE1}

echo "LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so %{instdir}/skype"\
 > %buildroot%{_bindir}/skype && chmod +x %buildroot%{_bindir}/skype

%post

tmpextdir=$(mktemp -d)
if ! [[ -d $tmpextdir ]]; then
echo "Failed to create temporary directory"
rm -r %{mytmp} 
exit 1
fi

%define tmpdir ${tmpextdir}/skype-%{version}

cd ${tmpextdir}
tar jxf %{mytmp}/skype-%{version}.tar.bz2

if ! [[ -d %{tmpdir} ]]; then
echo "Extracted file folder missing"
cd ..
rm -rf ${tmpextdir}
rm -r %{mytmp}
exit 1
fi


mkdir -p %{instdir}

cp -a %{tmpdir}/icons/* %{_iconsdir}
cp -a %{_iconsdir}/SkypeBlue_48x48.png %{_iconsdir}/skype.png
cp -a %{tmpdir}/skype.desktop %{_datadir}/applications/
mv %{tmpdir}/skype %{instdir}
mv %{tmpdir}/skype.desktop %{instdir}
mv %{tmpdir}/skype.conf %{instdir}
mv %{tmpdir}/LICENSE %{instdir}
mv %{tmpdir}/README %{instdir}
mv %{tmpdir}/avatars %{instdir}
mv %{tmpdir}/lang %{langdir}
mv %{tmpdir}/sounds %{sounddir}
mv %{tmpdir}/icons %{icondir}
rm -r %{tmpdir}
cd ..
rm -r ${tmpextdir}
rm -r %{mytmp}         

%clean

rm -rf $RPM_BUILD_ROOT

%files

%defattr(-,root,root)
%{_bindir}/skype

# If any extra files are added in install then 
# corresponding ghost files need to be added here
%ghost %{_iconsdir}/skype.png
%ghost %{_iconsdir}/SkypeBlue_*.png
%ghost %{_datadir}/applications/skype.desktop
%ghost %{instdir}

%changelog

* Sun Jun 12 2011 Barry Jackson <[email protected]> 2.2.0.35-7.mga1
- Added tests for failed directory creation, exiting with cleanup.
- Added note in %post.
- Removed resource option on launch command line as we use default.

* Sat Jun 11 2011 Barry Jackson <[email protected]> 2.2.0.35-6.mga1
- Added md5sum check on download and cleanup on fail.
- Downloads to /var/lib/get-skype - removed after install.
- Creates unique /tmp/tmp.xxxx dir for extraction of tar.
- Added versioning to .txt files.
- Added removal of all tmp directories after install.
- Corrected URL: 

* Thu Jun 9 2011 Barry Jackson <[email protected]> 2.2.0.35-5.mga1
- Bumped release to test update - no changes

* Thu Jun 9 2011 Barry Jackson <[email protected]> 2.2.0.35-4.mga1
- Moved installation to /usr/share instead of /opt
- Changed group and license
- Changed temporary dir
- Changed to wget for d/l

* Mon Jun 6 2011 Barry Jackson <[email protected]> 2.2.0.35-2.mga1
- Moved download to %pre to stop install if d/l fails

* Sun Jun 5 2011 Barry Jackson <[email protected]> 2.2.0.35-1.mga1
- Changed get-skype version to follow Skype version.
- Changed URL to directly download only correct version.
- A copy of the downloaded file is retained in /tmp/skype-%{version} to
- speed re-installation (unless you clean /tmp)

* Sat Jun 4 2011 Barry Jackson <[email protected]> 0.2.mga1
- Now all files are registered in rpm database.
- lang, avatar and sound filenames supplied in source files.

Reply via email to