Programming‎ > ‎

Autoconf/RPM

GNU Autoconf and RPM Tips

Here are GNU autoconf and RPM tips.

Index


How can I change the install directory (different from the configured one)?

   
  $ make prefix=$newprefix install
  

The convenience of configured Makefile is that it contains all these definitions and you can replace any of them by the above method. Some of these definitions are:


  prefix = 
  ...
  exec_prefix = $(prefix)
  bindir = ${exec_prefix}/bins
  bindir = ${exec_prefix}/sbinlib
  execdir = ${exec_prefix}/lib
  execdatadir = ${prefix}/share
  sysconfdir = ${prefix}/etc
  sharedstatedir = ${prefix}/com
  localstatedir = ${prefix}/var
  libdir = ${exec_prefix}/lib
  infodir = ${prefix}/info
  mandir = ${prefix}/man
  includedir = ${prefix}/include
  oldincludedir = /usr/include
  pkgdatadir = $(datadir)/freesurfer
  pkglibdir = $(libdir)/freesurfer
  pkgincludedir = $(includedir)/freesurferCCCPPCXX
  

Top


How can I fix the error 'can't locate object method "path" via package "Request"'?

The exact error message is the following:


  Can't locate object method "path" via package "Request" at /usr/share/autoconf/Autom4te/C4che.pm 
  line 69, <GEN1> 
  line 214.aclocal: autom4te failed with exit status: 1
  

It is really weird error message. It turned out that this is telling the fact that the cached one in $project/autom4te.cache is out of sync. What you should do is to remove autom4te.cachedirectory.

Top


How should I write the spec file for RPM?

Here is the sample spec file for shared lib. The trick is to use %configure which will use the default system installation, which defines bindir, includedir, libdir, sysconfdir, datadir, mandir, infodir. You can use these directories for %files section as


  %{_bindir}/*  %{_includedir}/*  
  %{_libdir}/*
  

Another trick is to have DESTDIR at %install section so that even though build is assuming the standard directories, the creation of rpm is done at $RPM_BUILD_DIR.


  Summary: 
  test hello lib programName: 
  hellolibVersion: 1.0
  Release: 1
  License: 
  GPLGroup: 
  Development/ToolsURL: http://www.nmr.mgh.harvard.edu/~tosaSource0: 
  %{name}-%{version}.tar.gz
  BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
  Prefix:/usr%description%prep%setup -q%build%configuremake%installrm -rf $RPM_BUILD_ROOT
  make DESTDIR="$RPM_BUILD_ROOT" install%cleanrm 
  -rf $RPM_BUILD_ROOT%files%defattr(-,root,root,-)%doc%{_libdir}/libhello*%changelog* 
  Wed Nov 10 2004 Yasunari Tosa - Initial build.
  

Top


How can I create a patch file?

When you produce a pathc file, you create two directories: the first one to be the original sourcetree and the second one to be your edited tree. Then create a unified diff formattedfile:

  
  diff -ruNbB orig mine > patch.txt
  

where -b (ignore white space) -B (ignore blank lines) -N (handle new file) -r recursive. Here is more explanantion: devchannel.

In order to apply the patch, go into the orig directory and then do:

  
  cd orig  
  patch -p1 < ../patch.txt
  

Top


How can I remove the reference in RPM database?

I happened to delete the software package directory. rpm -qa still remembers it, but when I do "rpm -e package", it complains about not able to find a script.What should I do?

   
  # rpm -e --noscripts package
  

Top


How can I create my own RPM package?

The pain in opensource development is that the documentation becomes outdated quickly. Even though the book on RPM is available in pdf form, it is out of date. Here is the web site to get the most recent information on RPM: http://www.rpm.org. The book Maximum RPM Sams in softcover (450 pages - ISBN: 0672311054) can be had as pdf format http://www.rpm.org/local/maximum-rpm.ps.gz. This book covers all aspects of RPM. Unfortunately some items (important ones) are outdated. Matthias Saou wrote a very good article on how-to at http://www.rpm.org/howto/thefight. Here I just list the minimum items which is differnt from the book. Another site Mandrake RPM HOWTO is kept updated http://qa.mandrakesoft.com/twiki/bin/view/Main/RpmHowTo

First of all, you can build your own RPM as a user, not root. In order to do this, you create ~/.rpmmacros, which has the following line:

  
  %_topdir     /home/tosa/RPM
  

Note that .rpmrc is obsolte. You use _topdir, not topdir

You create subdirectories under this $_topdir, SPECS, SOURCES, RPMS, SRPMS, BUILD. SOURCES will have *.tar.gz files. BUILD will have the expanded source. RPMS/$arch will have the built RPMs. SRPMS will have source RPMs.

In order to build rpm, you use rpmbuild (not rpm).In order to specify arch, you use --target=CPU-vendor-OS where CPU can be i686, vendor can be redhat, OS can be linux. (--buildarch, --buildos are obsolte).

If you use emacs to create a spec file, you automatically get the template(the following is what I get when I tried to create test.spec) :


  Summary: 
  Name: 
  testVersion: 
  Release: 1
  License: 
  Group: 
  URL: 
  Source0: %{name}-%{version}.tar.gz
  BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot%description%prep%setup 
    -q%build%installrm -rf $RPM_BUILD_ROOT%cleanrm 
	-rf $RPM_BUILD_ROOT%files%defattr(-,root,root,-)%doc%changelog* 
	Tue Aug 10 2004 Yasunari Tosa  - Initial build.
  

In order to create file list (you put after %doc), you just do rpmbuild -bi specfile. You get a list of files which are installed and thus you just copy them into the spec file.

Top

Home

Updated November 26th,2004