Open Ethernet Networking (OpEN) API Guide and Reference Manual
3.6.0.3
|
In this section we define how to build the RPMs that are supplied in the RPM tar ball. This allows the customer to make changes to the standard binary RPMs that Broadcom provides, or to add additional RPMs. Note that the RPMs need only be recompiled if the customer is modifying or adding RPMs, or if they are using a custom OS or CPU.
To build the RPMs, a CentOS 6.2 64-bit Linux host is required. This host must be configured with certain packages, and configured to allow certain root users.
The RPM build host must be a CentOS 6.2 64-bit Linux machine. Using a virtual machine is sufficient, and is often a good choice. CentOS should be installed using standard options except when asked what type of installation (Desktop, Minimal Desktop, Minimal etc), select "Software Development Workstation" or "Desktop".
The reason for using CentOS 6.2 for the build machine is because it addresses some package dependency issues when building CentOS 6.2 source RPMs. For example, some packages require that other packages be present during the build, but they are not required when the resultant binary RPM is installed. Since we are using CentOS 6.2 as the build machine, it is easy to satisfy those build dependencies (this is what the script from the Additional Host Package Installation section does). Other Linux distributions could be used as the build machine, but they would not be able to take advantage of this dependency short cut and the RPM build system would need to be modified.
CentOS must be disabled from installing updates to the 6.2 distribution. If updates are allowed to occur then this can break the RPM build environment. To disable updates copy the rpms.<toolchain>.<cpu>-<version>/config/CentOS-Base.repo file to /etc/yum.repos.d. You should then issue the yum clean all
command to clear the yum cache, and yum -y distro-sync
to force a sync of all packages with CentOS 6.2 versions:
unix% su # cd rpms.<toolchain>.<cpu>-<version> # cp config/CentOS-Base.repo /etc/yum.repos.d # # yum clean all # # yum -y distro-sync # # exit unix% logout
As part of the RPM build process the RPM build user needs to be able to run with root privileges. For the purposes of this document, we assume the username that is building the RPMs is "broadcom". To enable the RPM build user to get root access requires modifications to the /etc/group and /etc/sudoers files as shown below. Note that after making these changes you must fully logout from the system and then log back in again.
unix% su # cd /etc # vi group Add ",broadcom" to the line that starts with "wheel:" # vi sudoers Search for the line "\# %wheel ALL=(ALL) NOPASSWD: ALL" and uncomment it # exit unix% logout
You can test that sudo is working by using the sudo -n whoami
command:
unix% sudo -n whoami root unix%
If you get any other response than "root" then please check your /etc/group and /etc/sudoers files, and remember to fully log out after changing them. The RPM build process will also validate the sudo setup.
After the CentOS 6.2 host has been installed, additional packages must be added in order to support the RPM build process. A script that installs these packages is supplied by Broadcom in the RPM tar ball. This is available in the rpms.<toolchain>.<cpu>-<version>/src/tools directory. Note that this script must be executed by the root user. For example:
unix% cd rpms.<toolchain>.<cpu>-<version>/src/tools unix% sudo ./inst-build-pkgs.sh .. Complete! unix%
The RPM build machine must also have the Broadcom tool chain installed. See the Tool Chain Installation section for further details on this. Once the tool chain is installed a symlink must be created from it into your soon-to-be-created fake root directory. The RPM build process actually uses two fake roots: one for the build process and one for creating the initial bootstrap files that are needed for installing the rpm application. Both of these fake root directories are located under /tmp/fakeroot-<tcarch>-$USER/build (e.g. /tmp/fakeroot-brl_3.8.e500_v2-broadcom); one in the build subdirectory and the other in the install subdirectory. Note that these fake roots are created for you as part of the compile process.
The compiler already uses a fake root for linking purposes (e.g. /projects/nwsoft-toolchains/brl/brl_3.8/e500v2/usr/bin/powerpc-broadcom-linux-gnuspe for a BRL 3.8 tool chain on an e500_v2 type CPU). We must link our build fake root directory into the compiler fake root, and we do it using the same directory layout as will be used on the final target (i.e. RPMs will be installed into /mnt/fastpath/usr).
The steps below illustrate this for the BRL 3.8 tool chain on an e500_v2 type CPU. Note that even though the fake root might not exist yet it is ok to create a symlink to it.
unix% su # cd /projects/nwsoft-toolchains/brl/brl_3.8/e500v2/usr/powerpc-broadcom-linux-gnuspe # rm -f mnt # ln -sf /tmp/fakeroot-brl_3.8.e500_v2-broadcom/build/mnt mnt # exit unit%
The steps below illustrate this for the XLP MIPS tool chain.
unix% su # cd /projects/nwsoft-toolchains/netlogic/sdk-2.2.7/toolchains_bin/mipscross/linux/mips64-nlm-linux # rm -f mnt # ln -sf /tmp/fakeroot-brl_2.0.1.xlp-broadcom/build/mnt mnt # exit unit%
The build process will check that this fake root link is correct.
If you are using the XLP/WRX MIPS toolchain then new shell script aliases to the tools must be created for two reasons:
To use the new shell script aliases, copy them from the appropriate src/tools/nl-sdk-<version> directory of the RPM tar ball, and update a soft link, as shown below:
unix% su # cp -f src/tools/nl-sdk-3.0.1-ehb/* /projects/nwsoft-toolchains/netlogic/sdk-3.0.1-ehb/toolchains_bin/mipscross/linux/bin # # cd /projects/nwsoft-toolchains/netlogic/sdk-3.0.1-ehb/toolchains_bin/mipscross/linux # ln -s mips64-nlm-linux mips64-nlmbroadcom-linux # exit unix%
The rpmbuild command is used by the Makefiles to build a package. rpmbuild will parse the <package>.spec file, extract the source code, apply patches, perform the build, install the binaries and then create the <package>.rpm file. This is all done in the rpms.<toolchain>.<cpu>-<version>/output/rpmbuild directory. Within that directory a number of standard subdirectories are used:
These directories will be created for you as part of the build process.
Two RPM configuration files must be copied from the Broadcom RPM tar ball into the build users home directory: .rpmmacros and .rpmrc. These are available in the rpms.<toolchain>.<cpu>-<version>/config directory of the RPM tar ball. For example:
unix% cd rpms.<toolchain>.<cpu>-<version> unix% cp ~/.rpmmacros ~/.rpmmacros.bak unix% cp -f config/DOTrpmmacros ~/.rpmmacros unix% cp ~/.rpmrc ~/.rpmrc.bak unix% cp -f config/DOTrpmrc ~/.rpmrc
You must then edit the first line in ~/.rpmmacros so that it points to the location that you are using for building RPMs. This location should be the rpms.<toolchain>.<cpu>-<version>/output/rpmbuild directory that was created when extracting the RPM tar ball. For example, if you are using the BRL 3.8 tool chain on an e500_v2 type CPU then edit ~/.rpmmacros and change the line that starts with "%_topdir" to /$FULLPATH/rpms.brl_3.8.e500_v2-1.0.1.7/output/rpmbuild.
Before any RPMs can be compiled, the source RPMs must be installed. For all RPMs supplied by Broadcom, the source RPM is supplied in the rpms.<toolchain>.<cpu>-<version>/SRPMS directory of the RPM tar ball. All of the source RPMs should be installed as follows:
unix% cd rpms.<toolchain>.<cpu>-<version>/output/SRPMS unix% rpm -i *.src.rpm
After completing all of the above steps you are now in a position to start building the RPMs that are supplied by Broadcom. To facilitate this, Broadcom provides Makefiles that perform all of the work of using rpmbuild to build the RPM, then installing it into a fake root file system for subsequent RPM builds, and creating the appropriate links in that fake root file system. The Makefiles also configure all of the correct compiler environment variables and flags.
To compile the RPMs simply step into the rpms.<toolchain>.<cpu>-<version> directory from the RPM tar ball and type make \<toolchain\>.\<cpu\>
. For example, to make the RPMs for a BRL 3.8 tool chain on the e500_v2 family of CPUs (note that this make will typically take two or more hours):
unix% cd rpms.brl_3.8.e500_v2-1.0.1.7 unix% make brl_3.8.e500_v2 ... Build Complete unix%
The following is a list of the results of the RPM compile:
Note: The output/RPMS is actually a copy and merge of the output/rpmbuild/RPMS/<cpu> and output/rpmbuild/RPMS/noarch directories. Likewise output/SRPMS is a copy of output/rpmbuild/SRPMS. This is done to simplify the installation of the RPMs with the rpm-install script and to allow the output directory to be deleted without loosing the source RPMs.
It should be noted that the RPMs build on top of each other. For example, you cannot compile the telnet package itself until the libraries and header files of the ncurses RPM have been built and installed. This dependency is already part of the Broadcom Makefile that builds the RPMs, but care must be taken when changing and then recompiling a package after having already compiled other packages. Please note the following tips when compiling the RPMs:
make clean
before compiling the RPMs.make clean
.A full clean of the RPM build directory can be done with make distroclean
. Note that this will delete the entire output directory - be careful if you have installed additional RPMs into the output/rpmbuild/SOURCES and output/rpmbuild/SPECS directories.