使用命令行选项构建 deb 包版本

Build deb package version with command line option

构建 deb 包的新手。我有一个构建脚本来为 Ubuntu 生成包。 changelog 中有版本号。我想使用 version 文件在不触及 changelog 的情况下自动构建 deb 包的过程,并且该文件仅包含类似 1.0.0 的版本号。

如何将版本号传递给 debuild 命令?

   debuild --no-lintian --preserve-envvar=PATH --check-dirname-level 0 --no-tgz-check -uc -us

我没有足够的代表发表评论,但我可以想到 2 种方法来完成这个。

首先是从文件中读取所有选项并对其执行 debuild,包括版本号(假设您使 'debuild' 成为全局别名或函数):

#!/bin/bash
file="/home/user/build_options.txt"
while IFS= read -r line
do
    debuild $line
done <"$file"

您的 build_options.txt 文件类似于:

--version 1.0.0 --no-lintian --preserve-envvar=PATH --check-dirname-level 0 --no-tgz-check -uc -us
--version 1.0.1 --no-lintian --preserve-envvar=PATH --check-dirname-level 0 --no-tgz-check -uc -us
...

第二种方法取决于您编写 "debuild" 脚本所用的语言。我假设您正在围绕 dpkg-deb 创建一个包装器?本质上,您为 --version 选项编写一个函数,该函数期望打开文件的路径并逐行读取版本号,以逗号分隔等。在 Python 中,这可以通过以下方式完成argparse 模块(参见 https://docs.python.org/2/howto/argparse.html). Another great working example can be seen in this TensorFlow script: https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/examples/learn/wide_n_deep_tutorial.py

第二种方法的总体思路是编写一个使用 --version 标志读取版本文件的函数,但此解决方案将特定于您选择的语言。可能相关:https://github.com/tarantool/tarantool/wiki/Automatic-RPM-DEB-Packages-module-building.

一般的想法是,一个新版本的 debian 软件包由更新日志条目决定。可以使用 dch 帮助程序脚本自动添加条目。