improve description for building rpms
[openafs-wiki.git] / AFSLore / HowToBuildOpenAFSFromSource.mdwn
index a4009dd..0d76ee0 100644 (file)
-This is a guide on how to build [[OpenAFS]] from source code. Note that [[OpenAFS]] pre-built binaries are available on the [[OpenAFS]] site and are available as prebuilt packages for many platforms. These instructions may be useful for you if you need to build [[OpenAFS]] from source.
+This page describes how to build OpenAFS binaries from source code.
+The information is specific to unix-like systems. See the
+README-WINDOWS file in the root of the OpenAFS source code tree for
+instructions and software needed to build OpenAFS on Microsoft Windows.
+
+Unless otherwise noted, the information on this page is for version 1.6.x
+(available as pre-release 3 at the time of this writing).
+
+## Getting Started
+
+The following shows how to download source code tarballs and build the
+OpenAFS binaries:
+
+    $ wget http://openafs.org/dl/openafs/<version>/openafs-<version>-src.tar.bz2
+    $ wget http://openafs.org/dl/openafs/<version>/openafs-<version>-doc.tar.bz2
+    $ tar xjf openafs-<version>-src.tar.bz2 
+    $ tar xjf openafs-<version>-doc.tar.bz2 
+    $ cd openafs-<version>
+    $ ./configure
+    $ make
+
+See <http://openafs.org/dl/openafs> for available versions.
+
+The following shows how to do a git checkout and build the OpenAFS binaries,
+
+    $ git clone git://git.openafs.org/openafs.git
+    $ cd openafs
+    $ git checkout <branch-or-tag>
+    $ ./regen.sh
+    $ ./configure
+    $ make
+
+You will usually want to specify configure options. For example, to enable the
+traditional Transarc/IBM AFS installation paths, run configure with the
+--enable-transarc-paths option. (Read on for more information about configure
+options.)
+
+    $ ./configure --enable-transarc-paths $ make
+    $ make
+    $ make dest 
+
+See the end of this page for instructions on how to build RPM packages.
+
+## Build OpenAFS 
+
+Building and packaging OpenAFS is not difficult on current unix-like
+systems. A small number of fairly common libraries and tools are required. The
+kernel headers and a compiler capable of building a kernel module is needed to
+build the OpenAFS kernel module (used by the cache manager and for
+inode-backend fileservers.) The gnu autoconf and automake tools are used to
+configure the build system, so should be familiar to most people accustomed to
+building binaries on unix-like systems.
+
+Begin by verifying you have the prerequisite tools and libraries installed on your
+build host. These are listed in the next section. You will need to obtain the
+OpenAFS source code, either by downloading a release tar file, or by checking
+out a version from the git repository.
+
+See the README file for details on building OpenAFS and platform specific
+notes. See src/SOURCE-MAP for a brief description of each source code component.
+
+A script called regen.sh is used to build the configure script and to
+generate the man page documentation from perl pod formatted files.
+
+The configure sets up the build system for your platform. Configure will
+attempt to detect your platform type and capabilities. Configure will generate
+the makefiles using automake. You may need to specify configure options to
+enable certain compile-time features. Run ./configure --help to see a
+complete list of the available configure options.
+
+After a successful run of configure, run make in the top level directory to
+build all the client and server OpenAFS binaries. The server binaries, user and
+admin tools, and the cache manager can be installed manually if you are not
+using your systems package manager, for example if you are installing OpenAFS
+on solaris, or if the target system is being used for testing and development.
+The installation paths depend on the configure options specified.
+
+The process for building rpm packages is actually a bit different than what was
+just described above.  Packaging scripts in the source tree are used to build
+rpms from a source code tree tar file. You'll need to create two tar files, one
+of the source and one of the documentation. A script is run to build a source
+rpm, which can be used to build the various rpm packages.  Details are given
+below in the section Building RPMs.
+
+## Prerequisites
+
+The following tools are needed to build OpenAFS from source from a tar file:
+
+- make
+- compiler
+- assembler
+- linker
+- ranlib
+- lex/yacc
+- install
+- perl 5.6 or better (only to build the documention)
+
+In addtion to the above, the following tools are needed to build OpenAFS 
+from a git checkout:
+
+- git
+- autoconf 2.60 or better
+- automake
 
-### <a name="Requirements"></a> Requirements
+The compiler used must be capable of building kernel modules for the target
+platform.
 
-Tools
+> Note for RHEL users: RedHat Enterprise Linux 5.5 and less shipped with a
+> version of autoconf too old to generate the OpenAFS configure script.
+> Fortunately, the recently released RHEL 6.0 shipped with a more up to date
+> version of autoconf which mets the minimum version needed to generate the
+> configure script.
 
-- cvs client
-- autoconf
-- automake
-- perl 5.6
-- gcc (versions?)
-- GNU make
-- lex/yacc (flex/bison)
+The following tools are needed to build OpenAFS RPMS:
 
-Libraries
+- perl 5.6 or better
+- rpmbuild
+
+The following development libraries are needed:
 
 - libc
-- kerberos, optional, but recommended
-- ncurses
+- kerberos 5
+- ncurses (optional, needed to build scout/afsmonitor)
+- pam (optional)
 - kernel headers
 
-The Kerberos development libraries are required if you are going to build with Kerberos 5 support. The [[OpenAFS]] legacy kaserver is deprecated.
+The ncurses libraries are needed to build the ncurses based admin tools
+scout and afsmonitor. The kerberos 5 libraries are needed to build kerberos 5
+support, which is *strongly* recommended.
+
+### Linux Debian Packages
+
+On a Debian-based linux distribution, all of the required packages can be
+install with the following commands apt-get commands,
+
+    $ apt-get install git-core autoconf automake make gcc flex bison
+    $ apt-get install libc6-dev libkrb5-dev libncurses5-dev linux-headers-$(uname -r)
+
+### Linux RPM Packages
+
+On a RedHat-based linux distributions, all of the required packages can be
+installed with the following yum commands,
+
+     $ yum install gcc autoconf automake make flex bison rpm-build
+     $ yum install glibc-devel krb5-devel ncurses-devel pam-devel kernel-devel-$(uname -r)
+
+### Solaris Packages
+
+For Solaris packages, start by installing pkg-get, if you have not already.
+
+     $ wget http://www.opencsw.org/pkg-get
+     $ pkgadd -d /path/to/pkg-get
+     $ wget --output-document=/tmp/gpg.key http://www.opencsw.org/get-it/mirrors/
+     $ gpg --import /tmp/gpg.key
+
+Check to make sure pkg-get is installed properly by doing a pkg-get compare.
+It should output a list of installed packages compared to up-to-date remote packages.
+
+With pkg-get installed, go ahead and begin installing the necessary packages
+
+     $ pkg-get install gcc flex bison automake autoconf gmake
+     $ pkg-get install krb5_kdc ncurses
+
+## Getting the Source Code
+
+See [[GitDevelopers]] for details on how to use git to fetch OpenAFS source
+code and to submit source code changes to the OpenAFS project. This is the
+preferred method to retrieve the source code.  Briefly, first create a local
+clone of the git repository and then checkout a local branch of the version you
+need to build.  For example,
+
+    $ git clone git://git.openafs.org/openafs.git
+    $ cd openafs
+    $ git checkout openafs-stable-<major>-<minor>-<patchlevel>
+
+Compressed tar files of the source tree are made available for each stable and
+development release. The most recent release is located at
+<http://openafs.org/release/latest.html>.  Archives for releases are located at
+/afs/openafs.org/software/openafs/ and <http://dl.openafs.org/dl>. For example,
+to download and uncompress version 1.4.14,
+
+    $ wget http://dl.openafs.org/dl/1.4.14/openafs-1.4.14-src.tar.bz2
+    $ wget http://dl.openafs.org/dl/1.4.14/openafs-1.4.14-doc.tar.bz2
+    $ tar xjf openafs-1.4.14-src.tar.bz2
+    $ tar xjf openafs-1.4.14-doc.tar.bz2
+    $ cd openafs-1.4.14
+
+The -src archive contains the source code and the -doc archive contains the
+documentation in xml and pod format. Having a separate archive for
+documentation allows people working on documentation to download just the pod
+and xml portions of the project.
+
+### Regen
+
+After a git checkout, run the regen.sh shell script to generate a
+configure script (and a configure-libafs script) and to generate
+the man pages. The regen.sh script runs the autoconf tools to
+generate the configure scripts and runs perl to generate the
+man pages.
+
+    ./regen.sh
+
+You can skip the generation of the man pages by specifying the '-q'
+option to regen.sh.
+
+    ./regen.sh -q
+
+Always run regen.sh again (and then configure) if you change any of the OpenAFS
+m4 autoconf macros, such as configure.ac or any of the macros under src/cf.
+
+## Configure
+
+The OpenAFS configure script has many options available. Take some time to read
+the README file and the output of configure --help before running configure the
+first time. The most common options are introduced below.
+
+### AFS sysname
+
+AFS uses an identifier called a *sysname* to distinguish platforms. configure
+will automatically detect the sysname of the build system and by default
+assumes the target system matches. If you are building for a target system
+which is different than the build system, or if for some reason the sysname
+detection fails, you will need to manually specify the sysname with the
+--with-afs-sysname option.  See the README file for a complete list of sysnames.
+
+The 'sysname' is also used as the name of the destination sub-directory for the
+binaries created during the build. This sub-directory is automatically created
+during the build.
+
+### Installation Directory Path Modes
+
+There are two modes for directory path handling: *Transarc mode* and *default
+mode*. The mode is selected with the --enable-transarc-paths option.
+
+Traditionally, AFS server binaries and configuration files are located in the
+directory /usr/afs and client binaries and configuration files are located in
+the directory /usr/vice/etc. This convention is known as *Transarc path mode*
+because it was the convention adopted by Transarc/IBM in the commercial
+predecessor of OpenAFS.  Use the --enable-transarc-paths configure option to
+build binaries compatible with the Transarc installation convention.
+
+When configure is run without the --enable-transarc-paths option, the build
+system is configured to be in the *default mode*. This mode builds OpenAFS with
+installation paths more commonly used in open-source projects, for example
+/usr/local.  The standard configure --prefix option(s) can be used to specify
+non-default directories.  See the README for details on the type of installation
+directories and the configure options to set the paths.
+
+Installation paths are set at build time. Do not mix binaries for the two modes
+on the same system.
+
+### Linux Kernel Headers
+
+When building on linux, configure will attempt to detect the path to the linux
+kernel headers.  If this path is not found on the build system, you must
+specify the path with the --with-linux-kernel-headers option. For example,
+
+    --with-linux-kernel-headers=/usr/src/linux
+
+### Kerberos 5 configuration
+
+The 1.6.0 configure scripts should automatically find the kerberos 5
+libraries and headers.
+
+If you need to build 1.4.x, or if the krb5-config file is in a non-standard
+location, use the --with-krb5-conf option to specify the path to the krb5-config
+utility (part of the kerberos 5 development package).
+
+    --with-krb5-conf=/usr/bin/krb5-config
+
+
+### Debugging Options
+
+To enable a debugging build, specify the --enable-debug option on the
+./configure command line.  This builds with debugging compiler options and
+disables stripping of binaries.
+
+    --enable-debug                enable compilation of the user space code
+                                     with debugging information
+    --enable-debug-kernel         enable compilation of the kernel module
+                                     with debugging information
+    --enable-checking             Enable compiler warnings when building
+                                    with gcc and treat compiler warnings
+                                    as errors
+
+### Feature Options
+
+There are many configure options for OpenAFS. See the ./configure --help
+for a complete list and README for more details.  Common options are:
+
+    --enable-bos-restricted-mode  enable bosserver restricted mode 
+                                     which disables certain bosserver functionality
+    --enable-bos-new-config       enable bosserver pickup of BosConfig.new on restarts
+    --enable-namei-fileserver     force compilation of namei fileserver
+                                    in preference to inode fileserver
+                                    on systems were inode is the default
+    --enable-supergroups          enable support for nested pts groups
+                                   WARNING: Once you make use of this option
+                                   by nesting one group inside another,
+                                   the resulting PTS database cannot be correctly
+                                   and safely used by a ptserver built 
+                                   without this option. 
 
-If you are building on Debian, you can get the required software with the following apt-get commands.
+### Configure changes in 1.6.0
 
-      apt-get install cvs autoconf automake make gcc flex bison
-      apt-get install libc6-dev libkrb5-dev libncurses5-dev linux-headers-$(uname -r)
+If you have been building the 1.5.0 freatures branch, note the following configure
+options have been removed in 1.6.0. Each feature is now always on, except as noted:
 
-### <a name="Getting the Source Code from CVS"></a> Getting the Source Code from CVS
+* --disable-afsdb
+* --disable-largefile-fileserver
+* --enable-bos-restricted
+* --enable-fast-restart (off, but the code is still there)
+* --disable-full-vos-listvol
+* --enable-disconnected
+* --enable-icmp-pmtu-discovery
+* --enable-demand-attach-fs (see below)
 
-You can get development snapshots from the [[OpenAFS]] CVS repository . The CVS tree may not always have code which can currently be built. While every effort is made to keep the head of the tree buildable, you may at any time find yourself between commits and hence have a tree which does not build, or worse, causes more serious problems.
+In 1.5.x, the demand attach fileserver feature was enabld by the a configure
+switch. Starting in 1.6.0, both DAFS and legacy binaries are built. The
+DAFS binaries are prefixed with 'da', expect for the new salvageserver, since
+salvageserver is new with DAFS.
 
-First you need to run cvs login. This step is normally only done once. A ~/.cvspass file will be created for additional checkouts.
 
-       cvs -d :pserver:anonymous@cvs.openafs.org:/cvs  login
-       password is anonymous
+## Make
 
-Before doing a CVS check out, you'll need to decide which branch you want to check out. The trunk is for bleeding edge development and may not even build. The current stable series is openafs-stable-1\_4\_x and the current development work is going on the openafs-devel-1\_5\_x branch.
+After a successful configure, run make to build OpenAFS. The
+default target will build all.
 
-See the CVSWeb interface at <http://www.openafs.org/frameset/cgi-bin/cvsweb.cgi/openafs/> for the full list of available branches and tags.
+    $ make
 
-To check out the stable branch:
 
-       cvs -d :pserver:anonymous@cvs.openafs.org:/cvs checkout -r openafs-stable-1_4_x openafs
+## Install
 
-To check out the development branch:
+You can install the OpenAFS binaries outside a package system
+by copying the binaries. If you built OpenAFS in the default
+mode (that is without --enable-transarc-paths), run the install
+target as root to install the binaries.
 
-       cvs -d :pserver:anonymous@cvs.openafs.org:/cvs checkout -r openafs-devel-1_5_x openafs
+    $ sudo make install
 
-This will create a source tree in a directory named openafs.
+If configure was run with --enable-transarc-paths, then run make to build a
+binary distribution directory, and then manually copy the files as the root
+user. To install the server and client binaries,
 
-Run the regen.sh script to create the configure script.
+    $ make dest
+    $ cd <sysname>/dest
+    $ sudo mkdir /usr/afs
+    $ sudo mkdir /usr/vice
+    $ sudo mkdir /usr/vice/etc
+    $ sudo cp -p -r root.server/usr/afs/* /usr/afs
+    $ sudo cp -p -r root.client/usr/vice/etc/* /usr/vice/etc
 
-       cd openafs
-       ./regen.sh
+See the Quick Start Guide for complete instructions to setup
+the OpenAFS cache manager and servers.
 
-### <a name="Building the Binaries"></a> Building the Binaries
+The 'make dest' command places workstation binaries in the sub-directories of
+<sysname>/dest: bin, etc, man, lib, include. Optionally, copy these to you
+local filesystem or install them in an appropriate path in AFS. To install
+these file into your local filesystem:
 
-#### <a name="Transarc Paths"></a> Transarc Paths
+    $ sudo mkdir /usr/afsws
+    $ sudo cp -p -r bin /usr/afsws
+    $ sudo cp -p -r etc /usr/afsws
+    $ sudo cp -p -r man /usr/afsws
+    $ sudo cp -p -r lib /usr/afsws
+    $ sudo cp -p -r include /usr/afsws
 
-By convention, [[OpenAFS]] server binaries and related files are located in /usr/afs, and client binaries and related files are located in /usr/vice. These are known as Transarc paths, so called because that is is the convention used by Transarc, the company that first commercialized AFS. To build with the Transarc paths, specify --enable-transarc-paths as a configure option.
+See [Storing AFS Binaries in AFS](http://docs.openafs.org/QuickStartUnix/ch02s29.html) for instructions on
+how to store the workstation binaries in AFS.
 
-There are a couple of side effects that you need need to be aware of when building with the --enable-transarc-paths mode. First of all, the typical make install target does not work in this mode. Instead the 'make dest' target is used to build a directory of the binaries to be copied to the target system. Secondly, the packaging targets are not executed, so for example the redhat spec file is not generated to build the rpms.
+## Post build
+
+Some make targets of interest
+
+- make clean - remove build artifacts
+- make distclean - remove build and configure artifacts
+- make tests - make the (old) afs test suite
 
-To build with Keberos support (recommended), you'll need to have the Keberos development libraries, and if available for your platform, the krb5-config. You will need the full path the the krb5-config script. For example
 
-       $ which krb5-config
-       /usr/bin/krb5-config
+## Building RPM packages
+A script called makesrpm.pl is provided to build a source RPM package.  You can
+use the generated source RPM to build the binaries and create the RPM packages
+for your source code tree of OpenAFS.
 
-To build [[OpenAFS]] with Kerberos 5 support and the Transarc path conventions:
+The first step is to create a source tree of OpenAFS. Run the regen.sh script
+to build the docs and to generate the configure script. Also, use git describe
+to make a version stamp file which will be used by the packaging process. This
+example shows how to get a source tree from a remote git repo.
 
-       ./configure  --enable-transarc-paths --with-krb5-conf=/usr/bin/krb5-config
-       make
-       make dest
+    $ git clone git://git.openafs.org/openafs.git openafs-<version>
+    $ cd openafs-<version>
+    $ git checkout <tagname>
+    $ git describe >.version
+    $ ./regen.sh
 
-If all goes well, then the binaries are located in a platform sub-directory, the name of which is platform specific, for example 'i386\_linux26/dest'.
+The _version_ is the dotted OpenAFS version number, such as 1.6.0,
+and the _tagname_ is the git tag for the version, such as openafs-stable-1_6_0.
+The _version_ number for pre-releases are suffixed with pre<number>. For example,
+to build 1.6.0pre5, create a directory called openafs-1.6.0pre5.
 
-The 'make install' command does not work with Transarc paths. You will have to manually copy the binaries into place after running make dest. For more information, see the Quick Start Guide for Unix on the [[OpenAFS]] documentation page.
+Next, create a source RPM file. This requires creating a tar file for the
+source files and a tar file for the documents.  Run the makesrpm program
+to generate an OpenAFS source RPM.
 
-      # cp -r i386_linux26/dest/root.client/usr/vice/etc/modload /usr/vice/etc
-      # cp i386_linux26/dest/root.client/usr/vice/etc/afsd /usr/vice/etc
-      # cp -r i386_linux26/dest/bin /usr/afsws
-      # cp -r i386_linux26/dest/etc /usr/afsws
-      # cp -r i386_linux26/dest/include /usr/afsws
-      # cp -r i386_linux26/dest/lib /usr/afsws
-      # cp -r i386_linux26/dest/root.server/usr/afs/* /usr/afs
+    $ cd .. # move out of the source tree
+    $ tar cjf openafs-<version>-src.tar.bz2 openafs-<version> --exclude .git --exclude doc
+    $ tar cjf openafs-<version>-doc.tar.bz2 openafs-<version>/doc
+    $ openafs-<version>/src/packaging/RedHat/makesrpm.pl openafs-<version>-src.tar.bz2 openafs-<version>-doc.tar.bz2
 
-#### <a name="Stardard Paths"></a> Stardard Paths
+At this point you should have a source RPM called openafs-<version>-1.0.src.rpm. See the makesrpm.pl for additional options.
+The source tree and tar files are no longer needed.
 
-To build [[OpenAFS]] with Kerberos 5 support, and with a custom install path,
+Finally, run rpmbuild to build the build binary RPM packages. If all goes well, the final
+output will show the destination directory and an exit code of zero.
 
-       ./configure --prefix=/usr/local/openafs --with-krb5-conf=(full path to krb5-config script)
-       make
-       sudo make install
+    $ rpmbuild --rebuild openafs-<version>-1.0.src.rpm
+    ...
+    + cd /usr/src/redhat/BUILD
+    + rm -rf openafs-<version>
+    + exit 0
 
-### <a name="Initial testing"></a> Initial testing
+Alternatively, the source RPM may be installed, which will place the sources in the
+rpm SOURCE directory and a spec file in the rpm SPEC directory. 
 
--- [[MichaelMeffie]] - 09 Oct 2007