Howto Packaging EzWeb

Introduction

Creating the Package

Remove any .pyc file from source directory

   $ rm -f $(find ezweb-platform_20080125 -name "*.pyc")

Create the package data layout

   $ mkdir -p debian/usr/share/ezweb-platform
   $ mkdir -p debian/etc/ezweb-platform
   $ mkdir -p debian/etc/apache2/sites-available
   $ mkdir -p debian/etc/apache2/sites-enabled
   $ mkdir -p debian/var/lib/ezweb-platform
   $ mkdir -p debian/DEBIAN

Move the package contents

   $ cp -r ezweb-platform_20080125/* debian/usr/share/ezweb-platform/

Edit the control file

   $ vim debian/DEBIAN/control

Control file contents should look like

Package: ezweb-platform
Version: 20080125
Section: web
Priority: optional
Architecture: all
Depends: python (>= 2.4), apache2 (>= 2.0), libapache2-mod-python, python-xml,  python-django (>>0.96), python-pysqlite2
Maintainer: Alvaro Polo Valdenebro <apv@tid.es>
Description: EzWeb Platform
 This package provides the EzWeb Platform, the Telefonica I+D Mashup Engine

Edit the Apache 2 virtual host config file

   $ vim debian/etc/apache2/sites-available/ezweb-platform

Apache 2 config file should look like this

NameVirtualHost *

<VirtualHost *>
  ServerAdmin webmaster@localhost

  ServerName localhost

  DocumentRoot /usr/share/ezweb

  ErrorLog /var/log/apache2/ezweb-error.log

  LogLevel warn

  CustomLog /var/log/apache2/ezweb-access.log combined

  ServerSignature On

  <Location />
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings

    PythonPath "['/usr/share/ezweb'] + sys.path"
  </Location>

  <Location /media>
    SetHandler None
  </Location>

</VirtualHost>

Edit the post-installation script

   $ vim debian/DEBIAN/postinst

Post-installation script should look like

#!/bin/sh

###
# Set the correct file owner
#
chown -R root:root /usr/share/ezweb-platform
chown root:root /etc/apache2/sites-available/ezweb-platform

###
# Create a link to settings in /etc
#
ln -s /usr/share/ezweb-platform/settings.py /etc/ezweb-platform/settings.py

###
# Set the correct hostname for virtual host
#
while true; do
   echo -n "Please, select a host name for your EzWeb site: "

   read hostname

   if [ -z $hostname ] ; then
     echo "Invalid hostname, please try again."
   else
     break
   fi
done

cat /etc/apache2/sites-available/ezweb-platform | sed s/localhost/$hostname/g > /tmp/ezweb-postinst
mv /tmp/ezweb-postinst /etc/apache2/sites-available/ezweb-platform

ln -s /etc/apache2/sites-available/ezweb-platform /etc/apache2/sites-enabled/010-ezweb-platform

###
# Initialize the database
#
mkdir -p /var/lib/ezweb-platform

cd /usr/share/ezweb-platform
python manage.py syncdb

chown -R www-data:www-data /var/lib/ezweb-platform


###
# Restart apache 2 web server
###
/etc/init.d/apache2 restart

Create the package

   $ dpkg-deb --build debian ezweb-platform_20080125.deb

Attachments