Adding Packages

From LinuxC6xWiki

Jump to: navigation, search

Contents

Introduction

The goal of this document is to explain how to add extra packages into the Linux root file system when generating a 'full-root' profile. The support of several example packages is already present in the release.

Main concepts

The additional packages are located in two directories:

  • ~/my-linux-c6x/projects/packages/ that contains the building rules (spec files) and the additional patches (optional)
  • ~/my-linux-c6x/projects/package-downloads/ that contains the archives of the package sources

The packages are built using the RPM system (http://rpm.org/) adapted for C6x cross-compilation.

RPM uses spec files (*.spec) for describing how to cross-compile the sources and how to generate the packages. The spec files are located in the ~/my-linux-c6x/projects/packages/<package_name>-<version>/ directory.

The original package sources may need to be patched for cross-compilation or c6x architecture support. In this case the patch are referenced in the spec file and must be located in the same directory as the spec file.

Building the packages

To build these packages, choose the 'full-root' profile with the ROOTFS environment variable (by either set it manually or in the setenv file). Then set in the same way the PKG_LIST environment variable with the list of packages you want to build. For example to build all extra packages, set PKG_LIST="zlib net-snmp polarssl ttcp dhrystone nbench-byte tcpdump iperf openssl ethtool".

Afterwards you only have to type 'make rootfs' in the ~/my-linux-c6x/linux-c6x-project/ directory or rebuild the whole project with '.prj build'.

Adding a new package

For this purpose we will use a didactic approach based on concrete example: adding the LUA script language package (http://www.lua.org/) into the full-root filesytem.

Get the sources

You first need to download the sources of this packages into the ~/my-linux-c6x/projects/package-downloads/ directory. The LUA sources can be downloaded from here: [[1]].

Create the spec file

Go in the ~/my-linux-c6x/projects/packages directory, create a lua-5.2.0 directory and go in it:

 mkdir lua-5.2.0
 cd lua-5.2.0

Then edit a new lua.spec file with your favorite editor like following:

Name            : lua
Version         : 5.2.0
Release         : 1
Group           : Development/Languages
Summary         : Lua embeddable scripting language
License         : MIT
URL             : Development/Languages
Buildroot       : %{_tmppath}/%{name}-%{version}
Source          : %{name}-%{version}.tar.gz
  
%description
  
Lua is a programming language originally designed for extending applications,
but also frequently used as a general-purpose, stand-alone language.
Lua combines simple procedural syntax (similar to Pascal) with powerful
data description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, interpreted from bytecodes, and has
automatic memory management, making it ideal for configuration, scripting,
and rapid prototyping.
 
Lua is implemented as a small library of C functions, written in ANSI C, 
and compiles unmodified in all known platforms. The implementation goals
are simplicity, efficiency, portability, and low embedding cost.
  
%prep
%setup -q

%build
%make PLAT=generic MYCFLAGS="$RPM_OPT_FLAGS" AR="${RPM_ARCH_PREFIX}-ar rcu"

%install
mkdir -p $RPM_BUILD_ROOT/usr/{bin,lib}
install -s src/lua src/luac $RPM_BUILD_ROOT/usr/bin/
install src/lib*.a $RPM_BUILD_ROOT/usr/lib/

%files
%defattr(-,root,root)
/usr/bin/*
/usr/lib/*
%doc [A-Z]* doc/*.html doc/*.gif

%changelog

Build the package

Add the new package in the PKG_LIST environment variable and build the root filesystem:

 cd ~/my-linux-c6x/linux-c6x-project/
 source setenv
 export PKG_LIST="$PKG_LIST lua"
 export ROOTFS=full-root
 make rootfs

The newly created root filesystem is thus available in ~/my-linux-c6x/product in the full-root-c6x-* files.

Note that when the package build failed, you can go in the package build directory for debugging: ~/my-linux-c6x/Build/packages.<profile>/BUILD/<package_name>/

Personal tools
Create a book