Create .deb Package for Femhub
Clone this wiki locally
In this tutorial, we'll go step by step through the process of creating .deb packages, starting with really simple packages.
A Debian package is basically a tar archive, consist of
- control file, It contains information about a package
- Installation scripts
Create a package directory named "my_package"
Create a sub directory named "my_package/DEBIAN"
Create a control file & installation scripts
preinst, this script is responsible to do any task before installation starts
postinst, this script is responsible to do any task after extraction of the content of the package
prerm, this script is responsible to do any task before removal of any file installed by the package, like stopping some services etc.
postrm, this script is responsible to remove any file installed by the package
Note: permission of scripts should be 755
Add data files & directories that are to be copied during installation For eg, lets say we need few files to be copied in our system as
then add these files and dirs as
during installation all the content of my_package/ will be extracted in /
build the package
$ dpkg-deb --build my_package
this will create my_package.deb
Example of control file: my_package/DEBIAN/control
Package: femhub-online-lab-sdk-1.0.0 Source: Version: 1.0.0 Architecture: amd64 Maintainer: firstname.lastname@example.org Installed-Size: 1000 Depends: python2.6 (>= 2.6.5), python-numpy (>= 1.3.0), python-scipy (>= 0.7.0) Conflicts: Replaces: Section: Priority: optional Homepage: https://github.com/femhub/femhub-online-lab-sdk Description: FEMhub Online Lab Software Development Kit (SDK) The purpose of this SDK is to facilitate the development of applications for the FEMhub Online Lab (http://lab.femhub.org). The goal of the FEMhub Online Lab is to make computer modeling and simulation accessible to anyone, without a need to own expensive hardware or software. The Online Lab operates inside the web browser window that turns into a virtual computer desktop. The Online Lab is accessible from PCs, laptops, netbooks, iPads, PDAs, and even web-enabled smart phones.
Example of preinst file: my_package/DEBIAN/preinst
#! /bin/bash set -e if [ "$SPKG_LOCAL" = "" ]; then echo "SPKG_LOCAL undefined ... exiting"; exit 1 fi
Example of postinst file: my_package/DEBIAN/postinst
#! /bin/bash set -e if [ "$SPKG_LOCAL" = "" ]; then echo "SPKG_LOCAL undefined ... exiting"; exit 1 fi PACKAGE_NAME=femhub_online_lab_sdk CONFIG_DIR="$SPKG_LOCAL/share/onlinelab/" # remove old install: rm -rf $SPKG_LOCAL/lib/python/site-packages/onlinelab CONFIG_DIR_BACKUP=`mktemp -d --tmpdir=$SPKG_LOCAL/share/` mkdir -p $CONFIG_DIR mv $CONFIG_DIR $CONFIG_DIR_BACKUP/ echo "Old data are stored in: $CONFIG_DIR_BACKUP" # install online lab cp -pr onlinelab $SPKG_LOCAL/lib/python/site-packages/ cp bin/onlinelab $SPKG_LOCAL/bin mkdir -p $CONFIG_DIR cp -r ui $CONFIG_DIR/ # init the online lab onlinelab sdk init --home=$CONFIG_DIR/sdk-home --ui-path=$CONFIG_DIR/ui # allow to pass the os.environ into the engine Python process (so that # LD_LIBRARY_PATH and other things are properly set): echo "ENVIRON = True" >> $CONFIG_DIR/sdk-home/settings.py # Try to copy the data from the old installation: if [ -f "$CONFIG_DIR_BACKUP/onlinelab/sdk-home/onlinelab.db" ]; then echo "Copying old database into the new lab" cp "$CONFIG_DIR_BACKUP/onlinelab/sdk-home/onlinelab.db" $CONFIG_DIR/sdk-home/ else echo "No old database found, nothing copied." fi if [ $? -ne 0 ]; then echo "Error installing femhub_online_lab_sdk" exit 1 fi