Preparing PharoLauncher for the classroom

Hi,

I was asked on #slack by user embee (Martin Baehr) how he can create an up to date setup with "PharoLauncher" 
configuration locally that he can afterwards easily distribute ("unzip and go") to 40 Windows PCs for a 
training/presentation.

He was preparing Pharo for Singapore FOSSASIA conference workshop at the science center computer lab.

I helped him with the following short guide that may be useful to others too.

Have fun
T. 


-------------------------------------------------------------------------------------------------------------------------------------------------

A. Portable version of Launcher vor Windows
===========================================
  1. Go to https://ci.inria.fr/pharo/view/Launcher/job/Launcher/ and click on "VERSION=stable"
     for a green build  
  2. Download "Pharo-win.zip"
     (Direct link is https://ci.inria.fr/pharo/view/Launcher/job/Launcher/PHARO=40,VERSION=stable,VM=vm,label=linux/lastSuccessfulBuild/artifact/Pharo-win.zip)

  3. Extract this to c:\ so you end up with a directory "c:\Pharo"

B. Create some folders
======================
  4. Create a new folder "images" 

  5. Create a new folder "vm" with two subfolders "spur" and "nonspur"
  
So you end up with  
  
  - Pharo 
  !- images
  !- vm
   !- spur
   !- nonspur

C. Install stable "non-Spur" VM
=============================== 
The existing stable VM (before the introduction of Spur) is required for all "PreSpur" images with image version <= 50496
(so latest Pharo 4 and initial images when Pharo 5 was started before switching to Spur during Pharo 5 development)
  
  6. Visit http://files.pharo.org/vm/pharo/win/ and download "Pharo-VM-win-stable.zip"
  
  7. This is the Pharo 4 stable Cog VM. Extract the contents to "C:\Pharo\vm\nonspur"

  8. Copy the source files
           C:\Pharo\PharoV10.sources also to C:\Pharo\vm\nonspur
		   C:\Pharo\PharoV20.sources also to C:\Pharo\vm\nonspur
		   C:\Pharo\PharoV30.sources also to C:\Pharo\vm\nonspur
		   C:\Pharo\PharoV40.sources also to C:\Pharo\vm\nonspur  
 
D. Install latest Spur VM 
=========================
The new, fast and shiny Spur VM is required for all "Spur" images with image version 50497 onwards
(so latest Pharo 5)

  9. Visit http://files.pharo.org/vm/pharo-spur32/win/ and download "PharoVM-Spur32-win-latest.zip"   
  
 10. This is the "bleeding edge" Spur VM. Extract the contents to "C:\Pharo\vm\spur"
  
 11. Copy only the source file
           C:\Pharo\PharoV40.sources also to C:\Pharo\vm\spur

E. Configure Pharo Launcher
===========================
 11. Start C:\Pharo\Pharo.exe by double clicking on it, this will open the Pharo Launcher window
 
 12. At the bottom right corner of the Window there is a button called "Open Settings". This opens 
     the settings browser for Pharo Launcher. Click on the node "PharoLauncher" in the settings tree.

 13. For the setting "Spur VM Full Path" enter ".\vm\spur\Pharo.exe" and hit ENTER
 
 14. For the setting "VM Full Path" enter ".\vm\nonspur\Pharo.exe" and hit ENTER
 
F. Hack the "images" folder location to be relative
=================================================== 
 15. When you try to change "Location of your images" to be relative like ".\images" you will 
     notice that it always changes back to an absolute path "C:\Pharo\images". So we need to hack
	 this:
 
 16. Hit "SHIFT" + "ENTER" to open the Pharo Spotter. Enter "PhLDirectoryBasedImageRepository" 
     to open a browser on this class. and change the class method #location to look like
     that
 
       location
	       ^ FileSystem workingDirectory / 'images' 
 
 17. Close the class browser, close the settings browser and leave the Pharo Launcher by
     clicking on "Quit" in the bottom right corner. Note that the launcher image is saved
	 on exit - so our code change will be in effect when we start Launcher again.
	 
Now ZIP the c:\Pharo folder and you can extract it on any computer that you like.

So when you distribute the ZIP the image folder should be clean. But you can also download
and include preconfigured images that you like your audience to be working with.
	 
G. Sharing caches
=================
With the above setup each time you download and start an image using the Launcher a new
"package-cache" for Monticello/Metacello downloads will be created for each image directory.

To avoid such a cache per image and use a general cache for all images it is helpful to
change the package-cache location in each image. This can easily be done:

  18. Start an image and evaluate 
  
        StartupPreferencesLoader preferencesGeneralFolder
	  
	  to find out which preferences folder usually is used. In my example this is 
      C:\Users\root\AppData\Roaming\pharo	  

  19. Go to this folder and create a file called "startup.st" with the following contents:
  
        |mczCache|
        mczCache := 'C:\Software\Pharo\cache' asFileReference.
        MCCacheRepository cacheDirectory: mczCache.
        UIManager inform: 'Package cache set to', mczCache fullName

If you solely work with the setup and following our path logic you can even give this as 
a relative path in the startup script:
  
        mczCache := FileSystem workingDirectory parent parent / 'package-cache'
		
Details on further startup customization can be found on 
https://marianopeck.wordpress.com/2012/05/12/startuploader-running-startup-scripts-in-pharo/		


Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: