In a previous post, Dave Scott showed how easy it now is to install the core components of XenServer on a standard installation of CentOS, using xenserver-core. Since then, we have been hard at work adding features and functionality, and making it even smoother and easier to install from our repositories. However, since developers are a major part of the audience for xenserver-core, we have also paid a lot of attention to making it as smooth and easy as possible to build the packages for yourself.
On RPM-based distributions, the packages are built using a tool called mock. Mock builds each new package in a fresh chroot environment, ensuring that your system isn't affected by the by-products of building packages, and that missing dependencies in the package specifications don't go unnoticed. To install it on a RHEL/CentOS system then you will need to add the EPEL repositories. Here is a useful article for CentOS.
After adding EPEL, install and set up mock:
yum install -y mock rpm-build
Mock will refuse to run as root - you can run it using your own user account, or a special account you create for this purpose. To add this account to the mock group, type the following as root:
useradd -G mock <username>
su - <username>
Building the packages
With the prerequisites installed, building xenserver-core is a 4-step process:
Clone the xenserver-core repository. If you are planning to make changes, you should fork the repository on GitHub and clone that instead. To clone the main xenserver-core repository, type:
git clone https://github.com/xapi-project/xenserver-core.git
This configures mock and initializes an RPM repository in the RPMS directory, where the built packages will be stored. Enter the directory created by git (by default, it will be called "xenserver-core") and type:
Generate the makefile which will actually build the xenserver-core packages:
./makemake.py > Makefile
Start the build:
Building all the xenserver-core packages takes around 90 minutes on a reasonably fast machine, and requires a couple of gigabytes of free disk space. When the build finishes, you will find source packages in the SRPMS directory, and binaries in RPMS.
Installing your new packages
The most flexible way to install your packages is to copy newly-built RPM repository to a web server and configure YUM on your target machine to download packages from there. Assuming that you already have a web server set up, copy the RPMS and SRPMS directories to your server's DOCROOT directory.
To configure the target machine to use your new repository, create /etc/yum.repos.d/xapi.conf, filling in your repository's baseurl as appropriate:
name=CentOS-$releasever - xenserver-core
name=CentOS-$releasever - xenserver-core
After this, type yum install xenserver-core to install the packages from your new repository. Once the installation is complete, run the xenserver-install-wizard command to configure xenserver-core. Please note that, unless you were already running under Xen, you will have to reboot to complete the installation.
What's going on here?
When you cloned the xenserver-core repository you may have noticed that it doesn't actually contain any software. Instead, it has a collection of RPM SPEC files, along with the build scripts we ran above. When you run make, it downloads each package's source code from the upstream repository, builds a source RPM, then uses mock to compile the binary RPM, as you can see in this snippet of build output:
Please give us feedback
We want to make xenserver-core as easy as possible to install, build and use. We would love to hear what you think of our progress so far. You can contact us through comments on this blog. If you have development questions about XenServer and its components, try the firstname.lastname@example.org mailing list.
If you run into any problems or bugs in xenserver-core's packaging or build scripts, please raise an issue on our GitHub issues page.
Following the instructions above will build xenserver-core for an RPM-based distribution such as Fedora or CentOS. What if you prefer Ubuntu or another Debian-based distribution? Try cloning the repository onto your Ubuntu machine and running the build there. The results may surprise you!
More updates coming soon...