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

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

问题描述

我正在尝试第一次为Debian打包一个小型图书馆。为此,我使用的是Debian官方的官方手册,但是由于两天的时间我遇到了一个不能解决的问题。
这是我打包的方式:




  • 创建tarball(这里是libvl_1.0.orig.tar.gz)

  • 使用dh_make在debian目录中生成debian conf文件

  • 正确修改控制文件,更改日志和版权。

  • 使用dpkg-buildpackage命令构建软件包。



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



为了做到这一点,我正在使用make来运行安装过程时创建这些链接。如果您启动'make install'命令,这是正常的。但是当使用dpkg进行安装时,如果创建了链接,则无法找到原因。我也尝试使用postinst脚本,但没有任何结果。下面是我的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)

全部: libvl

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

安装:
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

我猜问题在那里。我会感谢任何答案或评论: - )



非常感谢!

解决方案

请参阅 man dh_link


$ b $我在github上创建了一个示例,在 / bin / helloworld / bin / hello 和一个符号链接c $ c>



您可以在系统上演示如下:

 #创建deb包
curl -O https://gist.github.com/RichardBronosky/5358867/raw/deb-packaging-example.sh
bash deb-packaging-example.sh

#安装deb包
dpkg --install hello-world * .deb

#检查脚本
ls -la / bin / hello *
/ bin / hello
/ bin / helloworld

秘密是由 hello-world-0.1 / debian / hello-world.links 文件档案:8430b077cca41bb704ad62cbec681aacc2cbb4a6#档案-deb-packaging-example-sh-L18rel =nofollow>第18行(在撰写本文时)脚本。查看...



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


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

Thanks you very much !

解决方案

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

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

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