August 22, 2008

Getting started with Nexenta Development - Part 2

In this part we will take a look at the steps followed to port an application from Ubuntu and build a package.

I decided to do this via a screencast. You may not be able to fastforward or rewind, so I've also listed out the steps you will need to follow below the screencast. Click below to open the screencast. Or download it for offline viewing here.

[caption id="" align="aligncenter" width="576" caption="Getting started with Nexenta screencast"]Getting started with Nexenta screencast[/caption]

Getting Access

We have a build machine available at gnusolaris.org where you can login to do your nexenta development (and not have to hassle with installing locally). You will use ssh to login, and can get the details by asking on IRC (#nexenta@freenode), or on the development mailing list gnusol-devel@sonic.net.

Logging in

You can login using your favourite shell and terminal program. The screencast uses gnome-terminal. If you are on Windows you can use the Putty client. Use

ssh username@gnusolaris.org

and enter the password when prompted.

Entering the Devzone

One of the core features of opensolaris is Zones (zfs is currently stealing all the thunder). Since giving root access to everyone is not an option, and building without it is not one either, the Nexenta project has innovated and created the so called development zones. These provide a method to quickly create a developer environment and give you root access to it. When no longer required, this zone can be painlessly removed.

The commands sure would be complex.. right? As simple as

  • devzone_create  --- creates a development zone
  • devzone_enter --- enter a devzone
  • devzone_free --- remove the zone when no longer required :)

Simple as that.

Once you have entered a newly created zone, use the following commands to get it up to date

apt­-get update; APT_CLONE_ENV=1 apt-­get dist­-upgrade

Also, you will have to create/import your gpg key for signing packages. Further instructions at http://www.nexenta.org/os/CreatePublicGPGKey

Building a package

So now that we have our environment ready, lets build a package. In the screencast we take an example of libid3tag, which is a C library that is used to parse the headers in mp3 files.

First check if the package is available in the repository (Well libid3tag is not, but you would need to check if the package you are trying to port is already in or not)

#apt-cache search package

Searched for the expression package in the repository and lists the matches if present.

If it doesnt exist, you get it from Ubuntu's repostiory mirror using the apt-upstream-tool

#apt-upstream-tool -e -p package

-e : extract the package

-p : the package name

Once we have the sources.. move into the directory, there would be 2 copies.. one original, and one for us to edit and use.

Move into this directory (this is referred to as the "package root") and make sure the changelog reflects the distro as Nexenta. You can edit the changelog entry using

#debchange

in the package root.

Next satisfy all the build dependencies of the package.. this is required if the package has to built. Do this via running the following command in the package root.

#apt-satisfydepends

The above tool will lookup all dependencies and install them from the repository if available. (If not, you would also have to port that package)

Once the above completes successfully, create the package using

#dpkg-buildpackage -sa

-sa : Bundle the source code with the package

If the above completes successfully, you will be presented with a prompt to enter your GPG passphrase to sign the package.

Once this is done your package is built and present in the parent directory to the package root. Install all .deb files to verify that they install correctly. Do this using

#dpkg -i packagename.deb

You can also take a look at the contents of the deb using

#dpkg-deb -c *.deb

Once the install goes smoothly and all looks good, upload it to the repository using

#dput *.changes

This will upload the files to the repository, and send out mails to the nexenta-changes mailing list.

Further information is availabe on the Nexenta wiki documentation section and at http://www.nexenta.org/os/BuildingPackages