Creating symlinks when packaging a Library (Debian)?
Asked Answered
R

2

7

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 :-)

Rupertruperta answered 10/5, 2012 at 12:22 Comment(0)
E
7

See man dh_link

I have an example gist on github that creates /bin/hello and a symbolic link to it at /bin/helloworld

You can demo it on your system like so:

# 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

The secret is the hello-world-0.1/debian/hello-world.links file that is created by line 18 (at the time of this writing) of the script. Check it out...

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

Emmer answered 11/4, 2013 at 5:45 Comment(1)
I am not working on this project any more but you are right. Thanks, it will certainly help me one day.Rupertruperta
C
2
$(LN) /usr/lib/$(LIB).$(MAJOR).$(MINOR) /usr/lib/$(LIB).1
$(LN) /usr/lib/$(LIB).$(MAJOR) /usr/lib/$(LIB)

In the code above, you are directly linking to a target into /usr/lib (ie. on the build machine), but this way it will not be part of the package. Instead, you should be linking in a subdir of DESTDIR, so that the symlink is eventually put in the packaged subtree.

Cq answered 16/5, 2012 at 9:38 Comment(1)
I was confused by this answer because it references $(LN) from the original post. As shown in the answer from stackoverflow.com/users/117471/bruno-bronosky the correct way to put symlinks in a package is with the pkg.links file, not with ln.Gosser

© 2022 - 2024 — McMap. All rights reserved.