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

Example for generating file on apply instead of copying it? #93

Closed
FrederikLauber opened this issue Jan 24, 2021 · 3 comments
Closed

Example for generating file on apply instead of copying it? #93

FrederikLauber opened this issue Jan 24, 2021 · 3 comments

Comments

@FrederikLauber
Copy link

Hi,

sorry if this is already answered in the documentation (if so, I havent found it)
but is it possible to create a file on apply instead of copying it?

Example would be an initramfs. I would like to ignore the file from saves and on apply run mkinitcpio -p to generate it.
As all packages and other files need to be already present for that, I would have to run that as the last command in the apply chain so I guess I should create a file 99-zzzzcreate.sh and put mkinitcpio -p into it but wouldn't that also run the command on every save?
Cheers

@CyberShadow
Copy link
Owner

The primitive for creating a file is CreateFile, which is suitable for inlining small text files in the configuration.

Logically, aconfmgr needs to have the exact contents of files it manages, so that it knows if a file as specified by the configuration differs from the copy on the system. So, yes, non-trivial files would need to be generated as part of parsing the configuration for aconfmgr to be able to manage their contents. You could implement some kind of caching mechanism to avoid doing so every time the configuration is parsed. Alternatively, if the contents of the file is not important and only its absence/presence is, you could make the configuration generate it if it is absent on the system, but if it is already present on the system, just copy it from there.

@FrederikLauber
Copy link
Author

Thanks for the answer, maybe I have to specify a bit.
I do not care about the content of the file and hence never copy it as the content will be outdated at the time I apply the config, I want to create the file once all other changes have been done to the system.
Examples for this could be the mirrorlist file (I would just run reflector to get an up to date version instead of copying an outdated version) or the initramfs ( I might not even apply to the same hardware so I need to remake that).
So I would like to tell aconfmgr "Ignore that file!" during a save and on apply "Execute these commands".

@CyberShadow
Copy link
Owner

Well, that doesn't really fit into aconfmgr's model. It needs to be able to compare what's on the system and what the configuration is trying to make the system look like, and in order for it to be able to do that, the configuration must compile to a complete representation of the system configuration. This is what enables things like saving incremental configuration changes, apply confirmation prompts, and the diff action.

My previous comment includes some suggestions of making it work within that model. Outside that model, you could create a script on top of aconfmgr, or perform the system changes directly from within the configuration (checking if aconfmgr_action is apply). See #23 for a similar question of making system changes outside of aconfmgr's model.

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

No branches or pull requests

2 participants