How to build RPM packages of Tupi

First at all, I want to share with you the resources I was reading before starting my adventure.

A very short version:
http://www.ibm.com/developerworks/library/l-rpm1/

A long version:
http://fedoraproject.org/wiki/PackageMaintainers/CreatingPackageHowTo

Advices and good hints:
http://fedoraproject.org/wiki/Packaging:Guidelines

This experience was done on Fedora 14, following these steps:

- Install the set of tools required to build RPM packages, as root type:

# yum groupinstall "Development Tools"
# yum install rpmdevtools

- For security reasons, RPM installers shouldn't be built by root, so try another user. In my case, the user "tupi":

# /usr/sbin/useradd tupi

- Log in as user "tupi":

# su - tupi

- Set a local environment to build the RPM package:

% rpmdev-setuptree

A new directory called "rpmbuild" will be created following this structure:

/home/tupi/rpmbuild
/home/tupi/rpmbuild/BUILDROOT
/home/tupi/rpmbuild/SRPMS
/home/tupi/rpmbuild/SPECS
/home/tupi/rpmbuild/RPMS
/home/tupi/rpmbuild/SOURCES
/home/tupi/rpmbuild/BUILD

- Get the Tupi's source code and compress the directory:

% git clone http://git.gitorious.org/tupi/tupi.git
% rm -rf tupi/.git/
% mv tupi tupi-0.1
% tar cvfz tupi-0.1-5.tar.gz tupi-0.1

- Move the compressed file into the folder "SOURCES":

% mv tupi-0.1-5.tar.gz rpmbuild/SOURCES

- To create the RPM installer, it's necessary to write a configuration file with extension ".spec", in this case "tupi.spec". After some failed tries, I finally got a functional version.
Make sure you copy this file into the directory "SPECS":

% cp tupi.spec rpmbuild/SPECS

- Get in the directory "rpmbuild" and start the packaging process:

% cd rpmbuild
% rpmbuild -v -bb --clean SPECS/tupi.spec

If everything goes well, congratulations! you will find the RPM installer into the folder "RPMS":

% ls /home/tupi/rpmbuild/RPMS/i686
    tupi-0.1-5.i686.rpm

If you want to test it, as root type:
# cd /home/tupi/rpmbuild/RPMS/i686
# rpm -i tupi-0.1-5.i686.rpm

A short-cut of Tupi will appear in the Graphics section of your Applications menu.

In the case of Fedora 14, I had to run this command additionally, due to SELinux restrictions:

# chcon -t execmem_exec_t '/usr/bin/tupi.bin'

Note: If you update the Tupi package from Fedora 14, it's very possible that you get the next message when you try to run Tupi:
/usr/bin/tupi.bin: error while loading shared libraries: libxvidcore.so.4.2: cannot enable executable stack as shared object requires: Permission denied

To resolve this problem, run these commands as root:
# execstack -c /usr/lib/libxvidcore.so.4.2
# execstack -c /usr/lib/libmp3lame.so.0