pharo-project / pharo-launcher

Lets you manage your pharo images and download new ones
https://pharo-project.github.io/pharo-launcher/
MIT License
109 stars 46 forks source link

Allow to run start-up script at image creation time #489

Open demarey opened 4 years ago

demarey commented 4 years ago

Suggested by @bergel and @astares: Allow to run start-up scrit at image creation time instead of launching time (first launch)

Describe the request

It would be great that the script is executed when I create the image At least, in the scenarios I envision to use the scripting features, it makes much more sense to create the image and initialize it. As such, when I open it, I get an initialized image

I would have expected these launcher image initialization scripts to be applied when image is created already. Because otherwise this is somehow confusing / colliding with the regular startup scripts that one could apply to an image: also because these image startup scripts are also stored on a different location: "C:\Users\USERNAME\AppData\Roaming\pharo\9.0" (depending on version) or "C:\Users\USERNAME\AppData\Roaming\pharo" (general)

demarey commented 4 years ago

I wanted to have image creation fast. Also, if your image needs arguments or another vm that the default one, I do not have this information at image creation time. It means running the script could not work. I also did this choice to let the user have a visual feedback of what the script is doing. Maybe it could be done at image creation time with the default configuration. I do not know what is the best option (depending on people usage)

demarey commented 4 years ago

@bergel suggested:

Maybe a checkbox when creating the script would do the think. Something like "Execute script when creating the image (vs when launching it)"

demarey commented 4 years ago

@bergel @astares I was about to implement the feature but it raises a lot of questions that make me think it may not be a good idea to have it. An init script is not a startup script. It is meant to be executed only once (e.g. load code, configure the image) and then, you save your image. To allow to run an init script at image creation time, I could:

As a user, I would also like that my image got "magically" initialized when I click create but the initialization time will still be there (e.g. code loading time) either at creation time or at first launch time. I do not see the difference there.

astares commented 4 years ago

Whatever will be provided should be easy to use by the end user. Basic use cases could be like:

  1. A user might want to download a clean Px image and use it directly (basic funtionality of Launcher)

  2. A user might want to download a clean Px image and combine it with some script (to load framework or customize the image with code) and use it directly - code is loaded when image starts (new funtionality of Launcher of init scripts)

  3. A user might want to download a clean Px image and combine it with some script (to load framework or customize the image with code) and use the result as (local) template for further image creation - so the code should not be loaded again

  4. A user might want to download a clean Px image and run a general startup script when the image launches

  5. A user might want to download a clean Px image and run a script for all Px-family images when the image launches

  6. A user might want to download a clean Px image and run an image specific script for this particular P image

Maybe there are others.

If I'm not mistaken Launcher covers 1-2.

Pharo images currently already provide 4 to 5 or 6:

A) startup scripts for general (for all images independent from version) B) startup scripts per version (Pharo 7, Pharo 8, Pharo 9

See World menu -> System -> Startup. One needs to create a startup.st file in the mentioned folders.

image

Dont know how this mechanism interferes/collides with the init scripts now provided in Launcher (are Pharo startup.st scripts evaluated after the script given by Launcher or not or not at all).

Maybe allowing to edit these directly from Launcher would be helpful. I do not know if an option

C) startup scripts per image

exists. For instance when the image finds a startup.st file in the image folder.

If the scope A, B and even C is already provided by the images then Launcher should maybe have the possibility to edit these "scoped" startup scripts:

a) the global startup script b) a version specific startup script c) a per image specific script file

Anyway - I guess case 3 is not very well covered or need to be done manually (open the image with launcher, load something and save image, then later copy this image in Launcher to do new experiments)

demarey commented 4 years ago

Yes, 1-2 are covered by Pharo Launcher. 3 is almost covered: you create an image with an init script, save the image. Then you can click on the image in PL to convert it to a template. Maybe there is some usage for it. I personally prefer to set up a CI job to build the image with the script to have an up-to-date image. Then, I create an image in Pharo Launcher from the Jenkins server. And yes Pharo images currently already provide 4 to 5 or 6.

Yes, Pharo Launcher could offer the ability to edit "scoped" startup scripts. Where would you see this feature?