从CMake项目创建Debian软件包 [英] Creating a Debian Package from CMake Project

查看:83
本文介绍了从CMake项目创建Debian软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑从现有库(paho-mqtt-c)创建一个Debian软件包.该项目使用CMake作为其构建系统.经过研究后,我认为我需要创建两个或三个不同的程序包:

I am considering to create a Debian package from an existing library (paho-mqtt-c). The project uses CMake as its build system. After some research I think I need to create two or three different packages:

  • libpaho-mqtt3(带有库.so文件和相关内容)
  • libpaho-mqtt3-dev(带有头文件)
  • 也许我还需要带有示例文件或文档的第三个软件包(称为 paho-mqtt3 ?)

我已经进行了一些研究,当我使用CMake作为构建系统时,似乎至少存在三种不同的方式来创建Debian软件包:

I have done some research and it seems there exist at least three different ways how I can create a Debian package when I use CMake as my build system:

  1. 使用Debian文档中所述的debmake程序(第8章).
  2. 使用 cmake-debhelper .
  3. 使用 dh-cmake

我研究了这三种方法,似乎每种方法都有其优点和缺点.

I have looked into all three methods and it seems each has some advantages and disadvantages.

据我所知,使用debmake假定我在源代码和构建系统上都有一个上游tarball,然后在提取的tarball上调用debmake.之后,我得到了很多模板,我需要对其进行手动调整以填补缺失的空白.我开始这样做,但似乎很复杂.

As far as I have understood using debmake assumes I have an upstream tarball with the sources and the build system and then I invoke debmake on the extracted tarball. Afterwards I get a lot of templates which I need to manually adjust to fill in the missing gaps. I started doing this but it seems quite complex.

我尝试使用它,但是收到很多错误.github页面上有一个未解决的问题,但没有解决方案,所以我不再关注这个问题.这也是 paho-mqtt-c 构建系统当前正在使用的系统,但是由于链接的问题,它无法正常工作.

I tried to use it but received lots of errors. The github page has an open issue with no solution so I stopped looking at this. This is also what the paho-mqtt-c build system is currently using, but it does not work due to the issue linked.

我简要地研究了一下,这似乎是最现代的解决方案,应该可以将其与CPack结合使用.但是,似乎dh-cmake仅适用于Ubuntu 18.04和16.04,但是我使用的是Ubuntu 19.10,因此无法在我的系统上安装dh-cmake.

I briefly looked into this and it seems to be the most modern solution and it should be possible to combine this with CPack. However, it seems dh-cmake is only available for Ubuntu 18.04 and 16.04, but I am using Ubuntu 19.10 so I was not able to install dh-cmake on my system.

我错过了研究的任何内容吗?从使用CMake管理的软件中创建Debian软件包的推荐步骤是什么?阅读哪些文档是有用的?

Have I missed anything in my research? What are the recommended steps to create a Debian package from a software managed with CMake and which documentation is useful to read?

推荐答案

简而言之,在Ubuntu上,您至少需要创建以下文件:

In short, on Ubuntu you need to create at least these files:

debian/
 changelog
 control
 copyright
 rules

然后运行 debuild ,它将运行 cmake install 到临时文件夹并从中打包一个可安装的 deb 包.要快速创建这些 debian 文件,请运行 dh_make --createorig ,然后按 s 作为源包.然后,您需要按照第章4. debian目录下的必需文件《 Debian新维护人员指南》.

And then run debuild and it will run cmake install to temporary folder and pack an installable deb package from it. To quickly create those debian files run dh_make --createorig and press s for source package. Then you'll need to carefully edit debian files as described in Chapter 4. Required files under the debian directory of Debian New Maintainers' Guide.

如果您需要设置cmake属性或进行任何其他配置,则需要在规则中调整 override_dh_auto_configure :

If you need to set cmake properties or make any other configuration then you'll need to adjust override_dh_auto_configure in rules:

#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
export DH_VERBOSE = 1

%:
    dh $@

override_dh_auto_configure:
    dh_auto_configure -- \
    -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \
    -DIWINFO_SUPPORT=OFF

-DCMAKE_LIBRARY_PATH = $(DEB_HOST_MULTIARCH) -DIWINFO_SUPPORT = OFF 将直接传递给cmake.

Here the -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) and -DIWINFO_SUPPORT=OFF will be directly passed to cmake.

然后您可以将软件包上传到Ubuntu PPA:

You can then upload your package to Ubuntu PPA:

debuild -S -I
dput dput ppa:your-launchpad-user/your-ppa ../*_source.changes

此PPA构建机器人将编译您的软件包并将其发布到PPA,您将在

After that PPA build bot will compile and publish your package to PPA and you'll see them on https://launchpad.net/~your-launchpad-user/+archive/ubuntu/your-ppa/+packages

不幸的是,还有很多其他步骤,我只是简单地介绍了.

Unfortunately there is a lot of other steps, I just described briefly.

dh-cmake是更复杂的东西所必需的.如果您想发布到PPA,CPack将无法为您服务,因为它的buildbot仍然会运行debhelper(debuild的短版),因此它需要 debian 文件夹

The dh-cmake is needed for more sophisticated things. CPack won't work for you if you want to publish to PPA because its buildbot will anyway run debhelper (short version of debuild) so it needs for the debian folder

这篇关于从CMake项目创建Debian软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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