简体   繁体   中英

Build deb package version with command line option

Newbie to build deb package. I've a build script to generate packages for Ubuntu. Version number is there in changelog . I'd like to automate the process of building deb packages without touching changelog using a version file and the file consists of only version number something like 1.0.0 .

How can I pass the version number to debuild command?

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

I don't have enough rep to comment, but I can think of 2 ways to accomplish this.

The first would be to read all options from a file and execute debuild on it including the version number as such (assuming you make 'debuild' a global alias or function):

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

Where your build_options.txt file looks something like:

--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
...

The second method depends on the language you are writing your "debuild" script in. I assume you're creating a wrapper around dpkg-deb ? Essentially, you write a function for the --version option which expects a path to a file to open and read in the version numbers line by line, comma separated, etc. In Python, this can be accomplished with the argparse module (see 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 .

The general idea for the 2nd method is writing a function that reads the version file using the --version flag, but this solution will be specific to your language of choice. Possibly related: https://github.com/tarantool/tarantool/wiki/Automatic-RPM-DEB-Packages-module-building .

The general idea is, that a new version of a debian package is determined by a changelog entry. Adding the entry can be automated using the dch helper script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM