Mailinglist Archive: opensuse (3378 mails)

< Previous Next >
Re: Could someone who knows how to build RPMs/write .spec files please review this?
  • From: "S.Toms" <smotrs@xxxxxxxxxxxxxx>
  • Date: Thu, 11 Apr 2002 18:54:07 -0700 (PDT)
  • Message-id: <Pine.LNX.4.33.0204111840390.2688-100000@xxxxxxxxxxxxxxxxxxx>
On Thu, 11 Apr 2002, JW wrote:

j> Hey,
j>
j> I have "SusEified" the Kopete Instant Messanger RPM, and it builds and
j> runs on SuSE 7.3 Pro w/ KDE3 update.
j>
j> Yay! My first working RPM conversion :-)
j>
j> Before I send it to the Kopete developers and SuSE contrib FTP, I'd
j> like someone who has experience with spec files to review mine, and see
j> if there's anything wrong with it.
j>
j> TiA!
j>
j> Entire kopete.spec file included inline, below
j>
j> --------------------- BEGIN kopete.spec ----------------------
j>
j> #
j> # spec file for package kopete (Version 0.3)
j> #

<snipped a bit>

j>
j> %install
j> rm -rf %{buildroot}
j> make prefix=%{buildroot}/opt/kde3 exec_prefix=%{buildroot}/opt/kde3 bindir=%{buildroot}/opt/kde3/bin sbindir=%{buildroot}/opt/kde3/sbin sysconfdir=%{buildroot}/etc datadir=%{buildroot}/opt/kde3/share/apps/kopete includedir=%{buildroot}/opt/kde3/include libdir=%{buildroot}/opt/kde3/lib libexecdir=%{buildroot}/opt/kde3/libexec localstatedir=%{buildroot}/var sharedstatedir=%{buildroot}/usr/com mandir=%{buildroot}/usr/share/man infodir=%{buildroot}/usr/share/info install
j>

For readabilities sake, I like to wrap long lines like this in the spec
file, like the following

make prefix=%{buildroot}/opt/kde3 \
exec_prefix=%{buildroot}/opt/kde3 \
bindir=%{buildroot}/opt/kde3/bin \
sbindir=%{buildroot}/opt/kde3/sbin \
sysconfdir=%{buildroot}/etc \
datadir=%{buildroot}/opt/kde3/share/apps/kopete \
includedir=%{buildroot}/opt/kde3/include \
libdir=%{buildroot}/opt/kde3/lib
libexecdir=%{buildroot}/opt/kde3/libexec \
localstatedir=%{buildroot}/var \
sharedstatedir=%{buildroot}/usr/com \
mandir=%{buildroot}/usr/share/man \
infodir=%{buildroot}/usr/share/info \
install


This gives it a list like look which can make it easier to spot
something you may have missed. Looks pretty good though


j>

I also like to remove the build directories upon completion with the
following

%clean
test -d $RPM_BUILD_ROOT && rm -rf $RPM_BUILD_ROOT
test -d $RPM_BUILD_DIR/%{name}-%{version} && \
rm -rf $RPM_BUILD_DIR/%{name}-%{version}


There's no real reason to keep them around. You could also do a check
within the %install section just to be sure your not working with old
source like so

test -d $RPM_BUILD_ROOT && rm -rf $RPM_BUILD_ROOT

this has the benefit of erasing an existing build directory that may have
been left behind from an aborted build attempt. Allowing an execution of
rpm -ba kopete.spec

to start from scratch thus verifying that everything compiles correctly
from scratch.
Again, these arn't necessary, but I thought I would share. :)

j> %post -p /sbin/ldconfig
j>
j> %postun -p /sbin/ldconfig
j>
j>
j> %files
j>
j> %defattr(-, root, root)
j>
j> %doc AUTHORS COPYING ChangeLog NEWS README README.emoticons
j> /opt/kde3
j>
j> %changelog -n kopete
j> * Sat Apr 6 2002 Simon Perreault
j> - Initial RPM release.
j>
j>
j>
j> --------------------- END kopete.spec ----------------------
j>

--

S.Toms - smotrs at mindspring.com - www.mindspring.com/~smotrs
SuSE Linux v7.3+ - Kernel 2.4.10-4GB




< Previous Next >
References