msv-lab / modus

A language for building Docker/OCI container images
GNU Affero General Public License v3.0
280 stars 9 forks source link

merge: share a shell? #165

Open maowtm opened 2 years ago

maowtm commented 2 years ago

I just realized that it might actually be more helpful to define merge as making all the run commands share a single shell execution. This makes writing things like the following very easy:

install_foo(...) :- (
  run("savedAptMark=$(apt-mark showmanual)"),
  build_foo(...),
  run("apt-mark manual $savedAptMark")
)::merge.

Although this does means that if we want to move away from the "shell-escape copy() paths and turn the whole thing into a shell script" approach things will get very complicated.

mechtaev commented 2 years ago

This would mean that using and not using ::merge will result in different builds.

micromaomao commented 2 years ago

Yeah that's a good point… Currently to do this I'm just saving the variable to a file, which I guess works well enough. But I wonder if we want to have an operator specifically to do this kind of single-shell merges, just to simplify situations like these.

mechtaev commented 2 years ago

Is it going to be shallow, or deep, i.e. affecting build_foo as well? If deep, it will break code modularity.