5

I'm trying for the first time to package for Debian a small library. For this, I'm using the official Debian Policy manual but since two days I encounter an issue than I cannot fix.

This is the way I'm packaging :

  • Creating the tarball (here libvl_1.0.orig.tar.gz)
  • Using dh_make to generate the debian conf file in the debian directory
  • Modifying the control file, changelog and copyright properly.
  • Building the package using the dpkg-buildpackage command.

Up to here, there is no problem. But as it is a library, I need to create some symlinks while installing it, this related to the SONAME of the library. Here my library is called libvl. So for example, I'm building a file named libvl.so.1.0 as it is the first version. In order to do it right, I guess I should create symlinks like this :

libvl.so -> libvl.so.1 -> libvl.so.1.0

To do this, I'm trying to create those links while running the install process with make. This is working if you launch the 'make install' command. But when installing with dpkg, none if the links are created and I cannot get why. I tried also to use a postinst script but without any results. Here is below my makefile :

DESTDIR =
LIBDIR = usr/lib

LIB = libvl.so
MAJOR = 1
MINOR = 0

CC = gcc
CC_FLAGS = -Wall -ansi -Isrc/
LD_FLAGS =
LN = ln -s

SRC = very_long.c

OBJ = $(SRC:.c=.o)

all: libvl

libvl: $(OBJ)
    $(CC) -fPIC -c $(SRC)
    $(CC) -shared -a -o $(LIBDIR)/$(LIB).$(MAJOR).$(MINOR) $(OBJ)

install:
    install -d -m 0755 -o root -g root $(DESTDIR)/$(LIBDIR)
    install -m 0755 -o root -g root $(LIBDIR)/$(LIB).$(MAJOR).$(MINOR) $(DESTDIR)/$(LIBDIR)

    $(LN) /usr/lib/$(LIB).$(MAJOR).$(MINOR) /usr/lib/$(LIB).1
    $(LN) /usr/lib/$(LIB).$(MAJOR) /usr/lib/$(LIB)

clean:
    rm $(OBJ) $(LIBDIR)/$(LIB).1.0

I guess the problem is there. I will appreciate any answer or comment on this :-)

4

2 回答 2

7

man dh_link

我在 github 上有一个示例要点,它创建/bin/hello了一个指向它的符号链接/bin/helloworld

你可以像这样在你的系统上演示它:

# Create the deb package
curl -O https://gist.github.com/RichardBronosky/5358867/raw/deb-packaging-example.sh
bash deb-packaging-example.sh

# Install the deb package
dpkg --install hello-world*.deb

# Check the scripts
ls -la /bin/hello*
/bin/hello
/bin/helloworld

秘密是由脚本的第 18 行(在撰写本文时)hello-world-0.1/debian/hello-world.links创建的文件。一探究竟...

https://gist.github.com/RichardBronosky/5358867

于 2013-04-11T05:45:31.663 回答
2
$(LN) /usr/lib/$(LIB).$(MAJOR).$(MINOR) /usr/lib/$(LIB).1
$(LN) /usr/lib/$(LIB).$(MAJOR) /usr/lib/$(LIB)

在上面的代码中,您直接将目标链接到 /usr/lib 中(即在构建机器上),但这样它就不会成为包的一部分。相反,您应该在 DESTDIR 的子目录中进行链接,以便最终将符号链接放入打包的子树中。

于 2012-05-16T09:38:05.453 回答