Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument in fpm for reading from config file #1827

Closed
willfurnell opened this issue Sep 2, 2021 · 5 comments
Closed

Argument in fpm for reading from config file #1827

willfurnell opened this issue Sep 2, 2021 · 5 comments

Comments

@willfurnell
Copy link

Hello,
As far as I can see, fpm can read in from a ".fpm" file in the local directory for getting it's command line arguments. Is there a way to specify an arbiraty confile file rather than just the ".fpm" file? - I'd like to be able to maintain lots of similar config files in the same place. e.g. I could call fpm with

fpm --config package1.fpm
fpm --config package2.fpm 

where package1.config and package2.config are distinct ".fpm" files. This would help make things easier to automate for building many packages.
Thank you!

@jordansissel
Copy link
Owner

I like this idea.

This might cause some confusion with the existing --config-files flag, though. Specifically, having --config mean "load this file as command line flags for fpm" and --config-files ... mean "label this path as a config file in the destination package" -- these two concepts are unrelated, and such similar naming feels like a good way to cause confusion.

I would like to find a way to present this feature to folks without that confusion. Any thoughts?

Maybe fpm package1.fpm ? Or fpm --extra-args-from package1.fpm ?


Something that works today!

Or, for something that works today, we could use the FPMOPTS env variable. This feature was added in #977, but it isn't documented anywhere (besides the giant changelog file).

Here's an example using FPMOPTS:

% cat test.fpm
-s empty
-t deb
-n example
-v 1.0
--depends hello

% FPMOPTS="$(cat test.fpm)" bundle exec bin/fpm
Loading flags from FPMOPTS environment variable {:level=>:warn}
Additional options: -s empty -t deb -n example -v 1.0 --depends hello {:level=>:warn}
Debian packaging tools generally labels all files in /etc as config files, as mandated by policy, so fpm defaults to this behavior for deb packages. You can disable this default behavior with --deb-no-default-config-files flag {:level=>:warn}
Created package {:path=>"example_1.0_amd64.deb"}

With the above example, you could have per-package files, and replace:

# Your example:
fpm --config package1.fpm

# Should work today using FPMOPTS:
FPMOPTS="$(cat package1.fpm)" fpm

This trick uses a shell feature where foo=bar variable settings can appear before the program name and bourne shells (bash, etc) will interpret this as you wanting it to be set as an environment variable in the program itself (without changing any variables in the shell)

Thoughts?

@willfurnell
Copy link
Author

Sorry for the long wait for a reply! I think making it an argument like fpm --extra-args-from package1.fpm would be preferable in my opinion - but whatever you think is best - I'm not really experienced in making command line software so I'm not sure on best practices :) !

Thank you for the 'what works today' section as well, much appreciated!

@jordansissel
Copy link
Owner

I found a way to possibly make this work as a flag in fpm: #1902 (comment)

No promises on when/if it'll get implemented, but the prototype looks promising to me :)

@jordansissel
Copy link
Owner

Fixed, I hope, by #1905 which adds --fpm-options-file flag

@jordansissel
Copy link
Owner

fpm 1.15.0 released with this new --fpm-options-file flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants