HFST: Hfst Debian Releasing (Old)

The dummy library and tools

You are in the directory libraries-for-debian-testing that contains the files foo.h,

namespace foo {
  int foo_function(int i);
}

foo.cc,

#include "foo.h"
#include "bar.h"

namespace foo {
  int foo_function(int i)
  {
    return bar::bar_function(i) + 3;
  }
}

bar.h,

namespace bar {
  int bar_function(int i);
}

bar.cc,

#include "bar.h"

namespace bar {
  int bar_function(int i) {
    return i + 4;
  }
}

and foo-tool.cc

#include "foo.h"
#include <cstdio>

int main() {
  int i = foo::foo_function(3);
  fprintf(stderr, "%i == 10\n", i);
}

The tools and libraries can be created with the following commands in the directory libraries-for-debian-testing:

gcc -fPIC -g -c -Wall foo.cc
gcc -fPIC -g -c -Wall bar.cc
gcc -shared -Wl,-soname,libfoo.so.0 -o libfoo.so.0.0.0 foo.o -lc
gcc -shared -Wl,-soname,libbar.so.0 -o libbar.so.0.0.0 bar.o -lc
ldconfig -n .
ln -sf -T libbar.so.0.0.0 libbar.so
ln -sf -T libfoo.so.0.0.0 libfoo.so
gcc -I. -c foo-tool.cc -o foo-tool.o
export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH
gcc -L. foo-tool.o -lfoo -lbar -o foo-tool
chmod ugo+rx foo-tool

The dummy debian files

The directory libraries-for-debian-testing contains the directory debian-package that contains the following directories and files:

debian
   DEBIAN
      control
      postinst
      shlibs
   usr
      bin
      lib
      share
         doc
            foo-dev
               changelog.Debian
               copyright
         man
            man1

The file control contains

Package: foo-dev
Source: foo
Version: 1-1.1
Section: devel
Priority: optional
Architecture: amd64
Provides: libbar
Depends: libc6 (>= 1.1)
Maintainer: FOO team <foo@bar.fi>
Description: This package contains FOO library and commandline tools
  More description here.

The file postinst contains

#!/bin/sh
set -e
if [ "$1" = configure ] ; then
    sudo ldconfig;
fi
#DEBHELPER#
exit 0

The file shlibs contains

libfoo 0
libbar 0

The file changelog.Debian contains

foo (0.0-0) unstable; urgency=low

  * Initial release

 -- Foo Bar <foo@bar.fi>  Thu, 17 Mar 2011 02:09:22 +0200

The file copyright contains

This work was packaged for Debian by:

    Foo Bar <foo@bar.fi> on Thu, 17 Mar 2011 02:09:22 +0200

It was downloaded from <http://sf.net/projects/hfst/files/>

Upstream Author(s):

    Foo Bar <foo@bar.fi>

Copyright:

    Copyright (C) 2011 University of Helsinki <hfst-bugs@helsinki.fi>

License: GPL-3
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    .
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    .
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    .
    On Debian systems, the full text of the GNU General Public
    License version 3 can be found in the file
    `/usr/share/common-licenses/GPL-3'

The Debian packaging is:

    Copyright (C) 2011 Foo Bar <foo@bar.fi>

and is licensed under the GPL version 3,
see `/usr/share/common-licenses/GPL-3'.

Copying the library and tools

Copy the tools and libraries (execute the commands in the directory debian-package)

cp ../foo-tool debian/usr/bin/
cp -P ../libfoo* debian/usr/lib/
cp -P ../libbar* debian/usr/lib/
strip debian/usr/lib/*
strip debian/usr/bin/*
chmod 0644 debian/usr/lib/*

Configure the libraries (this might yield a warning that foo-tool is uselessly linked against libbar)

cp debian/DEBIAN/control debian/control
dpkg-shlibdeps debian/usr/bin/*
rm debian/control

gzip the changelog file

gzip --best debian/usr/share/doc/foo-dev/changelog.Debian

Make the package

fakeroot dpkg-deb --build debian

Test if the package is ok (lintian will give some warnings, see if they should be handled...)

lintian debian.deb

To install the package, execute

sudo dpkg -i debian.deb

and to remove

sudo dpkg -r foo-dev

For 32-bit system

When in directory /mnt/i386/home/eaxelson/hfst-debian/, execute the following commands:

#
# copy the command line programs
#
cp /usr/local/bin/hfst-* ./debian/usr/bin/
strip ./debian/usr/bin/*

#
# copy the libraries
#
cp /usr/local/lib/libhfst.so.11.0.0 ./debian/usr/lib/
cp /usr/local/lib/libfst.so.0.0.0 ./debian/usr/lib/
cp /usr/lib/libsfst.so ./debian/usr/lib/
cp /usr/lib/libfoma.so.0.9.16 ./debian/usr/lib/

cd debian/usr/lib/

ln -s -T libhfst.so.11.0.0 libhfst.so.11
ln -s -T libhfst.so.11 libhfst.so

ln -s -T libfst.so.0.0.0 libfst.so.0
ln -s -T libfst.so.0 libfst.so

ln -s -T libfoma.so.0.9.16 libfoma.so.0
ln -s -T libfoma.so.0 libfoma.so

# handle also libsfst
# add -Wl,-soname,libsfst.so.0 to sfst library when compiling

strip *
chmod 0644 *

cd ../../..

#
# copy the header files
#
cp -P -R  /usr/local/include/hfst/* debian/usr/include/hfst/ 
chmod 0644 debian/usr/include/*
chmod 0755 debian/usr/include/hfst

#
# Remove the rpaths from HFST tools
#
cd debian/usr/bin
for program in *; 
do  
    if ! [ -L "$program" ]; then 
        sudo chrpath -d $program ; 
    fi; 
done
cd ../../..

#
# Configure the libraries
#
cp debian/DEBIAN/control debian/control
dpkg-shlibdeps debian/usr/bin/*
rm debian/control

#
# gzip the changelog file, if needed
#
if [ -e debian/usr/share/doc/hfst-dev/changelog.Debian ]; then
    gzip --force --best debian/usr/share/doc/hfst-dev/changelog.Debian;
fi

#
# gzip the man pages
#
gzip --best --force debian/usr/share/man/man1/*.1

#
# Make the package
#
fakeroot dpkg-deb --build debian

#
# Make a copy of the current directory without the .svn files
#
cd ..
tar -c --exclude=.svn hfst-debian | tar -x -C hfst-debian-copy
cd hfst-debian-copy
mv hfst-debian/* .
rmdir hfst-debian


#
# Test if the package is ok (lintian will probably give some warnings, 
# see if they should be handled...)
#
lintian debian.deb

# E: hfst-dev: executable-in-usr-share-doc usr/share/doc/hfst-dev/changelog.Debian.gz 0755
# E: hfst-dev: executable-in-usr-share-doc usr/share/doc/hfst-dev/copyright 0755
# E: hfst-dev: control-file-has-bad-permissions shlibs 0755 != 0644

chmod ugo-x debian/usr/share/doc/hfst-dev/changelog.Debian.gz
chmod ugo-x debian/usr/share/doc/hfst-dev/copyright
chmod ugo-x debian/DEBIAN/shlibs

# E: hfst-dev: sharedobject-in-library-directory-missing-soname usr/lib/libsfst.so
# FIX: add -Wl,-soname,libsfst.so.0 to sfst library when compiling



-- ErikAxelson - 2011-11-17
Topic revision: r12 - 2012-02-03 - ErikAxelson
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback