Build RPMs for
Native Application Hosting
This section explains how you can build RPMs for native application hosting.
Set Up the Build Environment
This section describes the two methods of preparing and setting the build environment for native application hosting.
- Create Native Build Environment Using QEMU Hypervisor
- Create a Cross-Build Environment Using the SDK Shell Script
Create Native Build Environment Using QEMU Hypervisor
This section describes a method of creating the native Wind River Linux 7.0 build environment, and running the environment ISO by using a Quick Emulator (QEMU) hypervisor.
Prerequisites
Configuration Procedure
-
Launch the native WRL7 ISO and install it onto a disk image.
qemu-system-x86_64 -m 16G -cdrom <path-to-the-downloaded-iso-file> -net nic -net user -hda ./wrl7.img -cpu core2duo -show-cursor -usb -usbdevice wacom-tablet -vga vmware
-
Relaunch the native build environment with the installed image.
qemu-system-x86_64 -m 16G -net nic -net user -hda ./wrl7.img -cpu core2duo -show-cursor -usb -usbdevice wacom-tablet -vga vmware
The native build environment is ready for hosting third-party applications. The user is connected to the VGA console port of the native QEMU VM.
Alternatively, a user can connect to an SSH service running inside the VM.
Create a Cross-Build Environment Using the SDK Shell Script
As an alternative to the native environment, you can create a cross-build environment by using a WRL7 cross-SDK shell script. You can install the SDK by running the shell script on a general-purpose Linux environment, such as an Ubuntu 14.04 host machine.
Prerequisites
Ensure that the following requirements are met before you proceed with the installation.
Installation Procedure
To install the SDK for native application hosting, use these steps:
-
Download the SDK from the Cisco repository.
wget https://devhub.cisco.com/artifactory/xr600/app-dev-sdk/x86_64/ wrlinux-7.0.0.2-glibc-x86_64-intel_x86_64-wrlinux-image-glibc-std-sdk.sh
-
Install the SDK by running the shell script.
john@sjc-ads-4587:john$ ./wrlinux-7.0.0.2-glibc-x86_64-intel_x86_64-wrlinux-image-glibc-std-sdk.sh
-
Enter the target directory for installing the SDK.
Choose a target directory that has sufficient storage space.
Enter target directory for SDK (default: /opt/windriver/wrlinux/7.0-intel-x86-64): /nobackup/john/sdk_extract You are about to install the SDK to "/nobackup/john/sdk_extract". Proceed[Y/n]? Y
On successful installation, a message is displayed on the screen.
Extracting SDK...done Setting it up...done SDK has been successfully set up and is ready to be used.
The SDK for native application hosting is successfully installed.
What to do Next
You can set up the environment variables, and validate them as explained in this section.
-
Navigate to the directory, where the SDK is installed and set up the environment variables by running the following commands: The commands execute the environment setup file that was extracted during SDK installation.
-
Validate the installed environment variables by running the env command to view all variable values.
-
Validate the CC environment variable by running the env | grep CC command, and verifying whether the following value is assigned:
CC=x86_64-wrs-linux-gcc -m64 --sysroot=/nobackup/john/sdk_extract/sysroots/core2-64-wrs-linux
Alternatively, you can use the echo command:
echo $CC x86_64-wrs-linux-gcc -m64 --sysroot=/opt/windriver/wrlinux/7.0-intel-x86-64/sysroots/core2-64-wrs-linux
-
Verify whether the PATH environment variable points to the base directory, where the SDK was installed.
To verify the path, run the env | grep PATH command and check whether the following path is displayed:
PATH=<sdk_extract>/sysroots/ x86_64-wrlinuxsdk-linux/usr/bin: <sdk_extract>/sysroots/x86_64-wrlinuxsdk-linux/usr/bin/x86_64-wrs-linux
Alternatively, you can use the echo command:
echo $PATH <sdk_extract>/sysroots/x86_64-wrlinuxsdk-linux/usr/bin: <sdk_extract>/sysroots/x86_64-wrlinuxsdk-linux/usr/bin/x86_64-wrs-linux
-
Navigate to the directory that contains the application source code, and start building the application.
Note
You should remove all the *.la temporary files from the SDK root file system. To do this, use the following commands: bash# cd <sdk_extract>/sysroots/ bash# find . -name \*.la | xargs rm -f
Build Native RPMs
This section describes the procedure for building applications by using either the native environment, or the cross-build environment. It is recommended that you use the native build environment.
There are two ways of building applications from source code.
One method is to build an application from a source code archive; this is explained in this section. The other method is to build it from a source RPM, which is not recommended.
Prerequisites
Ensure that the following requirements are met before you proceed:
Configuration Procedure
To build applications, use the following steps:
-
Navigate to the directory that contains the source code for the application.
-
Run the following commands to extract the application (if compressed).
bash-4.1$ tar xzvf tcpdump-4.7.4.tar.gz
-
Change your directory to the application directory.
bash-4.1$ cd tcpdump-4.7.4
-
Build your application to generate an executable file.
tcpdump-4.7.4$ ./configure tcpdump-4.7.4$ make
-
Verify the executable file in your directory.
tcpdump-4.7.4$ ls -1 ./tcpdump -rwxr-xr-x 1 john eng 3677288 Jun 15 23:10 ./tcpdump
The executable file is listed as tcpdump.
The executable file is ready to be packaged for hosting your application on IOS XR.
What to do Next
Package the application binaries so that it can be installed on IOS XR.
The recommended packaging format is RPM so that it can hosted on IOS XR.
To build an RPM:
Use the following steps to package the binaries:
-
Create a .spec file in the SPECS directory.
# %define __strip /bin/true Name: tcpdump Version: 4.7.4 Release: XR Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root License: Copyright (c) 2015 Cisco Systems Inc. All rights reserved. Packager: mark SOURCE0 : %{name}-%{version}.tar.gz Group: 3'rd party applicaiton Summary: Tcpdump cross compiled for WRL6 %description This is a cross compiled version of tcpdump using IOS XR sdk for WRL7 %prep %setup -q -n %{name}-%{version} %build # This where sdk is being sourced source /nobackup/mark/sdk_extract_18/tmp/env.sh ./configure make %install rm -rf ${RPM_BUILD_ROOT} # make DESTDIR=$RPM_BUILD_ROOT install mkdir -p ${RPM_BUILD_ROOT}%{_sbindir} install -m755 tcpdump ${RPM_BUILD_ROOT}%{_sbindir} %files %defattr(-,root,root) %{_sbindir}/tcpdump %pre %post %preun %postun %clean rm -rf $RPM_BUILD_ROOT
-
Build the RPM.
mark@tenby:redhat$ cd /usr/src/redhat/SPECS/ mark@tenby:SPECS$ rpmbuild -ba tcpdump.spec
The RPM build used is the 5.4.14 version.
-
Verify that the binary is built in the RPMS directory.
mark@tenby:x86_64$ pwd /usr/src/redhat/RPMS/x86_64 mark@tenby:x86_64$ ls tcpdump-4.7.4-XR.x86_64.rpm
The native applications are ready to be hosted. For information on hosting native applications, see Run iPerf as a Native Application.