The Open Source Swiss Army Knife

/unix/rpm/
/unix/rpm/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /unix   /rpm 
Permalink: rpmbuild.htm
Title: add
article options : please login   |  print view

building with rpm: making source packages and spec files and compiling source files

  1. old ways of building: old arguments before 2003
  2. new ways of building: rpmbuild
  3. making a spec file

old ways of building

    source packages (SRPMS)
  • rpm -i netdrivers-3.0-1.src.rpm
    this moves the src to /usr/src/redhat/SPECS/ and creates there the file netdrivers.spec
  • cd /usr/src/redhat
  • rpm -bb SPECS/netdrivers.spec
    this should build the binary version for the kernels, placing that in RPMS/.
  • rpm -i --force RPMS/i386/netdrivers-3.0-1.i386.rpm
    which installs the newly built package
  • and the following shows how to unpackage source from an rpm file without installing or compiling it using rpm commands.

    
      bash$ mkdir my_temp_build
      bash$ cd my_temp_build
      bash$ rpm2cpio gcc-*.src.rpm | cpio -dimv
      bash$ tar zxvf gcc*.tar.gz
      bash$ cd gcc-2.96
      bash$ ./configure
      bash$ make
    
    
  • rebuilding the rpm with different option (source: openssh.spec)
    # Reserve options to override askpass settings with:
    # rpm -ba|--rebuild --define 'skip_xxx 1'
    %{?skip_x11_askpass:%define no_x11_askpass 1}
    %{?skip_gnome_askpass:%define no_gnome_askpass 1}
    [root@www SPECS]# rpm -ba  openssh.spec | --rebuild --define 'skip_x11_askpas' openssh.spec
    -bash: --rebuild: command not found
    error: File /usr/src/redhat/SOURCES/openssh-3.5p1.tar.gz: No such file or directory
    

new ways: rpmbuild of building

  1. rpm --rebuilddb: fixes a corrupted databse used by the rpm program (just a note)
  2. rpmbuild {-ba|-bb|-bp|-bc|-bi|-bl|-bs} [rpmbuild-options] SPECFILE ...

    (from the info page)
     The  build  modes of rpm are now resident in the /usr/bin/rpmbuild exe-
           cutable. Although legacy compatibility provided  by  the  popt  aliases
           below  has been adequate, the compatibility is not perfect; hence build
           mode compatibility through popt aliases  is  being  removed  from  rpm.
           Install  the rpmbuild package, and see rpmbuild(8) for documentation of
           all the rpm build modes previously documented here in rpm(8).
    
           Add the following lines to /etc/popt if you wish to  continue  invoking
           rpmbuild from the rpm command line:
    
           rpm     exec --bp               rpmb -bp
           rpm     exec --bc               rpmb -bc
           rpm     exec --bi               rpmb -bi
           rpm     exec --bl               rpmb -bl
           rpm     exec --ba               rpmb -ba
           rpm     exec --bb               rpmb -bb
           rpm     exec --bs               rpmb -bs
    
    [root@www SPECS]# rpmbuild openssh.spec
    [root@www SPECS]# rpmbuild -bb openssh.spec (builds like rpm -bb)
    
    
  3. rpm --showrc -- >lists the /usr/lib/rpm/rpmrc file, file which sets the configuration features of rpm
  4. [root@www SPECS]# rpm -q --scripts openssh-server
    preinstall scriptlet (through /bin/sh):
    /usr/sbin/useradd -c "Privilege-separated SSH" -u 74 \
    -s /sbin/nologin -r -d /var/empty/sshd sshd 2> /dev/null || :
    postinstall scriptlet (through /bin/sh):
    /sbin/chkconfig --add sshd
    preuninstall scriptlet (through /bin/sh):
    if [ "$1" = 0 ]
    then
    /sbin/service sshd stop > /dev/null 2>&1 || :
    /sbin/chkconfig --del sshd
    fi
    postuninstall scriptlet (through /bin/sh):
    /sbin/service sshd condrestart > /dev/null 2>&1 || :
  5. another way to specify the prefix
     $ rpm -ba --define 'prefix /opt/rtems/binutils-2.13.2.1-gcc-
     3.2.1-newlib-1.11.0' --define 'gnat 0' --define 'gcj 0' 
     powerpc-rtems-gcc-3.2.1-newlib-1.11.0.spec
    

    actually, that doesn't work just edit /var/lib/macros ... including the one in the i686 direcotry
  6. defining config options to rpmbuild script
    Take the following example:
    
        rpmbuild --define 'config_options --with-gm=/opt/gm' --rebuild ...
    
    Note the single quotes after --define; --define only takes one
    argument.  That argument is later parsed by the specfile parser.
    Hence, you put both the key and value in a single shell argument
    enclosed in quotes.
    
    This is effectively the same as having the following line in your
    specfile:
    
        %define config_options --with-gm=/opt/gm
    
    So how is this useful, and how does this accomplish my above-stated
    
    

    making the spec file

    1. postun
    2. %define sshd_uid 74
    3. post

    postun

    source: openssh.spec

    %postun if [ $1 = 0 ]; then
          stop services and maybe do some cleanup
    fi

    post

    source: openssh.spec
    %post server
    /sbin/chkconfig --add sshd
    
    %postun server
    /sbin/service sshd condrestart > /dev/null 2>&1 || :
    

    Leave a Reply
    Your Name:     anonymous
    Your Email:
    Website:  
    Comments:

    The author will be notified of your reply.
    return to top