[Tip] Image init scripts when working with PharoLauncher

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Tip] Image init scripts when working with PharoLauncher

Torsten Bergmann
PharoLauncher [1] allows you to work with many Pharo images.

You can download fresh images, clone existing ones and with its access
to the Pharo CI it allows you to easily reproduce errors in specific Pharo
image versions. I REALLY like this tool when working with Pharo.

There is a customizable hardware key on my laptop that I can just press
to open PharoLauncher, manage and launch the images and dive into the
world of Pharo.


To optimize my Pharo "easy access workflows" further I wanted all the
images that I started with PharoLauncher:
 - to share a common metacello repository cache (where all the mcz
   are stored independent from image location) for faster loading
 - to have the possibility to preset the Squeaksource, SS3 and STHub password already
 - to set my authors name

All this is already explained in Marianos blog posts [2] and [3] and
the PharoEnterprise book [4].

Nonetheless I would like to share the script that I personally use.
Maybe (in an adopted version) it is usefull for other PharoLauncher
users as well:
 
=====================================================================
COMMON SETTINGS FOR ALL PHARO IMAGES WHEN STARTED USING PHAROLAUNCHER
=====================================================================
Open any Pharo 3.0/4.0 image and execute

   StartupPreferencesLoader preferencesGeneralFolder fullName

in a workspace to find out the common preferences folder on your
local machine.

You can put a Smalltalk script into this folder, for instance
"initAllImages.st" that is evaluated each time an image runs.


I've found the following script very useful:

-----------------------------------------------------------------
| sharedPackageCacheDirectory |
"Never apply to PharoLauncher itself"
(SmalltalkImage current imageName includesSubstring: 'Launcher') ifTrue: [ ^self ].

"ask if script should be applied"
(UIManager default confirm: 'Apply init script from ', StartupPreferencesLoader preferencesGeneralFolder fullName,' to image') ifFalse: [^self ].

"Use a shared package cache to store Monticello MCS files for all images"
sharedPackageCacheDirectory := 'C:\Pharo\commonpackage-cache' asFileReference
        ensureCreateDirectory;
        yourself.
MCCacheRepository default directory: sharedPackageCacheDirectory.

"Set password for Squeaksource"
(MCRepositoryGroup default  repositories
        select: [:each | (each isKindOf: MCHttpRepository)
                                                and: [((each locationWithTrailingSlash includesSubstring: 'www.squeaksource.com')
                                                or: [each locationWithTrailingSlash includesSubstring: 'http://ss3.gemstone.com/ss/'])]
                        ])
        do: [:each | each user: 'squeaksourceuser'; password: 'secretsqueaksourcepassword'].

"Set password for SmalltalkHub (hub and HTTP repos)"
(MCRepositoryGroup default  repositories
        select: [:each |
                (each isKindOf: MCSmalltalkhubRepository) and: [each locationWithTrailingSlash includesSubstring: 'smalltalkhub.com']
                ])
        do: [:each | each user: 'PharoUser'; password: 'sthubpassword'].

(MCRepositoryGroup default  repositories
        select: [:each |
                (each isKindOf: MCHttpRepository) and: [each locationWithTrailingSlash includesSubstring: 'smalltalkhub.com']
                ])
        do: [:each | each user: 'PharoUser'; password: 'sthubpassword'].
       
"Set author name"
Author fullName: 'PharoUser'.

UIManager default inform: 'Script applied'.

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

Hope it is usefull for others too.

Bye
T.

[1] http://www.smalltalkhub.com/#!/~Pharo/PharoLauncher
[2] http://marianopeck.wordpress.com/2012/05/19/pharo-tips-and-tricks/
[3] http://marianopeck.wordpress.com/2012/05/12/startuploader-running-startup-scripts-in-pharo/
[4] https://ci.inria.fr/pharo-contribution/job/PharoForTheEnterprise/ws/StartupPreferences/

Reply | Threaded
Open this post in threaded view
|

Re: [Tip] Image init scripts when working with PharoLauncher

Sean P. DeNigris
Administrator
Torsten Bergmann wrote
Nonetheless I would like to share the script that I personally use
Cool, thanks! My script was getting too complicated, so I made it into a class with a MetaC config, and the script is now just a Gofer load. This has the additional benefit that the start up scripts for the Pharo loader never change (they're just Gofer loads) and so avoid the caching problems that can otherwise arise.

Torsten Bergmann wrote
"Set password for Squeaksource"
(MCRepositoryGroup default  repositories
        select: [:each | (each isKindOf: MCHttpRepository)
                                                and: [((each locationWithTrailingSlash includesSubstring: 'www.squeaksource.com')
                                                or: [each locationWithTrailingSlash includesSubstring: 'http://ss3.gemstone.com/ss/'])]
                        ])
        do: [:each | each user: 'squeaksourceuser'; password: 'secretsqueaksourcepassword'].
...
I do something like this too. The shortcoming is that newly created repos are not authenticated. This should be in core built into the repo objects. I guess that's what the KeyChain stuff is about?
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: [Tip] Image init scripts when working with PharoLauncher

stepharo
> Cool, thanks! My script was getting too complicated, so I made it into a
> class with a MetaC config, and the script is now just a Gofer load. This has
> the additional benefit that the start up scripts for the Pharo loader never
> change (they're just Gofer loads) and so avoid the caching problems that can
> otherwise arise.

Yes this is the right way to manage scripts: turn them into classes :)

>
>
> Torsten Bergmann wrote
>> "Set password for Squeaksource"
>> (MCRepositoryGroup default  repositories
>> select: [:each | (each isKindOf: MCHttpRepository)
>> and: [((each locationWithTrailingSlash includesSubstring:
>> 'www.squeaksource.com')
>> or: [each locationWithTrailingSlash includesSubstring:
>> 'http://ss3.gemstone.com/ss/'])]
>> ])
>> do: [:each | each user: 'squeaksourceuser'; password:
>> 'secretsqueaksourcepassword'].
>> ...
> I do something like this too. The shortcoming is that newly created repos
> are not authenticated. This should be in core built into the repo objects. I
> guess that's what the KeyChain stuff is about?
>
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Tip-Image-init-scripts-when-working-with-PharoLauncher-tp4770062p4770135.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [Tip] Image init scripts when working with PharoLauncher

Damien Cassou
In reply to this post by Torsten Bergmann

On Fri, Jul 25, 2014 at 1:54 PM, Torsten Bergmann <[hidden email]> wrote:
> I've found the following script very useful:


here is what I do for MC credentials:

    credentials := Dictionary new.
    MCRepository classVarNamed: 'Settings' put: credentials.
    credentials at: 'account smalltalkhub'  put: '*smalltalkhub.com*  DamienCassou:mypassword'.
    credentials at: 'account squeaksource'  put: '*squeaksource.com* dc:mypassword'.
    credentials at: 'account ss3'           put: '*ss3.gemstone.com* dc:mypassword'.
    credentials at: 'account source.squeak' put: '*source.squeak.org* DamienCassou:mypassword'.



--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without losing enthusiasm."
Winston Churchill