Subject: Continued Hacktivity: Generic Fortune RPM Spec

From: Shlomi Fish <[email-masked]>
Date: Sun, 21 Jul 2002 17:34:57 +0300 (IDT)

It's included below with Tzafrir's input taken into account. Enjoy!

Regards,

	Shlomi Fish

# Base Macros which need to be set
%define packageprefix fortune-mod-fortunes
%define packagebase shlomif
%define archivebase fortunes-shlomif
%define version 0.2.4
%define fortunefilesprefix shlomif-

# Derived Macros
%define name %{packageprefix}-%{packagebase}
%define archivewithver %{archivebase}-%{version}
%define archivefull %{archivewithver}.tar.gz

%define fortunedatadir %{_datadir}/games/fortunes

Name: %{name}
Version: %{version}
Release: 7
Copyright: Free to use but restricted
Group: Toys

Source: http://vipe.technion.ac.il/~shlomif/humour/fortunes/%{archivefull}
BuildArch: noarch
Buildroot: %{_tmppath}/%{name}-root
URL: http://vipe.technion.ac.il/~shlomif/humour/fortunes/
Serial: 1
BuildRequires: fortune-mod
Requires: fortune-mod
Summary: Fortune Cookies Collection by Shlomi Fish

%description
This package contains several collections of fortune cookies by Shlomi Fish.
Namely, a collection of his own quotes, some of his favourites from various
sources; a collection of excerpts from the T.V. Show Friends; the Rules of
Open Source Programming, and a collection of reasons why there is no IGLU
cabal.

%prep
%setup -n %{archivewithver}
cat <<EOF > README
This is a group of fortune files collected by Shlomi Fish.
EOF

%build

myprefix="%{fortunefilesprefix}"
rm -f *.dat
ls | grep -v "\\." | grep -v "[A-Z]" | \
    ( while read T ; do        \
        mv "$T" "${myprefix}$T"  ;     \
        /usr/sbin/strfile "${myprefix}$T" "${myprefix}$T.dat"  ;    \
     done )

%install

rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{fortunedatadir}
for I in *.dat ; do
    cp $I "`echo "$I" | sed 's/\.dat$//'`" \
        $RPM_BUILD_ROOT/%{fortunedatadir}
done

%files
%defattr(-,root,root)
%{fortunedatadir}/*
%doc README

%clean
rm -rf $RPM_BUILD_ROOT

%changelog
* Sun Jul 21 2002 Shlomi Fish <[email-masked]> 0.2.4-7
- Applied Tzafrir's Suggestions:
- Created the macro %{fortunedatadir} to specify the locations of the files
- Broke up long lines.
- Added fortune-mod to the BuildRequires
- Made the script /bin/sh compatible
- Changed a mkdir loop to mkdir -p
- Removed the empty %post and %postun targets
- Added a README file.

* Fri May 31 2002 Shlomi Fish <[email-masked]> 0.2.2-2
- Added macros all over the place

* Thu May 30 2002 Shlomi Fish <[email-masked]> 0.2.2-1
- first release - testing.

----------------------------------------------------------------------
Shlomi Fish        [email-masked]
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"