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 :
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 :-)
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
$(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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With