update gerrit list
[openafs-wiki.git] / devel / HowToBuildOpenAfsRpmPackages.mdwn
index 71a0dbf..ef21719 100644 (file)
@@ -8,108 +8,129 @@ the OpenAFS source code.
 
 ## Prerequisites
 
-Upgrade your kernel to the most recent version:
+Upgrade your kernel to the most recent version.
 
     $ sudo yum update kernel
-    $ sudo reboot                   # if updated
+    $ sudo reboot  # if updated
 
-Install the kernel-devel package for your running kernel.
+After rebooting (if neeed), install the kernel headers for your current kernel
+version.
 
     $ sudo yum install "kernel-devel-uname-r == $(uname -r)"
 
-Install the packages required to build the OpenAFS source RPM (SRPM):
+Install the `elfutils-devel` package if building on RHEL 8/CentOS 8.
+
+    $ sudo yum install elfutils-devel  # if RHEL/CentOS 8
+
+Install the packages required to build the OpenAFS source RPM.
 
     $ sudo yum install rpm-build yum-utils make perl libtool bzip2 wget
 
-Additional build dependencies will be installed after the spec file is
-generated.
+The OpenAFS build dependencies will be installed after the source RPM file is
+generated in the steps below.
 
 # Building OpenAFS RPMs
 
-This section describes how to build RPMs for OpenAFS release or pre-release.
-See "Advanced topics" below to build packages based on the `master` branch for
-development and testing.
-
 ## Method 1: Building from source code distribution
 
 The OpenAFS Release Team provides software releases as source code
-distributions. A source RPM (SRPM) file can easily be built from a source
+distributions. A source RPM file can easily be built from a source
 distribution release with the `makesrpm.pl` script provided in the source tree.
 
 Download the source distribution files from [openafs.org][3].  Four files are
 provided in a release; a source tarball, a documentation tarball, release
-notes, and a change log. Extract the `makesrpm.pl` script from the source
-tarball and then run `makesrpm.pl` to build the source RPM (SRPM). The
-resulting SRPM will be placed in the current directory.  Install the SRPM in
-your package workspace. Use the `yum-builddeps` to install the build
-dependencies. Run `rpmbuild` to build the binary RPMs.  The resulting RPMs will
-be placed in `~/rpmbuild/RPMS`.
-
-    # Download source release.
-    $ wget https://www.openafs.org/dl/openafs/1.8.5/openafs-1.8.5-src.tar.bz2
-    $ wget https://www.openafs.org/dl/openafs/1.8.5/openafs-1.8.5-doc.tar.bz2
-    $ wget https://www.openafs.org/dl/openafs/1.8.5/RELNOTES-1.8.5
-    $ wget https://www.openafs.org/dl/openafs/1.8.5/ChangeLog
-
-    # Build the source RPM.
-    $ tar xf openafs-1.8.5-src.tar.bz2 --strip-components=4 '*/makesrpm.pl'
-    $ perl makesrpm.pl openafs-1.8.5-src.tar.bz2 openafs-1.8.5-doc.tar.bz2 RELNOTES-1.8.5 ChangeLog
-
-    # Install build dependencies and build the binary RPMs.
-    $ rpm -iv openafs-1.8.5-1.src.rpm
-    $ sudo yum-builddep ~/rpmbuild/SPECS/openafs.spec
-    $ rpmbuild -bb ~/rpmbuild/SPECS/openafs.spec
+notes, and a change log.
+
+    $ VERSION=1.8.6  # for example
+    $ wget https://www.openafs.org/dl/openafs/${VERSION}/openafs-${VERSION}-src.tar.bz2
+    $ wget https://www.openafs.org/dl/openafs/${VERSION}/openafs-${VERSION}-doc.tar.bz2
+    $ wget https://www.openafs.org/dl/openafs/${VERSION}/RELNOTES-${VERSION}
+    $ wget https://www.openafs.org/dl/openafs/${VERSION}/ChangeLog
+
+Extract the `makesrpm.pl` script from the source tarball and then run it to
+generate the source RPM. The resulting source RPM will be placed in the current
+directory.
+
+    $ tar xf openafs-${VERSION}-src.tar.bz2 --strip-components=4 '*/makesrpm.pl'
+    $ perl makesrpm.pl openafs-${VERSION}-src.tar.bz2 openafs-${VERSION}-doc.tar.bz2 RELNOTES-${VERSION} ChangeLog
+
+Install the OpenAFS build dependencies with `yum-builddep`. This command will
+retrieve the required packages from the rpm spec file inside the source RPM.
 
-If the build dependencies are already installed, you can let rpmbuild install
-the source RPM and build the packages in one step:
+    $ sudo yum-builddep openafs-${VERSION}-1.src.rpm
 
-    $ rpmbuild --rebuild openafs-1.8.5-1.src.rpm
+Finally, run `rpmbuild` to build the binary RPMs.  The resulting RPMs will be
+placed in `$HOME/rpmbuild/RPMS`.
+
+    $ rpmbuild --rebuild openafs-${VERSION}-1.src.rpm
 
 ## Method 2: Building from a git checkout
 
-The OpenAFS makefile has a targets to build a source RPM (SRPM) from a git
-checkout of a release or pre-release tag.  A downside to this method is the
-release notes and change log provided in the OpenAFS source distribution
-releases are not included in the generated SRPM. This method can also be used
-to build RPMs from a local branch based on an OpenAFS stable branch, such as
-`openafs-stable-1_8_x`. See "Advanced topics" below to see how to build packages for testing
-based on the `master` branch.
-
-To build packages from a git checkout, clone the repository, then checkout the
-release or pre-release tag, or a commit based on a stable branch.  Run the
-`regen.sh` tool to generate the `configure` script, then run `configure` to
-generate the makefile. (The `configure` options given in this step are not used
-to generate the binaries; those are defined in the spec file.)  The resulting
-source RPM will be placed in the `./packages` directory.
+This method can be used to build rpms for OpenAFS from a git checkout of a
+release tag or the current stable or development branch.  A downside to this
+method is the release notes and change log provided in the OpenAFS source
+distribution releases are not included in the generated source RPM.
+
+When building packages from a git checkout, be sure to always build in a clean
+directory. In particular be sure the 'packages' directory is absent or empty
+before building rpms. Also, be sure there are no uncommitted source code
+changes. This method will only package code which has been committed, any
+uncommitted changes will not be packaged.
+
+The OpenAFS makefile includes the `make srpm` target to build a source RPM from
+a git checkout of a release or pre-release tag.  As of OpenAFS version 1.9.0,
+the OpenAFS makefile includes the `make rpm` tag.
+
+First, install the following packages needed to generate the makefile.
 
     $ sudo yum install git make krb5-devel
 
+Create a local git clone of the OpenAFS git repository and checkout the tag or
+branch to be packaged.
+
     $ git clone git://git.openafs.org/openafs.git
     $ cd openafs
-    $ git checkout openafs-stable-1_8_5
+    $ git checkout <branch-or-tag>  # e.g., openafs-stable-1_8_5, openafs-devel-1_9_x, master
+
+Run the `regen.sh` tool to generate the `configure` script, then run
+`configure` to generate the OpenAFS makefile.  Make the `dist` and `srpm`
+targets to generate the source RPM. The resulting source RPM will be placed in
+the `./packages` directory.  (Note: The `configure` options given in this step
+are not used to generate the binaries. The actual configure options are defined
+in the spec file `openafs.spec.in`.)
 
     $ ./regen.sh -q
     $ ./configure --disable-kernel-module
-    $ make dist
-    $ make srpm
+    $ make dist srpm
 
-    # Install build dependencies and build the binary RPMs.
-    $ rpm -iv packages/openafs-1.8.5-1.src.rpm
-    $ sudo yum-builddep ~/rpmbuild/SPECS/openafs.spec
-    $ rpmbuild -bb ~/rpmbuild/SPECS/openafs.spec
+Install the OpenAFS build dependencies with `yum-builddep`. This command will
+retrieve the required packages from the rpm spec file inside the source RPM.
 
-If the build dependencies have already been installed, you can let rpmbuild
-install the source RPM and build the packages in one step:
+    $ sudo yum-builddep ./packages/openafs-*.src.rpm
 
-    $ rpmbuild --rebuild packages/openafs-1.8.5-1.src.rpm
+Build the binary RPMs with `rpmbuild`. By default, packages will be placed in
+`$HOME/rpmbuild/RPMS`. See **rpmbuild options** below for various rpmbuild
+options.
 
-## Build options
+    $ rpmbuild --rebuild packages/openafs-*.src.rpm
+
+The `make rpm` target is available as of OpenAFS 1.9.0.  This target will build
+the source distribution, source RPM, and binary RPM files. The rpm files will
+be placed in the `./packages/rpmbuild/RPMS` directory. If the build
+dependencies are already installed, the rpm files can be built with a single
+`make rpm` command after generating the `Makefile`.
+
+    $ ./regen.sh -q
+    $ ./configure --disable-kernel-module  # generate the Makefile
+    $ make rpm                             # create the source and binary rpm files
+
+## rpmbuild options
 
 The OpenAFS spec file provides several options to select which packages are to
-be  built by `rpmbuild` and to enable certain build-time features in the
+be built by `rpmbuild` and to enable certain build-time features in the
 binaries. These options are specified as `rpmbuild`  command line arguments.
 
-The `build_userspace` and `build_modules` defines control when the the kernel
+The `build_userspace` and `build_modules` defines control when the kernel
 module packages are to be built. Userspace packages includes all of the
 packages except the kernel module package, including the servers and the
 OpenAFS client Dynamic Kernel Module System (DKMS) package. By default,
@@ -117,13 +138,21 @@ both the userspace and kernel modules are built.
 
 To build all of the packages except the OpenAFS kernel module:
 
-    $ rpmbuild -bb --define "build_userspace 1" --define "build_modules 0" ~/rpmbuild/SPECS/openafs.spec
+    $ rpmbuild \
+      --rebuild \
+      --define "build_userspace 1" \
+      --define "build_modules 0" \
+      ./packages/openafs-*.src.rpm
 
 To build only the OpenAFS kernel module for the currently running kernel:
 
-    $ rpmbuild -bb --define "build_userspace 0" --define "build_modules 1" ~/rpmbuild/SPECS/openafs.spec
+    $ rpmbuild \
+      --rebuild \
+      --define "build_userspace 0" \
+      --define "build_modules 1" \
+      ./packages/openafs-*.src.rpm
 
-Specify the `kervers` option to build kernel modules for specific kernel
+Specify the `kernvers` option to build kernel modules for specific kernel
 versions.  Install `kernel-devel` packages for the versions you wish to build.
 You may need to configure and enable the CentOS Vault "update" repositories for
 older kernel versions.
@@ -135,6 +164,8 @@ older kernel versions.
     kernel-devel-3.10.0-957.27.2.el7.x86_64
     kernel-devel-3.10.0-1062.12.1.el7.x86_64
 
+    $ rpm -i ./packages/openafs-*.src.rpm
+
     $ rpmbuild \
       -bb \
       --define "build_userspace 0" \
@@ -190,20 +221,22 @@ to `0x0001` before running rpmbuild.
 ## Installing client RPMs with the Dynamic Kernel Module System (DKMS)
 
 The Dynamic Kernel Module System (DKMS) kernel modules take longer to install,
-but are automatically rebuilt after the kernel is upgraded. Unless you are
-maintaining, or have access to, a yum repository which tracks kernel updates
-and builds matching OpenAFS kernel modules for each update, you will want to
-use the DKMS method to install the OpenAFS kernel module.
+but are automatically rebuilt after the kernel is upgraded on the target
+system. Unless you are maintaining, or have access to, a yum repository which
+tracks kernel updates and builds matching OpenAFS kernel modules for each
+update, you will want to use the DKMS method to install the OpenAFS kernel
+module.
 
 Add the EPEL yum repository, which provides the DKMS system.  Install the
 Kerberos5 workstation package, which provides the `kinit` program. Install the
 OpenAFS DKMS and openafs Kerberos5 support packages with `yum`. This will take
-some time as the kernel-module is built from source.  Be sure to install
-the openafs-client and dkms-openafs packages in a single `yum install`
-invocation.
+some time as the kernel-module is built from source.  Be sure to install the
+openafs-client and  packages in a single `yum install` invocation.
 
     $ cd ~/rpmbuild/RPMS/x86_64
     $ sudo yum install epel-release
+    $ sudo yum install make
+    $ sudo yum install "kernel-devel-uname-r == $(uname -r)"
     $ sudo yum install \
         krb5-workstation \
         openafs-1.8.5-1.el8.x86_64.rpm \
@@ -244,13 +277,13 @@ Install the server package with:
 [Mock][4] is a tool for building packages in a chroot. The mock chroot
 isolation makes it makes it easier to build a large number of kernel module
 versions on a single build host. In addition, mock provides a clean build
-environment for each build, and mock will automatically install the build
+environment for each build and mock will automatically install the build
 requirements specified by the openafs.spec file in the temporary mock chroot.
 
 Mock also provides the ability to build RPMs for different distributions on one
 machine. For example, one could build RPMs targeted for CentOS 6, 7, and 8 on
-one CentOS 8 build host. Although it is possible to build RPMs for other
-distributions with mock, it not possible to build RPMs for other architectures,
+single CentOS 8 build host. Although it is possible to build RPMs for other
+distributions with mock, it not possible to build RPMs for other architectures
 since mock does not support cross-compiling.
 
 Install mock and add yourself to the 'mock' group.
@@ -259,24 +292,18 @@ Install mock and add yourself to the 'mock' group.
     $ sudo usermod -a -G mock $USER
     $ newgrp - mock
 
-To build OpenAFS rpms with mock, first create the OpenAFS RPM as shown above.
-Then run the mock commands to build the packages using the mock system.
+To build OpenAFS rpms with mock, first create the OpenAFS source RPM as shown
+above, then run the mock commands to build the packages using the mock system.
 
-    $ mock --rebuild openafs-1.8.5-1.src.rpm
+    $ mock --rebuild ./packages/openafs-*.src.rpm
 
 ## Building RPMs with afsutil
 
 [afsutil][5] is a python tool to facilitate OpenAFS development.  The `afsutil
 package` command is a front-end tool for building RPMs from a git checkout,
-with or without mock. The main advantages of using `afsutil package` to build
-packages is that it makes it easy to build a source RPM (SRPM) from a git
-commit based on the master branch (as well as stable branches). This can be
-helpful to build packages for testing or to make changes to the master branch
-version of the spec file.
-
-When used with mock, `afsutil` will, by default, build kernel modules for
-every kernel-devel version discovered in the enabled yum repositories within
-the mock chroot.
+with or without mock.  When used with mock, `afsutil` will, by default, build
+kernel modules for every kernel-devel version discovered in the enabled yum
+repositories within the mock chroot.
 
 OpenAFS packages require a copy of the CellServDB client configuration file.
 `afsutil package` will automatically download the CellServDB version specified
@@ -284,12 +311,21 @@ in the spec file from grand.central.org. An alternate CellServDB file can be
 specified by url or local path with the `--csdb` option.
 
 RPM packages for `afsutil` are available. This is the preferred installation
-method on CentOS.  Alternatively, `aftutil` may be installed with `pip`, or from
-source.
+method on CentOS.  Alternatively, `afsutil` may be installed with `pip` or
+from source.
 
 ### Method 1: Installing afsutil with yum
 
-    $ sudo yum install https://download.sinenomine.net/openafs/repo/sna-openafs-release-latest.noarch.rpm
+Create the yum configuration file `/etc/yum.repos.d/sna-openafs-contrib.repo`:
+
+    [sna-openafs-contrib]
+    name=Sine Nomine Associates: Contributed Extras for OpenAFS
+    baseurl=https://download.sinenomine.net/openafs/contrib/packages/CentOS/$releasever
+    enabled=1
+    gpgcheck=0
+
+Install `afsutil` with `yum`:
+
     $ sudo yum install afsutil
 
 ### Method 2: Installing afsutil with pip
@@ -297,14 +333,14 @@ source.
     $ sudo yum install epel-release   # if RHEL/CentOS
     $ sudo yum install python2-pip    # if RHEL/CentOS 8
     $ sudo yum install python-pip     # if RHEL/CentOS 7 or earlier
-    $ sudo pip install afsutil
+    $ pip install --user afsutil
 
-### Method 2: Installing afsutil from source
+### Method 3: Installing afsutil from source
 
     $ git clone https://github.com/openafs-contrib/afsutil
     $ cd afsutil
     $ python configure.py  # or, python2 configure.py on RHEL/CentOS 8
-    $ sudo make install
+    $ make install-user
 
 ### Building RPMs with afsutil
 
@@ -314,7 +350,6 @@ To build OpenAFS packages from a git checkout:
     $ git clone git://git.openafs.org/openafs.git
     $ cd openafs
     $ afsutil package
-    $ ls packages
 
 The `afsutil package` command will build packages for the userspace and kernel
 modules by default. See the `--build` option to build these separately.