Repository navigation
Debian Packages
TODO à relire, corriger, préciser et réorganiser.
## Introduction Un paquet DEBIAN installe tous les fichiers nécéssaires à divers endroits du système.
Cet article, présente comment configurer un nouveau projet JAVA afin de créer rapidement un livrable DEBIAN.
Tutoriel pour commencer : http://alp.developpez.com/tutoriels/debian/creer-paquet
Afin de permettre à dpkg de faire un paquet, nous devons respecter une aborescence particulière. L'arborescence à créer est simple :
/
+-- delivery
+-- conf
| `-- ...
+-- debian
| +-- changelog
| +-- compat
| +-- control
| +-- copyright
| +-- dirs
| +-- docs
| +-- postinst
| `-- rules
+-- lib
| `-- ...
+-- CHANGELOG
+-- README.TXT
+-- MyApp.jar
+-- my_app
+-- my_app.desktop
+-- my_app.sh
`-- my_icon.png
Sera édité et rempli à chaque build de paquet. Le créer vide pour l'instant.
Indique la version de compatibilité minimum avec DPKG. Pour une Hardy, doit contenir :
4
Le fichier de description du paquet
Source: {NOM DU PAQUET SOURCE}
Section: contrib/net
Priority: optional
Maintainer: Me <me@somewhere.com>
Build-Depends: debhelper (>= 4.0.0)
Standards-Version: 3.6.1
Package: {NOM DU PAQUET}
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, {LISTE DES PAQUETS DEBIAN DE DEPENDANCE}
Description: {DESCRIPTION COURTE}
{DESCRIPTION}
Le fichier de copyrights de votre application
This work was packaged for Debian by:
Me <me@somewhere.com> on Tue, 31 Aug 2010 09:23:10 +0200
Copyright:
Copyright (C) 2010 MyCompany All rights reserved.
License:
Redistribution and use in source and binary forms, with or without
modification, are not permitted.
This software is provided by MyCompany `as is' and any express or implied
warranties, including but not limited to, the implied warranties of
merchantability and fitness for a particular purpose are disclaimed. In no
event shall MyCompany and contributors be liable for any direct, indirect,
incidental, special, exemplary, or consequential damages (including, but
not limited to, procurement of substitute goods or services; loss of use,
data, or profits; or business interruption) hoever caused and on any
theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of
this software, even if advised of the possibility of such damage.
The Debian packaging is:
Copyright (C) 2010 Me <me@somewhere.com>
and is licensed under the GPL version 3, see above.
Fichier contenant la liste des repertoires dans lequel des éléments seronts installés. Par ex:
usr/bin
usr/share/applications/
usr/share/pixmaps/
...
Un script exécuté après l'installation. Par ex :
#!/bin/bash
set -e
case "$1" in
configure|reconfigure)
chmod 755 /usr/share/my_app/my_app.sh /usr/local/bin/my_app
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 1
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
Le fichier le plus important. Il défini l'ensemble des éléments installé et leur déploiement.
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
configure: configure-stamp
configure-stamp:
dh_testdir
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
dh_install conf/* etc/my_app/
dh_install --exclude lib/.svn lib usr/share/my_app/
dh_install remote-booth.sh usr/share/my_app/
dh_install MyApp.jar usr/share/my_app/
dh_install my_app usr/local/bin/
dh_install my_app.desktop usr/share/applications/
dh_install my_icon.png usr/share/pixmaps/
dh_install CHANGELOG usr/share/doc/my_app/
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
# dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_python
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
Il existe une commande qui permet de créer une arborescence DEBIAN automatiquement.
cd delivery
dh_make --single --native --email devteam@ymagis.net --packagename {NOM DU PACKAGE} [--copyright {FICHIER DE LICENSE}]
Ne pas hésiter à repasser dessus pour customiser un peu.
...
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
dh_install mydaemon.sh usr/share/mydaemon/
dh_install mydaemon-jar-with-dependencies.jar usr/share/mydaemon/
dh_install mydaemon usr/bin/
dh_install conf/init.d/mydaemon etc/init.d/
...
Un script d'init permet de démarrer/eteindre automatique le démon.
#! /bin/bash
start() {
start-stop-daemon --background --start --pidfile /var/run/mydaemon.pid -c user:nogroup --startas /bin/bash /usr/bin/mydaemon -- > /dev/null 2>&1
}
stop() {
ps ax | grep mydaemon | grep -v grep | awk '{print $1}' | xargs kill -9
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
log_action_msg "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
#!/bin/bash
action="$1"
oldversion="$2"
case "$1" in
configure|reconfigure)
chmod 755 /usr/share/mydaemon/mydaemon.sh
chmod 755 /usr/share/mydaemon/mydaemon-jar-with-dependencies.jar
chmod 755 /usr/bin/mydaemon
chmod 755 /etc/init.d/mydaemon
update-rc.d mydaemon start 20 2 3 4 5 . stop 20 0 1 6 .
/etc/init.d/mydaemon start
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 1
;;
*)
echo "postinst called with unknown argument '$1'" >&2
exit 1
;;
esac
exit 0
Une fois l'arborescence en place il suffit de la commiter dans SVN pour permettre la livraison en moins de 5 minutes.
Il est possible de modifier le fichier .bashrc de façon à éviter que dpkg redemande les informations du mainteneur du paquet DEBIAN :
cat >> ~/.bashrc << EOF
export DEBEMAIL="me@somewhere.com"
export EMAIL="me@somewhere.com"
export DEBFULLNAME="Me"
export NAME="Me"
EOF
Pour livrer désormais, il suffit de :
- se connecter sur la machine de build
- récupérer le répertoire delivery depuis SVN ou mettre a jour les sources
- Première livraison d'un soft
svn co http://{MON SERVEUR SVN}/my_app/trunk/delivery my_app
cd my_app
# OU
# Soft déja livré au moin une fois
cd my_app
svn up
- mettre à jour le changelog (il est possible de copier les lignes du fichier CHANGELOG qui reflete normalement les modifs)
dch -i
Ne pas oublier d'incrémenter le numéro de paquet systématiquement lorsqu'on construit un nouveau DEBIAN, même si le numéro de version du logiciel n'a pas changé (ex : 1.11-tag1 => 1.11-tag2).
5.construire le paquet
#Un script permet d'automatiser la tache
cd my_app
/home/sysadm/build.sh
#ou pour les plus téméraires
dpkg-buildpackage -us -rfakeroot -e{ADRESSE EMAIL DE LA CLEF DE SIGNATURE}
#pour packager une version i386 sur l'amd64
linux32 dpkg-buildpackage -ai386 -us -rfakeroot -e{ADRESSE EMAIL DE LA CLEF DE SIGNATURE}
rm -f ../*.dsc ../*.changes ../*.tar.gz
La procédure créé un package nommé ../my_app_version-?amd64.deb.
Il existe une tâche ANT permettant la création automatique des paquets DEBIAN :
Installer le module ant gerant les packages debian
cd /tmp/
wget http://ant-deb-task.googlecode.com/files/ant-deb-0.0.1.jar
sudo cp ant-deb-0.0.1.jar /usr/share/ant/lib/
Editer le fichier build.xml et y mettre :
<?xml version="1.0" encoding="UTF-8"?>
<project name="RemoteBooth" default="default" basedir=".">
<description>Builds, tests, and runs the project RemoteBooth.</description>
<import file="nbproject/build-impl.xml"/>
<target name="-post-jar">
<echo file="${dist.dir}/${application.title}.sh">
#!/bin/bash
java -jar RemoteBooth.jar
</echo>
<echo file="${dist.dir}/${application.title}">
#!/bin/bash
cd /usr/share/${application.title}
./${application.title}.sh
</echo>
<path id="ant-deb.classpath">
<fileset dir="/usr/share/ant/lib/" includes="ant-deb-0.0.1.jar"/>
</path>
<taskdef name="deb" classname="com.googlecode.ant_deb_task.Deb" classpathref="ant-deb.classpath"/>
<fail unless="dist.dir">Must set dist.dir</fail>
<deb
todir="${dist.dir}"
section="utils"
package="${application.title}"
depends="xingest, libwebkit-browser-perl, xtightvncviewer, barco-communicator, wine, digital-cinema-comm, sun-java5-jre | sun-java6-jre">
<version upstream="1.0"/>
<description synopsis="YMAGIS tools to help the projectionist daily operate his auditoriums">
${application.desc}
</description>
<tarfileset dir="${dist.dir}" prefix="usr/share/${application.title}">
<include name="*.jar"/>
<include name="*.sh"/>
<include name="lib/*"/>
</tarfileset>
<tarfileset dir="${dist.dir}" prefix="usr/bin/">
<include name="${application.title}"/>
</tarfileset>
</deb>
</target>
</project>
------------------>8-----------------------------------------
#!/bin/bash
# Christophe Cassagnabere & David Giangiacomo
# Custom script to set automatically the version number
# for PHP apps in debian packages.
#
VERSION=`date "+%y.%m.%d.%H"`
REVISION=`svn info | grep '^Revision:' | sed -e 's/^Revision: //'`
if [ -f ./debian/config ]; then
sed -i "s/^VERSION=.*$/VERSION=\"${VERSION}\"/" ./debian/config
sed -i "s/^REVISION=.*$/REVISION=\"${REVISION}\"/" ./debian/config
fi
dch -v ${VERSION}-r${REVISION}
------------------8<-----------------------------------------