Make:从工作目录名称中提取数字(Debian 打包规则)

发布于 2024-12-19 23:29:06 字数 1396 浏览 1 评论 0原文

我需要一些帮助来解决以下问题:

我有一个每天使用 Launchpad 的食谱功能构建的 debian 软件包。版本名称(以及源目录的名称)是自动生成的,并包括当前的修订号。我想修改 debian/rules 文件以提取修订号并将其传递给 CMake。

到目前为止它不起作用 - 似乎一个空字符串被传递给 CMake。我不知道问题是出在我的 make 代码中还是其他地方。

规则文件:

#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

%:
    dh $@ --parallel --list-missing

# Try to detect the Bazaar revision number from the directory name
ifneq ($(findstring bzr,$(PWD)),)
COMPONENTS := $(PWD)
COMPONENTSL := $(subst -,' ',COMPONENTS)
COMPONENTSLL := $(subst ~,' ',COMPONENTSL)
BZRVER := $(filter bzr%,COMPONENTSLL)
BZRVERN := $(subst bzr,,$(BZRVER))
override_dh_auto_configure:
    dh_auto_configure -- -DRELEASE_BUILD=0 -DBZR_REVISION=$(BZRVERN)
endif

构建日志的相关部分:

make[1]: Entering directory `/build/buildd/stellarium-0.11.2~bzr5066'
dh_auto_configure -- -DRELEASE_BUILD=0 -DBZR_REVISION=
    mkdir -p obj-i686-linux-gnu
    cd obj-i686-linux-gnu
    cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DRELEASE_BUILD=0 -DBZR_REVISION=

完整日志在这里: https://launchpadlibrarian.net/86783083/buildlog_ubuntu-natty-i386.stellarium_0.11.2~bzr5066-0ubuntu0~natty1_BUILDING.txt.gz

有什么想法吗?

I'd like some help with the following problem:

I have a debian package built daily with Launchpad's Recipes feature. The version name (and the name of the source directory) is automatically generated and includes current revision number. I want to modify the debian/rules file to extract the revision number and pass it to CMake.

So far it doesn't work - it seems that an empty string is passed to CMake. I don't know if the problem is in my make code or in something else.

The rules file:

#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

%:
    dh $@ --parallel --list-missing

# Try to detect the Bazaar revision number from the directory name
ifneq ($(findstring bzr,$(PWD)),)
COMPONENTS := $(PWD)
COMPONENTSL := $(subst -,' ',COMPONENTS)
COMPONENTSLL := $(subst ~,' ',COMPONENTSL)
BZRVER := $(filter bzr%,COMPONENTSLL)
BZRVERN := $(subst bzr,,$(BZRVER))
override_dh_auto_configure:
    dh_auto_configure -- -DRELEASE_BUILD=0 -DBZR_REVISION=$(BZRVERN)
endif

Relevant section of the build log:

make[1]: Entering directory `/build/buildd/stellarium-0.11.2~bzr5066'
dh_auto_configure -- -DRELEASE_BUILD=0 -DBZR_REVISION=
    mkdir -p obj-i686-linux-gnu
    cd obj-i686-linux-gnu
    cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DRELEASE_BUILD=0 -DBZR_REVISION=

The full log is here:
https://launchpadlibrarian.net/86783083/buildlog_ubuntu-natty-i386.stellarium_0.11.2~bzr5066-0ubuntu0~natty1_BUILDING.txt.gz

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤寂小茶 2024-12-26 23:29:06

您至少在这些行中犯了一个错误:

COMPONENTSL := $(subst -,' ',COMPONENTS)
COMPONENTSLL := $(subst ~,' ',COMPONENTSL)
BZRVER := $(filter bzr%,COMPONENTSLL)

您必须对 COMPONENTSXX 变量的实际值进行更改,因此它们的名称应该包含在 $(...).

如果您唯一需要的是修订号(示例中为 5066),则可以按如下方式提取:

BZR_REVISION := $(lastword $(subst ~bzr, ,$(PWD)))

You've made a mistake at least in these lines:

COMPONENTSL := $(subst -,' ',COMPONENTS)
COMPONENTSLL := $(subst ~,' ',COMPONENTSL)
BZRVER := $(filter bzr%,COMPONENTSLL)

You have to perform changes on the actual values of COMPONENTSXX variables, thus their names should be enclosed into $(...).

If the only thing you need is the revision number (5066 in your example), it could be extracted as follows:

BZR_REVISION := $(lastword $(subst ~bzr, ,$(PWD)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文