Rpmbuild
From Christoph's Personal Wiki
Revision as of 21:46, 11 February 2010 by Christoph (Talk | contribs) (New page: '''rpmbuild''' (aka '''rpm-build''') is a series of scripts and executable programs that are used to build packages using RPM. ==Example usage== ''Note: In the fol...)
rpmbuild (aka rpm-build) is a series of scripts and executable programs that are used to build packages using RPM.
Example usage
Note: In the following examples, I will use an actual build I did for the latest version of Raster3D.
As an regular user (not root) create a directory tree based on ~/rpmbuild:
cd mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} echo '%-topdir %(echo $HOME)/rpmbuild' > .rpmmacros
- Download and unpack the latest tarball of Raster3D:
cd ~/rpmbuild/SOURCES wget http://skuld.bmsc.washington.edu/raster3d/Raster3D_2.7d.tar.gz
- Make necessary changes to spec file, then execute:
rpmbuild -ba raster3d-2.9.spec
Example spec file
Note: This is a real spec file, used in building the Raster3D RPM.
Summary: Raster3D photorealistic molecular graphics package Name: Raster3D Version: 2.9 Release: 1 %define r3dver %{name}_%{version} License: Source freely available, redistribution restricted Source: http://www.bmsc.washington.edu/raster3d/%{name}_%{version}.tar.gz URL: http://www.bmsc.washington.edu/raster3d Packager: Ethan A Merritt Group: Graphics BuildRoot:%{_tmppath}/%{name}-%{version}-buildroot #BuildRequires: libpng-devel zlib-devel libjpeg-devel libtiff-devel # # You may or may not want the following definitions %define _prefix /usr/local %define _bindir %{_prefix}/bin %define _mandir %{_prefix}/man %define _datadir %{_prefix}/share %description The Raster3D molecular graphics package consists of a core rendering program and a number of ancillary programs that produce input files for rendering from PDB (Protein Data Bank) files of atomic coordinates. Raster3D can also render images composed using other programs such as Molscript or XtalView. Raster3D uses a fast Z-buffer algorithm to produce high quality pixel images featuring one shadowing light source, additional non-shadowing light sources, specular highlighting, transparency, and Phong shaded surfaces. Output is to a pixel image with 24 bits of color information per pixel. Raster3D does not depend on graphics hardware. Program reference and requested citation: Merritt & Bacon (1997) Meth. Enzymol. 277, 505-524. %prep %setup -q -n %{r3dver} %build make clean if [ -x $PGI/linux86/bin/pgf77 ]; then make linux-pgf77 make all FFLAGS='-O -Munroll -tp px' PLIBS='/usr/lib/libpng.a' elif [ -x /usr/bin/gfortran ]; then make linux-gfortran make all LDFLAGS="-static -ljbig" else make linux make all FFLAGS="$RPM_OPT_FLAGS" CFLAGS="$RPM_OPT_FLAGS" fi # Changing R3D_LIB grep -v R3D_LIB Raster3D.csh > Raster3D.csh.$$ echo "setenv R3D_LIB %{_datadir}/Raster3D/materials" >> Raster3D.csh.$$ mv Raster3D.csh.$$ Raster3D.csh grep -v R3D_LIB Raster3D.sh > Raster3D.sh.$$ echo "export R3D_LIB=%{_datadir}/Raster3D/materials" >> Raster3D.sh.$$ mv Raster3D.sh.$$ Raster3D.sh %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{_datadir} mkdir -p $RPM_BUILD_ROOT%{_mandir} mkdir -p $RPM_BUILD_ROOT%{_bindir} make install prefix=$RPM_BUILD_ROOT%{_prefix} \ datadir=$RPM_BUILD_ROOT%{_datadir}/Raster3D/materials \ mandir=$RPM_BUILD_ROOT%{_mandir}/manl mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/profile.d install -m755 Raster3D.{csh,sh} $RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/ %clean rm -rf $RPM_BUILD_ROOT %files %defattr (-,root,root) %doc README CHANGELOG BUGS doc/R3D_manual.pdf VERSION %{_bindir}/avs2ps %{_bindir}/balls %{_bindir}/label3d %{_bindir}/rastep %{_bindir}/render %{_bindir}/ribbon %{_bindir}/rings3d %{_bindir}/rods %{_bindir}/normal3d %{_bindir}/stereo3d %{_mandir}/manl/avs2ps.l %{_mandir}/manl/balls.l %{_mandir}/manl/label3d.l %{_mandir}/manl/normal3d.l %{_mandir}/manl/r3d_objects.l %{_mandir}/manl/r3dtops.l %{_mandir}/manl/rastep.l %{_mandir}/manl/raster3d.l %{_mandir}/manl/render.l %{_mandir}/manl/ribbon.l %{_mandir}/manl/rods.l %{_mandir}/manl/stereo3d.l %{_datadir}/Raster3D %{_sysconfdir}/profile.d/Raster3D.csh %{_sysconfdir}/profile.d/Raster3D.sh %post MGK= if [ -a /usr/lib/ImageMagick/config/delegates.mgk ]; then MGK="/usr/lib/ImageMagick/config/delegates.mgk" elif [ -a /usr/X11R6/share/ImageMagick/delegates.mgk ]; then MGK="/usr/X11R6/share/ImageMagick/delegates.mgk" elif [ -a /usr/lib/ImageMagick/delegates.mgk ]; then MGK="/usr/lib/ImageMagick/delegates.mgk" fi OLD="# Raster3D 2.6 \nr3d=> \nrender -tiff %o < %i" XML=" <delegate decode=\"r3d\" command='render -png \"%o\"<\"%i\"' />" if [ -n "$MGK" ]; then if grep -q "xml" $MGK; then if ! grep -q "r3d" $MGK; then cp -f $MGK /tmp/delegates.bak.$$ sed "/<\/delegatemap>/{x;s!^!$XML!;G;}" $MGK > /tmp/delegates.mgk.$$ cp -f /tmp/delegates.mgk.$$ $MGK rm -f /tmp/delegates.mgk.$$ fi else if grep -q "r3d" $MGK; then echo -e $OLD >> $MGK fi fi fi %postun MGK= if [ -a /usr/lib/ImageMagick/config/delegates.mgk ]; then MGK="/usr/lib/ImageMagick/config/delegates.mgk" elif [ -a /usr/X11R6/share/ImageMagick/delegates.mgk ]; then MGK="/usr/X11R6/share/ImageMagick/delegates.mgk" elif [ -a /usr/lib/ImageMagick/delegates.mgk ]; then MGK="/usr/lib/ImageMagick/delegates.mgk" fi if [ -n "$MGK" ]; then grep -v r3d $MGK > /tmp/delegates.mgk.$$ cp -f /tmp/delegates.mgk.$$ $MGK rm -f /tmp/delegates.mgk.$$ fi %changelog * Thu Jan 21 2010 Christoph Champ - changed "mkdirhier" to "mkdir -p"