You will find bellow a spec file for building rpm packages (for Fedora, RedHat, CentOS, SUSE, etc)

How to use it:

Option 1
- drop the spec file in /usr/src/redhat/SPECS as anki.spec
- drop the anki source tarball in /usr/src/redhat/SOURCES
- edit the second line of the spec file and adjust the version number
- run rpmbuild -ba /usr/src/redhat/SPECS/anki.spec

Option 2: preferred method, for developers/maintainers
- please include the spec file into the tarball itself, into the root dir
- edit the second line of the spec file and adjust the version number
- the user should be able to generate the rpms directly from the tarball by issuing the command rpmbuild -ta <tarball>

Collect the rpms from /usr/src/redhat/RPMS/noarch and /usr/src/redhat/SRPMS

Notes:

Tested on Fedora 8 x86_64, all Fedora distros having the required packages should work.

Other rpm based distributions may require additional packages not in main repositories or renaming of the package names in the Requires: lines.

Spec file to create rpm packages:

# SET THIS ONE TO THE CURRENT ANKI VERSION
%define anki_current_version 0.9.6

# for Fedora:
# - you shouldn't need to change anything below

#####################################################################

%define debug_package %{nil}

%{expand: %%define pyver %(python -c 'import sys;print(sys.version[0:3])')}


#----------------------------------------------------------
Summary:        flashcard program for using space repetition learning
Name:           anki
Version:        %{anki_current_version}
Release:        1
Source:         http://ichi2.net/anki/download/anki-%{version}.tgz
URL:            http://ichi2.net/anki/
License:        GPL
Group:          Applications/Multimedia
Requires:       qt4, PyQt4
Requires:       python-sqlalchemy, python-simplejson, python-sqlite2
Requires:       numpy, python-matplotlib
Requires:       pygame
BuildRoot:      /var/tmp/%{name}-%{version}-root
BuildArch:      noarch

%description
Anki is a program designed to help you remember facts (such as words
and phrases in a foreign language) as easily, quickly and efficiently
as possible. Anki is based on a theory called spaced repetition.


#----------------------------------------------------------
%prep

RPM_BUILD_ROOT="/var/tmp/%{name}-%{version}-root"

%setup

%build

CFLAGS="${RPM_OPT_FLAGS}" python  setup.py build


#----------------------------------------------------------
%install

cd libanki
python setup.py install --root=${RPM_BUILD_ROOT} --record=installed_files
cd ..

python setup.py install --root=${RPM_BUILD_ROOT} --record=installed_files

python -O %{_libdir}/python%{pyver}/compileall.py \
       ${RPM_BUILD_ROOT}%{_libdir}/python%{pyver}/site-packages

desktop-file-install                                               \
       --dir ${RPM_BUILD_ROOT}/%{_datadir}/applnk/Edutainment      \
       anki.desktop

mkdir -p ${RPM_BUILD_ROOT}/%{_mandir}/man1
cp /usr/src/redhat/BUILD/anki-0.9.6/debian/anki.1 \
   ${RPM_BUILD_ROOT}/%{_mandir}/man1
gzip -f ${RPM_BUILD_ROOT}/%{_mandir}/man1/anki.1

# compile the filelist
# - call the python bytecompiler to figure out the *.pyc, *.pyo
#   (lives in /usr/lib, not %%{_libdir})
/usr/lib/rpm/brp-python-bytecompile
echo '%defattr(0644,root,root,0755)' > filelist
# - generate directory list
find ${RPM_BUILD_ROOT} -type d >> filelist
# - delete prefix
sed -i -e "s|${RPM_BUILD_ROOT}||" filelist
# - delete lines containing only system directories
sed -i -e 's|^/etc$||'                          filelist
sed -i -e 's|^/usr$||'                          filelist
sed -i -e 's|^/usr/bin$||'                      filelist
sed -i -e 's|^/usr/lib$||'                      filelist
sed -i -e 's|^/usr/lib/python%{pyver}$||'       filelist
sed -i -e 's|^/usr/lib/python%{pyver}/site-packages$||' filelist
sed -i -e 's|^/usr/share$||'                    filelist
sed -i -e 's|^/usr/share/man$||'                filelist
sed -i -e 's|^/usr/share/man/man1$||'           filelist
sed -i -e 's|^/usr/share/applnk$||'             filelist
sed -i -e 's|^/usr/share/applnk/Edutainment$||' filelist
sed -i -e 's|^/var$||'                          filelist
# - delete empty lines
sed -i -e '/^$/d' filelist
# - define the remaining as directories
sed -i -e 's|^/|%dir &|' filelist
# - find files
find ${RPM_BUILD_ROOT} -type f >> filelist
# - delete prefix
sed -i -e "s|${RPM_BUILD_ROOT}||" filelist
# - mark all /etc files as config
sed -i -e 's|^/etc|%config(noreplace) &|' filelist
# - define specific ownerships, modes
sed -i -e 's|^/usr/bin/anki$|%attr(0755,root,root) &|' filelist
# - find symlinks
find ${RPM_BUILD_ROOT} -type l >> filelist
# - delete prefix
sed -i -e "s|${RPM_BUILD_ROOT}||" filelist
# - add doc files
echo '%doc COPYING CREDITS ChangeLog' >> filelist
echo '%doc README README.development README.translating' >> filelist
# - remove the *.pyc, *.pyo files created by the bytecompiler
#   (they will be recreated)
find ${RPM_BUILD_ROOT} -name '*.pyc' -exec rm \{} \;
find ${RPM_BUILD_ROOT} -name '*.pyo' -exec rm \{} \;


#----------------------------------------------------------
%clean
[ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT}


#----------------------------------------------------------
%files -f filelist


#----------------------------------------------------------
%changelog
* Tue Jul 15 2008 Rurik Christiansen <rurikc@gmail.UseYourMind.com>
- first spec

AnkiSpecFile (last edited 2008-07-15 05:57:08 by )