Packaging: VDSM v4.12.0 packaged on Ubuntu

Add files for building VDSM .deb packages on Ubuntu. The package is
split into vdsm-python, vdsm-client, vdsm, vdsm-tests ,various vdsm
hooks, vdsm-python-cpopen vdsm-yajsonrpc and vdsm-gluster.

How does it work.
The deb packaging scripts are written according to Debian New
Maintainers' Guide [1]. We use dh_make, quilt and -buildpackage to do
the packaging. All files unde the sub-dir debian are related to
packaging. The most important ones are as follow.

debian/changelog
This file declares the deb package version.

debian/control
This file declares the dependency packages and other basic informations

debian/rules
This file is an executable Makefile. During the packaging process, it
calls dh_XXX helpers to do the things. We can override some of the stages to
provide custom actions. In this rule file, the following build options
are used.
1 Do not configure libvirt to use sanlock, since it's not supported on
Ubuntu.
2 Do not configure libvirt to use selinux and apparmor. Becuase apparmor
is conflicting with VDSM, and libvirt on Ubuntu does not compiled with
selinux support, so just do not use the security driver of libvirt.
3 Hooks are enabled and built into respetive packages.

debian/package-name.install
Describe files go to the respective sub .deb packages. The directory
containing the file is created automatically.

debian/package-name.dirs
Any dir that is not created automatically by the .intall file.

debian/vdsm.postinst
debian/vdsm.postrm
debian/vdsm.preinst
debian/vdsm.prerm
These four files are maintainer scripts. They are like %pre %post %preun
and %postun in a RPM .spec file. They are run before VDSM package is
intalled, upgraded, and removed. The Debian upgrading process is not
like RPM.
Script execution order when updating a RPM [2]
     %pre of new package
     (package install)
     %post of new package
     %preun of old package
     (removal of old package)
     %postun of old package
Script execution order when updating DEB [3]
    old->prerm upgrade new_ver
    new->preinst upgrade old_ver
    (new files are unpackad)
    old->postrm upgrade new_ver
    (old files are deleted)
    new->postinst configure old_ver
So you will see the contents of these file is very different with
vdsm.spec.in. Another difference is Debian do not generate .pyc files
when packaging, instead, it just ship .py files and after install,
compile the .py to .pyc according to /etc/python/debian_config [4]. The
postinst and prerm scripts do this automatically if we include the
string "#DEBHELPER#". This means actions calling the .pyc files should
happen after the .pyc files are generated.

Other files are just boilerplates to fill.

There are some dependencies that are too old or not available on Ubuntu.

python-ethtool
Too old. The official maintainer does not work on it any longer. So we
have to download the source package and repackage it using the latest
upstream.

python-pthreading
Not available on Ubuntu, need to create .deb packages.

python-rtslib
Ubuntu provide the official version, but in functional tests we use the
Fedora forked version. The two versions are not compatible. Now we do
not add python-rtslib dependency to vdsm-tests. The user can install the
Fedora forked version by "pip install rtslib-fb", if they want to run
functional tests.

sanlock
Too old. The official maintainer does not work on it any longer, but he
helps me and provide new version of sanlock packages. These new packages
are not in Debian official repository unless they are well tested. For
now we can host these packages together with VDSM .deb package. The
packages are for Debian, thus I made a little change to fit into Ubuntu.

libvirt-sanlock
libvirt-sanlock is not available on Ubuntu, but it's in Debian "sid",
the next Debian release. Not sure Ubuntu will take lbvirt-sanlock in
next release. So now just drop libvirt disk locking.

I re-packaged python-ethtool, and packaged python-pthreading from sratch.
sanlock pakcages are provided by the original maintainer, and I modified
it to suit into Ubuntu. The packages are put on launchpad.net [5]. To test
the package, firstly setup a Ubuntu 1304 server, then run the following
command.

add-apt-repository ppa:zhshzhou/vdsm-ubuntu
add-apt-repository ppa:semiosis/ubuntu-glusterfs-3.4
aptitude update
aptitude install python-pip vdsm vdsm-gluster vdsm-tests vdsm-client
pip install rtslib-fb
chmod a+r /boot/vmlinuz* /boot/initrd.img*
cd /usr/share/vdsm/tests
./run_tests.sh functional/virtTests.py functional/storageTests.py

[1] http://www.debian.org/doc/manuals/maint-guide/index.en.html
[2] http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
[3] https://wiki.debian.org/MaintainerScripts
[4] http://www.debian.org/doc/packaging-manuals/python-policy/ch-module_packages.html#s-byte_compilation
[5] https://launchpad.net/~zhshzhou/+archive/vdsm-ubuntu

Change-Id: Iab62aeadfa65baef3f0f4e6da2592fa0ff451c6f
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com>
Reviewed-on: http://gerrit.ovirt.org/18443
Reviewed-by: Dan Kenigsberg <danken@redhat.com>