如何将版本号作为变量传入rpmbuilder?

问题描述 投票:0回答:1

构建一个RPM是我们CI流程的一部分,所以我自然而然地希望版本号作为一个参数传入到 rpmbuild但我不能让它工作。我试了一下 这个问题但它说我不能把'$'放在定义字符串中。

[mangolorax@localhost build_artifacts]$ ./package_release.sh 1.3.3.7
+ BUILD_VERSION_STRING=1.3.3.7
+ BUILD_DIR=/home/builder/build
+ exec rpmdev-setuptree
+ cd /home/mangolorax/rpmbuild/SPECS/
+ ln -sf /home/builder/build/mvpn.spec
+ rpmbuild --target x86_64 --define 'version ${BUILD_VERSION_STRING}' -bb mvpn.spec -vv
Building target platforms: x86_64
Building for target x86_64
error: line 2: Illegal char '$' in: Version: ${BUILD_VERSION_STRING}

我还发现 这个问题但在我看来,这似乎是一个可笑的令人费解的问题解决方案。当然,一定有一个更简单的方法来解决这个问题?还是我从根本上误解了这个问题?

linux bash centos rpm
1个回答
1
投票

整个问题是,我使用了单引号围绕着 --define 弦。在 bash 这意味着字符串中的所有内容都是按字面意思传递的,没有扩展任何变量。如果我调用 rpmbuild 像这样代替,它的工作与预期的一样。

rpmbuild --target x86_64 --define "version ${BUILD_VERSION_STRING}" -bb mvpn.spec -vv

© www.soinside.com 2019 - 2024. All rights reserved.