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

Check file existence only after running exec-pre #280

Open
Harvie opened this issue Jan 21, 2025 · 1 comment
Open

Check file existence only after running exec-pre #280

Harvie opened this issue Jan 21, 2025 · 1 comment

Comments

@Harvie
Copy link
Contributor

Harvie commented Jan 21, 2025

Lets say i want to generate some custom/proprietary/niche kind of image that is not supported in genimage and the upstream support does not even make sense. I've found following works quite well. Please note i am demonstrating creation of ext4 image, which is obviously supported by genimage, but lets pretend it's not.

image file.img {
  file {}
  size = 5M
  name = "MYLABEL"
  exec-pre = "truncate -s $IMAGESIZE $IMAGEOUTFILE; mkfs.ext4 -L $IMAGENAME $IMAGEOUTFILE"
}

There is only one problem. exec-pre is not executed unless file.img already exists, so i need to do touch file.img before running genimage. I think it would be nice to have way of postponing the stat() after exec-pre OR providing something like exec-gen that would be executed beforehand.

What do you think about such change?

@michaelolbrich
Copy link
Member

I think we should make it explicit instead and have a custom type:

image file.img {
  custom {
      exec = "truncate -s $IMAGESIZE $IMAGEOUTFILE; mkfs.ext4 -L $IMAGENAME $IMAGEOUTFILE"
  }
  size = 5M
  name = "MYLABEL"
}

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