1

Building an RPM is part of our CI-flow, so naturally I want the version number passed as a parameter into rpmbuild, but I can't get it to work. I tried the solution from this question, but it says I can't put '$' in define-strings:

[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}

I also found this question, but it seems to me to be a ridiculously convoluted solution to the problem. Surely there must be a simpler way of doing this? Or have I fundamentally misunderstood this problem?

Fylke
  • 1,753
  • 3
  • 19
  • 30

1 Answers1

1

The entire problem was that I used single quotes around the --define string. In bash that means that everything inside the string is passed literally without expanding any variables. If I call rpmbuild like this instead, it works as expected:

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

Fylke
  • 1,753
  • 3
  • 19
  • 30