Skip to content

CentOS Build Instructions

Andrew R. Lake edited this page Sep 23, 2015 · 11 revisions

Introduction

This page contains information about building various components of the Toolkit in CentOS 6.

Kernel

The Toolkit includes a custom version of the CentOS 6 RHEL (Red Hat Enterprise Linux) kernel.

To build this kernel, you will need a host with CentOS 6, and the 'rpm-build' package installed (optionally mock) with at least 15 GB of space available.

Preparing The Kernel Source

Building The Kernel

  • To build the kernel SRPM run: rpmbuild --define "_sourcedir ." --define "_srcrpmdir ." --nodeps -bs *spec
  • If the above commands executed properly you should see a kernel SRPM file
    • If not look through the output to determine what went wrong
  • To build the kernel run mock (make sure your user is in the "mock" group):
    • x86_64: mock -r epel-6-x86_64 --resultdir=$HOME/mock-results/epel-6-x86_64/ --arch=x86_64 --without=debug --without=kabichk kernel_file.src.rpm
    • i386: mock -r epel-6-i386 --resultdir=$HOME/mock-results/epel-6-i386 --arch=i386 --target=i686 --without=debug --without=kabichk kernel_file.src.rpm
    • You also need to run a third command to build the firmware as noarch:
      • mock -r epel-6-i386 --resultdir=$HOME/mock-results/epel-6-i386 --arch=i386 --target=noarch --without=debug --without=kabichk --with=firmware kernel_file.src.rpm
    • If new patches have been added, these commands may error out due to patches that don't apply cleanly. If so, these patches will need modified as appropriate and the command rerun (look here)

Customizing The Toolkit NetInstall

The pS-Performance Toolkit NetInstall is built using custom CentOS kickstart files. You can read more about kickstart installations here. The kickstart file defines the set of software repositories to use, the set of software to install, and a script that performs some system configuration once the software has been installed. Customizing the toolkit will involve changing one or more of those elements in the kickstart files.

Pre-Requisites

The build procedures here assume that the toolkit ISOs are being built on CentOS 6. The steps may work on other systems, but have only been tested on CentOS 6.

For building custom versions of the NetInstall, you'll need a copy of ImageMagick installed on the host. This should be available via yum.

For building custom versions of the NetInstall, you will need a copy of mkisofs installed on the host. This should be available via yum.

Building The Toolkit

You can download the kickstarts, images and scripts needed to build the toolkit by doing a git checkout of http://github.com/perfsonar/toolkit-building

The important directories for customization are kickstarts, images, and scripts. The kickstarts directory contains the files used for generating the kickstarts used by the NetInstall setup. The scripts directory contains scripts used for building the toolkit. The images directory contains the image displayed when the CD is first booted.

If you run the script build_netinstall.sh as root, it should build an ISO of the NetInstall.

As of the CentOS 6 release, there is an option to specify whether to build a 32-bit or 64-bit version. If the script is executed without any parameters it will automatically build a 32-bit version of the Toolkit, however if you wish to build a 64-bit version you must supply the script with an architecture parameter. For example, to build a 64-bit version of the NetInstall you would run build_netinstall.sh --arch x86_64 as root. Note that this requires all Toolkit software to be rebuilt for 64-bit compatibility.

The general build process of the NetInstall roceeds as follows:

  • Patches the 'generic' kickstart file (centos6-base.cfg) with NetInstall-specific modifications (centos6-netinstall.patch)
  • Modifies the generic CentOS netinstall CD (in the resources directory) to include the kickstart and to boot using it
  • Modifies the generic CentOS netinstall CD to use the proper boot image

Customizing The Toolkit

To customize the toolkit, you will need to modify the kickstart file. The centos6-base.cfg file in the kickstarts directory is the 'generic' kickstart file. There is patch file centos6-netinstall.patch that modifies this kickstart file.

There are a large number of directives inside the kickstart. The meaning of most of these is outside the scope of this document, but should be available here.

Customizing The Software Yum Repositories

The set of repositories that will be used to retrieve RPMs from can be customized. This allows you to use a local mirror to speed up builds as well as to include new or customized RPMs. Note, however, that when changing the repositories, you must make sure that the software to be installed (either directly or to satisfy dependencies) must still be available in the set of repositories.

The 'repo' lines specify the set of repositories to use:

repo --name=a-Internet2    --baseurl=http://software.internet2.edu/rpms/i386/main/

The above line tells the kickstart to use the Internet2 repository and gives the URL of the yum repository.

Note: the repositories here are only used for installation. They will not be available after installation. If you want to make these software repositories available after installation, you must either have the kickstart install an appropriate repository package (see here for an example of the repository package), or have the post installation script add the appropriate .repo and key files.

Customizing The Software To Install

In the %packages section, there are a list of packages to install or not install. Any packages that start with "@" are package groups (e.g. @core is the set of core packages). Any packages that start with "-" are packages that should not be installed (e.g. -sysreport says to not install the sysreport package). All other packages are normal packages to install like you might do with yum.

You can add any packages here that you might want installed.

Customizing The Toolkit System Environment

The toolkit system environment can be configured using the %post script. This script is run after the software packages have been installed, and allow for modifications to be made to the installed system before it is booted for the first time.

There is an existing %post script that performs a number of tasks needed by the toolkit. However, this script can be modified to include any desired configuration for the toolkit system. For example, users could be added, or configuration files could be modified. The existing post installation script includes a wide variety of methods for configuring aspects of the installed system.

The thing to remember when making changes is that the patch files expect to patch the centos6-base.cfg file. There are a few ways to go about making changes. One way is to make changes to the centos6-base.cfg in such a way that they don't conflict with the patches. This is generally the path of least resistance.

Building Toolkit Packages With Mock

This page contains background information on mock. The latter sections assume basic knowledge of mock and 'holding' repositories, and that the holding repository has been configured as described.

This page contains information on creating and building source RPMs. The latter sections assume basic knowledge of building source RPMs.

i2_mock utility

To ease the use of mock, we built a simple wrapper script over the mock command which simply sets some default values:

  • The uniqueext value will be set to the callers username
  • The architecture is set to "i386"
  • The default build environment is set to "epel-6" (RedHat6 + the EPEL repositories)
  • The output directory is set to /home/username/holding/environment/architecture/name
#!/usr/bin/perl

use strict;
use warnings;

use Getopt::Long;

Getopt::Long::Configure("pass_through");
Getopt::Long::Configure("no_ignore_case");

my $uniqueext;
my $resultdir;
my $arch;
my $distro;

my $result = GetOptions("uniqueext=s", \$uniqueext, "resultdir=s", \$resultdir, "arch=s", \$arch, "distro=s", \$distro);

my @remaining_args = @ARGV;

my $srpm = $ARGV[$#ARGV];
unless ($srpm)
{
	print "No source RPM specified.\n";
	exit(-1);
}

unless (`rpm -qp $srpm 2>/dev/null`)
{
	print "Invalid SRPM: $srpm";
	exit(-1);
}

my ($name, $pass, $uid, $gid, $quota, $comment, $gcos, $dir, $shell, $expire) = getpwuid($>);

$arch = "i386" unless ($arch);
$distro = "epel-6" unless ($distro);
$uniqueext = $name unless ($uniqueext);
$resultdir = "/home/$name/holding/$distro/$arch/" . `rpm -qp $srpm 2>/dev/null` unless ($resultdir);
chomp($resultdir);

my $mycfg = "$distro-$arch";
$mycfg = "$distro-i386" if ( ! -e "/etc/mock/$mycfg" and $arch eq "i686" and -e "/etc/mock/$distro-i386.cfg");

my @args = ();
push @args, ("/usr/bin/mock");
push @args, ("-r", $mycfg);
push @args, ("--resultdir", $resultdir);
push @args, ("--uniqueext", $uniqueext);
push @args, ("--arch", $arch);
push @args, @remaining_args;

print join(" ", @args) . "\n";
system(@args);

I2utils

  • Build a source RPM of I2utils (e.g. I2util-1.1-1.el6.src.rpm)
  • Run: i2_mock [I2utils SRPM] (e.g. i2_mock I2util-1.1-1.el6.src.rpm)

web100_userland

bwctl

owamp

ndt

  • Place a built RPM of I2utils into the 'holding' repository
  • Place a built RPM of web100_userland into the 'holding' repository
  • Build a source RPM of ndt (e.g. ndt-3.6.4-3.el6.src.rpm)
  • Run: i2_mock [ndt SRPM] (e.g. ndt-3.6.4-3.el6.src.rpm)

npad

nuttcp

dbxml

perl dbxml

  • Place a built RPM of dbxml into the 'holding' repository
  • Build a source RPM of perl-dbxml (e.g. perl-dbxml-2.5.16-1.el6.src.rpm)
  • Run: i2_mock [perl-dbxml SRPM] (e.g. i2_mock perl-dbxml-2.5.16-1.el6.src.rpm)

kernel

  • Build a source RPM of the kernel. This will involve steps described above. (e.g. kernel-2.6.32-279.2.1.el6.web100.src.rpm)
  • Run i2_mock --arch i686 --without debug --without kabichk [kernel SRPM] (e.g. i2_mock --arch i686 --without debug --without kabichk kernel-2.6.32-279.2.1.el6.web100.src.rpm)
    • NOTE: make sure you have at least 5 GB of available disk space for building the set of kernels
Clone this wiki locally