
#include "bacula_template.inc" title="RPM Packaging" num=22

<h1>Bacula<sup><small>&reg;</small></sup> - RPM Packaging FAQ</h1>

<ol>
        <li><a href="#faq1">How do I build Bacula for platform xxx?</a></li>
        <li><a href="#faq2">How do I control which database support gets built?</a></li>
        <li><a href="#faq3">What other defines are used?</a></li>
        <li><a href="#faq4">I'm getting errors about not having permission when I try
        to build the packages. Do I need to be root?</a></li>
        <li><a href="#faq5">I'm building my own rpms but on all platforms and compiles
        I get an unresolved dependancy for something called /usr/afsws/bin/pagsh.</a></li>
</ol>

<h3>Answers</h3>

<ol>
        <li><a name="faq1"><b>How do I build Bacula for platform xxx?</b></a><br><br>
        The bacula spec file contains defines to build for several platforms:
        RedHat 7.x (rh7), RedHat 8.0 (rh8), RedHat 9 (rh9), Fedora Core 1 (fc1),
        and Whitebox Enterprise Linux 3.0 (wb3). The package build is controlled
        by a define set at the beginning of the file. These defines basically just
        control the dependancy information that gets coded into the finished rpm
        package. So while you could technically build a package without defining a
        platform, or with an incorrect platform, and have it install and run it
        would not contain correct dependancy information for the rpm database.<br><br>
        The platform define may be edited in the spec file directly (by default all
        defines are set to 0 or "not set"). For example, to build the RedHat 7.x
        package find the line in the spec file which reads
        <pre>
        %define rh7 0
        </pre>
        and edit it to read
        <pre>
        %define rh7 1
        </pre>
        Alternately you may pass the define on the command line when calling rpmbuild:    
        <pre>
        rpmbuild -ba --define "build_rh7 1" bacula.spec
        rpmbuild --rebuild --define build_rh7 1" bacula-x.x.x-x.src.rpm        
        </pre>
        </li>

        <li><a name="faq2"><b>How do I control which database support gets built?</b></a><br><br>
        By default sqlite support will be compiled statically from the depkgs and the
        bacula-sqlite package will be produced. To get the MySQL package and support either
        set the
        <pre>
        %define mysql 0
        </pre>
        to
        <pre>
        %define mysql 1           
        </pre>
        in the spec file directly or pass it to rpmbuild on the command line:    
        <pre>
        rpmbuild -ba --define "build_rh7 1" --define "build_mysql 1" bacula.spec        
        </pre>
        </li>

        <li><a name="faq3"><b>What other defines are used?</b></a><br><br>
        Two other building defines of note are the depkgs_version and tomsrtbt identifiers. These
        two defines are set with each release and must match the version of those sources that are
        being used to build the packages. You would not ordinarily need to edit these.
        </li>

        <li><a name="faq4"><b>I'm getting errors about not having permission when I try
        to build the packages. Do I need to be root?</b></a><br><br>
        No, you do not need to be root and, in fact, it is better practice to build rpm packages
        as a non-root user. Bacula packages are designed to be built by a regular user but you must
        make a few changes on your system to do this. If you are building on your own system then
        the simplest method is to add write permissions for all to the build directory
        (/usr/src/redhat/). To accomplish this execute the following command as root:    
        <pre>
        chmod -R 777 /usr/src/redhat
        </pre>
        If you are working on a shared system where you can not use the method above then you need to
        recreate the /usr/src/redhat directory tree with all of it's subdirectories inside your home
        directory. Then create a file named 
        <code>.rpmmacros</code> in your home directory (or edit
        the file if it already exists) and add the following line:
        <pre>
        %_topdir /home/myuser/redhat       
        </pre>
        </li>

        <li><a name="faq5"><b>I'm building my own rpms but on all platforms and compiles
        I get an unresolved dependancy for something called /usr/afsws/bin/pagsh.</b></a><br><br>
        This is a shell from the OpenAFS (Andrew File System). If you are seeing this then you
        chose to include the docs/examples directory in your package. One of the example scripts
        in this directory is a pagsh script. Rpmbuild, when scanning for dependancies, looks at
        the shebang line of all packaged scripts in addition to checking shared libraries. To avoid
        this do not package the examples directory.
        </li>
</ol>
<page_prev name="Using Bacula to Improve Security" url="verify.html">
<page_next name="Restoring Files with a Bootstrap File" url="bootstrap.html">
