打包库(Debian)时创建符号链接? [英] Creating symlinks when packaging a Library (Debian)?

查看:42
本文介绍了打包库(Debian)时创建符号链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试为 Debian 打包一个小型库.为此,我使用了官方的 Debian 政策手册,但两天后我遇到了一个无法解决的问题.

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.

这是我的包装方式:

  • 创建压缩包(此处为 libvl_1.0.orig.tar.gz)
  • 使用dh_make生成debian目录下的debian conf文件
  • 正确修改控制文件、变更日志和版权.
  • 使用 dpkg-buildpackage 命令构建包.

到这里,没有问题.但由于它是一个库,我需要在安装它时创建一些符号链接,这与库的 SONAME 有关.这里我的库叫做 libvl.例如,我正在构建一个名为 libvl.so.1.0 的文件,因为它是第一个版本.为了做对,我想我应该创建这样的符号链接:

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

为此,我尝试在使用 make 运行安装过程时创建这些链接.如果您启动make install"命令,这将起作用.但是当使用 dpkg 安装时,如果创建了链接,则没有,我不知道为什么.我也尝试使用 postinst 脚本,但没有任何结果.这是我的makefile下面:

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

推荐答案

参见man dh_link

我在 github 上有一个示例 gist,它创建 /bin/hello 并在 /bin/helloworld

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

秘诀是 第 18 行(在撰写本文时).看看吧……

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

这篇关于打包库(Debian)时创建符号链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆