Re: Newbie trying to build a binary RPM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Frank W. Miller wrote:
> Here's my current spec file:
> 
> Summary: A SIP-based softphone for the Linux Operating System
> Name: sip
> Version: 0.9.1
> Release: 1
> Copyright: Free for non-commercial use
> Group: Applications/Communications
> Source: %{name}-%{version}.tgz

Good so far.  But add this line:

  BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot

_tmppath will be something like /var/tmp and the others follow to
create a path such as /var/tmp/sip-0.9.1-1-buildroot.  This is where
you will create an image to package for the %files section.  The
actual name is not extremely critical and you will see variations.

> %description

Fine.

> %prep
> %setup

If you change '%setup' to be '%setup -q' it will produce less verbose
output at a time when it is very unlikely to fail.  When producing
many builds this is often the preferred mode because otherwise huge
logs are produced that are basically low in useful content.  You only
have two lines but on packages with hundreds of files this is a big
deal.

  %setup -q

> %build

Your build script is empty.  Why have it at all?  Delete that line.
It is not needed.  The normal thing in rpms is to compile the program
in the build section.  Strongly recommended.  But it is not required.
If this is for your own personal use then okay.

> %install
> install -o 0 -g 0 -s -v -m 755 sip /usr/local/bin/sip
> install -o 0 -g 0 -v -m 644 ring.wav /etc/sip/ring.wav

This script is run during package build time, not during package
install time.  Therefore you do not install to /usr/local or /etc or
anyplace else in the real system.  Instead install into the buildroot.

This also enables you to build as a non-root user.  If you were really
installet in /etc you would need to be root to build the rpm.  That is
not good.  One day you will be debugging a script and as root instead
of doing 'rm -rf /etc/sip' you will have 'rm -rf /etc /sip' and if
running as a non-root user no harm done.  But if running as root it
leaves the system in a bad state.

The standard method is to use $RPM_BUILD_ROOT to access the BuildRoot:
location specified in the header.

  %install
  install -o 0 -g 0 -s -v -m 755 sip $RPM_BUILD_ROOT/usr/local/bin/sip
  install -o 0 -g 0 -v -m 644 ring.wav $RPM_BUILD_ROOT/etc/sip/ring.wav

Personally, if I am going to build an rpm package and install it on
the system then it does not go into /usr/local/bin and instead goes
into /usr/bin.  Especially if you are going to use /etc then you
should use /usr/bin.  There are several macros to use in this case.

  %install
  rm -rf $RPM_BUILD_ROOT
  install -o 0 -g 0 -s -v -m 755 sip $RPM_BUILD_ROOT%{_bindir}/sip
  install -o 0 -g 0 -v -m 644 ring.wav $RPM_BUILD_ROOT%{_sysconfdir}/sip/ring.wav

The above assumes that _sysconfdir is configured to be /etc.  This has
some variance on different systems so YMMV.  If you are on a system
with _sysconfdir /usr/etc you may want to change the system
configuration.  But _bindir should be good regardless.

Add this section:

  %clean
  rm -rf $RPM_BUILD_ROOT

> %files
> /usr/local/bin/sip
> /etc/sip/ring.wav

  %files
  %defattr(-,root,root)
  %{_bindir}/sip
  %{_sysconfdir}/sip/ring.wav

Hope that helps,
Bob


[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux