Sure, why not. It's not that hard.
If the system is unchanged rpm's are built in the /usr/src/redhat tree:
BUILD -> here are rpm's unpacked, configured and compiled
RPMS -> packaged rpm's are stored here
SOURCES -> tarballs and patches
SPECS -> the .spec files with which to script building an rpm
SRPMS -> packaged rpm's are stored here (tarball+patches+spec file)
BTW, before I continue, some tarballs come with a spec file (zcat tarball.tgz|tar -t|grep -ie "\.spec$"). Then you can build it straight away with "rpm -tb app.spec" and forget the rest below.
OK. You already know you will have to install the dependencies like development libraries. Next grab the last .src.rpm (or the spec file, get the latest tarball separately) and install/place it. This will leave you with the tarball (+patches if any) in SOURCES and the .spec file in SPECS. Unpack the tarball manually, apply patches, then configure and compile it to see if there are no errors. If there aren't any continue looking at the .spec file. Here is a crude example:
Code:
%define name app
%define ver 0.1
%define rel 1
Summary: %{name}
Name: %name
Version: %ver
Release: %rel
Copyright: GPL
Group: Console/Applications
URL: http://www.One.com/~Some/app.html
Source: %{name}-%{ver}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}
Provides: %{name}
%description
This is a useful app.
%prep
%setup -q
%build
./configure --prefix=/usr/local
make
%install
rm -rf $RPM_BUILD_ROOT
make prefix=$RPM_BUILD_ROOT%{prefix} install-strip
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog NEWS README doc/*
%{config}/etc/app.conf
%{prefix}/sbin/app
%changelog
* Sat Sep 11 1999 Some One <Some@One.com>
- First rpm
Check the topmost defines so the %{name} and %{ver} is in sync with the version of your tarball, else rpm can't find and unpack it. Usually you don't have to tweak the rest above %prep and %setup unless you got patching to do. Under %build you'll find the commands you previously ran on the commandline to get the package to build: replace 'em here if necessary. Now try "rpm -bb app.spec" (bb=build only binary rpm) and see if it will build. If it fails the commands can be seen in tmpfiles in the %{_tmppath} (see: rpmbuild --showrc|grep -ie topdir). Post any errors here and we'll see.
This looks like a lot, but it isn't. And you're right, when you got the spec file right for one rpm you usually don't have to tweak much afterwards.
* If you think you will want to build more rpm's have a look at this IBM developerWorks doc
Packaging software with RPM, Part 2: Building without root. Because if you keep building rpm's as root account user you will probably fsck up one time polluting your system.