-
Notifications
You must be signed in to change notification settings - Fork 47
Create .deb Package for Femhub
In this tutorial, we'll go step by step through the pocess 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
- data
Create a package directory named "my_package"
Create a sub directory named "my_package/DEBIAN"
Create a control file & installation scripts
- my_package/DEBIAN/control
- my_package/DEBIAN/preinst
- my_package/DEBIAN/postinst
- my_package/DEBIAN/prerm
- my_package/DEBIAN/postrm
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 removel of any file installed by the package, like stoping 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
- /usr/bin/my_file
- /var/www/my_dir
then add these files and dirs as
- my_package/usr/bin/my_file
- my_package/var/www/my_dir
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
Package: femhub-online-lab-sdk-1.0.0
Source:
Version: 1.0.0
Architecture: amd64
Maintainer: [email protected]
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.
#! /bin/bash
set -e
if [ "$SPKG_LOCAL" = "" ]; then
echo "SPKG_LOCAL undefined ... exiting";
exit 1
fi
#! /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